diff --git a/acceptance/tests/environment/can_enumerate_environments.rb b/acceptance/tests/environment/can_enumerate_environments.rb index 46d3d2222..a7757192a 100644 --- a/acceptance/tests/environment/can_enumerate_environments.rb +++ b/acceptance/tests/environment/can_enumerate_environments.rb @@ -1,69 +1,69 @@ test_name "Can enumerate environments via an HTTP endpoint" def master_port(agent) setting_on(agent, "agent", "masterport") end def setting_on(host, section, name) on(host, puppet("config", "print", name, "--section", section)).stdout.chomp end def full_path(host, path) if host['platform'] =~ /win/ on(host, "cygpath '#{path}'").stdout.chomp else path end end def curl_master_from(agent, path, headers = '', &block) url = "https://#{master}:#{master_port(agent)}#{path}" cert_path = full_path(agent, setting_on(agent, "agent", "hostcert")) key_path = full_path(agent, setting_on(agent, "agent", "hostprivkey")) curl_base = "curl --tlsv1 -sg --cert \"#{cert_path}\" --key \"#{key_path}\" -k -H '#{headers}'" on agent, "#{curl_base} '#{url}'", &block end -master_user = on(master, "puppet master --configprint user").stdout.strip +master_user = on(master, puppet("master --configprint user")).stdout.strip environments_dir = create_tmpdir_for_user master, "environments" apply_manifest_on(master, <<-MANIFEST) File { ensure => directory, owner => #{master_user}, group => #{master['group']}, mode => "0770", } file { "#{environments_dir}":; "#{environments_dir}/env1":; "#{environments_dir}/env2":; } MANIFEST master_opts = { :master => { :environmentpath => environments_dir } } if master.is_pe? master_opts[:master][:basemodulepath] = master['sitemoduledir'] end with_puppet_running_on(master, master_opts) do agents.each do |agent| step "Ensure that an unauthenticated client cannot access the environments list" do on agent, "curl --tlsv1 -ksv https://#{master}:#{master_port(agent)}/v2.0/environments", :acceptable_exit_codes => [0,7] do assert_match(/< HTTP\/1\.\d 403/, stderr) end end step "Ensure that an authenticated client can retrieve the list of environments" do curl_master_from(agent, '/v2.0/environments') do data = JSON.parse(stdout) assert_equal(["env1", "env2", "production"], data["environments"].keys.sort) end end end end diff --git a/acceptance/tests/environment/use_environment_from_environmentpath.rb b/acceptance/tests/environment/use_environment_from_environmentpath.rb index 8739d76c1..f5e84ef77 100644 --- a/acceptance/tests/environment/use_environment_from_environmentpath.rb +++ b/acceptance/tests/environment/use_environment_from_environmentpath.rb @@ -1,189 +1,189 @@ test_name "Use environments from the environmentpath" require 'puppet/acceptance/classifier_utils' extend Puppet::Acceptance::ClassifierUtils classify_nodes_as_agent_specified_if_classifer_present testdir = create_tmpdir_for_user master, 'use_environmentpath' def generate_environment(path_to_env, environment) env_content = <<-EOS "#{path_to_env}/#{environment}":; "#{path_to_env}/#{environment}/manifests":; "#{path_to_env}/#{environment}/modules":; EOS end def generate_module_content(module_name, options = {}) base_path = options[:base_path] environment = options[:environment] env_path = options[:env_path] path_to_module = [base_path, env_path, environment, "modules"].compact.join("/") module_info = "module-#{module_name}" module_info << "-from-#{environment}" if environment module_content = <<-EOS "#{path_to_module}/#{module_name}":; "#{path_to_module}/#{module_name}/manifests":; "#{path_to_module}/#{module_name}/files":; "#{path_to_module}/#{module_name}/templates":; "#{path_to_module}/#{module_name}/lib":; "#{path_to_module}/#{module_name}/lib/facter":; "#{path_to_module}/#{module_name}/manifests/init.pp": ensure => file, mode => "0640", content => 'class #{module_name} { notify { "template-#{module_name}": message => template("#{module_name}/our_template.erb") } file { "$agent_file_location/file-#{module_info}": source => "puppet:///modules/#{module_name}/data" } }' ; "#{path_to_module}/#{module_name}/lib/facter/environment_fact_#{module_name}.rb": ensure => file, mode => "0640", content => "Facter.add(:environment_fact_#{module_name}) { setcode { 'environment fact from #{module_info}' } }" ; "#{path_to_module}/#{module_name}/files/data": ensure => file, mode => "0640", content => "data file from #{module_info}" ; "#{path_to_module}/#{module_name}/templates/our_template.erb": ensure => file, mode => "0640", content => "<%= @environment_fact_#{module_name} %>" ; EOS end def generate_site_manifest(path_to_manifest, *modules_to_include) manifest_content = <<-EOS "#{path_to_manifest}/site.pp": ensure => file, mode => "0640", content => "#{modules_to_include.map { |m| "include #{m}" }.join("\n")}" ; EOS end -master_user = on(master, "puppet master --configprint user").stdout.strip +master_user = on(master, puppet("master --configprint user")).stdout.strip apply_manifest_on(master, <<-MANIFEST, :catch_failures => true) File { ensure => directory, owner => #{master_user}, group => #{master['group']}, mode => "0770", } file { "#{testdir}":; "#{testdir}/base":; "#{testdir}/additional":; "#{testdir}/modules":; #{generate_environment("#{testdir}/base", "shadowed")} #{generate_environment("#{testdir}/base", "onlybase")} #{generate_environment("#{testdir}/additional", "shadowed")} #{generate_module_content("atmp", :base_path => testdir, :env_path => 'base', :environment => 'shadowed')} #{generate_site_manifest("#{testdir}/base/shadowed/manifests", "atmp", "globalmod")} #{generate_module_content("atmp", :base_path => testdir, :env_path => 'base', :environment => 'onlybase')} #{generate_site_manifest("#{testdir}/base/onlybase/manifests", "atmp", "globalmod")} #{generate_module_content("atmp", :base_path => testdir, :env_path => 'additional', :environment => 'shadowed')} #{generate_site_manifest("#{testdir}/additional/shadowed/manifests", "atmp", "globalmod")} # And one global module (--modulepath setting) #{generate_module_content("globalmod", :base_path => testdir)} "#{testdir}/additional/production":; "#{testdir}/additional/production/manifests":; #{generate_site_manifest("#{testdir}/additional/production/manifests", "globalmod")} } MANIFEST def run_with_environment(agent, environment, options = {}) expected_exit_code = options[:expected_exit_code] || 2 expected_strings = options[:expected_strings] step "running an agent in environment '#{environment}'" atmp = agent.tmpdir("use_environmentpath_#{environment}") agent_config = [ "-t", "--server", master, ] agent_config << '--environment' << environment if environment # This to test how the agent behaves when using the directory environment # loaders (which will not load an environment if it does not exist) agent_config << "--environmentpath='$confdir/environments'" if agent != master agent_config << { 'ENV' => { "FACTER_agent_file_location" => atmp }, } on(agent, puppet("agent", *agent_config), :acceptable_exit_codes => [expected_exit_code]) do |result| yield atmp, result end on agent, "rm -rf #{atmp}" end master_opts = { 'master' => { 'environmentpath' => "#{testdir}/additional:#{testdir}/base", 'basemodulepath' => "#{testdir}/modules", } } if master.is_pe? master_opts['master']['basemodulepath'] << ":#{master['sitemoduledir']}" end with_puppet_running_on master, master_opts, testdir do agents.each do |agent| run_with_environment(agent, "shadowed") do |tmpdir,catalog_result| ["module-atmp-from-shadowed", "module-globalmod"].each do |expected| assert_match(/environment fact from #{expected}/, catalog_result.stdout) end ["module-atmp-from-shadowed", "module-globalmod"].each do |expected| on agent, "cat #{tmpdir}/file-#{expected}" do |file_result| assert_match(/data file from #{expected}/, file_result.stdout) end end end run_with_environment(agent, "onlybase") do |tmpdir,catalog_result| ["module-atmp-from-onlybase", "module-globalmod"].each do |expected| assert_match(/environment fact from #{expected}/, catalog_result.stdout) end ["module-atmp-from-onlybase", "module-globalmod"].each do |expected| on agent, "cat #{tmpdir}/file-#{expected}" do |file_result| assert_match(/data file from #{expected}/, file_result.stdout) end end end run_with_environment(agent, nil, :expected_exit_code => 2) do |tmpdir, catalog_result| assert_no_match(/module-atmp/, catalog_result.stdout, "module-atmp was included despite no environment being loaded") assert_match(/environment fact from module-globalmod/, catalog_result.stdout) on agent, "cat #{tmpdir}/file-module-globalmod" do |file_result| assert_match(/data file from module-globalmod/, file_result.stdout) end end end end diff --git a/acceptance/tests/modules/install/with_environment.rb b/acceptance/tests/modules/install/with_environment.rb index 1eeccce5c..8497e6cd0 100644 --- a/acceptance/tests/modules/install/with_environment.rb +++ b/acceptance/tests/modules/install/with_environment.rb @@ -1,64 +1,64 @@ test_name 'puppet module install (with environment)' require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils hosts.each do |host| skip_test "skip tests requiring forge certs on solaris and aix" if host['platform'] =~ /solaris/ end tmpdir = master.tmpdir('module-install-with-environment') module_author = "pmtacceptance" module_name = "nginx" orig_installed_modules = get_installed_modules_for_hosts hosts teardown do rm_installed_modules_from_hosts orig_installed_modules, (get_installed_modules_for_hosts hosts) end step 'Setup' stub_forge_on(master) puppet_conf = generate_base_directory_environments(tmpdir) check_module_install_in = lambda do |environment_path, module_install_args| - on master, "puppet module install #{module_author}-#{module_name} --config=#{puppet_conf} #{module_install_args}" do + on(master, puppet("module install #{module_author}-#{module_name} --config=#{puppet_conf} #{module_install_args}")) do assert_module_installed_ui(stdout, module_author, module_name) assert_match(/#{environment_path}/, stdout, "Notice of non default install path was not displayed") end assert_module_installed_on_disk(master, module_name, environment_path) end step 'Install a module into a non default directory environment' do check_module_install_in.call("#{tmpdir}/environments/direnv/modules", "--environment=direnv") end step 'Prepare a separate modulepath' modulepath_dir = master.tmpdir("modulepath") apply_manifest_on(master, <<-MANIFEST , :catch_failures => true) file { [ '#{tmpdir}/environments/production', '#{modulepath_dir}', ]: ensure => directory, owner => #{master['user']}, } MANIFEST step "Install a module into --modulepath #{modulepath_dir} despite the implicit production directory env existing" do check_module_install_in.call(modulepath_dir, "--modulepath=#{modulepath_dir}") end step "Uninstall so we can try a different scenario" do - on master, "puppet module uninstall #{module_author}-#{module_name} --config=#{puppet_conf} --modulepath=#{modulepath_dir}" + on(master, puppet("module uninstall #{module_author}-#{module_name} --config=#{puppet_conf} --modulepath=#{modulepath_dir}")) end step "Install a module into --modulepath #{modulepath_dir} with a directory env specified" do check_module_install_in.call(modulepath_dir, "--modulepath=#{modulepath_dir} --environment=direnv") end diff --git a/acceptance/tests/modules/uninstall/with_environment.rb b/acceptance/tests/modules/uninstall/with_environment.rb index 8bfe51d0f..7c9e93484 100644 --- a/acceptance/tests/modules/uninstall/with_environment.rb +++ b/acceptance/tests/modules/uninstall/with_environment.rb @@ -1,48 +1,48 @@ test_name 'puppet module uninstall (with environment)' require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils tmpdir = master.tmpdir('module-uninstall-with-environment') step 'Setup' stub_forge_on(master) puppet_conf = generate_base_directory_environments(tmpdir) crakorn_metadata = <<-EOS { "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] } EOS # Configure a non-default environment apply_manifest_on master, %Q{ file { [ '#{tmpdir}/environments/direnv/modules', '#{tmpdir}/environments/direnv/modules/crakorn', ]: ensure => directory, } file { '#{tmpdir}/environments/direnv/modules/crakorn/metadata.json': content => '#{crakorn_metadata}', } } step 'Uninstall a module from a non default directory environment' do environment_path = "#{tmpdir}/environments/direnv/modules" - on master, "puppet module uninstall jimmy-crakorn --config=#{puppet_conf} --environment=direnv" do + on(master, puppet("module uninstall jimmy-crakorn --config=#{puppet_conf} --environment=direnv")) do assert_equal <<-OUTPUT, stdout \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{environment_path} OUTPUT end on master, "[ ! -d #{environment_path}/crackorn ]" end diff --git a/acceptance/tests/resource/package/ips/basic_tests.rb b/acceptance/tests/resource/package/ips/basic_tests.rb index a41508837..84243fb0d 100644 --- a/acceptance/tests/resource/package/ips/basic_tests.rb +++ b/acceptance/tests/resource/package/ips/basic_tests.rb @@ -1,73 +1,73 @@ test_name "Package:IPS basic tests" confine :to, :platform => 'solaris-11' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::IPSUtils teardown do step "cleanup" agents.each do |agent| clean agent end end agents.each do |agent| step "IPS: clean slate" clean agent step "IPS: setup" setup agent setup_fakeroot agent send_pkg agent, :pkg => 'mypkg@0.0.1' set_publisher agent step "IPS: basic ensure we are clean" apply_manifest_on(agent, 'package {mypkg : ensure=>absent}') on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do assert_no_match( /mypkg@0.0.1/, result.stdout, "err: #{agent}") end step "IPS: basic - it should create" apply_manifest_on(agent, 'package {mypkg : ensure=>present}') do assert_match( /ensure: created/, result.stdout, "err: #{agent}") end step "IPS: check it was created" - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /ensure => '0\.0\.1,.*'/, result.stdout, "err: #{agent}") end step "IPS: do not upgrade until latest is mentioned" send_pkg agent,:pkg => 'mypkg@0.0.2' apply_manifest_on(agent, 'package {mypkg : ensure=>present}') do assert_no_match( /ensure: created/, result.stdout, "err: #{agent}") end step "IPS: verify it was not upgraded" - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /ensure => '0\.0\.1,.*'/, result.stdout, "err: #{agent}") end step "IPS: ask to be latest" apply_manifest_on(agent, 'package {mypkg : ensure=>latest}') step "IPS: ensure it was upgraded" - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /ensure => '0\.0\.2,.*'/, result.stdout, "err: #{agent}") end step "IPS: when there are more than one option, choose latest." send_pkg agent,:pkg => 'mypkg@0.0.3' send_pkg agent,:pkg => 'mypkg@0.0.4' apply_manifest_on(agent, 'package {mypkg : ensure=>latest}') - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /ensure => '0\.0\.4,.*'/, result.stdout, "err: #{agent}") end step "IPS: ensure removed." apply_manifest_on(agent, 'package {mypkg : ensure=>absent}') on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do assert_no_match( /mypkg@0.0.1/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/package/ips/should_create.rb b/acceptance/tests/resource/package/ips/should_create.rb index 88242d6e8..6c339162a 100644 --- a/acceptance/tests/resource/package/ips/should_create.rb +++ b/acceptance/tests/resource/package/ips/should_create.rb @@ -1,34 +1,34 @@ test_name "Package:IPS basic tests" confine :to, :platform => 'solaris-11' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::IPSUtils teardown do step "cleanup" agents.each do |agent| clean agent end end agents.each do |agent| step "IPS: clean slate" clean agent step "IPS: setup" setup agent setup_fakeroot agent send_pkg agent, :pkg => 'mypkg@0.0.1' set_publisher agent step "IPS: basic - it should create" apply_manifest_on(agent, 'package {mypkg : ensure=>present}') do assert_match( /ensure: created/, result.stdout, "err: #{agent}") end step "IPS: check it was created" - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /ensure => '0\.0\.1,.*'/, result.stdout, "err: #{agent}") end on agent, "pkg list -v mypkg" do assert_match( /mypkg@0.0.1/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/package/ips/should_query.rb b/acceptance/tests/resource/package/ips/should_query.rb index e5627b08e..048a3fe4f 100644 --- a/acceptance/tests/resource/package/ips/should_query.rb +++ b/acceptance/tests/resource/package/ips/should_query.rb @@ -1,33 +1,33 @@ test_name "Package:IPS query" confine :to, :platform => 'solaris-11' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::IPSUtils teardown do step "cleanup" agents.each do |agent| clean agent end end agents.each do |agent| step "IPS: setup" setup agent setup_fakeroot agent send_pkg agent, :pkg => 'mypkg@0.0.1' set_publisher agent step "IPS: basic - it should create" apply_manifest_on(agent, 'package {mypkg : ensure=>"present"}') do assert_match( /ensure: created/, result.stdout, "err: #{agent}") end - on agent, "puppet resource package mypkg" do + on(agent, puppet("resource package mypkg")) do assert_match( /0.0.1/, result.stdout, "err: #{agent}") end - on agent, "puppet resource package" do + on(agent, puppet("resource package")) do assert_match( /0.0.1/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/service/smf_basic_tests.rb b/acceptance/tests/resource/service/smf_basic_tests.rb index 0eda50c04..67aff0000 100644 --- a/acceptance/tests/resource/service/smf_basic_tests.rb +++ b/acceptance/tests/resource/service/smf_basic_tests.rb @@ -1,40 +1,40 @@ test_name "SMF: basic tests" confine :to, :platform => 'solaris' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::SMFUtils teardown do step "SMF: cleanup" agents.each do |agent| clean agent, :service => 'tstapp' end end agents.each do |agent| clean agent, :service => 'tstapp' manifest, method = setup agent, :service => 'tstapp' step "SMF: clean slate" apply_manifest_on(agent, 'service {tstapp : ensure=>stopped}') do assert_match( /.*/, result.stdout, "err: #{agent}") end step "SMF: ensure it is created with a manifest" apply_manifest_on(agent, 'service {tstapp : ensure=>running, manifest=>"%s"}' % manifest) do assert_match( / ensure changed 'stopped'.* to 'running'/, result.stdout, "err: #{agent}") end step "SMF: verify it with puppet" - on agent, "puppet resource service tstapp" do + on(agent, puppet("resource service tstapp")) do assert_match( /ensure => 'running'/, result.stdout, "err: #{agent}") end step "SMF: verify with svcs that the service is online" on agent, "svcs -l application/tstapp" do assert_match( /state\s+online/, result.stdout, "err: #{agent}") end step "SMF: stop the service" apply_manifest_on(agent, 'service {tstapp : ensure=>stopped}') do assert_match( /changed 'running'.* to 'stopped'/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/service/smf_should_query.rb b/acceptance/tests/resource/service/smf_should_query.rb index 3da796ac9..d2613c539 100644 --- a/acceptance/tests/resource/service/smf_should_query.rb +++ b/acceptance/tests/resource/service/smf_should_query.rb @@ -1,29 +1,29 @@ test_name "SMF: should query instances" confine :to, :platform => 'solaris' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::SMFUtils teardown do step "SMF: cleanup" agents.each do |agent| clean agent, :service => 'tstapp' end end agents.each do |agent| manifest, method = setup agent, :service => 'tstapp' step "SMF: ensre it is created with a manifest" apply_manifest_on(agent, 'service {tstapp : ensure=>running, manifest=>"%s"}' % manifest) do assert_match( / ensure changed 'stopped'.* to 'running'/, result.stdout, "err: #{agent}") end step "SMF: query the resource" - on agent, "puppet resource service tstapp" do + on(agent, puppet("resource service tstapp")) do assert_match( /ensure => 'running'/, result.stdout, "err: #{agent}") end step "SMF: query all the instances" - on agent, "puppet resource service" do + on(agent, puppet("resource service")) do assert_match( /tstapp/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/zpool/basic_tests.rb b/acceptance/tests/resource/zpool/basic_tests.rb index 5467395bf..d453c8bdb 100644 --- a/acceptance/tests/resource/zpool/basic_tests.rb +++ b/acceptance/tests/resource/zpool/basic_tests.rb @@ -1,161 +1,161 @@ test_name "ZPool: configuration" confine :to, :platform => 'solaris' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::ZPoolUtils teardown do step "ZPool: cleanup" agents.each do |agent| clean agent end end agents.each do |agent| step "ZPool: setup" setup agent #----------------------------------- step "ZPool: create zpool disk" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, disk=>'/ztstpool/dsk1' }") do assert_match( /ensure: created/, result.stdout, "err: #{agent}") end step "ZPool: zpool should be idempotent" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, disk=>'/ztstpool/dsk1' }") do assert_no_match( /ensure: created/, result.stdout, "err: #{agent}") end step "ZPool: remove zpool" apply_manifest_on(agent, "zpool{ tstpool: ensure=>absent }") do assert_match( /ensure: removed/ , result.stdout, "err: #{agent}") end step "ZPool: create zpool with a disk array" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, disk=>['/ztstpool/dsk1','/ztstpool/dsk2'] }") do assert_match( /ensure: created/ , result.stdout, "err: #{agent}") end step "ZPool: verify disk array was created" on agent, "zpool list -H" do assert_match( /tstpool/ , result.stdout, "err: #{agent}") end step "ZPool: verify puppet resource reports on the disk array" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure => 'present'/, result.stdout, "err: #{agent}") assert_match(/disk +=> .'.+dsk1 .+dsk2'./, result.stdout, "err: #{agent}") end step "ZPool: remove zpool in preparation for mirror tests" apply_manifest_on(agent, "zpool{ tstpool: ensure=>absent }") do assert_match( /ensure: removed/ , result.stdout, "err: #{agent}") end step "ZPool: create mirrored zpool with 3 virtual devices" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, mirror=>['/ztstpool/dsk1 /ztstpool/dsk2 /ztstpool/dsk3'] }") do assert_match( /ensure: created/ , result.stdout, "err: #{agent}") end step "ZPool: verify mirrors were created" on agent, "zpool status -v tstpool" do # NAME STATE READ WRITE CKSUM # tstpool ONLINE 0 0 0 # mirror-0 ONLINE 0 0 0 # /ztstpool/dsk1 ONLINE 0 0 0 # /ztstpool/dsk2 ONLINE 0 0 0 # /ztstpool/dsk3 ONLINE 0 0 0 assert_match( /tstpool.*\n\s+mirror.*\n\s*\/ztstpool\/dsk1.*\n\s*\/ztstpool\/dsk2.*\n\s*\/ztstpool\/dsk3/m, result.stdout, "err: #{agent}") end step "ZPool: verify puppet resource reports on the mirror" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure => 'present'/, result.stdout, "err: #{agent}") assert_match(/mirror => \['\/ztstpool\/dsk1 \/ztstpool\/dsk2 \/ztstpool\/dsk3'\]/, result.stdout, "err: #{agent}") end step "ZPool: remove zpool in preparation for multiple mirrors" apply_manifest_on(agent,"zpool{ tstpool: ensure=>absent }") do assert_match(/ensure: removed/, result.stdout, "err: #{agent}") end step "ZPool: create 2 mirrored zpools each with 2 virtual devices" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, mirror=>['/ztstpool/dsk1 /ztstpool/dsk2', '/ztstpool/dsk3 /ztstpool/dsk5'] }") do assert_match( /ensure: created/ , result.stdout, "err: #{agent}") end step "ZPool: verify both mirrors were created" on agent, "zpool status -v tstpool" do # NAME STATE READ WRITE CKSUM # tstpool ONLINE 0 0 0 # mirror-0 ONLINE 0 0 0 # /ztstpool/dsk1 ONLINE 0 0 0 # /ztstpool/dsk2 ONLINE 0 0 0 # mirror-1 ONLINE 0 0 0 # /ztstpool/dsk3 ONLINE 0 0 0 # /ztstpool/dsk5 ONLINE 0 0 0 assert_match( /tstpool.*\n\s+mirror.*\n\s*\/ztstpool\/dsk1.*\n\s*\/ztstpool\/dsk2.*\n\s+mirror.*\n\s*\/ztstpool\/dsk3.*\n\s*\/ztstpool\/dsk5/m, result.stdout, "err: #{agent}") end step "ZPool: verify puppet resource reports on both mirrors" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure => 'present'/, result.stdout, "err: #{agent}") assert_match(/mirror => \['\/ztstpool\/dsk1 \/ztstpool\/dsk2', '\/ztstpool\/dsk3 \/ztstpool\/dsk5'\]/, result.stdout, "err: #{agent}") end step "ZPool: remove zpool in preparation for raidz test" apply_manifest_on(agent,"zpool{ tstpool: ensure=>absent }") do assert_match(/ensure: removed/, result.stdout, "err: #{agent}") end step "ZPool: create raidz pool consisting of 3 virtual devices" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, raidz=>['/ztstpool/dsk1 /ztstpool/dsk2 /ztstpool/dsk3'] }") do assert_match( /ensure: created/ , result.stdout, "err: #{agent}") end step "ZPool: verify raidz pool was created" on agent, "zpool status -v tstpool" do # NAME STATE READ WRITE CKSUM # tstpool ONLINE 0 0 0 # raidz1-0 ONLINE 0 0 0 # /ztstpool/dsk1 ONLINE 0 0 0 # /ztstpool/dsk2 ONLINE 0 0 0 # /ztstpool/dsk3 ONLINE 0 0 0 assert_match( /tstpool.*\n\s+raidz.*\n\s*\/ztstpool\/dsk1.*\n\s*\/ztstpool\/dsk2.*\n\s*\/ztstpool\/dsk3/m, result.stdout, "err: #{agent}") end step "ZPool: verify puppet reports on the raidz pool" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure => 'present'/, result.stdout, "err: #{agent}") assert_match(/raidz => \['\/ztstpool\/dsk1 \/ztstpool\/dsk2 \/ztstpool\/dsk3'\]/, result.stdout, "err: #{agent}") end step "ZPool: remove zpool in preparation for multiple raidz pools" apply_manifest_on(agent,"zpool{ tstpool: ensure=>absent }") do assert_match(/ensure: removed/, result.stdout, "err: #{agent}") end step "ZPool: create 2 mirrored zpools each with 2 virtual devices" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, raidz=>['/ztstpool/dsk1 /ztstpool/dsk2', '/ztstpool/dsk3 /ztstpool/dsk5'] }") do assert_match( /ensure: created/ , result.stdout, "err: #{agent}") end step "ZPool: verify both raidz were created" on agent, "zpool status -v tstpool" do # NAME STATE READ WRITE CKSUM # tstpool ONLINE 0 0 0 # raidz1-0 ONLINE 0 0 0 # /ztstpool/dsk1 ONLINE 0 0 0 # /ztstpool/dsk2 ONLINE 0 0 0 # raidz1-1 ONLINE 0 0 0 # /ztstpool/dsk3 ONLINE 0 0 0 # /ztstpool/dsk5 ONLINE 0 0 0 assert_match( /tstpool.*\n\s+raidz.*\n\s*\/ztstpool\/dsk1.*\n\s*\/ztstpool\/dsk2.*\n\s+raidz.*\n\s*\/ztstpool\/dsk3.*\n\s*\/ztstpool\/dsk5/m, result.stdout, "err: #{agent}") end step "ZPool: verify puppet resource reports on both raidz" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure => 'present'/, result.stdout, "err: #{agent}") assert_match(/raidz => \['\/ztstpool\/dsk1 \/ztstpool\/dsk2', '\/ztstpool\/dsk3 \/ztstpool\/dsk5'\]/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/resource/zpool/should_query.rb b/acceptance/tests/resource/zpool/should_query.rb index ae169e016..7517fb596 100644 --- a/acceptance/tests/resource/zpool/should_query.rb +++ b/acceptance/tests/resource/zpool/should_query.rb @@ -1,33 +1,33 @@ test_name "ZPool: configuration" confine :to, :platform => 'solaris' require 'puppet/acceptance/solaris_util' extend Puppet::Acceptance::ZPoolUtils teardown do step "ZPool: cleanup" agents.each do |agent| clean agent end end agents.each do |agent| step "ZPool: setup" setup agent #----------------------------------- step "ZPool: ensure create" apply_manifest_on(agent, "zpool{ tstpool: ensure=>present, disk=>'/ztstpool/dsk1' }") do assert_match( /ensure: created/, result.stdout, "err: #{agent}") end step "ZPool: query one" - on agent, "puppet resource zpool tstpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/ensure *=> *'present'/, result.stdout, "err: #{agent}") end step "ZPool: query all" - on agent, "puppet resource zpool" do + on(agent, puppet("resource zpool tstpool")) do assert_match(/tstpool'/, result.stdout, "err: #{agent}") end end diff --git a/acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb b/acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb index ae5550c05..8d313b627 100644 --- a/acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb +++ b/acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb @@ -1,50 +1,50 @@ test_name "#3360: Allow duplicate CSR when allow_duplicate_certs is on" agent_hostnames = agents.map {|a| a.to_s} -with_puppet_running_on master, {'master' => {'allow_duplicate_certs' => true}} do +with_puppet_running_on(master, {'master' => {'allow_duplicate_certs' => true}}) do agents.each do |agent| step "Generate a certificate request for the agent" fqdn = on(agent, facter("fqdn")).stdout.strip - on agent, puppet("certificate generate #{fqdn} --ca-location remote --server #{master}") + on(agent, puppet("certificate generate #{fqdn} --ca-location remote --server #{master}")) end step "Collect the original certs" - on master, puppet_cert("--sign --all") - original_certs = on master, puppet_cert("--list --all") + on(master, puppet_cert("--sign --all")) + original_certs = on(master, puppet_cert("--list --all")) old_certs = {} original_certs.stdout.each_line do |line| if line =~ /^\+ (\S+) \((.+)\)$/ old_certs[$1] = $2 puts "old cert: #{$1} #{$2}" end end agents.each do |agent| fqdn = on(agent, facter("fqdn")).stdout.strip step "Make another request with the same certname" - on agent, puppet("certificate generate #{fqdn} --ca-location remote --server #{master}") + on(agent, puppet("certificate generate #{fqdn} --ca-location remote --server #{master}")) end step "Collect the new certs" - on master, puppet_cert("--sign --all") - new_cert_list = on master, puppet_cert("--list --all") + on(master, puppet_cert("--sign --all")) + new_cert_list = on(master, puppet_cert("--list --all")) new_certs = {} new_cert_list.stdout.each_line do |line| if line =~ /^\+ (\S+) \((.+)\)$/ new_certs[$1] = $2 puts "new cert: #{$1} #{$2}" end end step "Verify the certs have changed" # using the agent name as the key may cause errors; # agent name from cfg file is likely to have short name # where certs might be signed with long names. old_certs.each_key { |key| next if key.include? master # skip the masters cert, only care about agents assert_not_equal(old_certs[key], new_certs[key], "Expected #{key} to have a changed key") } end