From 2296df31bc291a856028374ee4d9cfe6908b3f9f Mon Sep 17 00:00:00 2001 From: hippo Date: Mon, 26 Oct 2015 10:37:46 +0800 Subject: [PATCH] Add kitchen test for docker --- .gitignore | 1 + .kitchen.travis.yml | 4 +++ .kitchen.yml | 16 +++++++++--- Berksfile | 2 +- Berksfile.lock | 25 ------------------- Gemfile | 7 +++--- recipes/package.rb | 2 +- recipes/source.rb | 2 +- .../python_test/recipes/test_exert.rb | 4 +-- test/integration/exert/bats/exert.bats | 6 ++--- 10 files changed, 30 insertions(+), 39 deletions(-) create mode 100644 .kitchen.travis.yml delete mode 100644 Berksfile.lock diff --git a/.gitignore b/.gitignore index 8fb3f98..838135e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ bin/* .bundle/* .kitchen/ .kitchen.local.yml +Berksfile.lock diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml new file mode 100644 index 0000000..1b4c649 --- /dev/null +++ b/.kitchen.travis.yml @@ -0,0 +1,4 @@ +--- +driver: + name: docker + require_chef_omnibus: "<%= ENV['CHEF_VERSION'] || 'latest' %>" diff --git a/.kitchen.yml b/.kitchen.yml index 6432844..cda3a23 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -3,6 +3,10 @@ driver_plugin: vagrant driver_config: require_chef_omnibus: true +chef_versions: +- 11.10 +- 12 + platforms: - name: ubuntu-12.10 driver_config: @@ -22,15 +26,21 @@ platforms: box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box run_list: ["recipe[apt]"] +- name: ubuntu-14.04 + driver_config: + box: opscode-ubuntu-14.04 + box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-14.04_provisionerless.box + run_list: ["recipe[apt]"] + - name: centos-5.9 driver_config: box: opscode-centos-5.9 box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box -- name: centos-6.4 +- name: centos-6.7 driver_config: - box: opscode-centos-6.4 - box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box + box: opscode-centos-6.7 + box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.7_provisionerless.box suites: - name: default diff --git a/Berksfile b/Berksfile index f59fa9c..4cbb25b 100644 --- a/Berksfile +++ b/Berksfile @@ -1,4 +1,4 @@ -site 'https://supermarket.chef.io' +source 'https://api.berkshelf.com' metadata diff --git a/Berksfile.lock b/Berksfile.lock deleted file mode 100644 index 2652d9d..0000000 --- a/Berksfile.lock +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": { - "python": { - "path": "." - }, - "minitest-handler": { - "locked_version": "1.1.2" - }, - "apt": { - "locked_version": "2.3.4" - }, - "yum": { - "locked_version": "3.0.2" - }, - "build-essential": { - "locked_version": "1.4.2" - }, - "python_test": { - "path": "./test/cookbooks/python_test" - }, - "chef_handler": { - "locked_version": "1.1.4" - } - } -} diff --git a/Gemfile b/Gemfile index 5334438..a52b01a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' -gem 'foodcritic', '>= 3.0.3' -gem 'berkshelf', '~> 2.0' -gem 'chefspec', '~> 3.0' +gem 'foodcritic' +gem 'berkshelf' +gem 'chefspec' +gem 'kitchen-docker' diff --git a/recipes/package.rb b/recipes/package.rb index 38ea3b3..ceca277 100644 --- a/recipes/package.rb +++ b/recipes/package.rb @@ -29,7 +29,7 @@ else python_pkgs = value_for_platform_family( "debian" => ["python","python-dev"], - "rhel" => ["python","python-devel"], + "rhel" => ["python","python-devel",'gcc'], "fedora" => ["python","python-devel"], "freebsd" => ["python"], "smartos" => ["python27"], diff --git a/recipes/source.rb b/recipes/source.rb index c6256f7..6acf445 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -24,7 +24,7 @@ make_options = node['python']['make_options'].join(" ") packages = value_for_platform_family( - "rhel" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"], + "rhel" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel",'tar'], "default" => ["libssl-dev","libbz2-dev","zlib1g-dev","libexpat1-dev","libdb-dev","libsqlite3-dev","libncursesw5-dev","libncurses5-dev","libreadline-dev","libsasl2-dev", "libgdbm-dev"] ) # diff --git a/test/cookbooks/python_test/recipes/test_exert.rb b/test/cookbooks/python_test/recipes/test_exert.rb index b0ad314..c329e19 100644 --- a/test/cookbooks/python_test/recipes/test_exert.rb +++ b/test/cookbooks/python_test/recipes/test_exert.rb @@ -18,7 +18,7 @@ # limitations under the License. # -python_virtualenv "#{Chef::Config[:file_cache_path]}/virtualenv" do +python_virtualenv "/tmp/kitchen/virtualenv" do interpreter "python" owner "root" group "root" @@ -27,7 +27,7 @@ python_pip "boto" do action :install - virtualenv "#{Chef::Config[:file_cache_path]}/virtualenv" + virtualenv "/tmp/kitchen/virtualenv" end python_pip "psutil" do diff --git a/test/integration/exert/bats/exert.bats b/test/integration/exert/bats/exert.bats index 714e3e1..efa3dab 100644 --- a/test/integration/exert/bats/exert.bats +++ b/test/integration/exert/bats/exert.bats @@ -1,13 +1,13 @@ #!/usr/bin/env bats @test "virtualenv test environment should exist" { - [ -f "/tmp/kitchen-chef-solo/cache/virtualenv/bin/activate" ] + [ -f "/tmp/kitchen/virtualenv/bin/activate" ] } @test "virtualenv test environment should be owned by root" { - ls -l /tmp/kitchen-chef-solo/cache/virtualenv | grep "root root" + ls -l /tmp/kitchen/virtualenv | grep "root root" } @test "virtualenv test environment should have boto working" { - /tmp/kitchen-chef-solo/cache/virtualenv/bin/python -c 'import boto; boto.Version' + /tmp/kitchen/virtualenv/bin/python -c 'import boto; boto.Version' }