puppet_litmus 1.0.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f42320bf296d7e6efb9370a3e39b775a868417f9dc337aa7c5dee5052b055c6f
4
- data.tar.gz: 607ab4fe445eb6f8b29d758212e84065b3e15b0273af85debec7676ea70c9115
3
+ metadata.gz: ec6aae4d826162090c6d1d7b05df110263b1d77b77879e72623529912a0948fb
4
+ data.tar.gz: b1d98ca5cad46e027ab1a0c15fdb37ae3e49b8dc70ddf423f2f34ec05e784e7b
5
5
  SHA512:
6
- metadata.gz: 6abadc5c20561dd3f0db0b0bfcd96b55ba0df2e2fdfa97576fb48caabe538287ccb86750264fe10c0831b23e20f89d34946d4df2dd3cdf2e1e0adccb7d3f6538
7
- data.tar.gz: f500ac82345c2c05abddf4e50d8c3492e37ef711b5c20a14fcda8d16ad6d5cecb13b64b43d343bd9e11eba242d80ef9584fa73f60fb36329c1b078d3c72f86bd
6
+ metadata.gz: 33254eeeb62d7be13711ee6941a666141715a07f7f3ecf37fb9dc3983403345b6880f4ff060b37b16b83ef7e5ab173982d4323be82af6aa720e59b7fe037f29c
7
+ data.tar.gz: a06db9fc523e6c6a586ff852cb60769313eb0dfb4be435f24f24038fda950fa87536b8f51248f8d7f36ed431189242f4d57f8dfdf8793d4c0f28d56244b7027a
data/README.md CHANGED
@@ -27,25 +27,36 @@ Litmus also facilitates parallel test runs and running tests in isolation. Each
27
27
 
28
28
  Install Litmus as a gem by running `gem install puppet_litmus`.
29
29
 
30
- - Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory strutcture you define exists.
30
+ - Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory structure you define exists.
31
31
 
32
32
  ## matrix_from_metadata_v2
33
33
 
34
- matrix_from_metadata_v2 tool generates github actions matrix from metadata.json
34
+ matrix_from_metadata_v2 tool generates a github action matrix from the supported operating systems listed in the module's metadata.json.
35
35
 
36
- How to use it: in the project module root directory run `bundle exec matrix_from_metadata_v2`
36
+ How to use it:
37
+ in the project module root directory run `bundle exec matrix_from_metadata_v2`
37
38
 
38
39
  ### --exclude-platforms parameter
39
40
 
40
- matrix_from_metadata_v2 accepts `--exclude-platforms <JSON array>` option in order to exclude some platforms from GA matrixes.
41
+ matrix_from_metadata_v2 accepts the `--exclude-platforms <JSON array>` argument in order to exclude some platforms from the matrix.
41
42
 
42
- In order to use this new functionality just simply run:
43
+ For example:
43
44
 
44
45
  `$: bundle exec matrix_from_metadata_v2 --exclude-platforms '["debian-11","centos-8"]'`
45
46
 
46
47
  > Note: The option value should be JSON string otherwise it will throw an error.
47
48
  > The values provided in the json array are case-insensitive `["debian-11","centos-8"]'` or `["Debian-11","CentOS-8"]'` are treated as being the same.
48
49
 
50
+ ### --custom-matrix parameter
51
+
52
+ matrix_from_metadata_v2 accepts the `--custom-matrix /path/to/matrix.json` argument in order to execute your test suite against a custom matrix. This is useful for use cases that do not fit the default matrix generated.
53
+
54
+ In order to use this new functionality, run:
55
+
56
+ `$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json`
57
+
58
+ > Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8"}, {..}]`), otherwise it will throw an error.
59
+
49
60
  ## Documentation
50
61
 
