Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@

basedir = master.tmpdir(File.basename(__FILE__, '.*'))
module_dir = "#{basedir}/environments/production/modules"
master_reportdir = create_tmpdir_for_user(master, 'reportdir')

master_opts = {
'main' => {
'environmentpath' => "#{basedir}/environments"
},
# The server no longer stores reports by default (reports = none);
# request storage explicitly like the other report-checking tests do.
'master' => {
'reportdir' => master_reportdir,
'reports' => 'store'
}
}

Expand All @@ -28,6 +35,7 @@
teardown do
cleanup_puppetserver_code_id_scripts(master, basedir)
on master, "rm -rf #{basedir}"
on master, "rm -rf #{master_reportdir}"

agents.each do |agent|
on(agent, puppet('config print lastrunfile')) do |command_result|
Expand Down Expand Up @@ -96,9 +104,9 @@
# sends a report.

step "Remove existing reports from server reports directory"
on(master, "rm -rf /opt/puppetlabs/server/data/puppetserver/reports/#{agent.node_name}/*")
r = on(master, "ls /opt/puppetlabs/server/data/puppetserver/reports/#{agent.node_name} | wc -l").stdout.chomp
assert_equal(r, '0', "reports directory should be empty!")
on(master, "rm -rf #{master_reportdir}/#{agent.node_name}/*")
r = on(master, "ls #{master_reportdir}/#{agent.node_name} 2>/dev/null | wc -l").stdout.chomp
assert_equal('0', r, "reports directory should be empty!")

step "Verify puppet run without drift does not make file request from server"
r = on(agent, puppet("agent",
Expand All @@ -113,8 +121,8 @@
assert_equal(r, "", "Fail: Did agent try to contact server?")

step "Verify report was delivered to server"
r = on(master, "ls /opt/puppetlabs/server/data/puppetserver/reports/#{agent.node_name} | wc -l").stdout.chomp
assert_equal(r, '1', "Reports directory should have one file")
r = on(master, "ls #{master_reportdir}/#{agent.node_name} | wc -l").stdout.chomp
assert_equal('1', r, "Reports directory should have one file")

step "agent: #{agent}: Remove the test file to simulate drift"
on(agent, "rm -rf #{agent_test_file_path}")
Expand Down
33 changes: 27 additions & 6 deletions acceptance/tests/lookup/lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ def mod_manifest_metadata_json(module_name = nil, testdir)
"project_page": null,
"issues_url": null,
"dependencies": [
],
"data_provider": "function"
]
}
',
mode => "0644",
}
# Hiera 5 module layer: bind the module data function
# (replaces the removed metadata.json "data_provider" key)
file { '#{testdir}/environments/production/modules/#{module_name}/hiera.yaml':
ensure => file,
content => '---
version: 5
hierarchy:
- name: "Module data function"
v4_data_hash: #{module_name}::data
',
mode => "0644",
}
file { '#{testdir}/environments/production/modules/#{module_name}/lib/puppet/bindings':
ensure => absent,
force => true,
Expand Down Expand Up @@ -202,14 +213,24 @@ def mod_manifest_metadata_json(module_name = nil, testdir)
ensure => file,
content => '
environment_timeout = 0
# for this environment, provide our own function to supply data to lookup
# implies a ruby function in <environment>/lib/puppet/functions/environment/data.rb
# named environment::data()
environment_data_provider = "function"
',
mode => "0640",
}

# Hiera 5 environment layer: bind the environment data function
# (replaces the removed environment_data_provider setting; the function
# lives in <environment>/lib/puppet/functions/environment/data.rb)
file { '#{testdir}/environments/production/hiera.yaml':
ensure => file,
content => '---
version: 5
hierarchy:
- name: "Environment data function"
v4_data_hash: environment::data
',
mode => "0640",
}

# the function to provide data for this environment
file { '#{testdir}/environments/production/lib/puppet/functions/environment/data.rb':
ensure => file,
Expand Down
Loading