puppet_litmus 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ccf17917e989f2e0396f8b0611dd22cdf714b1e72db8be39e44b796e29e6044
4
- data.tar.gz: fffb9cd11af3950794c48b23767e4990a278d4c9f2584497d432157b7c1cc031
3
+ metadata.gz: 8b28ee9fd69e25bb7644899b004f8c188940bf2f8df398cbff9f849813e3b0b7
4
+ data.tar.gz: d6da95723ccd59175d110b07d6a2244733f1e85e26ed4d075fb8ada7c7e4888f
5
5
  SHA512:
6
- metadata.gz: 11a2e60e31f2e4d830a1bb12ca1a872e184244852514913636edbc599489e8f5d3c94feb8c98d2166358ebba18a04e76daa4cefefda52c21cecc9306d6f18c1c
7
- data.tar.gz: 455dfdd8692055f23f79c916c0968cfd2a16d7ce7d13ea1c74b5ce8b8b83fa25ae346c4928b1fdb355cca1cdb18790beab89b57302d9f6b7f64c42bf4165c6fa
6
+ metadata.gz: d34ca11e5202fb7fd3f365c7c2fcf975404f71e8581e9d46b550241132d3f90d40801d2db576041cd64ac64d2a95cbb4406b9ca9db910a5197159e594f0ae7fb
7
+ data.tar.gz: 5734185bbf729d032023d99bd25630fbe1d16e1c77e5c9875a6ca5d53ca9dd518a7f07616c8a48efe908191a1775ee1b730ef6f9eb7594826dd3ae622de5be7c
@@ -37,7 +37,6 @@ IMAGE_TABLE = {
37
37
  }.freeze
38
38
 
39
39
  DOCKER_PLATFORMS = [
40
- 'CentOS-6',
41
40
  'CentOS-7',
42
41
  'CentOS-8',
43
42
  'Debian-10',
@@ -41,22 +41,22 @@ ARM_IMAGE_TABLE = {
41
41
  }.freeze
42
42
 
43
43
  DOCKER_PLATFORMS = {
44
- 'CentOS-6' => 'litmusimage/centos:6',
44
+ 'AmazonLinux-2' => 'litmusimage/amazonlinux:2',
45
+ 'AmazonLinux-2023' => 'litmusimage/amazonlinux:2023',
45
46
  'CentOS-7' => 'litmusimage/centos:7',
46
47
  'CentOS-8' => 'litmusimage/centos:stream8', # Support officaly moved to Stream8, metadata is being left as is
48
+ 'CentOS-9' => 'litmusimage/centos:stream9',
47
49
  'Rocky-8' => 'litmusimage/rockylinux:8',
50
+ 'Rocky-9' => 'litmusimage/rockylinux:9',
48
51
  'AlmaLinux-8' => 'litmusimage/almalinux:8',
49
- # 'Debian-8' => 'litmusimage/debian:8', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
50
- 'Debian-9' => 'litmusimage/debian:9',
52
+ 'AlmaLinux-9' => 'litmusimage/almalinux:9',
51
53
  'Debian-10' => 'litmusimage/debian:10',
52
54
  'Debian-11' => 'litmusimage/debian:11',
53
55
  'Debian-12' => 'litmusimage/debian:12',
54
- 'OracleLinux-6' => 'litmusimage/oraclelinux:6',
55
56
  'OracleLinux-7' => 'litmusimage/oraclelinux:7',
56
- 'Scientific-6' => 'litmusimage/scientificlinux:6',
57
+ 'OracleLinux-8' => 'litmusimage/oraclelinux:8',
58
+ 'OracleLinux-9' => 'litmusimage/oraclelinux:9',
57
59
  'Scientific-7' => 'litmusimage/scientificlinux:7',
58
- # 'Ubuntu-14.04' => 'litmusimage/ubuntu:14.04', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
59
- # 'Ubuntu-16.04' => 'litmusimage/ubuntu:16.04', Support Dropped
60
60
  'Ubuntu-18.04' => 'litmusimage/ubuntu:18.04',
61
61
  'Ubuntu-20.04' => 'litmusimage/ubuntu:20.04',
62
62
  'Ubuntu-22.04' => 'litmusimage/ubuntu:22.04'
@@ -210,9 +210,9 @@ namespace :litmus do
210
210
  # module_tar = Dir.glob('pkg/*.tar.gz').max_by { |f| File.mtime(f) }
211
211
  raise "Unable to find package in 'pkg/*.tar.gz'" if module_tar.nil?
212
212
 
213
- install_module(inventory_hash, args[:target_node_name], module_tar, args[:module_repository])
213
+ install_module(inventory_hash, target_nodes, module_tar, args[:module_repository])
214
214
 
215
- puts "Installed '#{module_tar}' on #{args[:target_node_name]}"
215
+ puts "Installed '#{module_tar}' on #{target_nodes.join(', ')}"
216
216
  end
217
217
 
218
218
  # Install the puppet modules from a source directory to nodes. It does not install dependencies.
@@ -241,10 +241,8 @@ namespace :litmus do
241
241
  include BoltSpec::Run
242
242
  module_tars.each do |module_tar|
243
243
  puts "Installing '#{module_tar}'"
244
- target_nodes.each do |target_node_name|
245
- install_module(inventory_hash, target_node_name, module_tar, args[:module_repository], args[:ignore_dependencies])
246
- puts "Installed '#{module_tar}' on #{target_node_name}"
247
- end
244
+ install_module(inventory_hash, target_nodes, module_tar, args[:module_repository], args[:ignore_dependencies])
245
+ puts "Installed '#{module_tar}' on #{target_nodes.join(', ')}"
248
246
  end
249
247
  end
250
248
 
@@ -26,7 +26,7 @@ module PuppetLitmus
26
26
 
27
27
  if target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'docker_nodes')
28
28
  host = ENV.fetch('TARGET_HOST', nil)
29
- set :backend, :docker
29
+ set :backend, :dockercli
30
30
  set :docker_container, host
31
31
  elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'ssh_nodes')
