simp-beaker-helpers 1.18.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fixtures.yml +8 -0
- data/.gitignore +8 -0
- data/.gitlab-ci.yml +163 -0
- data/.rspec +4 -0
- data/.rubocop.yml +546 -0
- data/.travis.yml +36 -0
- data/CHANGELOG.md +231 -0
- data/Gemfile +51 -0
- data/LICENSE +27 -0
- data/README.md +543 -0
- data/Rakefile +151 -0
- data/files/pki/clean.sh +1 -0
- data/files/pki/make.sh +101 -0
- data/files/pki/template_ca.cnf +259 -0
- data/files/pki/template_host.cnf +263 -0
- data/files/puppet-agent-versions.yaml +46 -0
- data/lib/simp/beaker_helpers.rb +1231 -0
- data/lib/simp/beaker_helpers/constants.rb +25 -0
- data/lib/simp/beaker_helpers/inspec.rb +328 -0
- data/lib/simp/beaker_helpers/snapshot.rb +156 -0
- data/lib/simp/beaker_helpers/ssg.rb +383 -0
- data/lib/simp/beaker_helpers/version.rb +5 -0
- data/lib/simp/beaker_helpers/windows.rb +16 -0
- data/lib/simp/rake/beaker.rb +269 -0
- data/simp-beaker-helpers.gemspec +38 -0
- data/spec/acceptance/nodesets/default.yml +32 -0
- data/spec/acceptance/suites/default/check_puppet_version_spec.rb +23 -0
- data/spec/acceptance/suites/default/enable_fips_spec.rb +23 -0
- data/spec/acceptance/suites/default/fixture_modules_spec.rb +22 -0
- data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +43 -0
- data/spec/acceptance/suites/default/nodesets +1 -0
- data/spec/acceptance/suites/default/pki_tests_spec.rb +55 -0
- data/spec/acceptance/suites/default/set_hieradata_on_spec.rb +33 -0
- data/spec/acceptance/suites/default/write_hieradata_to_spec.rb +33 -0
- data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +63 -0
- data/spec/acceptance/suites/fips_from_fixtures/metadata.yml +2 -0
- data/spec/acceptance/suites/fips_from_fixtures/nodesets +1 -0
- data/spec/acceptance/suites/offline/00_default_spec.rb +165 -0
- data/spec/acceptance/suites/offline/README +2 -0
- data/spec/acceptance/suites/offline/nodesets/default.yml +26 -0
- data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +25 -0
- data/spec/acceptance/suites/puppet_collections/metadata.yml +2 -0
- data/spec/acceptance/suites/puppet_collections/nodesets/default.yml +30 -0
- data/spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb +82 -0
- data/spec/acceptance/suites/snapshot/10_general_usage_spec.rb +56 -0
- data/spec/acceptance/suites/snapshot/nodesets +1 -0
- data/spec/acceptance/suites/windows/00_default_spec.rb +119 -0
- data/spec/acceptance/suites/windows/metadata.yml +2 -0
- data/spec/acceptance/suites/windows/nodesets/default.yml +33 -0
- data/spec/acceptance/suites/windows/nodesets/win2016.yml +35 -0
- data/spec/acceptance/suites/windows/nodesets/win2019.yml +34 -0
- data/spec/lib/simp/beaker_helpers_spec.rb +216 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/spec_helper_acceptance.rb +25 -0
- metadata +243 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
HOSTS:
|
2
|
+
el7:
|
3
|
+
platform: el-7-x86_64
|
4
|
+
box: centos/7
|
5
|
+
# This doesn't work with any other hypervisor
|
6
|
+
hypervisor: 'vagrant_libvirt'
|
7
|
+
vagrant_memsize: 3072
|
8
|
+
vagrant_cpus: 4
|
9
|
+
# Necessary to prevent network overlap inside the spawned test set
|
10
|
+
ip: '172.16.251.111'
|
11
|
+
netmask: '255.255.255.0'
|
12
|
+
|
13
|
+
CONFIG:
|
14
|
+
log_level: verbose
|
15
|
+
type: aio
|
16
|
+
<% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
|
17
|
+
puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
|
18
|
+
<% end -%>
|
19
|
+
libvirt:
|
20
|
+
# Ensure that we use the best option available
|
21
|
+
'cpu_mode': 'host-passthrough'
|
22
|
+
# Make sure that vagrant knows that we're rolling nested virt
|
23
|
+
'nested': true
|
24
|
+
# Necessary to prevent network overlap inside the spawned test set
|
25
|
+
'management_network_name': 'beaker-mgmt'
|
26
|
+
'management_network_address': '172.16.250.1/24'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This needs to be done so that we actually bring in a collection at the start
|
2
|
+
# of the run
|
3
|
+
#
|
4
|
+
# Choosing an arbitrary number in the middle of 5 so that we're not fooled by
|
5
|
+
# edge cases
|
6
|
+
#
|
7
|
+
ENV['PUPPET_VERSION'] = '5.1'
|
8
|
+
|
9
|
+
require 'spec_helper_acceptance'
|
10
|
+
|
11
|
+
Bundler.with_clean_env{
|
12
|
+
%x{bundle exec rake spec_prep}
|
13
|
+
}
|
14
|
+
|
15
|
+
hosts.each do |host|
|
16
|
+
describe 'make sure puppet version is valid' do
|
17
|
+
context "on #{host}" do
|
18
|
+
client_puppet_version = on(host, 'puppet --version').output.strip
|
19
|
+
|
20
|
+
it "should be running puppet version #{ENV['PUPPET_VERSION']}}" do
|
21
|
+
expect(Gem::Version.new(client_puppet_version)).to be >= Gem::Version.new(ENV['PUPPET_VERSION'])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%
|
2
|
+
if ENV['BEAKER_HYPERVISOR']
|
3
|
+
hypervisor = ENV['BEAKER_HYPERVISOR']
|
4
|
+
else
|
5
|
+
hypervisor = 'vagrant'
|
6
|
+
end
|
7
|
+
-%>
|
8
|
+
HOSTS:
|
9
|
+
server-el7:
|
10
|
+
roles:
|
11
|
+
- server
|
12
|
+
- default
|
13
|
+
- master
|
14
|
+
- el7
|
15
|
+
platform: el-7-x86_64
|
16
|
+
box: centos/7
|
17
|
+
hypervisor: <%= hypervisor %>
|
18
|
+
|
19
|
+
server-el6:
|
20
|
+
roles:
|
21
|
+
- el6
|
22
|
+
platform: el-6-x86_64
|
23
|
+
box: centos/6
|
24
|
+
hypervisor: <%= hypervisor %>
|
25
|
+
|
26
|
+
CONFIG:
|
27
|
+
log_level: verbose
|
28
|
+
type: aio
|
29
|
+
puppet_collection: puppet5
|
30
|
+
vagrant_memsize: 256
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
|
3
|
+
hosts.each do |host|
|
4
|
+
describe 'take a snapshot' do
|
5
|
+
context "on #{host}" do
|
6
|
+
it 'creates a file that should be saved' do
|
7
|
+
on(host, 'echo "keep" > /root/keep')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'takes a snapshot' do
|
11
|
+
Simp::BeakerHelpers::Snapshot.save(host, 'test')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'creates a file that should be removed' do
|
15
|
+
on(host, 'echo "trash" > /root/trash')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'restores a snapshot' do
|
19
|
+
Simp::BeakerHelpers::Snapshot.restore(host, 'test')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have the keep file' do
|
23
|
+
expect(host.file_exist?('/root/keep')).to be true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not have the trash file' do
|
27
|
+
expect(host.file_exist?('/root/trash')).to be false
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'creates a second file that should be saved' do
|
31
|
+
on(host, 'echo "keep2" > /root/keep2')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'takes a snapshot with the same name' do
|
35
|
+
Simp::BeakerHelpers::Snapshot.save(host, 'test')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'creates a file that should be removed' do
|
39
|
+
on(host, 'echo "trash" > /root/trash')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'restores a snapshot' do
|
43
|
+
Simp::BeakerHelpers::Snapshot.restore(host, 'test')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should have all keep files' do
|
47
|
+
expect(host.file_exist?('/root/keep')).to be true
|
48
|
+
expect(host.file_exist?('/root/keep2')).to be true
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should not have the trash file' do
|
52
|
+
expect(host.file_exist?('/root/trash')).to be false
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'takes a snapshot with a different name' do
|
56
|
+
Simp::BeakerHelpers::Snapshot.save(host, 'test2')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can list the snapshots' do
|
60
|
+
expect(Simp::BeakerHelpers::Snapshot.list(host)).to eq ["#{host}", 'test', 'test2']
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'can query for a specific snapshot' do
|
64
|
+
expect(Simp::BeakerHelpers::Snapshot.exist?(host, 'test')).to eq true
|
65
|
+
expect(Simp::BeakerHelpers::Snapshot.exist?(host, 'test2')).to eq true
|
66
|
+
expect(Simp::BeakerHelpers::Snapshot.exist?(host, 'nope')).to eq false
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'restores to the internal base' do
|
70
|
+
Simp::BeakerHelpers::Snapshot.restore_to_base(host)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'creates a file that should be saved' do
|
74
|
+
on(host, 'echo "keep" > /root/keep')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'creates a handoff snapshot for further tests' do
|
78
|
+
Simp::BeakerHelpers::Snapshot.save(host, 'handoff')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
|
3
|
+
hosts.each do |host|
|
4
|
+
describe 'snapshot workflow' do
|
5
|
+
context "on #{host}" do
|
6
|
+
shared_examples_for 'a snapshot test' do
|
7
|
+
let(:snapshots) { Simp::BeakerHelpers::Snapshot.list(host) }
|
8
|
+
|
9
|
+
it 'restores from the initial snapshot' do
|
10
|
+
if snapshots.include?(init_snapshot)
|
11
|
+
Simp::BeakerHelpers::Snapshot.restore(host, init_snapshot)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'adds the keep file if necessary' do
|
16
|
+
if init_snapshot == 'missing'
|
17
|
+
on(host, 'echo "keep" > /root/keep')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'adds a tracking file' do
|
22
|
+
on(host, 'echo "tracking" > /root/tracking')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'restores the snapshot' do
|
26
|
+
if init_snapshot == 'missing'
|
27
|
+
expect { Simp::BeakerHelpers::Snapshot.restore(host, init_snapshot) }.to raise_error(/not found/)
|
28
|
+
Simp::BeakerHelpers::Snapshot.restore_to_base(host)
|
29
|
+
else
|
30
|
+
Simp::BeakerHelpers::Snapshot.restore(host, init_snapshot)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have the keep file' do
|
35
|
+
expect(host.file_exist?('/root/keep')).to be true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not have the tracking file' do
|
39
|
+
expect(host.file_exist?('/root/tracking')).to be false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'existing snapshot' do
|
44
|
+
let(:init_snapshot) { 'handoff' }
|
45
|
+
|
46
|
+
include_examples 'a snapshot test'
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'missing snapshot' do
|
50
|
+
let(:init_snapshot) { 'missing' }
|
51
|
+
|
52
|
+
include_examples 'a snapshot test'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
spec/acceptance/suites/snapshot/../../nodesets
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'yaml'
|
3
|
+
require 'openssl'
|
4
|
+
require 'beaker-rspec'
|
5
|
+
require 'simp/beaker_helpers'
|
6
|
+
include Simp::BeakerHelpers
|
7
|
+
|
8
|
+
require 'beaker/puppet_install_helper'
|
9
|
+
|
10
|
+
unless ENV['BEAKER_provision'] == 'no'
|
11
|
+
hosts.each do |host|
|
12
|
+
unless Simp::BeakerHelpers::Snapshot.exist?(host, 'puppet_installed')
|
13
|
+
# Install Puppet
|
14
|
+
if host.is_pe?
|
15
|
+
install_pe
|
16
|
+
else
|
17
|
+
install_puppet
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |c|
|
24
|
+
# ensure that environment OS is ready on each host
|
25
|
+
fix_errata_on(hosts)
|
26
|
+
|
27
|
+
# Readable test descriptions
|
28
|
+
c.formatter = :documentation
|
29
|
+
|
30
|
+
# Configure all nodes in nodeset
|
31
|
+
c.before :suite do
|
32
|
+
begin
|
33
|
+
copy_fixture_modules_to( hosts )
|
34
|
+
|
35
|
+
nonwin = hosts.dup
|
36
|
+
nonwin.delete_if {|h| h[:platform] =~ /windows/ }
|
37
|
+
|
38
|
+
begin
|
39
|
+
server = only_host_with_role(nonwin, 'server')
|
40
|
+
rescue ArgumentError => e
|
41
|
+
server = only_host_with_role(nonwin, 'default')
|
42
|
+
end
|
43
|
+
# Generate and install PKI certificates on each SUT
|
44
|
+
Dir.mktmpdir do |cert_dir|
|
45
|
+
run_fake_pki_ca_on(server, nonwin, cert_dir )
|
46
|
+
nonwin.each{ |sut| copy_pki_to( sut, cert_dir, '/etc/pki/simp-testing' )}
|
47
|
+
end
|
48
|
+
|
49
|
+
# add PKI keys
|
50
|
+
copy_keydist_to(server)
|
51
|
+
rescue StandardError, ScriptError => e
|
52
|
+
if ENV['PRY']
|
53
|
+
require 'pry'; binding.pry
|
54
|
+
else
|
55
|
+
raise e
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'windows' do
|
62
|
+
|
63
|
+
let(:hieradata){{
|
64
|
+
'test::foo' => 'test'
|
65
|
+
}}
|
66
|
+
|
67
|
+
let(:manifest){ 'notify { "test": message => lookup("test::foo")}' }
|
68
|
+
|
69
|
+
hosts.each do |host|
|
70
|
+
context "on #{host}" do
|
71
|
+
|
72
|
+
let(:hiera_config){{
|
73
|
+
'version' => 5,
|
74
|
+
'hierarchy' => [
|
75
|
+
{
|
76
|
+
'name' => 'Common',
|
77
|
+
'path' => 'common.yaml'
|
78
|
+
},
|
79
|
+
{
|
80
|
+
'name' => 'SIMP Compliance Engine',
|
81
|
+
'lookup_key' => 'compliance_markup::enforcement'
|
82
|
+
}
|
83
|
+
],
|
84
|
+
'defaults' => {
|
85
|
+
'data_hash' => 'yaml_data',
|
86
|
+
'datadir' => hiera_datadir(host)
|
87
|
+
}
|
88
|
+
}}
|
89
|
+
|
90
|
+
if Simp::BeakerHelpers::Snapshot.exist?(host, 'puppet_installed')
|
91
|
+
Simp::BeakerHelpers::Snapshot.restore(host, 'puppet_installed')
|
92
|
+
else
|
93
|
+
Simp::BeakerHelpers::Snapshot.save(host, 'puppet_installed')
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'windows hosts coexising with linux hosts' do
|
97
|
+
context "on #{host}" do
|
98
|
+
it 'should have puppet installed' do
|
99
|
+
on(host, 'puppet --version')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be able to set the hiera config' do
|
103
|
+
set_hiera_config_on(host, hiera_config)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should be able to set the hieradata' do
|
107
|
+
set_hieradata_on(host, hieradata)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should be able to run puppet' do
|
111
|
+
output = apply_manifest_on(host, manifest).stdout
|
112
|
+
|
113
|
+
expect(output).to include "defined 'message' as 'test'"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%
|
2
|
+
if ENV['BEAKER_HYPERVISOR']
|
3
|
+
hypervisor = ENV['BEAKER_HYPERVISOR']
|
4
|
+
else
|
5
|
+
hypervisor = 'vagrant'
|
6
|
+
end
|
7
|
+
-%>
|
8
|
+
HOSTS:
|
9
|
+
win:
|
10
|
+
roles:
|
11
|
+
- windows
|
12
|
+
platform: windows-server-amd64
|
13
|
+
box: opentable/win-2012r2-standard-amd64-nocm # VBOX ONLY
|
14
|
+
hypervisor: <%= hypervisor %>
|
15
|
+
vagrant_memsize: 2048
|
16
|
+
vagrant_cpus: 2
|
17
|
+
user: vagrant
|
18
|
+
is_cygwin: false
|
19
|
+
|
20
|
+
el7:
|
21
|
+
roles:
|
22
|
+
- default
|
23
|
+
platform: el-7-x86_64
|
24
|
+
box: centos/7
|
25
|
+
hypervisor: <%= hypervisor %>
|
26
|
+
|
27
|
+
CONFIG:
|
28
|
+
log_level: verbose
|
29
|
+
type: aio
|
30
|
+
vagrant_memsize: 256
|
31
|
+
<% if ENV['BEAKER_PUPPET_ENVIRONMENT'] -%>
|
32
|
+
puppet_environment: <%= ENV['BEAKER_PUPPET_ENVIRONMENT'] %>
|
33
|
+
<% end -%>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%
|
2
|
+
if ENV['BEAKER_HYPERVISOR']
|
3
|
+
hypervisor = ENV['BEAKER_HYPERVISOR']
|
4
|
+
else
|
5
|
+
hypervisor = 'vagrant'
|
6
|
+
end
|
7
|
+
-%>
|
8
|
+
HOSTS:
|
9
|
+
win:
|
10
|
+
roles:
|
11
|
+
- windows
|
12
|
+
platform: windows-server-amd64
|
13
|
+
box: gusztavvargadr/windows-server
|
14
|
+
box_version: 1607.0.1909
|
15
|
+
hypervisor: <%= hypervisor %>
|
16
|
+
vagrant_memsize: 2048
|
17
|
+
vagrant_cpus: 2
|
18
|
+
user: vagrant
|
19
|
+
communicator: winrm
|
20
|
+
is_cygwin: false
|
21
|
+
|
22
|
+
el7:
|
23
|
+
roles:
|
24
|
+
- default
|
25
|
+
platform: el-7-x86_64
|
26
|
+
box: centos/7
|
27
|
+
hypervisor: <%= hypervisor %>
|
28
|
+
|
29
|
+
CONFIG:
|
30
|
+
log_level: verbose
|
31
|
+
type: aio
|
32
|
+
vagrant_memsize: 256
|
33
|
+
<% if ENV['BEAKER_PUPPET_ENVIRONMENT'] -%>
|
34
|
+
puppet_environment: <%= ENV['BEAKER_PUPPET_ENVIRONMENT'] %>
|
35
|
+
<% end -%>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
if ENV['BEAKER_HYPERVISOR']
|
3
|
+
hypervisor = ENV['BEAKER_HYPERVISOR']
|
4
|
+
else
|
5
|
+
hypervisor = 'vagrant'
|
6
|
+
end
|
7
|
+
-%>
|
8
|
+
HOSTS:
|
9
|
+
win:
|
10
|
+
roles:
|
11
|
+
- windows
|
12
|
+
platform: windows-server-amd64
|
13
|
+
box: gusztavvargadr/windows-server
|
14
|
+
hypervisor: <%= hypervisor %>
|
15
|
+
vagrant_memsize: 2048
|
16
|
+
vagrant_cpus: 2
|
17
|
+
user: vagrant
|
18
|
+
communicator: winrm
|
19
|
+
is_cygwin: false
|
20
|
+
|
21
|
+
el7:
|
22
|
+
roles:
|
23
|
+
- default
|
24
|
+
platform: el-7-x86_64
|
25
|
+
box: centos/7
|
26
|
+
hypervisor: <%= hypervisor %>
|
27
|
+
|
28
|
+
CONFIG:
|
29
|
+
log_level: verbose
|
30
|
+
type: aio
|
31
|
+
vagrant_memsize: 256
|
32
|
+
<% if ENV['BEAKER_PUPPET_ENVIRONMENT'] -%>
|
33
|
+
puppet_environment: <%= ENV['BEAKER_PUPPET_ENVIRONMENT'] %>
|
34
|
+
<% end -%>
|