beaker 4.39.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +6 -21
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +22 -0
- data/Gemfile +12 -7
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +4 -3
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -8
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -27
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +93 -198
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -24
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +22 -27
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/rubocop.yml +39 -0
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +28 -34
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +169 -158
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -36
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +13 -37
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
data/spec/helpers.rb
CHANGED
@@ -19,9 +19,8 @@ module TestFileHelpers
|
|
19
19
|
:solaris_hypervisor_snappaths => ["rpoooool/USER/z0"],
|
20
20
|
:vsphere_server => "vsphere.labs.net",
|
21
21
|
:vsphere_username => "vsphere@labs.com",
|
22
|
-
:vsphere_password => "supersekritpassword"} }
|
22
|
+
:vsphere_password => "supersekritpassword", } }
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
|
27
26
|
module HostHelpers
|
@@ -35,8 +34,7 @@ module HostHelpers
|
|
35
34
|
:box_url => 'http://default.box.url',
|
36
35
|
:image => 'default_image',
|
37
36
|
:flavor => 'm1.large',
|
38
|
-
:user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"'
|
39
|
-
}
|
37
|
+
:user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"', }
|
40
38
|
|
41
39
|
HOST_NAME = "vm%d"
|
42
40
|
HOST_SNAPSHOT = "snapshot%d"
|
@@ -48,55 +46,55 @@ module HostHelpers
|
|
48
46
|
HOST_PRIVATE_IP = "private.ip.for.%s"
|
49
47
|
|
50
48
|
def logger
|
51
|
-
double(
|
49
|
+
double('logger').as_null_object
|
52
50
|
end
|
53
51
|
|
54
52
|
def make_opts
|
55
53
|
opts = Beaker::Options::Presets.new
|
56
|
-
opts.presets.merge(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
54
|
+
opts.presets.merge(opts.env_vars).merge({ :logger => logger,
|
55
|
+
:host_config => 'sample.config',
|
56
|
+
:type => nil,
|
57
|
+
:pooling_api => 'http://vcloud.delivery.puppetlabs.net/',
|
58
|
+
:datastore => 'instance0',
|
59
|
+
:folder => 'Delivery/Quality Assurance/Staging/Dynamic',
|
60
|
+
:resourcepool => 'delivery/Quality Assurance/Staging/Dynamic',
|
61
|
+
:gce_project => 'beaker-compute',
|
62
|
+
:gce_keyfile => '/path/to/keyfile.p12',
|
63
|
+
:gce_password => 'notasecret',
|
64
|
+
:gce_email => '12345678910@developer.gserviceaccount.com',
|
65
|
+
:openstack_api_key => "P1as$w0rd",
|
66
|
+
:openstack_username => "user",
|
67
|
+
:openstack_auth_url => "http://openstack_hypervisor.labs.net:5000/v2.0/tokens",
|
68
|
+
:openstack_tenant => "testing",
|
69
|
+
:openstack_network => "testing",
|
70
|
+
:openstack_keyname => "nopass",
|
71
|
+
:floating_ip_pool => "my_pool",
|
72
|
+
:security_group => %w[my_sg default], })
|
75
73
|
end
|
76
74
|
|
77
|
-
def generate_result
|
78
|
-
result = double(
|
75
|
+
def generate_result(name, opts)
|
76
|
+
result = double('result')
|
79
77
|
stdout = opts.has_key?(:stdout) ? opts[:stdout] : name
|
80
78
|
stderr = opts.has_key?(:stderr) ? opts[:stderr] : name
|
81
|
-
exit_code = opts.has_key?(:exit_code) ? opts[:exit_code] :
|
79
|
+
exit_code = opts.has_key?(:exit_code) ? opts[:exit_code] : 0
|
82
80
|
exit_code = [exit_code].flatten
|
83
|
-
allow(
|
84
|
-
allow(
|
85
|
-
allow(
|
81
|
+
allow(result).to receive(:stdout).and_return(stdout)
|
82
|
+
allow(result).to receive(:stderr).and_return(stderr)
|
83
|
+
allow(result).to receive(:exit_code).and_return(*exit_code)
|
86
84
|
result
|
87
85
|
end
|
88
86
|
|
89
87
|
def make_host_opts name, opts
|
90
|
-
make_opts.merge(
|
88
|
+
make_opts.merge({ 'HOSTS' => { name => opts } }).merge(opts)
|
91
89
|
end
|
92
90
|
|
93
91
|
def make_host name, host_hash
|
94
92
|
host_hash = Beaker::Options::OptionsHash.new.merge(HOST_DEFAULTS.merge(host_hash))
|
95
93
|
|
96
|
-
host = Beaker::Host.create(
|
94
|
+
host = Beaker::Host.create(name, host_hash, make_opts)
|
97
95
|
|
98
|
-
allow(host).to receive(
|
99
|
-
allow(host).to receive(
|
96
|
+
allow(host).to receive(:exec).and_return(generate_result(name, host_hash))
|
97
|
+
allow(host).to receive(:close)
|
100
98
|
host
|
101
99
|
end
|
102
100
|
|
@@ -110,7 +108,7 @@ module HostHelpers
|
|
110
108
|
:dns_name => HOST_DNS_NAME % name,
|
111
109
|
:template => HOST_TEMPLATE % name,
|
112
110
|
:box => HOST_BOX % name,
|
113
|
-
:box_url => HOST_BOX_URL % name }.merge(
|
111
|
+
:box_url => HOST_BOX_URL % name, }.merge(preset_opts)
|
114
112
|
hosts << make_host(name, opts)
|
115
113
|
end
|
116
114
|
hosts
|
@@ -119,29 +117,26 @@ module HostHelpers
|
|
119
117
|
def make_instance instance_data = {}
|
120
118
|
OpenStruct.new instance_data
|
121
119
|
end
|
122
|
-
|
123
120
|
end
|
124
121
|
|
125
122
|
module PlatformHelpers
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
'huaweios']
|
131
|
-
|
123
|
+
DEBIANPLATFORMS = %w[debian
|
124
|
+
ubuntu
|
125
|
+
cumulus
|
126
|
+
huaweios]
|
132
127
|
|
133
128
|
FEDORASYSTEMD = (14..39).to_a.collect! { |i| "fedora-#{i}" }
|
134
129
|
|
135
|
-
SYSTEMDPLATFORMS = [
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
130
|
+
SYSTEMDPLATFORMS = %w[el-7
|
131
|
+
centos-7
|
132
|
+
redhat-7
|
133
|
+
oracle-7
|
134
|
+
scientific-7
|
135
|
+
eos-7
|
136
|
+
el-8
|
137
|
+
centos-8
|
138
|
+
redhat-8
|
139
|
+
oracle-8].concat(FEDORASYSTEMD)
|
145
140
|
|
146
141
|
FEDORASYSTEMV = (1..13).to_a.collect! { |i| "fedora-#{i}" }
|
147
142
|
|
@@ -151,5 +146,5 @@ module PlatformHelpers
|
|
151
146
|
'redhat',
|
152
147
|
'oracle',
|
153
148
|
'scientific',
|
154
|
-
'eos'].concat(FEDORASYSTEMV)
|
149
|
+
'eos',].concat(FEDORASYSTEMV)
|
155
150
|
end
|
data/spec/matchers.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
RSpec::Matchers.define :execute_commands_matching do |pattern|
|
2
2
|
match do |actual|
|
3
|
-
raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.
|
3
|
+
raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.is_a?(FakeHost::MockedExec)
|
4
|
+
|
4
5
|
@found_count = actual.command_strings.grep(pattern).size
|
5
6
|
@times.nil? ?
|
6
7
|
@found_count > 0 :
|
@@ -20,11 +21,11 @@ RSpec::Matchers.define :execute_commands_matching do |pattern|
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def message(actual, pattern, times, found_count)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
msg = times == 1 ?
|
25
|
+
"#{pattern} once" :
|
26
|
+
"#{pattern} #{times} times"
|
27
|
+
msg += " but instead found a count of #{found_count}" if found_count != times
|
28
|
+
msg + " in:\n #{actual.command_strings.pretty_inspect}"
|
28
29
|
end
|
29
30
|
|
30
31
|
failure_message do |actual|
|
@@ -38,7 +39,7 @@ end
|
|
38
39
|
|
39
40
|
RSpec::Matchers.define :execute_commands_matching_in_order do |*patterns|
|
40
41
|
match do |actual|
|
41
|
-
raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.
|
42
|
+
raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.is_a?(FakeHost::MockedExec)
|
42
43
|
|
43
44
|
remaining_patterns = patterns.clone
|
44
45
|
actual.command_strings.each do |line|
|
data/spec/mocks.rb
CHANGED
@@ -2,7 +2,6 @@ require 'rspec/mocks'
|
|
2
2
|
|
3
3
|
module MockNet
|
4
4
|
class HTTP
|
5
|
-
|
6
5
|
class Response
|
7
6
|
class ResponseHash
|
8
7
|
def []key
|
@@ -12,13 +11,11 @@ module MockNet
|
|
12
11
|
{ 'ok' => true, 'hostname' => 'pool' }
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
15
|
|
18
16
|
def body
|
19
17
|
ResponseHash.new
|
20
18
|
end
|
21
|
-
|
22
19
|
end
|
23
20
|
|
24
21
|
class Post
|
@@ -56,7 +53,6 @@ module MockNet
|
|
56
53
|
Response.new
|
57
54
|
end
|
58
55
|
end
|
59
|
-
|
60
56
|
end
|
61
57
|
|
62
58
|
module FakeHost
|
@@ -65,13 +61,12 @@ module FakeHost
|
|
65
61
|
def self.create(name = 'fakevm', platform = 'redhat-version-arch', options = {})
|
66
62
|
options_hash = Beaker::Options::OptionsHash.new.merge(options)
|
67
63
|
options_hash[:logger] = RSpec::Mocks::Double.new('logger').as_null_object
|
68
|
-
host = Beaker::Host.create(name, { 'platform' => Beaker::Platform.new(platform) }
|
64
|
+
host = Beaker::Host.create(name, { 'platform' => Beaker::Platform.new(platform) }, options_hash)
|
69
65
|
host.extend(MockedExec)
|
70
66
|
host
|
71
67
|
end
|
72
68
|
|
73
69
|
module MockedExec
|
74
|
-
|
75
70
|
def self.extended(other)
|
76
71
|
other.instance_eval do
|
77
72
|
send(:instance_variable_set, :@commands, [])
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fakefs
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-its
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: yard
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,30 +188,22 @@ dependencies:
|
|
202
188
|
name: in-parallel
|
203
189
|
requirement: !ruby/object:Gem::Requirement
|
204
190
|
requirements:
|
205
|
-
- - "
|
191
|
+
- - ">="
|
206
192
|
- !ruby/object:Gem::Version
|
207
193
|
version: '0.1'
|
194
|
+
- - "<"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '2.0'
|
208
197
|
type: :runtime
|
209
198
|
prerelease: false
|
210
199
|
version_requirements: !ruby/object:Gem::Requirement
|
211
200
|
requirements:
|
212
|
-
- - "
|
201
|
+
- - ">="
|
213
202
|
- !ruby/object:Gem::Version
|
214
203
|
version: '0.1'
|
215
|
-
-
|
216
|
-
name: open_uri_redirections
|
217
|
-
requirement: !ruby/object:Gem::Requirement
|
218
|
-
requirements:
|
219
|
-
- - "~>"
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: 0.2.1
|
222
|
-
type: :runtime
|
223
|
-
prerelease: false
|
224
|
-
version_requirements: !ruby/object:Gem::Requirement
|
225
|
-
requirements:
|
226
|
-
- - "~>"
|
204
|
+
- - "<"
|
227
205
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
206
|
+
version: '2.0'
|
229
207
|
- !ruby/object:Gem::Dependency
|
230
208
|
name: rsync
|
231
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -385,7 +363,6 @@ files:
|
|
385
363
|
- acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb
|
386
364
|
- acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb
|
387
365
|
- acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb
|
388
|
-
- acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb
|
389
366
|
- acceptance/tests/base/dsl/helpers/host_helpers/echo_on_test.rb
|
390
367
|
- acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb
|
391
368
|
- acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb
|
@@ -400,7 +377,6 @@ files:
|
|
400
377
|
- acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb
|
401
378
|
- acceptance/tests/base/dsl/platform_tag_confiner_test.rb
|
402
379
|
- acceptance/tests/base/dsl/structure_test.rb
|
403
|
-
- acceptance/tests/base/external_resources_test.rb
|
404
380
|
- acceptance/tests/base/host/file_test.rb
|
405
381
|
- acceptance/tests/base/host/group_test.rb
|
406
382
|
- acceptance/tests/base/host/host_test.rb
|
@@ -559,6 +535,7 @@ files:
|
|
559
535
|
- lib/beaker/test_suite.rb
|
560
536
|
- lib/beaker/test_suite_result.rb
|
561
537
|
- lib/beaker/version.rb
|
538
|
+
- rubocop.yml
|
562
539
|
- spec/beaker/cli_spec.rb
|
563
540
|
- spec/beaker/command_spec.rb
|
564
541
|
- spec/beaker/dsl/assertions_spec.rb
|
@@ -578,7 +555,6 @@ files:
|
|
578
555
|
- spec/beaker/host/mac/exec_spec.rb
|
579
556
|
- spec/beaker/host/mac/group_spec.rb
|
580
557
|
- spec/beaker/host/mac/user_spec.rb
|
581
|
-
- spec/beaker/host/mac_spec.rb
|
582
558
|
- spec/beaker/host/pswindows/exec_spec.rb
|
583
559
|
- spec/beaker/host/pswindows/file_spec.rb
|
584
560
|
- spec/beaker/host/pswindows/user_spec.rb
|
@@ -641,7 +617,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
641
617
|
requirements:
|
642
618
|
- - ">="
|
643
619
|
- !ruby/object:Gem::Version
|
644
|
-
version: '2.
|
620
|
+
version: '2.7'
|
645
621
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
646
622
|
requirements:
|
647
623
|
- - ">="
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require "helpers/test_helper"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
test_name "dsl::helpers::host_helpers #deploy_package_repo" do
|
5
|
-
|
6
|
-
confine_block :to, :platform => /^el-4/ do
|
7
|
-
|
8
|
-
step "#deploy_package_repo CURRENTLY does nothing and throws no error on the #{default['platform']} platform" do
|
9
|
-
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
|
10
|
-
|
11
|
-
Dir.mktmpdir do |local_dir|
|
12
|
-
name = "puppet-server"
|
13
|
-
version = "9.9.9"
|
14
|
-
platform = default['platform']
|
15
|
-
|
16
|
-
create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
|
17
|
-
|
18
|
-
assert_nil deploy_package_repo(default, local_dir, name, version)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
confine_block :to, :platform => /fedora|centos|eos|el-[56789]/i do
|
24
|
-
|
25
|
-
step "#deploy_package_repo pushes repo package to /etc/yum.repos.d on the remote host" do
|
26
|
-
Dir.mktmpdir do |local_dir|
|
27
|
-
name = "puppet-server"
|
28
|
-
version = "9.9.9"
|
29
|
-
platform = default['platform']
|
30
|
-
|
31
|
-
FileUtils.mkdir(File.join(local_dir, "rpm"))
|
32
|
-
_local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
|
33
|
-
|
34
|
-
deploy_package_repo default, local_dir, name, version
|
35
|
-
|
36
|
-
remote_contents = on(default, "cat /etc/yum.repos.d/#{name}.repo").stdout
|
37
|
-
assert_equal contents, remote_contents
|
38
|
-
|
39
|
-
# teardown
|
40
|
-
on default, "rm /etc/yum.repos.d/#{name}.repo"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
step "#deploy_package_repo CURRENTLY fails with NoMethodError when passed a hosts array" do
|
45
|
-
# NOTE: would expect this to handle host arrays, or raise Beaker::Host::CommandFailure
|
46
|
-
|
47
|
-
Dir.mktmpdir do |local_dir|
|
48
|
-
name = "puppet-server"
|
49
|
-
version = "9.9.9"
|
50
|
-
platform = default['platform']
|
51
|
-
|
52
|
-
create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
|
53
|
-
|
54
|
-
assert_raises NoMethodError do
|
55
|
-
deploy_package_repo hosts, local_dir, name, version
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
confine_block :to, :platform => /ubuntu|debian|cumulus/i do
|
62
|
-
|
63
|
-
step "#deploy_package_repo pushes repo package to /etc/apt/sources.list.d on the remote host" do
|
64
|
-
Dir.mktmpdir do |local_dir|
|
65
|
-
name = "puppet-server"
|
66
|
-
version = "9.9.9"
|
67
|
-
codename = default['platform'].codename
|
68
|
-
|
69
|
-
FileUtils.mkdir(File.join(local_dir, "deb"))
|
70
|
-
_local_filename, contents = create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
|
71
|
-
|
72
|
-
deploy_package_repo default, local_dir, name, version
|
73
|
-
|
74
|
-
remote_contents = on(default, "cat /etc/apt/sources.list.d/#{name}.list").stdout
|
75
|
-
assert_equal contents, remote_contents
|
76
|
-
|
77
|
-
# teardown
|
78
|
-
on default, "rm /etc/apt/sources.list.d/#{name}.list"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
step "#deploy_package_repo CURRENTLY fails with NoMethodError when passed a hosts array" do
|
83
|
-
# NOTE: would expect this to handle host arrays, or raise Beaker::Host::CommandFailure
|
84
|
-
|
85
|
-
Dir.mktmpdir do |local_dir|
|
86
|
-
name = "puppet-server"
|
87
|
-
version = "9.9.9"
|
88
|
-
codename = default['platform'].codename
|
89
|
-
|
90
|
-
FileUtils.mkdir(File.join(local_dir, "deb"))
|
91
|
-
create_local_file_from_fixture("simple_text_file", File.join(local_dir, "deb"), "pl-#{name}-#{version}-#{codename}.list")
|
92
|
-
|
93
|
-
assert_raises NoMethodError do
|
94
|
-
deploy_package_repo hosts, local_dir, name, version
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
confine_block :to, :platform => /opensuse|sles/i do
|
101
|
-
|
102
|
-
step "#deploy_package_repo updates zypper repository list on the remote host" do
|
103
|
-
Dir.mktmpdir do |local_dir|
|
104
|
-
name = "puppet-server"
|
105
|
-
version = "9.9.9"
|
106
|
-
platform = default['platform']
|
107
|
-
|
108
|
-
FileUtils.mkdir(File.join(local_dir, "rpm"))
|
109
|
-
create_local_file_from_fixture("#{default["platform"]}.repo", File.join(local_dir, "rpm"), "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
|
110
|
-
|
111
|
-
deploy_package_repo default, local_dir, name, version
|
112
|
-
|
113
|
-
result = on default, "zypper repos -d"
|
114
|
-
assert_match "PE-2016.4-#{default['platform']}", result.stdout
|
115
|
-
|
116
|
-
# teardown
|
117
|
-
on default, "zypper rr #{default['platform']}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
confine_block :except, :platform => /el-\d|fedora|centos|eos|ubuntu|debian|cumulus|opensuse|sles/i do
|
123
|
-
|
124
|
-
# OS X, windows (cygwin, powershell), solaris, etc.
|
125
|
-
|
126
|
-
step "#deploy_package_repo CURRENTLY fails with a RuntimeError on on the #{default['platform']} platform" do
|
127
|
-
# NOTE: would expect this to raise Beaker::Host::CommandFailure instead of RuntimeError
|
128
|
-
|
129
|
-
Dir.mktmpdir do |local_dir|
|
130
|
-
name = "puppet-server"
|
131
|
-
version = "9.9.9"
|
132
|
-
platform = default['platform']
|
133
|
-
|
134
|
-
create_local_file_from_fixture("simple_text_file", local_dir, "pl-#{name}-#{version}-repos-pe-#{platform}.repo")
|
135
|
-
|
136
|
-
assert_raises RuntimeError do
|
137
|
-
deploy_package_repo default, local_dir, name, version
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
test_name 'External Resources Test' do
|
2
|
-
step 'Verify EPEL resources are up and available' do
|
3
|
-
def build_url(el_version)
|
4
|
-
url_base = options[:epel_url]
|
5
|
-
"#{url_base}/epel-release-latest-#{el_version}.noarch.rpm"
|
6
|
-
end
|
7
|
-
|
8
|
-
def epel_url_test(el_version)
|
9
|
-
url = build_url(el_version)
|
10
|
-
# -I option just asks for headers, not looking to download the package
|
11
|
-
curl_cmd = Command.new("curl -I #{url}")
|
12
|
-
host = default
|
13
|
-
curl_headers_result = Result.new(host, curl_cmd)
|
14
|
-
curl_fail_msg = "EPEL curl failed, waiting for fibonacci backoff to retry..."
|
15
|
-
|
16
|
-
repeat_fibonacci_style_for(10) do
|
17
|
-
curl_headers_result = host.exec(curl_cmd)
|
18
|
-
curl_succeeded = curl_headers_result.exit_code == 0
|
19
|
-
logger.info(curl_fail_msg) unless curl_succeeded
|
20
|
-
curl_succeeded
|
21
|
-
end
|
22
|
-
assert_match(/200 OK/, curl_headers_result.stdout, "EPEL #{el_version} should be reachable at #{url}")
|
23
|
-
end
|
24
|
-
|
25
|
-
step 'Verify el_version numbers 6,7,8 are found on the epel resource' do
|
26
|
-
[6,7,8].each do |el_version|
|
27
|
-
epel_url_test(el_version)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Mac
|
4
|
-
describe Host do
|
5
|
-
let(:options) { @options ? @options : {} }
|
6
|
-
let(:platform) {
|
7
|
-
if @platform
|
8
|
-
{ :platform => Beaker::Platform.new( @platform) }
|
9
|
-
else
|
10
|
-
{ :platform => Beaker::Platform.new( 'osx-10.12-x86_64' ) }
|
11
|
-
end
|
12
|
-
}
|
13
|
-
let(:host) { make_host( 'name', options.merge(platform) ) }
|
14
|
-
|
15
|
-
describe '#puppet_agent_dev_package_info' do
|
16
|
-
it 'raises an error if puppet_collection isn\'t passed' do
|
17
|
-
expect { host.puppet_agent_dev_package_info(nil, 'maybe', :download_url => '') }.to raise_error(ArgumentError)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'raises an error if puppet_agent_version isn\'t passed' do
|
21
|
-
expect { host.puppet_agent_dev_package_info('maybe', nil, :download_url => '') }.to raise_error(ArgumentError)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'raises an error if opts[:download_url] isn\'t passed' do
|
25
|
-
expect { host.puppet_agent_dev_package_info('', '') }.to raise_error(ArgumentError)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns two strings that include the passed parameters' do
|
29
|
-
allow( host ).to receive( :link_exists? ).and_return(true)
|
30
|
-
return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1', :download_url => '' )
|
31
|
-
expect( return1 ).to match( /pc1/ )
|
32
|
-
expect( return2 ).to match( /pav1/ )
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'gets the correct file type' do
|
36
|
-
allow( host ).to receive( :link_exists? ).and_return(true)
|
37
|
-
_, return2 = host.puppet_agent_dev_package_info( 'pc2', 'pav2', :download_url => '' )
|
38
|
-
expect( return2 ).to match( /\.dmg$/ )
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'adds the version dot correctly if not supplied' do
|
42
|
-
@platform = 'osx-10.12-x86_64'
|
43
|
-
allow( host ).to receive( :link_exists? ).and_return(true)
|
44
|
-
release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3', :download_url => '' )
|
45
|
-
expect( release_path_end ).to match( /10\.12/ )
|
46
|
-
expect( release_file ).to match( /10\.12/ )
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'runs the correct install for osx platforms (newest link format)' do
|
50
|
-
allow( host ).to receive( :link_exists? ).and_return(true)
|
51
|
-
|
52
|
-
release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4', :download_url => '' )
|
53
|
-
# verify the mac package name starts the name correctly
|
54
|
-
expect( release_file ).to match( /^puppet-agent-pav4-/ )
|
55
|
-
# verify the "newest hotness" is set correctly for the end of the mac package name
|
56
|
-
expect( release_file ).to match( /#{Regexp.escape("-1.osx10.12.dmg")}$/ )
|
57
|
-
# verify the release path end is set correctly
|
58
|
-
expect( release_path_end ).to be === "apple/10.12/PC4/x86_64"
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'runs the correct install for osx platforms (new link format)' do
|
62
|
-
allow( host ).to receive( :link_exists? ).and_return( false, true )
|
63
|
-
|
64
|
-
release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC7', 'pav7', :download_url => '' )
|
65
|
-
# verify the mac package name starts the name correctly
|
66
|
-
expect( release_file ).to match( /^puppet-agent-pav7-/ )
|
67
|
-
# verify the "new hotness" is set correctly for the end of the mac package name
|
68
|
-
expect( release_file ).to match( /#{Regexp.escape("-1.sierra.dmg")}$/ )
|
69
|
-
# verify the release path end isn't changed in the "new hotness" case
|
70
|
-
expect( release_path_end ).to be === "apple/10.12/PC7/x86_64"
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'runs the correct install for osx platforms (old link format)' do
|
74
|
-
allow( host ).to receive( :link_exists? ).and_return(false)
|
75
|
-
|
76
|
-
release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8', :download_url => '' )
|
77
|
-
# verify the mac package name starts the name correctly
|
78
|
-
expect( release_file ).to match( /^puppet-agent-pav8-/ )
|
79
|
-
# verify the old way is set correctly for the end of the mac package name
|
80
|
-
expect( release_file ).to match( /#{Regexp.escape("-osx-10.12-x86_64.dmg")}$/ )
|
81
|
-
# verify the release path end is set correctly to the older method
|
82
|
-
expect( release_path_end ).to be === "apple/PC8"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#pe_puppet_agent_promoted_package_info' do
|
87
|
-
before do
|
88
|
-
@platform = "osx-10.15-x86_64"
|
89
|
-
end
|
90
|
-
|
91
|
-
it "uses the old scheme if the version is omitted" do
|
92
|
-
_, _, download_file = host.pe_puppet_agent_promoted_package_info('pa_collection')
|
93
|
-
|
94
|
-
expect(download_file).to eq('puppet-agent-osx-10.15.tar.gz')
|
95
|
-
end
|
96
|
-
|
97
|
-
{
|
98
|
-
'5.5.22' => 'puppet-agent-osx-10.15.tar.gz',
|
99
|
-
'6.27.0' => 'puppet-agent-osx-10.15.tar.gz',
|
100
|
-
'6.28.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
|
101
|
-
'7.0.0' => 'puppet-agent-osx-10.15.tar.gz',
|
102
|
-
'7.18.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
|
103
|
-
'8.0.0' => 'puppet-agent-osx-10.15-x86_64.tar.gz',
|
104
|
-
}.each_pair do |version, expected|
|
105
|
-
it "returns #{expected} for puppet-agent #{version}" do
|
106
|
-
_, _, download_file = host.pe_puppet_agent_promoted_package_info('pa_collection', puppet_agent_version: version)
|
107
|
-
|
108
|
-
expect(download_file).to eq(expected)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|