From f399dc24753bebafa0dfcdc17c9ed3baf03e81b4 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Fri, 18 Apr 2014 15:24:36 -0700 Subject: [PATCH] Added VCloud configs for 4 os types. Modified Registry to install local module rather than pull from repository Added a presuite file install_pe to install PuppetEnterprise Add rake task for testing pe --- .gitignore | 5 ++- Gemfile | 4 -- Rakefile | 18 ++++++-- acceptance/.beaker-pe.cfg | 12 ++++++ acceptance/config/windows-2003r2-i386.cfg | 25 +++++++++++ acceptance/config/windows-2003r2-x86_64.cfg | 25 +++++++++++ acceptance/config/windows-2008r2-x86_64.cfg | 25 +++++++++++ acceptance/config/windows-2012-x86_64.cfg | 23 +++++++++++ acceptance/lib/systest/util/registry.rb | 41 ++++++++++++++++++- acceptance/setup/install_pe.rb | 3 ++ .../resource/registry/should_create_key.rb | 7 ++-- .../registry/should_have_defined_type.rb | 5 ++- .../resource/registry/should_manage_values.rb | 4 +- .../resource/registry/should_pluginsync.rb | 4 +- .../registry/should_tolerate_mixed_case.rb | 4 +- 15 files changed, 183 insertions(+), 22 deletions(-) create mode 100644 acceptance/.beaker-pe.cfg create mode 100644 acceptance/config/windows-2003r2-i386.cfg create mode 100644 acceptance/config/windows-2003r2-x86_64.cfg create mode 100644 acceptance/config/windows-2008r2-x86_64.cfg create mode 100644 acceptance/config/windows-2012-x86_64.cfg create mode 100644 acceptance/setup/install_pe.rb diff --git a/.gitignore b/.gitignore index afc96ec1..6f08022e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ pkg/ .DS_Store coverage/ .idea/ -*.iml \ No newline at end of file +*.iml +acceptance/log/* +.vagrant +Gemfile.lock diff --git a/Gemfile b/Gemfile index f9730e13..c6c7eea7 100644 --- a/Gemfile +++ b/Gemfile @@ -13,11 +13,7 @@ end group :development, :test do gem 'rake', :require => false gem 'mocha', '~>0.10.5', :require => false - gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system', :require => false - gem 'rspec-system-puppet', :require => false - gem 'rspec-system-serverspec', :require => false gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false diff --git a/Rakefile b/Rakefile index e870c87f..a644b7e0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,3 @@ -require 'rake' -require 'rspec/core/rake_task' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' @@ -8,7 +6,7 @@ task :default => [:test] desc 'Run RSpec' RSpec::Core::RakeTask.new(:test) do |t| t.pattern = 'spec/{unit}/**/*.rb' -# t.rspec_opts = ['--color'] + #t.rspec_opts = ['--color'] end desc 'Generate code coverage' @@ -17,5 +15,17 @@ RSpec::Core::RakeTask.new(:coverage) do |t| t.rcov_opts = ['--exclude', 'spec'] end +desc "Run rake tasks" +task "beaker:test:pe" do |t, args| -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp","tests/**/*.pp"] \ No newline at end of file + cmd_str = "beaker --options-file .beaker-pe.cfg " + args.extras.each do |v| + cmd_str += "#{v} " + end + + Dir.chdir("./acceptance") + system(cmd_str) + Dir.chdir("../") +end + +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp","tests/**/*.pp"] diff --git a/acceptance/.beaker-pe.cfg b/acceptance/.beaker-pe.cfg new file mode 100644 index 00000000..68ff3f20 --- /dev/null +++ b/acceptance/.beaker-pe.cfg @@ -0,0 +1,12 @@ +{ + :load_path => "./lib/", + :hosts_file => './config/windows-2012-x86_64.cfg', + :type => "pe", + :pre_suite => ['./setup/install_pe.rb'], + :tests => "./tests", + :pe_dir => "http://neptune.delivery.puppetlabs.net/3.2/ci-ready", + :debug => true, + :timeout => 6000, + :ntp => true, + :keyfile => "~/.ssh/id_rsa-acceptance" +} diff --git a/acceptance/config/windows-2003r2-i386.cfg b/acceptance/config/windows-2003r2-i386.cfg new file mode 100644 index 00000000..1d61f107 --- /dev/null +++ b/acceptance/config/windows-2003r2-i386.cfg @@ -0,0 +1,25 @@ +HOSTS: + centos6: + roles: + - master + - database + - agent + - dashboard + platform: el-6-x86_64 + template: centos-6-x86_64 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ + w2k3r2: + roles: + - agent + platform: windows-2003r2-i386 + template: win-2003r2-i386 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ +CONFIG: + nfs_server: none + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/FOSS/Dynamic + resourcepool: delivery/Quality Assurance/FOSS/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/acceptance/config/windows-2003r2-x86_64.cfg b/acceptance/config/windows-2003r2-x86_64.cfg new file mode 100644 index 00000000..a81c19e7 --- /dev/null +++ b/acceptance/config/windows-2003r2-x86_64.cfg @@ -0,0 +1,25 @@ +HOSTS: + centos6: + roles: + - master + - database + - agent + - dashboard + platform: el-6-x86_64 + template: centos-6-x86_64 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ + w2k3r2: + roles: + - agent + platform: windows-2003r2-x86_64 + template: win-2003r2-x86_64 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ +CONFIG: + nfs_server: none + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/FOSS/Dynamic + resourcepool: delivery/Quality Assurance/FOSS/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/acceptance/config/windows-2008r2-x86_64.cfg b/acceptance/config/windows-2008r2-x86_64.cfg new file mode 100644 index 00000000..1ab3a91f --- /dev/null +++ b/acceptance/config/windows-2008r2-x86_64.cfg @@ -0,0 +1,25 @@ +HOSTS: + centos6: + roles: + - master + - database + - agent + - dashboard + platform: el-6-x86_64 + template: centos-6-x86_64 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ + w2k8r2: + roles: + - agent + platform: windows-2008r2-x86_64 + template: win-2008r2-x86_64 + hypervisor: vcloud + pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/ +CONFIG: + nfs_server: none + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/FOSS/Dynamic + resourcepool: delivery/Quality Assurance/FOSS/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/acceptance/config/windows-2012-x86_64.cfg b/acceptance/config/windows-2012-x86_64.cfg new file mode 100644 index 00000000..7ddcde94 --- /dev/null +++ b/acceptance/config/windows-2012-x86_64.cfg @@ -0,0 +1,23 @@ +HOSTS: + centos6: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + template: centos-6-x86_64 + hypervisor: vcloud + w2012: + roles: + - agent + - default + platform: windows-2012-x86_64 + template: win-2012-x86_64 + hypervisor: vcloud +CONFIG: + nfs_server: none + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/FOSS/Dynamic + resourcepool: delivery/Quality Assurance/FOSS/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/acceptance/lib/systest/util/registry.rb b/acceptance/lib/systest/util/registry.rb index ef675251..8f9562b7 100644 --- a/acceptance/lib/systest/util/registry.rb +++ b/acceptance/lib/systest/util/registry.rb @@ -1,4 +1,5 @@ require 'pathname' + require Pathname.new(__FILE__).dirname # This module is meant to be mixed into the individual test cases for the # registry module. @@ -82,6 +83,14 @@ def master_options "--modulepath=\"#{get_test_file_path(master, master_module_dir)}\" " + "--autosign true --pluginsync" end + def master_options_hash + @master_options_hash ||= { + :manifest => "#{get_test_file_path(master, master_manifest_file)}", + :modulepath => "#{get_test_file_path(master, master_module_dir)} ", + :autosign => true, + :pluginsync => true + } + end def agent_exit_codes # legal exit codes whenever we run the agent @@ -143,18 +152,37 @@ def create_test_file(host, file_rel_path, file_content, options) chown(host, options[:owner], options[:group], file_path) chmod(host, options[:mode], file_path) end - + def puppet_module_install(host = nil, source = nil, module_name = nil, module_path = '/etc/puppet/modules') + module_dir = File.join(module_path,module_name) + on host, "mkdir -p #{module_path}" + ['manifests','lib'].each do |folder| + on host, "mkdir -p #{File.join(module_dir,folder)}" + host.do_scp_to(File.join(source,folder),module_dir,{:mkdir => true}) + end + end def setup_master(master_manifest_content="# Intentionally Blank\n") step "Setup Puppet Master Manifest" do + proj_root = File.expand_path(File.join(File.dirname(__FILE__),'../../../../')) masters.each do |host| + puppet_module_install(host,proj_root,'registry',File.join(host['puppetpath'],"modules")) create_test_file(host, master_manifest_file, master_manifest_content, :mkdirs => true) + puppet_conf_update_ini = <<-MANIFEST + ini_setting{'Update Puppet.Conf': + ensure => present, + section => 'main', + key_val_separator => '=', + path => '#{host['puppetpath']}/puppet.conf', + setting => 'manifestdir', + value => '#{host_test_tmp_dirs[host.name]}/master_manifest/' } + MANIFEST + on host, puppet('apply','--debug'), :stdin => puppet_conf_update_ini end end step "Symlink the module(s) into the master modulepath" do masters.each do |host| moddir = get_test_file_path(host, master_module_dir) mkdirs(host, moddir) - on host, "ln -s /opt/puppet-git-repos/stdlib \"#{moddir}/stdlib\"; ln -s /opt/puppet-git-repos/registry \"#{moddir}/registry\"" + #on host, "ln -s /opt/puppet-git-repos/stdlib \"#{moddir}/stdlib\"; ln -s /opt/puppet-git-repos/registry \"#{moddir}/registry\"" end end end @@ -162,6 +190,15 @@ def setup_master(master_manifest_content="# Intentionally Blank\n") def clean_up step "Clean Up" do masters.each do |host| + puppet_conf_update_ini = <<-MANIFEST + ini_setting{'Revert Puppet.Conf': + ensure => absent, + section => 'main', + key_val_separator => '=', + path => '#{host['puppetpath']}/puppet.conf', + setting => 'manifestdir' } + MANIFEST + on host, puppet('apply','--debug'), :stdin => puppet_conf_update_ini on host, "rm -rf \"%s\"" % get_test_file_path(host, '') end agents.each do |host| diff --git a/acceptance/setup/install_pe.rb b/acceptance/setup/install_pe.rb new file mode 100644 index 00000000..33d46911 --- /dev/null +++ b/acceptance/setup/install_pe.rb @@ -0,0 +1,3 @@ +test_name "Installing Puppet Enterprise" do + install_pe +end diff --git a/acceptance/tests/resource/registry/should_create_key.rb b/acceptance/tests/resource/registry/should_create_key.rb index b3639c22..2c4ef326 100644 --- a/acceptance/tests/resource/registry/should_create_key.rb +++ b/acceptance/tests/resource/registry/should_create_key.rb @@ -1,6 +1,6 @@ require 'tempfile' require 'pathname' -require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry' +require 'systest/util/registry' # Include our utility methods in the singleton class of the test case instance. class << self include Systest::Util::Registry @@ -85,10 +85,11 @@ class phase3 { HERE # Setup the master to use the modules specified in the --modules option -setup_master master_manifest_content + step "Start the master" do - with_master_running_on(master, master_options) do + setup_master master_manifest_content + with_puppet_running_on master, :__commandline_args__ => master_options do # A set of keys we expect Puppet to create keys_created_native = [ /Registry_key\[HKLM.Software.Vendor.PuppetLabsTest\w+\].ensure: created/, diff --git a/acceptance/tests/resource/registry/should_have_defined_type.rb b/acceptance/tests/resource/registry/should_have_defined_type.rb index d3ed774c..dc65fd99 100644 --- a/acceptance/tests/resource/registry/should_have_defined_type.rb +++ b/acceptance/tests/resource/registry/should_have_defined_type.rb @@ -1,5 +1,5 @@ require 'pathname' -require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry' +require 'systest/util/registry' # Include our utility methods in the singleton class of the test case instance. class << self include Systest::Util::Registry @@ -49,7 +49,8 @@ class phase1 { setup_master master_manifest_content step "Start the master" do - with_master_running_on(master, master_options) do + with_puppet_running_on master, :__commandline_args__ => master_options do + # A set of keys we expect Puppet to create phase1_resources_created = [ /Registry_key\[HKLM.Software.Vendor.PuppetLabsTest\w+\].ensure: created/, diff --git a/acceptance/tests/resource/registry/should_manage_values.rb b/acceptance/tests/resource/registry/should_manage_values.rb index d2333fb7..657cb8e0 100644 --- a/acceptance/tests/resource/registry/should_manage_values.rb +++ b/acceptance/tests/resource/registry/should_manage_values.rb @@ -1,5 +1,5 @@ require 'pathname' -require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry' +require 'systest/util/registry' # Include our utility methods in the singleton class of the test case instance. class << self include Systest::Util::Registry @@ -215,7 +215,7 @@ class phase1 { setup_master master_manifest_content step "Start the master" do - with_master_running_on(master, master_options) do + with_puppet_running_on master, :__commandline_args__ => master_options do windows_agents.each do |agent| this_agent_args = agent_args % get_test_file_path(agent, agent_lib_dir) x64 = x64?(agent) diff --git a/acceptance/tests/resource/registry/should_pluginsync.rb b/acceptance/tests/resource/registry/should_pluginsync.rb index db04ccbf..29b7ae7f 100644 --- a/acceptance/tests/resource/registry/should_pluginsync.rb +++ b/acceptance/tests/resource/registry/should_pluginsync.rb @@ -1,5 +1,5 @@ require 'pathname' -require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry' +require 'systest/util/registry' # Include our utility methods in the singleton class of the test case instance. class << self include Systest::Util::Registry @@ -14,7 +14,7 @@ class << self setup_master master_manifest_content step "Start the master and test pluginsync" do - with_master_running_on(master, master_options) do + with_puppet_running_on master, :__commandline_args__ => master_options do windows_agents.each do |agent| this_agent_args = agent_args % get_test_file_path(agent, agent_lib_dir) run_agent_on(agent, this_agent_args, :acceptable_exit_codes => agent_exit_codes) do diff --git a/acceptance/tests/resource/registry/should_tolerate_mixed_case.rb b/acceptance/tests/resource/registry/should_tolerate_mixed_case.rb index bdee8bc1..6bd68106 100644 --- a/acceptance/tests/resource/registry/should_tolerate_mixed_case.rb +++ b/acceptance/tests/resource/registry/should_tolerate_mixed_case.rb @@ -1,5 +1,5 @@ require 'pathname' -require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry' +require 'systest/util/registry' # Include our utility methods in the singleton class of the test case instance. class << self include Systest::Util::Registry @@ -137,7 +137,7 @@ class phase1 { setup_master master_manifest_content step "Start the master" do - with_master_running_on(master, master_options) do + with_puppet_running_on master, :__commandline_args__ => master_options do windows_agents.each do |agent| this_agent_args = agent_args % get_test_file_path(agent, agent_lib_dir)