puppet_litmus 0.23.1 → 0.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/exe/matrix_from_metadata +2 -3
- data/exe/matrix_from_metadata_v2 +124 -0
- data/lib/puppet_litmus/inventory_manipulation.rb +1 -1
- data/lib/puppet_litmus/puppet_helpers.rb +8 -2
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/lib/puppet_litmus/rake_tasks_spec.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e2e2e71e771ea419d87cee723a5e5b7741f11a233ffe379953a3502776bc2d
|
4
|
+
data.tar.gz: 0ccdf33ad639e1391355c9c6f2769490167a4ea9e7c307cf635f193d51ea24a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6649698775dddc73e2f211bfbe5c69441fb10cee2a040bc2a475243e544467ceb3fdbe6b67ba07d79de11acdc8780132f7add4c06b9fbe97ddf03ff5e27e7543
|
7
|
+
data.tar.gz: a2697302f595adb29d8c966b96170d006111a14c618f78c40d7e62b8f96e0b2fd10512d7770752a110866847f2e7d0befab904ccea1837064b94e00f7b463073
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Litmus also facilitates parallel test runs and running tests in isolation. Each
|
|
22
22
|
|
23
23
|
Install Litmus as a gem by running ```gem install puppet_litmus```.
|
24
24
|
|
25
|
+
* Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory strutcture you define exists.
|
26
|
+
|
25
27
|
## Documentation
|
26
28
|
|
27
29
|
For documentation, see our [Litmus Docs Site](https://puppetlabs.github.io/litmus/).
|
data/exe/matrix_from_metadata
CHANGED
@@ -35,9 +35,8 @@ DOCKER_PLATFORMS = [
|
|
35
35
|
# This table uses the latest version in each collection for accurate
|
36
36
|
# comparison when evaluating puppet requirements from the metadata
|
37
37
|
COLLECTION_TABLE = {
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'7.0.0' => 'puppet7-nightly',
|
38
|
+
'6.21.0' => 'puppet6-nightly',
|
39
|
+
'7.4.0' => 'puppet7-nightly',
|
41
40
|
}.freeze
|
42
41
|
|
43
42
|
matrix = {
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# this script creates a build matrix for github actions from the claimed supported platforms and puppet versions in metadata.json
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
IMAGE_TABLE = {
|
9
|
+
'RedHat-7' => 'rhel-7',
|
10
|
+
'RedHat-8' => 'rhel-8',
|
11
|
+
'SLES-12' => 'sles-12',
|
12
|
+
'SLES-15' => 'sles-15',
|
13
|
+
'Windows-2012 R2' => 'windows-2012-r2-core',
|
14
|
+
'Windows-2016' => 'windows-2016',
|
15
|
+
'Windows-2019' => 'windows-2019-core',
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
DOCKER_PLATFORMS = {
|
19
|
+
'CentOS-6' => 'litmusimage/centos:6',
|
20
|
+
'CentOS-7' => 'litmusimage/centos:7',
|
21
|
+
'CentOS-8' => 'litmusimage/centos:8',
|
22
|
+
'Debian-10' => 'litmusimage/debian:10',
|
23
|
+
# 'Debian-8' => 'litmusimage/debian:8', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
|
24
|
+
'Debian-9' => 'litmusimage/debian:9',
|
25
|
+
'OracleLinux-6' => 'litmusimage/oraclelinux:6',
|
26
|
+
'OracleLinux-7' => 'litmusimage/oraclelinux:7',
|
27
|
+
'Scientific-6' => 'litmusimage/scientificlinux:6',
|
28
|
+
'Scientific-7' => 'litmusimage/scientificlinux:7',
|
29
|
+
# 'Ubuntu-14.04' => 'litmusimage/ubuntu:14.04', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
|
30
|
+
'Ubuntu-16.04' => 'litmusimage/ubuntu:16.04',
|
31
|
+
'Ubuntu-18.04' => 'litmusimage/ubuntu:18.04',
|
32
|
+
'Ubuntu-20.04' => 'litmusimage/ubuntu:20.04',
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
# This table uses the latest version in each collection for accurate
|
36
|
+
# comparison when evaluating puppet requirements from the metadata
|
37
|
+
COLLECTION_TABLE = [
|
38
|
+
{
|
39
|
+
puppet_maj_version: 6,
|
40
|
+
ruby_version: 2.5,
|
41
|
+
},
|
42
|
+
{
|
43
|
+
puppet_maj_version: 7,
|
44
|
+
ruby_version: 2.7,
|
45
|
+
},
|
46
|
+
].freeze
|
47
|
+
|
48
|
+
matrix = {
|
49
|
+
platforms: [],
|
50
|
+
collection: [],
|
51
|
+
}
|
52
|
+
|
53
|
+
spec_matrix = {
|
54
|
+
include: [],
|
55
|
+
}
|
56
|
+
|
57
|
+
metadata = JSON.parse(File.read('metadata.json'))
|
58
|
+
# Set platforms based on declared operating system support
|
59
|
+
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
60
|
+
os = sup['operatingsystem']
|
61
|
+
sup['operatingsystemrelease'].sort_by { |a| a.to_i }.each do |ver|
|
62
|
+
image_key = "#{os}-#{ver}"
|
63
|
+
if IMAGE_TABLE.key? image_key
|
64
|
+
matrix[:platforms] << {
|
65
|
+
label: image_key,
|
66
|
+
provider: 'provision::provision_service',
|
67
|
+
image: IMAGE_TABLE[image_key],
|
68
|
+
}
|
69
|
+
elsif DOCKER_PLATFORMS.key? image_key
|
70
|
+
matrix[:platforms] << {
|
71
|
+
label: image_key,
|
72
|
+
provider: 'provision::docker',
|
73
|
+
image: DOCKER_PLATFORMS[image_key],
|
74
|
+
}
|
75
|
+
else
|
76
|
+
puts "::warning::Cannot find image for #{image_key}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Set collections based on puppet version requirements
|
82
|
+
if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
83
|
+
metadata['requirements'].each do |req|
|
84
|
+
next unless req.key?('name') && req.key?('version_requirement') && req['name'] == 'puppet'
|
85
|
+
|
86
|
+
ver_regexp = %r{^([>=<]{1,2})\s*([\d.]+)\s+([>=<]{1,2})\s*([\d.]+)$}
|
87
|
+
match = ver_regexp.match(req['version_requirement'])
|
88
|
+
if match.nil?
|
89
|
+
puts "::warning::Didn't recognize version_requirement '#{req['version_requirement']}'"
|
90
|
+
break
|
91
|
+
end
|
92
|
+
|
93
|
+
cmp_one, ver_one, cmp_two, ver_two = match.captures
|
94
|
+
reqs = ["#{cmp_one} #{ver_one}", "#{cmp_two} #{ver_two}"]
|
95
|
+
|
96
|
+
COLLECTION_TABLE.each do |collection|
|
97
|
+
# Test against the "largest" puppet version in a collection, e.g. `7.9999` to allow puppet requirements with a non-zero lower bound on minor/patch versions.
|
98
|
+
# This assumes that such a boundary will always allow the latest actually existing puppet version of a release stream, trading off simplicity vs accuracy here.
|
99
|
+
next unless Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new("#{collection[:puppet_maj_version]}.9999"))
|
100
|
+
|
101
|
+
matrix[:collection] << "puppet#{collection[:puppet_maj_version]}-nightly"
|
102
|
+
spec_matrix[:include] << { puppet_version: "~> #{collection[:puppet_maj_version]}.0", ruby_version: collection[:ruby_version] }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Set to defaults (all collections) if no matches are found
|
108
|
+
if matrix[:collection].empty?
|
109
|
+
matrix[:collection] = COLLECTION_TABLE.map { |collection| "puppet#{collection[:puppet_maj_version]}-nightly" }
|
110
|
+
end
|
111
|
+
|
112
|
+
# Just to make sure there aren't any duplicates
|
113
|
+
matrix[:platforms] = matrix[:platforms].uniq.sort { |a, b| a[:label] <=> b[:label] }
|
114
|
+
matrix[:collection] = matrix[:collection].uniq.sort
|
115
|
+
|
116
|
+
puts "::set-output name=matrix::#{JSON.generate(matrix)}"
|
117
|
+
puts "::set-output name=spec_matrix::#{JSON.generate(spec_matrix)}"
|
118
|
+
|
119
|
+
acceptance_test_cell_count = matrix[:platforms].length * matrix[:collection].length
|
120
|
+
spec_test_cell_count = spec_matrix[:include].length
|
121
|
+
|
122
|
+
puts "Created matrix with #{acceptance_test_cell_count + spec_test_cell_count} cells:"
|
123
|
+
puts " - Acceptance Test Cells: #{acceptance_test_cell_count}"
|
124
|
+
puts " - Spec Test Cells: #{spec_test_cell_count}"
|
@@ -11,7 +11,7 @@ module PuppetLitmus::InventoryManipulation
|
|
11
11
|
def inventory_hash_from_inventory_file(inventory_full_path = nil)
|
12
12
|
require 'yaml'
|
13
13
|
inventory_full_path = if inventory_full_path.nil?
|
14
|
-
|
14
|
+
"#{Dir.pwd}/spec/fixtures/litmus_inventory.yaml"
|
15
15
|
else
|
16
16
|
inventory_full_path
|
17
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# helper functions for running puppet commands. They execute a target system specified by ENV['TARGET_HOST']
|
4
|
-
# heavily uses functions from here https://github.com/puppetlabs/bolt/blob/
|
4
|
+
# heavily uses functions from here https://github.com/puppetlabs/bolt/blob/main/developer-docs/bolt_spec-run.md
|
5
5
|
module PuppetLitmus::PuppetHelpers
|
6
6
|
# Applies a manifest twice. First checking for errors. Secondly to make sure no changes occur.
|
7
7
|
#
|
@@ -75,7 +75,13 @@ module PuppetLitmus::PuppetHelpers
|
|
75
75
|
span.add_field('litmus.node_name', target_node_name)
|
76
76
|
add_platform_field(inventory_hash, target_node_name)
|
77
77
|
|
78
|
-
|
78
|
+
# Forcibly set the locale of the command
|
79
|
+
locale = if os[:family] != 'windows'
|
80
|
+
'LC_ALL=en_US.UTF-8 '
|
81
|
+
else
|
82
|
+
''
|
83
|
+
end
|
84
|
+
command_to_run = "#{locale}#{opts[:prefix_command]} puppet apply #{manifest_file_location}"
|
79
85
|
command_to_run += ' --trace' if !opts[:trace].nil? && (opts[:trace] == true)
|
80
86
|
command_to_run += " --modulepath #{Dir.pwd}/spec/fixtures/modules" if target_node_name == 'litmus_localhost'
|
81
87
|
command_to_run += " --hiera_config='#{opts[:hiera_config]}'" unless opts[:hiera_config].nil?
|
@@ -16,7 +16,7 @@ describe 'litmus rake tasks' do
|
|
16
16
|
'operatingsystem_support' =>
|
17
17
|
[{ 'operatingsystem' => 'RedHat', 'operatingsystemrelease' => ['5'] },
|
18
18
|
{ 'operatingsystem' => 'Ubuntu', 'operatingsystemrelease' => ['14.04', '18.04'] }],
|
19
|
-
'template-ref' => 'heads/
|
19
|
+
'template-ref' => 'heads/main-0-g7827fc2' }
|
20
20
|
expect(File).to receive(:read).with(any_args).once
|
21
21
|
expect(JSON).to receive(:parse).with(any_args).and_return(metadata)
|
22
22
|
expect($stdout).to receive(:puts).with('redhat-5-x86_64')
|
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: 0.
|
4
|
+
version: 0.26.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: 2021-
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -166,12 +166,14 @@ email:
|
|
166
166
|
- info@puppet.com
|
167
167
|
executables:
|
168
168
|
- matrix_from_metadata
|
169
|
+
- matrix_from_metadata_v2
|
169
170
|
extensions: []
|
170
171
|
extra_rdoc_files: []
|
171
172
|
files:
|
172
173
|
- LICENSE
|
173
174
|
- README.md
|
174
175
|
- exe/matrix_from_metadata
|
176
|
+
- exe/matrix_from_metadata_v2
|
175
177
|
- lib/puppet_litmus.rb
|
176
178
|
- lib/puppet_litmus/inventory_manipulation.rb
|
177
179
|
- lib/puppet_litmus/puppet_helpers.rb
|
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
- !ruby/object:Gem::Version
|
210
212
|
version: '0'
|
211
213
|
requirements: []
|
212
|
-
rubygems_version: 3.1.
|
214
|
+
rubygems_version: 3.1.4
|
213
215
|
signing_key:
|
214
216
|
specification_version: 4
|
215
217
|
summary: Providing a simple command line tool for puppet content creators, to enable
|