|
| 1 | +test_name "ticket 1073: common package name in two different providers should be allowed" |
| 2 | + |
| 3 | +hosts_to_test = agents.select do |agent| |
| 4 | + agent['platform'].match /(?:centos|el-|fedora)/ |
| 5 | +end |
| 6 | +skip_test "No suitable hosts found" if hosts_to_test.empty? |
| 7 | + |
| 8 | +require 'puppet/acceptance/rpm_util' |
| 9 | +extend Puppet::Acceptance::RpmUtils |
| 10 | + |
| 11 | +rpm_options = {:pkg => 'guid', :version => '1.0'} |
| 12 | + |
| 13 | +teardown do |
| 14 | + step "cleanup" |
| 15 | + agents.each do |agent| |
| 16 | + clean_rpm agent, rpm_options |
| 17 | + end |
| 18 | +end |
| 19 | + |
| 20 | +def verify_state(hosts, pkg, state, match) |
| 21 | + hosts.each do |agent| |
| 22 | + # Note yum lists packages as <name>.<arch> |
| 23 | + on agent, 'yum list installed' do |
| 24 | + method(match).call(/^#{pkg}\./, stdout) |
| 25 | + end |
| 26 | + |
| 27 | + on agent, 'gem list --local' do |
| 28 | + method(match).call(/^#{pkg} /, stdout) |
| 29 | + end |
| 30 | + end |
| 31 | +end |
| 32 | + |
| 33 | +def verify_present(hosts, pkg) |
| 34 | + verify_state(hosts, pkg, '(?!purged|absent)[^\']+', :assert_match) |
| 35 | +end |
| 36 | + |
| 37 | +def verify_absent(hosts, pkg) |
| 38 | + verify_state(hosts, pkg, '(?:purged|absent)', :assert_no_match) |
| 39 | +end |
| 40 | + |
| 41 | +# Setup repo and package |
| 42 | +hosts_to_test.each do |agent| |
| 43 | + clean_rpm agent, rpm_options |
| 44 | + setup_rpm agent, rpm_options |
| 45 | + send_rpm agent, rpm_options |
| 46 | +end |
| 47 | + |
| 48 | +verify_absent hosts_to_test, 'guid' |
| 49 | + |
| 50 | +# Test error trying to install duplicate packages |
| 51 | +collide1_manifest = <<MANIFEST |
| 52 | + package {'guid': ensure => installed} |
| 53 | + package {'other-guid': name => 'guid', ensure => present} |
| 54 | +MANIFEST |
| 55 | + |
| 56 | +apply_manifest_on(hosts_to_test, collide1_manifest, :acceptable_exit_codes => [1]).each do |result| |
| 57 | + assert_match(/Error while evaluating a Resource Statement, Cannot alias Package\[other-guid\] to \["guid", nil\]/, "#{result.host}: #{result.stderr}") |
| 58 | +end |
| 59 | + |
| 60 | +verify_absent hosts_to_test, 'guid' |
| 61 | + |
| 62 | +collide2_manifest = <<MANIFEST |
| 63 | + package {'guid': ensure => '0.1.0', provider => gem} |
| 64 | + package {'other-guid': name => 'guid', ensure => installed, provider => gem} |
| 65 | +MANIFEST |
| 66 | + |
| 67 | +apply_manifest_on(hosts_to_test, collide2_manifest, :acceptable_exit_codes => [1]).each do |result| |
| 68 | + assert_match(/Error while evaluating a Resource Statement, Cannot alias Package\[other-guid\] to \["guid", "gem"\]/, "#{result.host}: #{result.stderr}") |
| 69 | +end |
| 70 | + |
| 71 | +verify_absent hosts_to_test, 'guid' |
| 72 | + |
| 73 | +# Test successful parallel installation |
| 74 | +install_manifest = <<MANIFEST |
| 75 | + package {'guid': ensure => installed} |
| 76 | +
|
| 77 | + package {'gem-guid': |
| 78 | + provider => gem, |
| 79 | + name => 'guid', |
| 80 | + ensure => installed, |
| 81 | + } |
| 82 | +MANIFEST |
| 83 | + |
| 84 | +apply_manifest_on(hosts_to_test, install_manifest).each do |result| |
| 85 | + assert_match('Package[guid]/ensure: created', "#{result.host}: #{result.stdout}") |
| 86 | + assert_match('Package[gem-guid]/ensure: created', "#{result.host}: #{result.stdout}") |
| 87 | +end |
| 88 | + |
| 89 | +verify_present hosts_to_test, 'guid' |
| 90 | + |
| 91 | +# Test removal |
| 92 | +remove_manifest = <<MANIFEST |
| 93 | + package {'gem-guid': |
| 94 | + provider => gem, |
| 95 | + name => 'guid', |
| 96 | + ensure => absent, |
| 97 | + } |
| 98 | +
|
| 99 | + package {'guid': ensure => absent} |
| 100 | +MANIFEST |
| 101 | + |
| 102 | +apply_manifest_on(hosts_to_test, remove_manifest).each do |result| |
| 103 | + assert_match('Package[guid]/ensure: removed', "#{result.host}: #{result.stdout}") |
| 104 | + assert_match('Package[gem-guid]/ensure: removed', "#{result.host}: #{result.stdout}") |
| 105 | +end |
| 106 | + |
| 107 | +verify_absent hosts_to_test, 'guid' |
| 108 | + |
0 commit comments