From 496735aa2ca1fd4de2b01a81ab5ea7a140e3991a Mon Sep 17 00:00:00 2001 From: Sean OMeara Date: Wed, 18 Dec 2013 20:06:30 -0500 Subject: [PATCH] Updating for yum ~> 3.0. Fixing up style for rubocop. Updating test-kitchen harness --- .kitchen.yml | 79 ++++++++++++++----- .rubocop.yml | 17 ++-- Gemfile | 8 +- metadata.rb | 3 +- recipes/package.rb | 6 +- recipes/repo.rb | 15 ++-- spec/spec_helper.rb | 7 +- spec/unit/recipes/default_spec.rb | 8 +- .../default/bats/check_service.bats | 3 + .../default/serverspec/default_spec.rb | 14 ---- .../source/bats/check_service.bats | 3 + .../source/serverspec/source_spec.rb | 19 ----- 12 files changed, 93 insertions(+), 89 deletions(-) create mode 100644 test/integration/default/bats/check_service.bats delete mode 100644 test/integration/default/serverspec/default_spec.rb create mode 100644 test/integration/source/bats/check_service.bats delete mode 100644 test/integration/source/serverspec/source_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index d5e2ad373..1489816f6 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,24 +1,67 @@ +--- driver_plugin: vagrant +driver_plugin: digitalocean driver_config: - require_chef_omnibus: true - customize: - memory: 512 + digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %> + digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %> + aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> + aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> + aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %> + ssh_key: <%= ENV['AWS_PRIVATE_KEY_PATH'] %> + rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %> + rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %> + require_chef_omnibus: latest platforms: - - name: ubuntu-12.10 - run_list: - - recipe[apt::default] - - name: ubuntu-12.04 - run_list: - - recipe[apt::default] - - name: ubuntu-10.04 - run_list: - - recipe[apt::default] - - name: debian-7.1.0 - run_list: - - recipe[apt::default] - - name: centos-6.4 - - name: centos-5.9 +- name: centos-5.8 + driver_plugin: digitalocean + driver_config: + image_id: 1601 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: centos-6.4 + driver_plugin: digitalocean + driver_config: + image_id: 562354 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: amazon-2013.09 + driver_plugin: ec2 + driver_config: + image_id: ami-3be4bc52 + username: ec2-user + +- name: fedora-19 + driver_plugin: digitalocean + driver_config: + image_id: 696598 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: ubuntu-1004 + driver_plugin: digitalocean + driver_config: + image_id: 14097 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1204 + driver_plugin: digitalocean + driver_config: + image_id: 1505447 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] suites: - name: default @@ -56,4 +99,4 @@ suites: - nginx::ngx_devel_module - nginx::ngx_lua_module - nginx::openssl_source - - nginx::upload_progress_module + - nginx::upload_progress_module \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index e11136d4f..2974c4273 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,14 +1,11 @@ -AllCops: - Excludes: - - vendor/** - -AlignParameters: - Enabled: false Encoding: Enabled: false -HashSyntax: + +AlignParameters: Enabled: false + LineLength: - Enabled: false -MethodLength: - Max: 30 + Max: 200 + +HashSyntax: + EnforcedStyle: hash_rockets \ No newline at end of file diff --git a/Gemfile b/Gemfile index 6f5b9fe81..f465c7829 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,13 @@ source 'https://rubygems.org' gem 'berkshelf', '~> 2.0' -gem 'chefspec', '~> 2.0' +gem 'chefspec', '~> 3.0' gem 'foodcritic', '~> 3.0' -gem 'rubocop', '~> 0.12' +gem 'rubocop' group :integration do - gem 'test-kitchen', '~> 1.0.0.beta' + gem 'test-kitchen', '~> 1.0' gem 'kitchen-vagrant', '~> 0.11' + gem 'kitchen-digitalocean' + gem 'kitchen-ec2' end diff --git a/metadata.rb b/metadata.rb index 47c6b9d4b..c3caaa30f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,8 @@ depends 'build-essential', '~> 1.4' depends 'ohai', '~> 1.1' depends 'runit', '~> 1.2' -depends 'yum', '< 3.0' +depends 'yum', '~> 3.0' +depends 'yum-epel' supports 'amazon' supports 'centos' diff --git a/recipes/package.rb b/recipes/package.rb index 4c7b17a97..977c0013e 100644 --- a/recipes/package.rb +++ b/recipes/package.rb @@ -22,7 +22,7 @@ if platform_family?('rhel') if node['nginx']['repo_source'] == 'epel' - include_recipe 'yum::epel' + include_recipe 'yum-epel' elsif node['nginx']['repo_source'] == 'nginx' include_recipe 'nginx::repo' elsif node['nginx']['repo_source'].nil? @@ -33,9 +33,7 @@ fail ArgumentError, "Unknown value '#{node['nginx']['repo_source']}' was passed to the nginx cookbook." end elsif platform_family?('debian') - if node['nginx']['repo_source'] == 'nginx' - include_recipe 'nginx::repo' - end + include_recipe 'nginx::repo' if node['nginx']['repo_source'] == 'nginx' end package node['nginx']['package_name'] do diff --git a/recipes/repo.rb b/recipes/repo.rb index 4a34095a5..0aff0ee37 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -20,19 +20,14 @@ case node['platform_family'] when 'rhel', 'fedora' - include_recipe 'yum::default' - - yum_key 'nginx' do - url 'http://nginx.org/keys/nginx_signing.key' - key 'RPM-GPG-KEY-Nginx' - action :add - end - + yum_repository 'nginx' do description 'Nginx.org Repository' - url node['nginx']['upstream_repository'] - key 'RPM-GPG-KEY-Nginx' + baseurl node['nginx']['upstream_repository'] + gpgkey 'http://nginx.org/keys/nginx_signing.key' + action :create end + when 'debian' include_recipe 'apt::default' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 15c12019f..1dd5126bf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,2 @@ -require 'berkshelf' require 'chefspec' -require_relative 'support/matchers/nginx_site' - -Berkshelf.ui.mute do - Berkshelf::Berksfile.from_file('Berksfile').install(path: 'vendor/cookbooks') -end +require 'chefspec/berkshelf' diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index 0b1748d04..2afcf735f 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'nginx::default' do - let(:chef_run) { ChefSpec::ChefRunner.new(:platform => 'debian', :version => '7.0').converge(described_recipe) } + let(:chef_run) { ChefSpec::Runner.new(:platform => 'debian', :version => '7.0').converge(described_recipe) } it 'loads the ohai plugin' do expect(chef_run).to include_recipe('nginx::ohai_plugin') @@ -15,12 +15,12 @@ context 'configured to install by package' do context 'in a redhat-based platform' do - let(:chef_run) { ChefSpec::ChefRunner.new(:platform => 'redhat', :version => '6.3').converge(described_recipe) } + let(:chef_run) { ChefSpec::Runner.new(:platform => 'redhat', :version => '6.3').converge(described_recipe) } - it 'includes the yum::epel recipe if the source is epel' do + it 'includes the yum-epel recipe if the source is epel' do chef_run.node.set['nginx']['repo_source'] = 'epel' chef_run.converge(described_recipe) - expect(chef_run).to include_recipe('yum::epel') + expect(chef_run).to include_recipe('yum-epel') end it 'includes the nginx::repo recipe if the source is not epel' do diff --git a/test/integration/default/bats/check_service.bats b/test/integration/default/bats/check_service.bats new file mode 100644 index 000000000..2306be385 --- /dev/null +++ b/test/integration/default/bats/check_service.bats @@ -0,0 +1,3 @@ +@test "check memcache service" { + ps -ef | grep nginx +} diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb deleted file mode 100644 index 77785ad47..000000000 --- a/test/integration/default/serverspec/default_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'serverspec' -include Serverspec::Helper::Exec -include Serverspec::Helper::DetectOS - -describe 'nginx::default' do - it 'installed nginx' do - expect(package('nginx')).to be_installed - end - - it 'has the service up and running' do - expect(service('nginx')).to be_enabled - expect(service('nginx')).to be_running - end -end diff --git a/test/integration/source/bats/check_service.bats b/test/integration/source/bats/check_service.bats new file mode 100644 index 000000000..2306be385 --- /dev/null +++ b/test/integration/source/bats/check_service.bats @@ -0,0 +1,3 @@ +@test "check memcache service" { + ps -ef | grep nginx +} diff --git a/test/integration/source/serverspec/source_spec.rb b/test/integration/source/serverspec/source_spec.rb deleted file mode 100644 index a708306a4..000000000 --- a/test/integration/source/serverspec/source_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'serverspec' -include Serverspec::Helper::Exec -include Serverspec::Helper::DetectOS - -describe 'nginx::source' do - it 'creates the nginx conf' do - expect(file('/etc/nginx/nginx.conf')).to be_a_file - end - - it 'has nginx running' do - # Because the output of the binary compiled does not include the word - # "running", we can't use ServerSpec's native `service` method. - if backend(Serverspec::Commands::Base).check_os == 'Debian' - expect(command('service nginx status')).to return_stdout(/^run: nginx/) - else - expect(command('/sbin/service nginx status')).to return_stdout(/running/) - end - end -end