diff --git a/acceptance/tests/agent/agent_disable_lockfile.rb b/acceptance/tests/agent/agent_disable_lockfile.rb index 8354c326a..0fcc5bfd5 100644 --- a/acceptance/tests/agent/agent_disable_lockfile.rb +++ b/acceptance/tests/agent/agent_disable_lockfile.rb @@ -1,94 +1,94 @@ test_name "the agent --disable/--enable functionality should manage the agent lockfile properly" # # This test is intended to ensure that puppet agent --enable/--disable # work properly, both in terms of complying with our public "API" around # lockfile semantics ( http://links.puppetlabs.com/agent_lockfiles ), and # in terms of actually restricting or allowing new agent runs to begin. # require 'puppet/acceptance/temp_file_utils' extend Puppet::Acceptance::TempFileUtils initialize_temp_dirs() @all_tests_passed = false ############################################################################### # BEGIN TEST LOGIC ############################################################################### teardown do if @all_tests_passed then remove_temp_dirs() end end tuples = [ ["reason not specified", false], ["I'm busy; go away.'", true] ] tuples.each do |expected_message, explicitly_specify_message| with_puppet_running_on(master, {}) do step "disable the agent; specify message? '#{explicitly_specify_message}', message: '#{expected_message}'" do agents.each do |agent| if (explicitly_specify_message) on(agent, puppet('agent', "--disable \"#{expected_message}\"")) else on(agent, puppet('agent', "--disable")) end - agent_disabled_lockfile = "#{agent['puppetvardir']}/state/agent_disabled.lock" + agent_disabled_lockfile = "#{agent.puppet['vardir']}/state/agent_disabled.lock" unless file_exists?(agent, agent_disabled_lockfile) then fail_test("Failed to create disabled lock file '#{agent_disabled_lockfile}' on agent '#{agent}'") end lock_file_content = file_contents(agent, agent_disabled_lockfile) # This is a hack; we should parse the JSON into a hash, but I don't # think I have a library available from the acceptance test framework # that I can use to do that. So I'm falling back to regex. lock_file_content_regex = /"disabled_message"\s*:\s*"#{expected_message}"/ unless lock_file_content =~ lock_file_content_regex fail_test("Disabled lock file contents invalid; expected to match '#{lock_file_content_regex}', got '#{lock_file_content}' on agent '#{agent}'") end end end step "attempt to run the agent (message: '#{expected_message}')" do agents.each do |agent| on(agent, puppet('agent', "--test --server #{master}"), :acceptable_exit_codes => [1]) do disabled_regex = /administratively disabled.*'#{expected_message}'/ unless result.stdout =~ disabled_regex fail_test("Unexpected output from attempt to run agent disabled; expecting to match '#{disabled_regex}', got '#{result.stdout}' on agent '#{agent}'") end end end end step "enable the agent (message: '#{expected_message}')" do agents.each do |agent| - agent_disabled_lockfile = "#{agent['puppetvardir']}/state/agent_disabled.lock" + agent_disabled_lockfile = "#{agent.puppet['vardir']}/state/agent_disabled.lock" on(agent, puppet('agent', "--enable")) if file_exists?(agent, agent_disabled_lockfile) then fail_test("Failed to remove disabled lock file '#{agent_disabled_lockfile}' on agent '#{agent}'") end end end step "verify that we can run the agent (message: '#{expected_message}')" do agents.each do |agent| on(agent, puppet('agent', "--test --server #{master}")) end end end # with_puppet_running_on block end # tuples block @all_tests_passed = true diff --git a/acceptance/tests/environment/use_enc_environment_for_pluginsync.rb b/acceptance/tests/environment/use_enc_environment_for_pluginsync.rb index 05902a37e..0a3f34a1c 100644 --- a/acceptance/tests/environment/use_enc_environment_for_pluginsync.rb +++ b/acceptance/tests/environment/use_enc_environment_for_pluginsync.rb @@ -1,43 +1,43 @@ test_name "Agent should use environment given by ENC for pluginsync" testdir = master.tmpdir('respect_enc_test') create_remote_file master, "#{testdir}/enc.rb", < { 'node_terminus' => 'exec', 'external_nodes' => "#{testdir}/enc.rb" }, 'special' => { 'modulepath' => "#{testdir}/special" } } if master.is_pe? master_opts['special']['modulepath'] << ":#{master['sitemoduledir']}" end on master, "mkdir -p #{testdir}/modules" # Create a plugin file on the master on master, "mkdir -p #{testdir}/special/amod/lib/puppet" create_remote_file(master, "#{testdir}/special/amod/lib/puppet/foo.rb", "#special_version") on master, "chown -R #{master['user']}:#{master['group']} #{testdir}" on master, "chmod -R g+rwX #{testdir}" with_puppet_running_on master, master_opts, testdir do agents.each do |agent| run_agent_on(agent, "--no-daemonize --onetime --server #{master}") - on agent, "cat #{agent['puppetvardir']}/lib/puppet/foo.rb" + on agent, "cat #{agent.puppet['vardir']}/lib/puppet/foo.rb" assert_match(/#special_version/, stdout, "The plugin from environment 'special' was not synced") - on agent, "rm -rf #{agent['puppetvardir']}/lib" + on agent, "rm -rf #{agent.puppet['vardir']}/lib" end end diff --git a/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb b/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb index 4005f4d68..076ca63d7 100644 --- a/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb +++ b/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb @@ -1,49 +1,49 @@ test_name "earlier modules take precendence over later modules in the modulepath" step "Create some modules in the modulepath" basedir = master.tmpdir("module_precedence") module1libdir = "#{basedir}/1" module2libdir = "#{basedir}/2" apply_manifest_on(master, < #{master['group']}, recurse => true, require => File[mod1, mod2] } Exec { path => "/bin:/usr/bin" } exec { "mod1path": command => "mkdir -p #{module1libdir}/a/lib" } exec { "mod2path": command => "mkdir -p #{module2libdir}/a/lib" } file { "mod1": path => "#{module1libdir}/a/lib/foo.rb", content => "'from the first module'", owner => #{master['group']}, require => Exec[mod1path] } file { "mod2": path => "#{module2libdir}/a/lib/foo.rb", content => "'from the second module'", owner => #{master['group']}, require => Exec[mod2path] } MANIFEST master_opts = { 'master' => { 'modulepath' => "#{module1libdir}:#{module2libdir}", 'node_terminus' => 'plain', } } with_puppet_running_on master, master_opts, basedir do agents.each do |agent| on(agent, puppet('agent', "-t --server #{master}")) - on agent, "cat #{agent['puppetvardir']}/lib/foo.rb" do + on agent, "cat #{agent.puppet['vardir']}/lib/foo.rb" do assert_match(/from the first module/, stdout, "The synced plugin was not found or the wrong version was synced") end end end diff --git a/acceptance/tests/ticket_6541_invalid_filebucket_files.rb b/acceptance/tests/ticket_6541_invalid_filebucket_files.rb index 11de0e6b2..46972d203 100644 --- a/acceptance/tests/ticket_6541_invalid_filebucket_files.rb +++ b/acceptance/tests/ticket_6541_invalid_filebucket_files.rb @@ -1,33 +1,33 @@ test_name "#6541: file type truncates target when filebucket cannot retrieve hash" agents.each do |agent| target=agent.tmpfile('6541-target') - on agent, host_command('rm -rf #{host["puppetvardir"]}/*bucket') + on agent, host_command('rm -rf #{host.puppet["vardir"]}/*bucket') step "write zero length file" manifest = "file { '#{target}': content => '' }" apply_manifest_on(agent, manifest) step "overwrite file, causing zero-length file to be backed up" manifest = "file { '#{target}': content => 'some text' }" apply_manifest_on(agent, manifest) test_name "verify invalid hashes should not change the file" manifest = "file { '#{target}': content => '{md5}notahash' }" apply_manifest_on(agent, manifest) do assert_no_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote the file") end test_name "verify valid but unbucketed hashes should not change the file" manifest = "file { '#{target}': content => '{md5}13ad7345d56b566a4408ffdcd877bc78' }" apply_manifest_on(agent, manifest) do assert_no_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote the file") end test_name "verify that an empty file can be retrieved from the filebucket" manifest = "file { '#{target}': content => '{md5}d41d8cd98f00b204e9800998ecf8427e' }" apply_manifest_on(agent, manifest) do assert_match(/content changed '\{md5\}552e21cd4cd9918678e3c1a0df491bc3' to '\{md5\}d41d8cd98f00b204e9800998ecf8427e'/, stdout, "#{agent}: shouldn't have overwrote the file") end end diff --git a/acceptance/tests/ticket_6734_6256_5530_5503.rb b/acceptance/tests/ticket_6734_6256_5530_5503.rb index 3b5d3f0ac..32d8b86cd 100644 --- a/acceptance/tests/ticket_6734_6256_5530_5503.rb +++ b/acceptance/tests/ticket_6734_6256_5530_5503.rb @@ -1,12 +1,12 @@ # Puppet master fails to start due to impropper # permissons on the puppet/ dir. Specially, the rrd # sub dir is not created when puppet master starts test_name "Tickets 6734 6256 5530 5503i Puppet Master fails to start" with_puppet_running_on master, {} do step "Check permissions on puppet/rrd/" - on master, "ls -l #{master['puppetvardir']} | grep rrd | awk '{print $3\" \"$4}'" do + on master, "ls -l #{master.puppet['vardir']} | grep rrd | awk '{print $3\" \"$4}'" do assert_match(/#{master['group']} #{master['group']}/, stdout, "puppet/rrd does not exist/wrong permissions") end end diff --git a/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb b/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb index ed862ce33..f6c23ca83 100644 --- a/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb +++ b/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb @@ -1,65 +1,65 @@ test_name "#9862: puppet runs without service user or group present" # puppet doesn't try to manage ownership on windows. confine :except, :platform => 'windows' require 'puppet/acceptance/temp_file_utils' extend Puppet::Acceptance::TempFileUtils initialize_temp_dirs def assert_ownership(agent, location, expected_user, expected_group) on(agent, "stat --format '%U:%G' #{location}") do assert_match(/#{expected_user}:#{expected_group}/, stdout) end end def missing_directory_for(agent, dir) agent_dir = get_test_file_path(agent, dir) on agent, "rm -rf #{agent_dir}" agent_dir end teardown do agents.each do |agent| step "ensure puppet resets it's user/group settings" on agent, puppet('apply', '-e', '"notify { puppet_run: }"') - on agent, "find #{agent['puppetvardir']} -user existinguser" do + on agent, "find #{agent.puppet['vardir']} -user existinguser" do assert_equal('',stdout) end on agent, puppet('resource', 'user', 'existinguser', 'ensure=absent') on agent, puppet('resource', 'group', 'existinggroup', 'ensure=absent') end end step "when the user and group are missing" agents.each do |agent| logdir = missing_directory_for(agent, 'log') on agent, puppet('apply', '-e', '"notify { puppet_run: }"', '--logdir', logdir, '--user', 'missinguser', '--group', 'missinggroup') do assert_match(/puppet_run/, stdout) assert_ownership(agent, logdir, 'root', 'root') end end step "when the user and group exist" agents.each do |agent| logdir = missing_directory_for(agent, 'log') on agent, puppet('resource', 'user', 'existinguser', 'ensure=present') on agent, puppet('resource', 'group', 'existinggroup', 'ensure=present') on agent, puppet('apply', '-e', '"notify { puppet_run: }"', '--logdir', logdir, '--user', 'existinguser', '--group', 'existinggroup') do assert_match(/puppet_run/, stdout) assert_ownership(agent, logdir, 'existinguser', 'existinggroup') end end