51
62
  For documentation, see our [Litmus Docs Site](https://puppetlabs.github.io/content-and-tooling-team/docs/litmus/).
@@ -94,29 +94,79 @@ else
94
94
  exclude_list = []
95
95
  end
96
96
 
97
+ # Force the use of the provision_service provisioner, if the --provision-service argument is present
98
+ if ARGV.include?('--provision-service')
99
+ provision_service_occurrences = ARGV.count { |arg| arg == '--provision-service' }
100
+ raise 'the --provision-service argument should be present just one time in the command' unless provision_service_occurrences <= 1
101
+
102
+ # NOTE: that the below are the only available images for the provision service
103
+ updated_platforms = {
104
+ 'AlmaLinux-8' => 'almalinux-cloud/almalinux-8',
105
+ 'CentOS-7' => 'centos-7',
106
+ 'CentOS-8' => 'centos-stream-8',
107
+ 'Rocky-8' => 'rocky-linux-cloud/rocky-linux-8',
108
+ 'Debian-10' => 'debian-10',
109
+ 'Debian-11' => 'debian-11',
110
+ 'Ubuntu-20.04' => 'ubuntu-2004-lts',
111
+ 'Ubuntu-22.04' => 'ubuntu-2204-lts'
112
+ }
113
+
114
+ updated_list = IMAGE_TABLE.dup.clone
115
+ updated_list.merge!(updated_platforms)
116
+
117
+ IMAGE_TABLE = updated_list.freeze
118
+ DOCKER_PLATFORMS = {}.freeze
119
+ end
120
+
97
121
  metadata_path = ENV['TEST_MATRIX_FROM_METADATA'] || 'metadata.json'
98
122
  metadata = JSON.parse(File.read(metadata_path))
99
- # Set platforms based on declared operating system support
100
- metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
101
- os = sup['operatingsystem']
102
- sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
103
- image_key = "#{os}-#{ver}"
104
-
105
- if IMAGE_TABLE.key?(image_key) && !exclude_list.include?(image_key.downcase)
106
- matrix[:platforms] << {
107
- label: image_key,
108
- provider: 'provision::provision_service',
109
- image: IMAGE_TABLE[image_key]
110
- }
111
- elsif DOCKER_PLATFORMS.key?(image_key) && !exclude_list.include?(image_key.downcase)
112
- matrix[:platforms] << {
113
- label: image_key,
114
- provider: 'provision::docker',
115
- image: DOCKER_PLATFORMS[image_key]
116
- }
123
+
124
+ # Allow the user to pass a file containing a custom matrix
125
+ if ARGV.include?('--custom-matrix')
126
+ custom_matrix_occurrences = ARGV.count { |arg| arg == '--custom-matrix' }
127
+ raise '--custom-matrix argument should be present just one time in the command' unless custom_matrix_occurrences <= 1
128
+
129
+ file_path = ARGV[ARGV.find_index('--custom-matrix') + 1]
130
+ raise 'no file path specified' if file_path.nil?
131
+
132
+ begin
133
+ custom_matrix = JSON.parse(File.read(file_path))
134
+ rescue StandardError => e
135
+ case e
136
+ when JSON::ParserError
137
+ raise 'the matrix must be an array of valid JSON objects'
138
+ when Errno::ENOENT
139
+ raise "File not found: #{e.message}"
117
140
  else
118
- puts "::warning::#{image_key} was excluded from testing" if exclude_list.include?(image_key.downcase)
119
- puts "::warning::Cannot find image for #{image_key}" unless exclude_list.include?(image_key.downcase)
141
+ raise "An unknown exception occurred: #{e.message}"
142
+ end
143
+ end
144
+ custom_matrix.each do |platform|
145
+ matrix[:platforms] << platform
146
+ end
147
+ else
148
+ # Set platforms based on declared operating system support
149
+ metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
150
+ os = sup['operatingsystem']
151
+ sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
152
+ image_key = "#{os}-#{ver}"
153
+
154
+ if IMAGE_TABLE.key?(image_key) && !exclude_list.include?(image_key.downcase)
155
+ matrix[:platforms] << {
156
+ label: image_key,
157
+ provider: 'provision_service',
158
+ image: IMAGE_TABLE[image_key]
159
+ }
160
+ elsif DOCKER_PLATFORMS.key?(image_key) && !exclude_list.include?(image_key.downcase)
161
+ matrix[:platforms] << {
162
+ label: image_key,
163
+ provider: 'docker',
164
+ image: DOCKER_PLATFORMS[image_key]
165
+ }
166
+ else
167
+ puts "::warning::#{image_key} was excluded from testing" if exclude_list.include?(image_key.downcase)
168
+ puts "::warning::Cannot find image for #{image_key}" unless exclude_list.include?(image_key.downcase)
169
+ end
120
170
  end
121
171
  end
122
172
  end
@@ -155,9 +205,8 @@ end
155
205
 
156
206
  # Set to defaults (all collections) if no matches are found
157
207
  matrix[:collection] = COLLECTION_TABLE.map { |collection| "puppet#{collection[:puppet_maj_version]}-nightly" } if matrix[:collection].empty?
158
-
159
208
  # Just to make sure there aren't any duplicates
160
- matrix[:platforms] = matrix[:platforms].uniq.sort_by { |a| a[:label] }
209
+ matrix[:platforms] = matrix[:platforms].uniq.sort_by { |a| a[:label] } unless ARGV.include?('--custom-matrix')
161
210
  matrix[:collection] = matrix[:collection].uniq.sort
162
211
 
163
212
  set_output('matrix', JSON.generate(matrix))
@@ -98,7 +98,8 @@ module PuppetLitmus::RakeHelper
98
98
 
99
99
  results = {}
100
100
  targets.each do |node_name|
101
- next if node_name == 'litmus_localhost'
101
+ # next if local host or provisioner fact empty/not set (GH-421)
102
+ next if node_name == 'litmus_localhost' || facts_from_node(inventory_hash, node_name)['provisioner'].nil?
102
103
 
103
104
  result = tear_down(node_name, inventory_hash)
104
105
  # Some provisioners tear_down targets that were created as a batch job.
@@ -287,7 +288,7 @@ module PuppetLitmus::RakeHelper
287
288
  if SUPPORTED_PROVISIONERS.include?(provisioner)
288
289
  "provision::#{provisioner}"
289
290
  else
290
- warn "WARNING: Unsuported provisioner '#{provisioner}', try #{SUPPORTED_PROVISIONERS.join('/')}"
291
+ warn "WARNING: Unsupported provisioner '#{provisioner}', try #{SUPPORTED_PROVISIONERS.join('/')}"
291
292
  provisioner.to_s
292
293
  end
293
294
  end
@@ -327,7 +328,7 @@ module PuppetLitmus::RakeHelper
327
328
  end
328
329
 
329
330
  def start_spinner(message)
330
- if (ENV['CI'] || '').casecmp('true').zero?
331
+ if (ENV['CI'] || '').casecmp('true').zero? || Gem.win_platform?
331
332
  puts message
332
333
  spinner = Thread.new do
333
334
  # CI systems are strange beasts, we only output a '.' every wee while to keep the terminal alive.
@@ -345,7 +346,7 @@ module PuppetLitmus::RakeHelper
345
346
  end
346
347
 
347
348
  def stop_spinner(spinner)
348
- if (ENV['CI'] || '').casecmp('true').zero?
349
+ if (ENV['CI'] || '').casecmp('true').zero? || Gem.win_platform?
349
350
  Thread.kill(spinner)
350
351
  else
351
352
  spinner.success
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version of this gem
4
4
  module PuppetLitmus
5
- VERSION = '1.0.3'
5
+ VERSION = '1.1.1'
6
6
  end
@@ -22,9 +22,9 @@ RSpec.describe 'matrix_from_metadata_v2' do
22
22
  [
23
23
  'matrix={',
24
24
  '"platforms":[',
25
- '{"label":"CentOS-6","provider":"provision::docker","image":"litmusimage/centos:6"},',
26
- '{"label":"RedHat-8","provider":"provision::provision_service","image":"rhel-8"},',
27
- '{"label":"Ubuntu-18.04","provider":"provision::docker","image":"litmusimage/ubuntu:18.04"}',
25
+ '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
26
+ '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},',
27
+ '{"label":"Ubuntu-18.04","provider":"docker","image":"litmusimage/ubuntu:18.04"}',
28
28
  '],',
29
29
  '"collection":[',
30
30
  '"puppet7-nightly","puppet8-nightly"',
@@ -59,8 +59,8 @@ RSpec.describe 'matrix_from_metadata_v2' do
59
59
  [
60
60
  'matrix={',
61
61
  '"platforms":[',
62
- '{"label":"CentOS-6","provider":"provision::docker","image":"litmusimage/centos:6"},',
63
- '{"label":"RedHat-8","provider":"provision::provision_service","image":"rhel-8"}',
62
+ '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
63
+ '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"}',
64
64
  '],',
65
65
  '"collection":[',
66
66
  '"puppet7-nightly","puppet8-nightly"',
@@ -96,7 +96,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
96
96
  [
97
97
  'matrix={',
98
98
  '"platforms":[',
99
- '{"label":"CentOS-6","provider":"provision::docker","image":"litmusimage/centos:6"}',
99
+ '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"}',
100
100
  '],',
101
101
  '"collection":[',
102
102
  '"puppet7-nightly","puppet8-nightly"',
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.0.3
4
+ version: 1.1.1
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-05-04 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt