From 787d776d20062299e5c22ce1452315bcc07f9ece Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 10:57:43 +0700 Subject: [PATCH 01/19] added basic kitchen.docker.yml --- .kitchen.docker.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .kitchen.docker.yml diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml new file mode 100644 index 0000000..bd1586c --- /dev/null +++ b/.kitchen.docker.yml @@ -0,0 +1,14 @@ +--- +driver: + name: dokken + chef_version: latest + privileged: true # because Docker and SystemD/Upstart + +transport: + name: dokken + +provisioner: + name: dokken + +verifier: + name: inspec From 7076f511f47cc1b73a7d1fc8ad3e6f3482e64b87 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 10:59:53 +0700 Subject: [PATCH 02/19] override platforms supported by kitchen-dokken --- .kitchen.docker.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml index bd1586c..28423b8 100644 --- a/.kitchen.docker.yml +++ b/.kitchen.docker.yml @@ -12,3 +12,34 @@ provisioner: verifier: name: inspec + +platforms: +- name: centos-6 + driver: + image: centos:6 + platform: rhel + pid_one_command: /sbin/init + intermediate_instructions: + - RUN yum -y install which initscripts + +- name: centos-7 + driver: + image: centos:7 + platform: rhel + pid_one_command: /usr/lib/systemd/systemd + intermediate_instructions: + - RUN yum -y install lsof which systemd-sysv initscripts + +- name: ubuntu-16.04 + driver: + image: ubuntu:16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: ubuntu-16.04 + driver: + image: ubuntu:16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update From 7cdcb847c0d451ebfb09813e34e344a78c6320af Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:17:09 +0700 Subject: [PATCH 03/19] added suite for dokken --- .kitchen.docker.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml index 28423b8..92b363a 100644 --- a/.kitchen.docker.yml +++ b/.kitchen.docker.yml @@ -43,3 +43,26 @@ platforms: pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update + +suites: + - name: default + driver: + vm_hostname: mongo3 + run_list: + - recipe[mongodb3::default] + attributes: + chef_client: + config: + force_logger: true + log_level: info + build-essential: + compile_time: false + mongodb3: + mongod: + disable-transparent-hugepages: true + provisioner: + client_rb: + environment: dev + excludes: + - oel-6.6 + - ami-2014.03 From e77794e7b09c92918b80ececcf1b4659782d6e11 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:21:29 +0700 Subject: [PATCH 04/19] use ChefDK for running test --- .travis.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9de479f..eaed0bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,18 @@ -language: ruby -rvm: -- 2.1.0 +# NOTE: we used ChefDK so we are not stick to which Ruby version. +sudo: required +dist: trusty + +# install the pre-release chef-dk. Use chef-stable-trusty to install the stable release +addons: + apt: + sources: + - chef-current-trusty + packages: + - chefdk + +# Don't `bundle install` which takes about 1.5 mins +install: echo "skip bundle install" + bundler_args: --without integration gemfile: - Gemfile From 3d7ab910ada65eee90309cb131a1992b80a24720 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:24:31 +0700 Subject: [PATCH 05/19] remove gemfile statement --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index eaed0bf..d11627c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,6 @@ addons: # Don't `bundle install` which takes about 1.5 mins install: echo "skip bundle install" -bundler_args: --without integration -gemfile: - - Gemfile branches: only: - master From 0ae30108474da8e6ca26b13d70a1820013719b6f Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:24:48 +0700 Subject: [PATCH 06/19] specify service Docker --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d11627c..88e186b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,9 @@ branches: only: - master - develop + +services: docker + before_script: - bundle exec berks script: From ac781d2f26c8900506b9a4fd97eee4d2eea84b28 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:26:19 +0700 Subject: [PATCH 07/19] fix wrong Docker driver parameters --- .kitchen.docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml index 92b363a..e6d5e80 100644 --- a/.kitchen.docker.yml +++ b/.kitchen.docker.yml @@ -30,10 +30,10 @@ platforms: intermediate_instructions: - RUN yum -y install lsof which systemd-sysv initscripts -- name: ubuntu-16.04 +- name: ubuntu-14.04 driver: - image: ubuntu:16.04 - pid_one_command: /bin/systemd + image: ubuntu-upstart:14.04 + pid_one_command: /sbin/init intermediate_instructions: - RUN /usr/bin/apt-get update From dd56d9ea4886fa4d24e8f45fa84bb2b4a4357188 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:27:01 +0700 Subject: [PATCH 08/19] env matrix --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 88e186b..8e533ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,13 @@ branches: services: docker +env: + matrix: + - INSTANCE=default-centos-6 + - INSTANCE=default-centos-7 + - INSTANCE=default-ubuntu-1404 + - INSTANCE=default-ubuntu-1604 + before_script: - bundle exec berks script: From 0e7cd66ded7859cc8c6cb97af9f6b85ef5a6ad74 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:27:28 +0700 Subject: [PATCH 09/19] before_script for Docker instances --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8e533ce..5c79770 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,8 @@ env: - INSTANCE=default-ubuntu-1604 before_script: - - bundle exec berks + - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) + - eval "$(/opt/chefdk/bin/chef shell-init bash)" script: - bundle exec foodcritic . - bundle exec rspec test/libraries From 68a47eef0d272d60a1f660e91ef3761b4751a57d Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 11:28:49 +0700 Subject: [PATCH 10/19] script to run the Integration test --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c79770..609a8b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,5 @@ env: before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - eval "$(/opt/chefdk/bin/chef shell-init bash)" -script: - - bundle exec foodcritic . - - bundle exec rspec test/libraries + +script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} From 697b2c8d3eb56c8d61d456daf5500848bf6ac22d Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:07:30 +0700 Subject: [PATCH 11/19] include before_script for unit test --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 609a8b8..18972f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,3 +32,11 @@ before_script: - eval "$(/opt/chefdk/bin/chef shell-init bash)" script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} + +matrix: + include: + - before_script: + - eval "$(/opt/chefdk/bin/chef shell-init bash)" + - /opt/chefdk/embedded/bin/chef --version + - /opt/chefdk/embedded/bin/cookstyle --version + - /opt/chefdk/embedded/bin/foodcritic --version From f2f1179d23b387dafb9805081a81ffaf50e9f117 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:11:57 +0700 Subject: [PATCH 12/19] Rake tasks for unit tests --- Rakefile | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..293ccde --- /dev/null +++ b/Rakefile @@ -0,0 +1,69 @@ +#!/usr/bin/env rake + +require_relative 'tasks/maintainers' + +# Style tests. cookstyle (rubocop) and Foodcritic +namespace :style do + begin + require 'cookstyle' + require 'rubocop/rake_task' + + desc 'Run Ruby style checks' + RuboCop::RakeTask.new(:ruby) + rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting style:ruby" unless ENV['CI'] + end + + begin + require 'foodcritic' + + desc 'Run Chef style checks' + FoodCritic::Rake::LintTask.new(:chef) do |t| + t.options = { + fail_tags: ['any'], + progress: true + } + end + rescue LoadError + puts ">>> Gem load error: #{e}, omitting style:chef" unless ENV['CI'] + end +end + +desc 'Run all style checks' +task style: ['style:chef', 'style:ruby'] + +# ChefSpec +begin + require 'rspec/core/rake_task' + + desc 'Run ChefSpec examples' + RSpec::Core::RakeTask.new(:spec) +rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting spec" unless ENV['CI'] +end + +# Integration tests. Kitchen.ci +namespace :integration do + begin + require 'kitchen/rake_tasks' + + desc 'Run kitchen integration tests' + Kitchen::RakeTasks.new + rescue StandardError => e + puts ">>> Kitchen error: #{e}, omitting #{task.name}" unless ENV['CI'] + end +end + +namespace :supermarket do + begin + require 'stove/rake_task' + + desc 'Publish cookbook to Supermarket with Stove' + Stove::RakeTask.new + rescue LoadError => e + puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV['CI'] + end +end + +# Default +task default: %w(style spec) From eef7467e0e27922f11c6154c16300c86d99a39eb Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:13:11 +0700 Subject: [PATCH 13/19] execute Rake tasks --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 18972f8..7629337 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,3 +40,6 @@ matrix: - /opt/chefdk/embedded/bin/chef --version - /opt/chefdk/embedded/bin/cookstyle --version - /opt/chefdk/embedded/bin/foodcritic --version + - script: + - /opt/chefdk/bin/chef exec rake + env: UNIT_AND_LINT=1 From db523fb8a85cbd52450df137122f35a55beb29b7 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:13:35 +0700 Subject: [PATCH 14/19] foodcritic --- .foodcritic | 1 + 1 file changed, 1 insertion(+) create mode 100644 .foodcritic diff --git a/.foodcritic b/.foodcritic new file mode 100644 index 0000000..cf9e43e --- /dev/null +++ b/.foodcritic @@ -0,0 +1 @@ +~FC057 From bbc505fd27202bb109d31ab486d79f960d5b9e86 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:20:28 +0700 Subject: [PATCH 15/19] added maintainers task --- tasks/maintainers.rb | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tasks/maintainers.rb diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb new file mode 100644 index 0000000..1ce3302 --- /dev/null +++ b/tasks/maintainers.rb @@ -0,0 +1,76 @@ +# +# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'rake' + +SOURCE = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.toml') +TARGET = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.md') + +begin + require 'tomlrb' + task default: 'maintainers:generate' + + namespace :maintainers do + desc 'Generate MarkDown version of MAINTAINERS file' + task :generate do + @toml = Tomlrb.load_file SOURCE + out = "\n\n" + + out << preamble + out << project_lieutenant + out << all_maintainers + + File.open(TARGET, 'w') do |fn| + fn.write out + end + end + end + +rescue LoadError + STDERR.puts "\n*** TomlRb not available. Skipping the Maintainers Rake task\n\n" +end + +private + +def preamble + <<-EOL +# #{@toml['Preamble']['title']} +#{@toml['Preamble']['text']} +EOL +end + +def project_lieutenant + <<-EOL +# #{@toml['Org']['Components']['Core']['title']} +#{github_link(@toml['Org']['Components']['Core']['lieutenant'])} + +EOL +end + +def all_maintainers + text = "# Maintainers\n" + @toml['Org']['Components']['Core']['maintainers'].each do |m| + text << "#{github_link(m)}\n" + end + text +end + +def github_link(person) + name = @toml['people'][person]['name'] + github = @toml['people'][person]['github'] + "* [#{name}](https://github.com/#{github})" +end From 83c074de186386ca3ecad2430d97e82779d4d4c4 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:22:14 +0700 Subject: [PATCH 16/19] added MAINTAINERS.toml --- MAINTAINERS.toml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 MAINTAINERS.toml diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml new file mode 100644 index 0000000..27c980e --- /dev/null +++ b/MAINTAINERS.toml @@ -0,0 +1,28 @@ +# +# This file is structured to be consumed by both humans and computers. +# It is a TOML document containing Markdown +# +[Preamble] + title = "Maintainers" + text = """ + +This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. + +Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. +""" + +[Org] + [Org.Components] + [Org.Components.Core] + title = "Project Maintainer" + + lieutenant = 'sunggun' + + maintainers = [ + 'sunggun' + ] + +[people] + [people.sunggun] + name = "Sunggun Yu" + github = "sunggun-yu" From c2902d528c8ae63fe66a895e5cf9eca822646bb9 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:22:51 +0700 Subject: [PATCH 17/19] generate MAINTAINERS.md --- MAINTAINERS.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 MAINTAINERS.md diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..d20421d --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,13 @@ + + +# Maintainers + +This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. + +Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. + +# Project Maintainer +* [Sunggun Yu](https://github.com/sunggun-yu) + +# Maintainers +* [Sunggun Yu](https://github.com/sunggun-yu) From c9091c670c73465f4c2104a25a567416c5ddc041 Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 12:24:31 +0700 Subject: [PATCH 18/19] update Issues and Sources --- metadata.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metadata.rb b/metadata.rb index 88556e1..e09d00f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -18,3 +18,6 @@ depends 'yum' depends 'user' depends 'runit', '~> 1.7.0' + +source_url 'https://github.com/sunggun-yu/chef-mongodb3/issues' +issues_url 'https://github.com/sunggun-yu/chef-mongodb3' From 1fa98be828856ba6a062c8b947301f3ea478cb2c Mon Sep 17 00:00:00 2001 From: cduong13 Date: Fri, 25 Nov 2016 14:51:36 +0700 Subject: [PATCH 19/19] separate build for Unit and Linter --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7629337..a9930c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,8 @@ before_script: script: KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} +# NOTE: we include a separate build for Unit test and Linter +# MIGHT NOT KNOW the purpose of `UNIT_AND_LINT=1`. matrix: include: - before_script: