From 5b8a168b7da8f9fbbff40ac72fe66c0870e4249f Mon Sep 17 00:00:00 2001 From: Miguel Ferreira Date: Tue, 5 Jan 2016 13:02:19 +0100 Subject: [PATCH] Add integration testing --- .../test_vagrant_chef_zero/chefignore | 12 +++++ .../test_vagrant_chef_zero/metadata.rb | 8 +++ .../test_vagrant_chef_zero/recipes/default.rb | 1 + test/fixtures/environments/test.json | 15 ++++++ test/fixtures/roles/test.json | 15 ++++++ test/integration/Vagrantfile | 49 +++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 test/fixtures/cookbooks/test_vagrant_chef_zero/chefignore create mode 100644 test/fixtures/cookbooks/test_vagrant_chef_zero/metadata.rb create mode 100644 test/fixtures/cookbooks/test_vagrant_chef_zero/recipes/default.rb create mode 100644 test/fixtures/environments/test.json create mode 100644 test/fixtures/roles/test.json create mode 100644 test/integration/Vagrantfile diff --git a/test/fixtures/cookbooks/test_vagrant_chef_zero/chefignore b/test/fixtures/cookbooks/test_vagrant_chef_zero/chefignore new file mode 100644 index 0000000..30c04ec --- /dev/null +++ b/test/fixtures/cookbooks/test_vagrant_chef_zero/chefignore @@ -0,0 +1,12 @@ +*file +*file.lock +bin +bundle +chefignore +spec +test +vendor +.git +.* +dev.* +*_dev diff --git a/test/fixtures/cookbooks/test_vagrant_chef_zero/metadata.rb b/test/fixtures/cookbooks/test_vagrant_chef_zero/metadata.rb new file mode 100644 index 0000000..2810b01 --- /dev/null +++ b/test/fixtures/cookbooks/test_vagrant_chef_zero/metadata.rb @@ -0,0 +1,8 @@ +name 'test_vagrant_chef_zero' +maintainer 'The Authors' +maintainer_email 'you@example.com' +license 'all_rights' +description 'Installs/Configures test_vagrant_chef_zero' +long_description 'Installs/Configures test_vagrant_chef_zero' +version '0.1.0' + diff --git a/test/fixtures/cookbooks/test_vagrant_chef_zero/recipes/default.rb b/test/fixtures/cookbooks/test_vagrant_chef_zero/recipes/default.rb new file mode 100644 index 0000000..0c8f304 --- /dev/null +++ b/test/fixtures/cookbooks/test_vagrant_chef_zero/recipes/default.rb @@ -0,0 +1 @@ +log 'Converging test_vagrant_chef_zero::default' diff --git a/test/fixtures/environments/test.json b/test/fixtures/environments/test.json new file mode 100644 index 0000000..2f4f5ef --- /dev/null +++ b/test/fixtures/environments/test.json @@ -0,0 +1,15 @@ +{ + "name": "test", + "description": "", + "cookbook_versions": { + + }, + "json_class": "Chef::Environment", + "chef_type": "environment", + "default_attributes": { + + }, + "override_attributes": { + + } +} diff --git a/test/fixtures/roles/test.json b/test/fixtures/roles/test.json new file mode 100644 index 0000000..52b321a --- /dev/null +++ b/test/fixtures/roles/test.json @@ -0,0 +1,15 @@ +{ + "name": "test", + "description": "", + "cookbook_versions": { + + }, + "json_class": "Chef::Role", + "chef_type": "role", + "default_attributes": { + + }, + "override_attributes": { + + } +} diff --git a/test/integration/Vagrantfile b/test/integration/Vagrantfile new file mode 100644 index 0000000..7000db3 --- /dev/null +++ b/test/integration/Vagrantfile @@ -0,0 +1,49 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +test_machines = { + 'windows' => { + 'box' => ENV['VAGRANT_TEST_WINDOWS_BOX'], # sbp_windows_2012_r2_20141211_1 + 'communicator' => :winrm, + 'guest' => :windows + }, + 'centos' => { + 'box' => ENV['VAGRANT_TEST_CENTOS_BOX'], # opscode-centos-7.1 + 'communicator' => :ssh, + 'guest' => :linux + } +} + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config| + test_machines.each_pair do |name, options| + global_config.vm.define name do |config| + + config.vm.box = options['box'] + + config.vm.communicator = options['communicator'] + config.vm.guest = options['guest'] + + config.vm.provider 'virtualbox' do |vb| + vb.gui = true + end + + config.berkshelf.enabled = true + + config.omnibus.chef_version = 'latest' + + config.chef_zero.cookbooks = [ '../fixtures/cookbooks' ] + config.chef_zero.environments = '../fixtures/environments' + config.chef_zero.roles = '../fixtures/roles' + + config.vm.provision 'chef_client', run: 'always' do |chef| + chef.environment = 'test' + chef.add_role 'test' + chef.log_level = 'info' + chef.run_list = [ 'recipe[test_vagrant_chef_zero::default]' ] + end + end + end +end