32
32
  set :backend, :ssh
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version of this gem
4
4
  module PuppetLitmus
5
- VERSION = '1.3.0'
5
+ VERSION = '1.4.0'
6
6
  end
@@ -14,6 +14,13 @@
14
14
  }
15
15
  ],
16
16
  "operatingsystem_support": [
17
+ {
18
+ "operatingsystem": "AmazonLinux",
19
+ "operatingsystemrelease": [
20
+ "2",
21
+ "2023"
22
+ ]
23
+ },
17
24
  {
18
25
  "operatingsystem": "CentOS",
19
26
  "operatingsystemrelease": [
@@ -17,12 +17,14 @@ RSpec.describe 'matrix_from_metadata_v2' do
17
17
  end
18
18
 
19
19
  it 'generates the matrix' do # rubocop:disable RSpec/ExampleLength
20
+ expect(result.stdout).to include('::warning::Cannot find image for CentOS-6')
20
21
  expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
21
22
  expect(github_output_content).to include(
22
23
  [
23
24
  'matrix={',
24
25
  '"platforms":[',
25
- '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
26
+ '{"label":"AmazonLinux-2","provider":"docker","image":"litmusimage/amazonlinux:2"},',
27
+ '{"label":"AmazonLinux-2023","provider":"docker","image":"litmusimage/amazonlinux:2023"},',
26
28
  '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},',
27
29
  '{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},',
28
30
  '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},',
@@ -39,7 +41,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
39
41
  expect(github_output_content).to include(
40
42
  'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
41
43
  )
42
- expect(result.stdout).to include("Created matrix with 16 cells:\n - Acceptance Test Cells: 14\n - Spec Test Cells: 2")
44
+ expect(result.stdout).to include("Created matrix with 18 cells:\n - Acceptance Test Cells: 16\n - Spec Test Cells: 2")
43
45
  end
44
46
  end
45
47
 
@@ -57,13 +59,15 @@ RSpec.describe 'matrix_from_metadata_v2' do
57
59
  end
58
60
 
59
61
  it 'generates the matrix without excluded platforms' do # rubocop:disable RSpec/ExampleLength
62
+ expect(result.stdout).to include('::warning::Cannot find image for CentOS-6')
60
63
  expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
61
64
  expect(result.stdout).to include('::warning::Ubuntu-18.04 was excluded from testing')
62
65
  expect(github_output_content).to include(
63
66
  [
64
67
  'matrix={',
65
68
  '"platforms":[',
66
- '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
69
+ '{"label":"AmazonLinux-2","provider":"docker","image":"litmusimage/amazonlinux:2"},',
70
+ '{"label":"AmazonLinux-2023","provider":"docker","image":"litmusimage/amazonlinux:2023"},',
67
71
  '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},',
68
72
  '{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},',
69
73
  '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},',
@@ -79,14 +83,14 @@ RSpec.describe 'matrix_from_metadata_v2' do
79
83
  expect(github_output_content).to include(
80
84
  'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
81
85
  )
82
- expect(result.stdout).to include("Created matrix with 14 cells:\n - Acceptance Test Cells: 12\n - Spec Test Cells: 2")
86
+ expect(result.stdout).to include("Created matrix with 16 cells:\n - Acceptance Test Cells: 14\n - Spec Test Cells: 2")
83
87
  end
84
88
  end
85
89
 
86
90
  context 'with --exclude-platforms \'["ubuntu-18.04","redhat-8"]\'' do
87
91
  let(:github_output) { Tempfile.new('github_output') }
88
92
  let(:github_output_content) { github_output.read }
89
- let(:result) { run_matrix_from_metadata_v2({ '--exclude-platforms' => ['ubuntu-18.04', 'ubuntu-22.04', 'redhat-8', 'redhat-9'] }) }
93
+ let(:result) { run_matrix_from_metadata_v2({ '--exclude-platforms' => ['amazonlinux-2', 'amazonlinux-2023', 'ubuntu-18.04', 'ubuntu-22.04', 'redhat-8', 'redhat-9'] }) }
90
94
 
91
95
  before do
92
96
  ENV['GITHUB_OUTPUT'] = github_output.path
@@ -98,6 +102,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
98
102
 
99
103
  it 'generates the matrix without excluded platforms' do
100
104
  expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
105
+ expect(result.stdout).to include('::warning::Cannot find image for CentOS-6')
101
106
  expect(result.stdout).to include('::warning::Ubuntu-18.04 was excluded from testing')
102
107
  expect(result.stdout).to include('::warning::Ubuntu-22.04 was excluded from testing')
103
108
  expect(result.stdout).to include('::warning::RedHat-8 was excluded from testing')
@@ -105,7 +110,6 @@ RSpec.describe 'matrix_from_metadata_v2' do
105
110
  [
106
111
  'matrix={',
107
112
  '"platforms":[',
108
- '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
109
113
  '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},',
110
114
  '{"label":"Ubuntu-22.04-arm","provider":"provision_service","image":"ubuntu-2204-lts-arm64"}',
111
115
  '],',
@@ -118,7 +122,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
118
122
  expect(github_output_content).to include(
119
123
  'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
120
124
  )
121
- expect(result.stdout).to include("Created matrix with 8 cells:\n - Acceptance Test Cells: 6\n - Spec Test Cells: 2")
125
+ expect(result.stdout).to include("Created matrix with 6 cells:\n - Acceptance Test Cells: 4\n - Spec Test Cells: 2")
122
126
  end
123
127
  end
124
128
  end
@@ -22,10 +22,60 @@ describe 'litmus rake tasks' do
22
22
  expect($stdout).to receive(:puts).with('redhat-5-x86_64')
23
23
  expect($stdout).to receive(:puts).with('ubuntu-1404-x86_64')
24
24
  expect($stdout).to receive(:puts).with('ubuntu-1804-x86_64')
25
+ allow_any_instance_of(Object).to receive(:exit)
25
26
  Rake::Task['litmus:metadata'].invoke
26
27
  end
27
28
  end
28
29
 
30
+ context 'with litmus:install_module' do
31
+ let(:args) { { target_node_name: nil, module_repository: nil } }
32
+ let(:inventory_hash) { { 'groups' => [{ 'name' => 'ssh_nodes', 'nodes' => [{ 'uri' => 'some.host' }, { 'uri' => 'some.otherhost' }] }] } }
33
+ let(:target_nodes) { ['some.host', 'some.otherhost'] }
34
+ let(:dummy_tar) { 'spec/data/doot.tar.gz' }
35
+
36
+ before do
37
+ Rake::Task['litmus:install_module'].reenable
38
+ allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
39
+ allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:find_targets).with(inventory_hash, args[:target_node_name]).and_return(target_nodes)
40
+ end
41
+
42
+ it 'installs module' do
43
+ expect_any_instance_of(Object).to receive(:build_module).and_return(dummy_tar)
44
+ expect($stdout).to receive(:puts).with("Built '#{dummy_tar}'")
45
+
46
+ expect_any_instance_of(Object).to receive(:install_module).with(inventory_hash, target_nodes, dummy_tar, args[:module_repository])
47
+ expect($stdout).to receive(:puts).with("Installed '#{dummy_tar}' on #{target_nodes.join(', ')}")
48
+ allow_any_instance_of(Object).to receive(:exit)
49
+ Rake::Task['litmus:install_module'].invoke(*args.values)
50
+ end
51
+
52
+ context 'with unknown target' do
53
+ let(:args) { { target_node_name: 'un.known', module_repository: nil } }
54
+ let(:target_nodes) { [] }
55
+
56
+ it 'exits with No targets found' do
57
+ expect do
58
+ expect($stdout).to receive(:puts).with('No targets found')
59
+ Rake::Task['litmus:install_module'].invoke(*args.values)
60
+ end.to raise_error(SystemExit) { |error|
61
+ expect(error.status).to eq(0)
62
+ }
63
+ end
64
+ end
65
+
66
+ context 'when build_module returns nil' do
67
+ let(:dummy_tar) { nil }
68
+
69
+ it 'raises error if build fails' do
70
+ expect_any_instance_of(Object).to receive(:build_module).and_return(dummy_tar)
71
+ expect($stdout).to receive(:puts).with("Built '#{dummy_tar}'")
72
+
73
+ expect { Rake::Task['litmus:install_module'].invoke(*args.values) }
74
+ .to raise_error(RuntimeError, "Unable to find package in 'pkg/*.tar.gz'")
75
+ end
76
+ end
77
+ end
78
+
29
79
  context 'with litmus:install_modules_from_directory' do
30
80
  let(:inventory_hash) { { 'groups' => [{ 'name' => 'ssh_nodes', 'nodes' => [{ 'uri' => 'some.host' }] }] } }
31
81
  let(:target_dir) { File.join(Dir.pwd, 'spec/fixtures/modules') }
@@ -44,6 +94,7 @@ describe 'litmus rake tasks' do
44
94
  expect($stdout).to receive(:puts).with(start_with('Installing \'spec/data/doot.tar.gz\''))
45
95
  expect_any_instance_of(Object).to receive(:run_command).twice.and_return([])
46
96
  expect($stdout).to receive(:puts).with(start_with('Installed \'spec/data/doot.tar.gz\''))
97
+ allow_any_instance_of(Object).to receive(:exit)
47
98
  Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/modules')
48
99
  end
49
100
  end
@@ -54,6 +105,7 @@ describe 'litmus rake tasks' do
54
105
  expect(Rake::Task['litmus:provision_list']).to receive(:invoke).with('default')
55
106
  expect(Rake::Task['litmus:install_agent']).to receive(:invoke).with('puppet6')
56
107
  expect(Rake::Task['litmus:install_module']).to receive(:invoke)
108
+ allow_any_instance_of(Object).to receive(:exit)
57
109
  Rake::Task['litmus:provision_install'].invoke('default', 'puppet6')
58
110
  end
59
111
  end
@@ -77,7 +129,7 @@ describe 'litmus rake tasks' do
77
129
  allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
78
130
  allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).with(any_args).and_return({})
79
131
  allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)
80
-
132
+ allow_any_instance_of(Object).to receive(:exit)
81
133
  expect { Rake::Task['litmus:provision'].invoke('docker', 'centos:7') }.to output(/#{expected_output}/).to_stdout
82
134
  end
83
135
  end
@@ -89,6 +141,7 @@ describe 'litmus rake tasks' do
89
141
  it 'no key in provision file' do
90
142
  allow(File).to receive(:file?).with(any_args).and_return(true)
91
143
  expect(YAML).to receive(:load_file).with(provision_file).and_return(provision_hash)
144
+ allow_any_instance_of(Object).to receive(:exit)
92
145
  expect { Rake::Task['litmus:provision_list'].invoke('deet') }.to raise_error(/deet/)
93
146
  end
94
147
  end
@@ -100,6 +153,7 @@ describe 'litmus rake tasks' do
100
153
  stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
101
154
  expect_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
102
155
  expect_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(inventory_hash, nil).and_return(true)
156
+ allow_any_instance_of(Object).to receive(:exit)
103
157
  Rake::Task['litmus:check_connectivity'].invoke
104
158
  end
105
159
  end
@@ -108,6 +162,7 @@ describe 'litmus rake tasks' do
108
162
  it 'calls spec_prep' do
109
163
  expect(Rake::Task['spec_prep']).to receive(:invoke).and_return('')
110
164
  expect_any_instance_of(RSpec::Core::RakeTask).to receive(:run_task)
165
+ allow_any_instance_of(Object).to receive(:exit)
111
166
  Rake::Task['litmus:acceptance:localhost'].invoke
112
167
  end
113
168
  end
@@ -5,11 +5,12 @@ load File.expand_path('../../../lib/puppet_litmus/util.rb', __dir__)
5
5
 
6
6
  RSpec.describe PuppetLitmus::Util do
7
7
  context 'when using interpolate_powershell' do
8
+ let(:command) { 'foo' }
9
+ let(:encoded) { Base64.strict_encode64(command.encode('UTF-16LE')) }
10
+
8
11
  it 'interpolates the command' do
9
- expect(described_class.interpolate_powershell('foo')).to match(/powershell\.exe/)
10
- expect(described_class.interpolate_powershell('foo')).to match(/NoProfile/)
11
- expect(described_class.interpolate_powershell('foo')).to match(/EncodedCommand/)
12
- expect(described_class.interpolate_powershell('foo')).not_to match(/foo/)
12
+ expect(described_class.interpolate_powershell(command)).to eql("powershell.exe -NoProfile -EncodedCommand #{encoded}")
13
+ expect(described_class.interpolate_powershell(command)).not_to match(/#{command}/)
13
14
  end
14
15
  end
15
16
  end
data/spec/spec_helper.rb CHANGED
@@ -5,32 +5,25 @@ require 'open3'
5
5
  require 'ostruct'
6
6
 
7
7
  if ENV['COVERAGE'] == 'yes'
8
- require 'simplecov'
9
-
10
- if ENV['CI'] == 'true'
11
- require 'codecov'
12
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
13
- else
8
+ begin
9
+ require 'simplecov'
10
+ require 'simplecov-console'
14
11
  SimpleCov.formatters = [
15
- SimpleCov::Formatter::HTMLFormatter
12
+ SimpleCov::Formatter::HTMLFormatter,
13
+ SimpleCov::Formatter::Console
16
14
  ]
17
- end
18
- SimpleCov.start do
19
- track_files 'lib/**/*.rb'
20
-
21
- add_filter '/spec'
22
15
 
23
- # do not track vendored files
24
- add_filter '/vendor'
25
- add_filter '/.vendor'
16
+ SimpleCov.start do
17
+ track_files 'lib/**/*.rb'
26
18
 
27
- # do not track gitignored files
28
- # this adds about 4 seconds to the coverage check
29
- # this could definitely be optimized
30
- add_filter do |f|
31
- # system returns true if exit status is 0, which with git-check-ignore means file is ignored
32
- system("git check-ignore --quiet #{f.filename}")
19
+ add_filter '/spec'
20
+ add_filter 'lib/puppet_litmus/version.rb'
21
+ # do not track vendored files
22
+ add_filter '/vendor'
23
+ add_filter '/.vendor'
33
24
  end
25
+ rescue LoadError
26
+ raise 'Add the simplecov & simplecov-console gems to Gemfile to enable this task'
34
27
  end
35
28
  end
36
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_litmus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2024-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt