Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pr/253'
Browse files Browse the repository at this point in the history
* upstream/pr/253:
  (HI-340) Fix hieradata path in acceptance tests
  • Loading branch information
joshcooper committed Feb 25, 2015
2 parents 00ce542 + 8c181c9 commit b2423a6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
14 changes: 5 additions & 9 deletions acceptance/tests/yaml_backend/00-setup.rb
@@ -1,14 +1,10 @@
test_name "Hiera setup for YAML backend"

agents.each do |agent|
codedir = agent.puppet['codedir']
hieradatadir = File.join(codedir, 'hieradata')
apply_manifest_on agent, <<-PP
file { '/etc/puppetlabs':
ensure => directory,
}->
file { '/etc/puppetlabs/code':
ensure => directory,
}->
file { '/etc/puppetlabs/code/hiera.yaml':
file { '#{codedir}/hiera.yaml':
ensure => present,
content => '---
:backends:
Expand All @@ -20,11 +16,11 @@
- "global"
:yaml:
:datadir: "#{agent['hieradatadir']}"
:datadir: "#{hieradatadir}"
'
}
file { '#{agent['hieradatadir']}':
file { '#{hieradatadir}':
ensure => directory,
recurse => true,
purge => true,
Expand Down
@@ -1,10 +1,12 @@
begin test_name "Lookup data using the default options"

agents.each do |agent|
codedir = agent.puppet['codedir']
hieradatadir = File.join(codedir, 'hieradata')

step 'Setup'
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}':
file { '#{hieradatadir}':
ensure => directory,
recurse => true,
purge => true,
Expand All @@ -13,7 +15,7 @@
PP

apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}/global.yaml':
file { '#{hieradatadir}/global.yaml':
ensure => present,
content => "---
http_port: 8080
Expand Down
16 changes: 9 additions & 7 deletions acceptance/tests/yaml_backend/03-lookup_data_with_a_scope.rb
@@ -1,23 +1,25 @@
begin test_name "Lookup data with a scope"

agents.each do |agent|
codedir = agent.puppet['codedir']
hieradatadir = File.join(codedir, 'hieradata')

teardown do
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}':
file { '#{hieradatadir}':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/scope.yaml': ensure => absent }
file { '/etc/puppet/scope.json': ensure => absent }
file { '#{codedir}/scope.yaml': ensure => absent }
file { '#{codedir}/scope.json': ensure => absent }
PP
end

step 'Setup'
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}/global.yaml':
file { '#{hieradatadir}/global.yaml':
ensure => present,
content => "---
http_port: 8080
Expand All @@ -34,7 +36,7 @@
"
}
file { '#{agent['hieradatadir']}/production.yaml':
file { '#{hieradatadir}/production.yaml':
ensure => present,
content => "---
http_port: 9090
Expand All @@ -43,7 +45,7 @@
"
}
file { '/etc/puppet/scope.yaml':
file { '#{codedir}/scope.yaml':
ensure => present,
content => "---
environment: production
Expand All @@ -52,7 +54,7 @@
PP

step "Try to lookup string data using a scope from a yaml file"
on agent, hiera('monitor', '--yaml', '/etc/puppet/scope.yaml'),
on agent, hiera('monitor', '--yaml', "#{codedir}/scope.yaml"),
:acceptable_exit_codes => [0] do
assert_output <<-OUTPUT
STDOUT> enable
Expand Down
@@ -1,37 +1,39 @@
begin test_name "Lookup data with Array search"

agents.each do |agent|
codedir = agent.puppet['codedir']
hieradatadir = File.join(codedir, 'hieradata')

teardown do
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}':
file { '#{hieradatadir}':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/scope.yaml': ensure => absent }
file { '/etc/puppet/scope.json': ensure => absent }
file { '#{codedir}/scope.yaml': ensure => absent }
file { '#{codedir}/scope.json': ensure => absent }
PP
end

step 'Setup'
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}/production.yaml':
file { '#{hieradatadir}/production.yaml':
ensure => present,
content => "---
ntpservers: ['production.ntp.puppetlabs.com']
"
}
file { '#{agent['hieradatadir']}/global.yaml':
file { '#{hieradatadir}/global.yaml':
ensure => present,
content => "---
ntpservers: ['global.ntp.puppetlabs.com']
"
}
file { '/etc/puppet/scope.yaml':
file { '#{codedir}/scope.yaml':
ensure => present,
content => "---
environment: production
Expand All @@ -40,7 +42,7 @@
PP

step "Try to lookup data using array search"
on agent, hiera('ntpservers', '--yaml', '/etc/puppet/scope.yaml', '--array'),
on agent, hiera('ntpservers', '--yaml', "#{codedir}/scope.yaml", '--array'),
:acceptable_exit_codes => [0] do
assert_output <<-OUTPUT
STDOUT> ["production.ntp.puppetlabs.com", "global.ntp.puppetlabs.com"]
Expand Down
16 changes: 9 additions & 7 deletions acceptance/tests/yaml_backend/05-lookup_data_with_hash_search.rb
@@ -1,23 +1,25 @@
begin test_name "Lookup data with Hash search"

agents.each do |agent|
codedir = agent.puppet['codedir']
hieradatadir = File.join(codedir, 'hieradata')

teardown do
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}':
file { '#{hieradatadir}':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/scope.yaml': ensure => absent }
file { '/etc/puppet/scope.json': ensure => absent }
file { '#{codedir}/scope.yaml': ensure => absent }
file { '#{codedir}/scope.json': ensure => absent }
PP
end

step 'Setup'
apply_manifest_on agent, <<-PP
file { '#{agent['hieradatadir']}/production.yaml':
file { '#{hieradatadir}/production.yaml':
ensure => present,
content => "---
users:
Expand All @@ -26,7 +28,7 @@
"
}
file { '#{agent['hieradatadir']}/global.yaml':
file { '#{hieradatadir}/global.yaml':
ensure => present,
content => "---
users:
Expand All @@ -35,7 +37,7 @@
"
}
file { '/etc/puppet/scope.yaml':
file { '#{codedir}/scope.yaml':
ensure => present,
content => "---
environment: production
Expand All @@ -44,7 +46,7 @@
PP

step "Try to lookup data using hash search"
on agent, hiera('users', '--yaml', '/etc/puppet/scope.yaml', '--hash'),
on agent, hiera('users', '--yaml', "#{codedir}/scope.yaml", '--hash'),
:acceptable_exit_codes => [0] do
assert_match /joe[^}]+"uid"=>1000}/, result.output
assert_match /pete[^}]+"uid"=>1001}/, result.output
Expand Down

0 comments on commit b2423a6

Please sign in to comment.