diff options
author | John Keiser <john@johnkeiser.com> | 2016-01-25 09:38:12 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-01-26 09:44:20 -0800 |
commit | c7758ccfa08a02c40561ac0cb683cefbf8bcab42 (patch) | |
tree | a55292643977210cec2d74e90964db52ef6c1260 | |
parent | 8d32dc4a67b03362b04e0a5eda717cb85dff9f27 (diff) | |
download | chef-c7758ccfa08a02c40561ac0cb683cefbf8bcab42.tar.gz |
Add acceptance test to run git cookbook
13 files changed, 448 insertions, 6 deletions
diff --git a/acceptance/Gemfile b/acceptance/Gemfile index 70d99492dd..f9a0b5497e 100644 --- a/acceptance/Gemfile +++ b/acceptance/Gemfile @@ -1,10 +1,12 @@ source "https://rubygems.org" gem "mixlib-install", github: "chef/mixlib-install" +gem "chef", path: ".." gem "chef-acceptance", github: "chef/chef-acceptance" -gem "test-kitchen", github: "sersut/test-kitchen", - branch: "sersut/mixlib-install-update" +gem "test-kitchen", github: "sersut/test-kitchen", branch: "sersut/mixlib-install-update" +gem "kitchen-ec2" gem "kitchen-inspec" gem "kitchen-vagrant" gem "windows_chef_zero" gem "winrm-transport" +gem "berkshelf" diff --git a/acceptance/README.md b/acceptance/README.md index 5f6bfc45ba..8f957debb2 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -16,15 +16,22 @@ export APPBUNDLER_ALLOW_RVM=true ### Setting up and running a test suite To get started, do a bundle install from the acceptance directory: ```shell -chef/acceptance$ bundle install +chef/acceptance$ bundle install --binstubs ``` To get some basic info and ensure chef-acceptance can be run, do: ```shell -chef/acceptance$ bundle exec chef-acceptance info +chef/acceptance$ bin/chef-acceptance info ``` To run a particular test suite, do the following: ```shell -chef/acceptance$ bundle exec chef-acceptance test TEST_SUITE +chef/acceptance$ bin/chef-acceptance test TEST_SUITE +``` + +To restrict which OS's will run, use the KITCHEN_INSTANCES environment variable: + +```shell +chef/acceptance$ export KITCHEN_INSTANCES=*-ubuntu-1404 +chef/acceptance$ bin/chef-acceptance test cookbook-git ``` diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/.gitignore b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/.gitignore new file mode 100644 index 0000000000..041413b040 --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/.gitignore @@ -0,0 +1,2 @@ +nodes/ +tmp/ diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/libraries/init.rb b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/libraries/init.rb new file mode 100644 index 0000000000..be84b88a0a --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/libraries/init.rb @@ -0,0 +1,16 @@ +module CookbookGit + def self.test_cookbook_name + "git" + end + def self.test_run_path + File.join(Chef.node["chef-acceptance"]["suite-dir"], "test_run") + end + def self.acceptance_path + File.expand_path("..", Chef.node["chef-acceptance"]["suite-dir"]) + end + def self.acceptance_gemfile + File.join(acceptance_path, "Gemfile") + end +end + +ENV["KITCHEN_LOCAL_YAML"] ||= File.join(Chef.node["chef-acceptance"]["suite-dir"], ".kitchen.#{ENV["KITCHEN_DRIVER"] || "vagrant"}.yml") diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/metadata.rb b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/metadata.rb new file mode 100644 index 0000000000..4c7c42d9bd --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/metadata.rb @@ -0,0 +1 @@ +name 'acceptance-cookbook' diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/destroy.rb b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/destroy.rb new file mode 100644 index 0000000000..faf9a87a86 --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/destroy.rb @@ -0,0 +1,5 @@ +# Run the test on the current platform +execute "bundle exec kitchen destroy #{ENV['KITCHEN_INSTANCES']}" do + cwd "#{CookbookGit.test_run_path}/#{CookbookGit.test_cookbook_name}" + env "BUNDLE_GEMFILE" => CookbookGit.acceptance_gemfile +end diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/provision.rb b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/provision.rb new file mode 100644 index 0000000000..b5efb93c57 --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/provision.rb @@ -0,0 +1,14 @@ +# Grab the cookbook +directory CookbookGit.test_run_path +# TODO Grab the source URL from supermarket +# TODO get git to include its kitchen tests in the cookbook. +git "#{CookbookGit.test_run_path}/#{CookbookGit.test_cookbook_name}" do + repository "https://github.com/jkeiser/#{CookbookGit.test_cookbook_name}.git" + branch "jk/windows-fix" +end + +# Run the test on the current platform +execute "bundle exec kitchen converge #{ENV['KITCHEN_INSTANCES']} -c" do + cwd "#{CookbookGit.test_run_path}/#{CookbookGit.test_cookbook_name}" + env "BUNDLE_GEMFILE" => CookbookGit.acceptance_gemfile +end diff --git a/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/verify.rb b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/verify.rb new file mode 100644 index 0000000000..55b362d131 --- /dev/null +++ b/acceptance/cookbook-git/.acceptance/acceptance-cookbook/recipes/verify.rb @@ -0,0 +1,5 @@ +# Run tests on the current platform +execute "bundle exec kitchen verify #{ENV['KITCHEN_INSTANCES']} -c" do + cwd "#{CookbookGit.test_run_path}/#{CookbookGit.test_cookbook_name}" + env "BUNDLE_GEMFILE" => CookbookGit.acceptance_gemfile +end diff --git a/acceptance/cookbook-git/.gitignore b/acceptance/cookbook-git/.gitignore new file mode 100644 index 0000000000..306f0cce57 --- /dev/null +++ b/acceptance/cookbook-git/.gitignore @@ -0,0 +1 @@ +test_run/ diff --git a/acceptance/cookbook-git/.kitchen.digitalocean.yml b/acceptance/cookbook-git/.kitchen.digitalocean.yml new file mode 100644 index 0000000000..744fb3d799 --- /dev/null +++ b/acceptance/cookbook-git/.kitchen.digitalocean.yml @@ -0,0 +1,19 @@ +driver: + name: digitalocean + digitalocean_access_token: <%= ENV['DIGITALOCEAN_API_TOKEN'] %> + region: <%= ENV['DIGITALOCEAN_REGION'] %> + size: 2gb + ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEYS'] %> + transport: + ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> + +platforms: +<% %w(centos-6.5 centos-7.0 + fedora-21 + debian-8.1 + ubuntu-12.04 ubuntu-14.04 ubuntu-15.10 +).each do |platform| %> + - name: #{platform} + driver_config: + image: <%= "#{platform.gsub('.', '-')}-x64" %> +<% end %> diff --git a/acceptance/cookbook-git/.kitchen.ec2.yml b/acceptance/cookbook-git/.kitchen.ec2.yml new file mode 100644 index 0000000000..b9a20bf2f2 --- /dev/null +++ b/acceptance/cookbook-git/.kitchen.ec2.yml @@ -0,0 +1,299 @@ +# chef-acceptance test --platform=ubuntu + +<% +def file_if_exists(path) + path = File.expand_path(path) + File.exist?(path) ? path : nil +end +%> + +driver: + name: ec2 + tags: + X-Project: Kitchen Tests + aws_ssh_key_id: <%= ENV['AWS_SSH_KEY_ID'] || ENV['USER'] %> + transport: + ssh_key: <%= file_if_exists("~/.ssh/#{ENV['AWS_SSH_KEY_ID'] || ENV['USERNAME']}.pem") || + file_if_exists("~/.ssh/#{ENV['AWS_SSH_KEY_ID'] || ENV['USERNAME']}") + file_if_exists("~/.ssh/id_rsa") %> + # test-specific stuff + region: us-west-2 + availability_zone: a + subnet_id: subnet-19ac017c + security_group_ids: ["sg-e401eb83", "sg-96274af3"] + instance_type: m3.large + +platforms: + # + # AIX + # + # - name: aix-6.1 + # - name: aix-7.1 + # + # Debian + # + - name: debian-8 + driver: + image_search: + name: debian-jessie-* + owner-id: 379101102735 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: admin + - name: debian-7 + driver: + image_search: + name: debian-wheezy-* + owner-id: 379101102735 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: standard + image-type: machine + instance_type: t2.micro + transport: + username: admin + - name: debian-6 + driver: + image_search: + name: debian-squeeze-* + owner-id: 379101102735 + architecture: x86_64 + virtualization-type: paravirtual + block-device-mapping.volume-type: standard + image-type: machine + instance_type: t1.micro + transport: + username: admin + # + # Ubuntu + # + - name: ubuntu-15.10 + driver: + image_search: + name: ubuntu/images/*/ubuntu-*-15.10-amd64-server-* + owner-id: 099720109477 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ubuntu + - name: ubuntu-14.04 + driver: + image_search: + name: ubuntu/images/*/ubuntu-*-14.04-*-server-* + owner-id: 099720109477 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ubuntu + - name: ubuntu-12.04 + driver: + image_search: + name: ubuntu/images/*/ubuntu-*-12.04-*-server-* + owner-id: 099720109477 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ubuntu + # + # Red Hat Enterprise Linux + # + - name: el-7 + driver: + image_search: + name: RHEL-7.* + owner-id: 309956199498 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ec2-user + - name: el-6 + driver: + image_search: + name: RHEL-6.* + owner-id: 309956199498 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ec2-user + - name: el-5 + driver: + image_search: + name: RHEL-5.* + owner-id: 309956199498 + architecture: x86_64 + virtualization-type: paravirtual + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t1.micro + transport: + username: ec2-user + # + # FreeBSD + # + - name: freebsd-10 + driver: + image_search: + name: FreeBSD/EC2 10.*-RELEASE* + owner-id: 118940168514 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ec2-user + - name: freebsd-9 + driver: + image_search: + name: FreeBSD/EC2 9.*-RELEASE* + owner-id: 118940168514 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: ec2-user + - name: freebsd-8 + driver: + image_search: + name: FreeBSD/EC2 8.*-RELEASE* + owner-id: 118940168514 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: standard + image-type: machine + instance_type: t2.micro + transport: + username: ec2-user + # + # OS/X + # + # - name: mac_os_x-10.11 + # - name: mac_os_x-10.10 + # - name: mac_os_x-10.9 + # - name: mac_os_x-10.8 + # + # Nexus??? + # + # - name: nexus-7 + # + # Solaris + # + # - name: solaris-11 + # - name: solaris-10 + # + # Windows + # + - name: windows-2012r2 + driver: + image_search: + name: Windows_Server-2012-R2*-English-*-Base-* + owner-alias: amazon + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: administrator + # user_data: | + # <powershell> + # $logfile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log" + # #PS Remoting and & winrm.cmd basic config + # Enable-PSRemoting -Force -SkipNetworkProfileCheck + # & winrm.cmd set winrm/config '@{MaxTimeoutms="1800000"}' >> $logfile + # & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile + # & winrm.cmd set winrm/config/winrs '@{MaxShellsPerUser="50"}' >> $logfile + # #Server settings - support username/password login + # & winrm.cmd set winrm/config/service/auth '@{Basic="true"}' >> $logfile + # & winrm.cmd set winrm/config/service '@{AllowUnencrypted="true"}' >> $logfile + # & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile + # #Firewall Config + # & netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any >> $logfile + # #Set script execution to unrestricted + # & Set-ExecutionPolicy Unrestricted -Force + # </powershell> + - name: windows-2012 + driver: + image_search: + name: Windows_Server-2012-RTM*-English-*-Base-* + owner-alias: amazon + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: administrator + - name: windows-2008r2 + driver: + image_search: + name: Windows_Server-2008-R2*-English-*-Base-* + owner-alias: amazon + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro + transport: + username: administrator + # + # Centos + # + - name: centos-7 + driver: + image_search: + name: CentOS Linux 7 * + owner-alias: aws-marketplace + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: standard + image-type: machine + instance_type: t2.micro + transport: + username: root + - name: centos-6 + driver: + image_search: + name: CentOS-6.5-GA-* + owner-alias: aws-marketplace + architecture: x86_64 + virtualization-type: paravirtual + block-device-mapping.volume-type: standard + image-type: machine + instance_type: t1.micro + transport: + username: root + # + # Fedora + # + - name: fedora-21 + driver: + image_search: + name: Fedora-Cloud-Base-21-* + owner-id: 125523088429 + architecture: x86_64 + virtualization-type: hvm + block-device-mapping.volume-type: gp2 + image-type: machine + instance_type: t2.micro diff --git a/acceptance/cookbook-git/.kitchen.vagrant.yml b/acceptance/cookbook-git/.kitchen.vagrant.yml new file mode 100644 index 0000000000..55d3161bc9 --- /dev/null +++ b/acceptance/cookbook-git/.kitchen.vagrant.yml @@ -0,0 +1,71 @@ +driver: + name: vagrant + forward_agent: yes + customize: + cpus: 2 + memory: 1024 + +platforms: +<% %w(debian-8 +debian-7 +debian-6 +ubuntu-15.10 +ubuntu-14.04 +ubuntu-12.04 +el-7 +el-6 +el-5 +freebsd-10 +freebsd-9 +freebsd-8 +centos-7 +centos-6 +fedora-21 +).each do |platform| %> + - name: <%= platform %> + driver: + box: opscode-<%= platform %> + box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_<%= platform %>_chef-provisionerless.box +<% end %> + +<% %w( +2012r2 +2012 +2008r2 +).each do |version| %> + - name: windows-<%= version %> + driver: + box: chef/windows-server-<%= version %>-standard +# URL is atlas +<% end %> + +suites: + - name: default + run_list: + - recipe[git] + attributes: {} + includes: ["ubuntu-14.04"] + excludes: ["windows-2012r2", "windows-2012", "windows-2008r2"] + - name: source + includes: ["nonexistent"] + excludes: ["ubuntu-12.04", "ubuntu-10.04", "windows-2012r2", "windows-2012", "windows-2008r2"] + run_list: + - recipe[git::source] + attributes: {} + - name: default-windows + includes: [ + # 'windows-8.1-professional', + # 'windows-2008r2-standard', + "windows-2012r2", + # "windows-2012", + # "windows-2008r2" + ] + run_list: + - recipe[git] + attributes: {} + +provisioner: + name: chef_zero + product_name: chef + product_version: latest + channel: current diff --git a/acceptance/trivial/.kitchen.yml b/acceptance/trivial/.kitchen.yml index a7d0a25f93..c0f1d782d2 100644 --- a/acceptance/trivial/.kitchen.yml +++ b/acceptance/trivial/.kitchen.yml @@ -23,5 +23,5 @@ suites: provisioner: product_name: chef product_version: latest - channel: current + channel: unstable run_list: |