beaker 3.17.0 → 3.18.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 +8 -8
- data/README.md +1 -1
- data/acceptance/tests/subcommands/init.rb +10 -3
- data/acceptance/tests/subcommands/provision.rb +3 -2
- data/docs/how_to/run_in_parallel.md +1 -1
- data/docs/tutorials/lets_write_a_test.md +58 -50
- data/lib/beaker/host/pswindows/exec.rb +23 -1
- data/lib/beaker/hypervisor/docker.rb +1 -1
- data/lib/beaker/options/homedir_options_file_parser.rb +0 -0
- data/lib/beaker/subcommand.rb +1 -1
- data/lib/beaker/test_suite.rb +5 -5
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/pswindows/exec_spec.rb +17 -0
- data/spec/beaker/hypervisor/docker_spec.rb +2 -2
- data/spec/beaker/subcommand_spec.rb +7 -0
- data/spec/beaker/test_suite_spec.rb +2 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWRlZjc1Y2Y2YTk4YjdmZjBjMWE4OGYxNWQ0YzFjNjllYjRmNGI2NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjQ4ZjYxNTFkZGU4NjVhMzBjOGRhYzc1NTM1NWNhYzE2YTA2NzkxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDVjMzVlYjg2MjYyYjM5NjUwYzQ4ZmVhYjk1NDY4MDJlZWQ5YTYzOTZlM2Ey
|
10
|
+
MTM0NDFmNDRjODhkN2RkOTBlMGFmNGJkMGIzY2RmYmZhZDY1NDVjZGVkNjg0
|
11
|
+
YmI5ODIzOTRmMTE1MmRlYjNhZmM1MGRkMjZkNzIzZTYyMTRjMDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTc4ZDBkYjYzM2E1NGYzZWVjMWQ4ZjRiMWVhMzhjZDlhYjYwNzY2ODhiMjli
|
14
|
+
MzA3MGYxNjVlOTk5NDllMWM3ZjI3YzVhMTFhODM1ODAxYzAwYjUxMzI0YTcx
|
15
|
+
OTU4Y2U3NTFlNWIyZWE2M2EzNDJhZmZiODg1NjZiNTY4MjZjYzg=
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ works and how to use it but assume that you have a basic understanding of key co
|
|
32
32
|
involved in addressing key problems and use-cases. They are more advanced than
|
33
33
|
tutorials and assume some knowledge of how Beaker works.
|
34
34
|
|
35
|
-
#Beaker Libraries
|
35
|
+
# Beaker Libraries
|
36
36
|
|
37
37
|
Beaker functionality has been extended through the use of libraries available as
|
38
38
|
gems. See the [complete list](docs/concepts/beaker_libraries.md) for available
|
@@ -5,18 +5,25 @@ test_name 'use the init subcommand' do
|
|
5
5
|
on default, 'rm -rf /root/* /root/.beaker'
|
6
6
|
end
|
7
7
|
|
8
|
+
step 'ensure beaker init requires hosts flag' do
|
9
|
+
result = on(default, 'beaker init')
|
10
|
+
assert_match(/No value(.+)--hosts/, result.raw_output)
|
11
|
+
end
|
12
|
+
|
8
13
|
step 'ensure beaker init writes YAML configuration files to disk' do
|
9
14
|
delete_root_folder_contents
|
10
|
-
on(default, 'beaker init')
|
15
|
+
on(default, 'beaker init --hosts centos6-64')
|
11
16
|
subcommand_options = on(default, "cat #{SubcommandUtil::SUBCOMMAND_OPTIONS}").stdout
|
12
17
|
subcommand_state = on(default, "cat #{SubcommandUtil::SUBCOMMAND_STATE}").stdout
|
13
|
-
|
18
|
+
parsed_options = YAML.parse(subcommand_options).to_ruby
|
19
|
+
assert(parsed_options["HOSTS"].count == 1)
|
20
|
+
assert(parsed_options.class == Hash)
|
14
21
|
assert(YAML.parse(subcommand_state).to_ruby.class == Hash)
|
15
22
|
end
|
16
23
|
|
17
24
|
step 'ensure beaker init saves beaker-run arguments to the subcommand_options.yaml' do
|
18
25
|
delete_root_folder_contents
|
19
|
-
on(default, 'beaker init --log-level verbose')
|
26
|
+
on(default, 'beaker init --log-level verbose --hosts centos6-64')
|
20
27
|
subcommand_options = on(default, "cat #{SubcommandUtil::SUBCOMMAND_OPTIONS}").stdout
|
21
28
|
hash = YAML.parse(subcommand_options).to_ruby
|
22
29
|
assert_equal('verbose', hash['log_level'])
|
@@ -8,10 +8,11 @@ test_name 'use the provision subcommand' do
|
|
8
8
|
|
9
9
|
step 'run beaker init and provision' do
|
10
10
|
delete_root_folder_contents
|
11
|
-
on(default, 'beaker init')
|
12
11
|
result = on(default, 'beaker provision --hosts centos6-64')
|
12
|
+
assert_match(/ERROR(.+)--hosts/, result.raw_output)
|
13
|
+
on(default, 'beaker init --hosts centos6-64')
|
14
|
+
result = on(default, 'beaker provision')
|
13
15
|
assert_match(/Using available host/, result.stdout)
|
14
|
-
|
15
16
|
subcommand_state = on(default, "cat #{SubcommandUtil::SUBCOMMAND_STATE}").stdout
|
16
17
|
subcommand_state = YAML.parse(subcommand_state).to_ruby
|
17
18
|
assert_equal(true, subcommand_state['provisioned'])
|
@@ -1,74 +1,82 @@
|
|
1
1
|
## The Task
|
2
2
|
|
3
|
-
|
3
|
+
We will write a test to check if a package (specifically HTTPD) is installed and running. To do this we will write two files:
|
4
|
+
1. `install.rb` - This file will install the package and start the service
|
5
|
+
2. `mytest.rb` - This file will have our core tests that checks if the package is installed and running
|
4
6
|
|
5
|
-
|
7
|
+
Note: We will exclude Windows OS from our testing due to variation of package name.
|
8
|
+
|
9
|
+
## Figure out steps
|
6
10
|
|
7
11
|
What needs to happen in this test:
|
8
12
|
|
9
|
-
* Install
|
10
|
-
*
|
11
|
-
*
|
13
|
+
* Install and run HTTPD
|
14
|
+
* Install HTTPD if its not available on our SUT
|
15
|
+
* Start HTTPD service
|
16
|
+
* Testing
|
17
|
+
* Test HTTPD is installed
|
18
|
+
* Test HTTPD service is running
|
12
19
|
|
13
20
|
## Create a host configuration file
|
14
|
-
$ beaker-hostgenerator redhat7-
|
15
|
-
|
16
|
-
## Install PE
|
17
|
-
|
18
|
-
We prefer to install PE once and then run a set of tests, so PE installation should not be part of the actual acceptance test.
|
21
|
+
$ beaker-hostgenerator redhat7-64 > redhat7-64.yaml
|
19
22
|
|
20
|
-
|
21
|
-
$ cd setup
|
22
|
-
$ cat > install.rb << RUBY
|
23
|
-
test_name "Installing Puppet Enterprise" do
|
24
|
-
install_pe
|
25
|
-
RUBY
|
26
|
-
$ cd ..
|
23
|
+
This command will generate a host file for our system under test (SUT). It will use vmpooler as hypervisor for the host. Please check out [this](https://github.com/puppetlabs/beaker/tree/master/docs/how_to/hypervisors) doc to learn more about hypervisors for beaker.
|
27
24
|
|
28
|
-
|
29
|
-
The install.rb script is used in our commandline to beaker, below.
|
30
|
-
|
31
|
-
## Create a test file
|
25
|
+
## Install and run HTTPD
|
32
26
|
|
33
|
-
|
27
|
+
Make a file named `install.rb` and put the following code into it:
|
34
28
|
|
35
|
-
|
36
|
-
|
29
|
+
```ruby
|
30
|
+
test_name "Installing and runnning HTTPD" do
|
37
31
|
|
38
|
-
|
32
|
+
# Don't run the install script on the following platform
|
33
|
+
confine :except, :platform => 'windows'
|
39
34
|
|
40
|
-
|
35
|
+
step "Install HTTPD" do
|
36
|
+
hosts.each do |host|
|
37
|
+
# Install HTTPD if it is not available on our SUT
|
38
|
+
install_package(host, 'httpd') unless check_for_package(host, 'httpd')
|
39
|
+
end
|
40
|
+
end
|
41
41
|
|
42
|
-
|
42
|
+
step "Start HTTPD" do
|
43
|
+
hosts.each do |host|
|
44
|
+
# Start HTTPD service
|
45
|
+
on(host, "service httpd start")
|
46
|
+
end
|
47
|
+
end
|
43
48
|
|
44
|
-
|
49
|
+
end
|
50
|
+
```
|
45
51
|
|
46
|
-
|
52
|
+
This places our install steps in a ruby script (`install.rb`) which will run on your SUT. The install.rb script is used in our commandline to beaker, below.
|
47
53
|
|
48
|
-
|
54
|
+
## Create a test file
|
49
55
|
|
50
|
-
|
56
|
+
Lets create test file that tests if HTTPD is installed and running on our hosts. Make a file called `mytest.rb` and add the following code to it:
|
51
57
|
|
52
58
|
```ruby
|
53
|
-
test_name "
|
54
|
-
|
55
|
-
# Don't run these tests on the following
|
56
|
-
confine :except, :platform => '
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
59
|
+
test_name "Check if HTTPD is installed and running" do
|
60
|
+
|
61
|
+
# Don't run these tests on the following platform
|
62
|
+
confine :except, :platform => 'windows'
|
63
|
+
|
64
|
+
step "Make sure HTTPD is installed" do
|
65
|
+
hosts.each do |host|
|
66
|
+
# Check if HTTPD is installed
|
67
|
+
assert check_for_package(host, 'httpd')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
step "Make sure HTTPD is running" do
|
72
|
+
hosts.each do |host|
|
73
|
+
on(host, "systemctl is-active httpd") do |result|
|
74
|
+
# Check if HTTPD is running
|
75
|
+
assert_equal(0, result.exit_code)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
72
80
|
end
|
73
81
|
```
|
74
82
|
|
@@ -164,11 +164,33 @@ module PSWindows::Exec
|
|
164
164
|
|
165
165
|
environment_string = ''
|
166
166
|
env_array.each_with_index do |env|
|
167
|
-
environment_string += "set #{env} && "
|
167
|
+
environment_string += "set \"#{env}\" && "
|
168
168
|
end
|
169
169
|
environment_string
|
170
170
|
end
|
171
171
|
|
172
|
+
def environment_variable_string_pair_array env
|
173
|
+
env_array = []
|
174
|
+
env.each_key do |key|
|
175
|
+
val = env[key]
|
176
|
+
if val.is_a?(Array)
|
177
|
+
val = val.join(':')
|
178
|
+
else
|
179
|
+
val = val.to_s
|
180
|
+
end
|
181
|
+
# doing this for the key itself & the upcase'd version allows us to remain
|
182
|
+
# backwards compatible
|
183
|
+
# TODO: (Next Major Version) get rid of upcase'd version
|
184
|
+
key_str = key.to_s
|
185
|
+
keys = [key_str]
|
186
|
+
keys << key_str.upcase if key_str.upcase != key_str
|
187
|
+
keys.each do |env_key|
|
188
|
+
env_array << "#{env_key}=\"#{val}\""
|
189
|
+
end
|
190
|
+
end
|
191
|
+
env_array
|
192
|
+
end
|
193
|
+
|
172
194
|
# Overrides the {Windows::Exec#ssh_permit_user_environment} method,
|
173
195
|
# since no steps are needed in this setup to allow user ssh environments
|
174
196
|
# to work.
|
@@ -145,7 +145,7 @@ module Beaker
|
|
145
145
|
if container = host['docker_container']
|
146
146
|
@logger.debug("stop container #{container.id}")
|
147
147
|
begin
|
148
|
-
container.
|
148
|
+
container.kill
|
149
149
|
sleep 2 # avoid a race condition where the root FS can't unmount
|
150
150
|
rescue Excon::Errors::ClientError => e
|
151
151
|
@logger.warn("stop of container #{container.id} failed: #{e.response.body}")
|
File without changes
|
data/lib/beaker/subcommand.rb
CHANGED
@@ -20,7 +20,6 @@ module Beaker
|
|
20
20
|
# a Beaker::CLI object executes, it can pick up these options. Notably excluded from this
|
21
21
|
# group are `help` and `version`. Please note that whenever the command_line_parser.rb is
|
22
22
|
# updated, this list should also be updated as well.
|
23
|
-
class_option :hosts, :aliases => '-h', :type => :string, :group => 'Beaker run'
|
24
23
|
class_option :'options-file', :aliases => '-o', :type => :string, :group => 'Beaker run'
|
25
24
|
class_option :helper, :type => :string, :group => 'Beaker run'
|
26
25
|
class_option :'load-path', :type => :string, :group => 'Beaker run'
|
@@ -62,6 +61,7 @@ module Beaker
|
|
62
61
|
as necessary.
|
63
62
|
LONGDESC
|
64
63
|
option :help, :type => :boolean, :hide => true
|
64
|
+
method_option :hosts, :aliases => '-h', :type => :string, :required => true
|
65
65
|
def init()
|
66
66
|
if options[:help]
|
67
67
|
invoke :help, [], ["init"]
|
data/lib/beaker/test_suite.rb
CHANGED
@@ -116,22 +116,22 @@ module Beaker
|
|
116
116
|
|
117
117
|
summary_logger.notify "Failed Tests Cases:"
|
118
118
|
(grouped_summary[:fail] || []).each do |test_case|
|
119
|
-
print_test_result(test_case)
|
119
|
+
summary_logger.notify print_test_result(test_case)
|
120
120
|
end
|
121
121
|
|
122
122
|
summary_logger.notify "Errored Tests Cases:"
|
123
123
|
(grouped_summary[:error] || []).each do |test_case|
|
124
|
-
print_test_result(test_case)
|
124
|
+
summary_logger.notify print_test_result(test_case)
|
125
125
|
end
|
126
126
|
|
127
127
|
summary_logger.notify "Skipped Tests Cases:"
|
128
128
|
(grouped_summary[:skip] || []).each do |test_case|
|
129
|
-
print_test_result(test_case)
|
129
|
+
summary_logger.notify print_test_result(test_case)
|
130
130
|
end
|
131
131
|
|
132
132
|
summary_logger.notify "Pending Tests Cases:"
|
133
133
|
(grouped_summary[:pending] || []).each do |test_case|
|
134
|
-
print_test_result(test_case)
|
134
|
+
summary_logger.notify print_test_result(test_case)
|
135
135
|
end
|
136
136
|
|
137
137
|
summary_logger.notify("\n\n")
|
@@ -152,7 +152,7 @@ module Beaker
|
|
152
152
|
else
|
153
153
|
test_case.test_status
|
154
154
|
end
|
155
|
-
|
155
|
+
" Test Case #{test_case.path} #{test_reported}"
|
156
156
|
end
|
157
157
|
|
158
158
|
# Writes Junit XML of this {TestSuiteResult}
|
data/lib/beaker/version.rb
CHANGED
@@ -50,5 +50,22 @@ module Beaker
|
|
50
50
|
expect( instance.mv(origin, destination, false) ).to be === 0
|
51
51
|
end
|
52
52
|
end
|
53
|
+
describe '#environment_string' do
|
54
|
+
let(:host) { {'pathseparator' => ':'} }
|
55
|
+
|
56
|
+
it 'returns a blank string if theres no env' do
|
57
|
+
expect( instance.environment_string( {} ) ).to be == ''
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'takes an env hash with var_name/value pairs' do
|
61
|
+
expect( instance.environment_string( {:HOME => '/', :http_proxy => 'http://foo'} ) ).
|
62
|
+
to be == 'set "HOME="/"" && set "http_proxy="http://foo"" && set "HTTP_PROXY="http://foo"" && '
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'takes an env hash with var_name/value[Array] pairs' do
|
66
|
+
expect( instance.environment_string( {:LD_PATH => ['/', '/tmp']}) ).
|
67
|
+
to be == "set \"LD_PATH=\"/:/tmp\"\" && "
|
68
|
+
end
|
69
|
+
end
|
53
70
|
end
|
54
71
|
end
|
@@ -65,7 +65,7 @@ module Beaker
|
|
65
65
|
},
|
66
66
|
},
|
67
67
|
})
|
68
|
-
allow( container ).to receive(:
|
68
|
+
allow( container ).to receive(:kill)
|
69
69
|
allow( container ).to receive(:delete)
|
70
70
|
allow( container ).to receive(:exec)
|
71
71
|
container
|
@@ -338,7 +338,7 @@ module Beaker
|
|
338
338
|
|
339
339
|
it 'should stop the containers' do
|
340
340
|
allow( docker ).to receive( :sleep ).and_return(true)
|
341
|
-
expect( container ).to receive(:
|
341
|
+
expect( container ).to receive(:kill)
|
342
342
|
docker.cleanup
|
343
343
|
end
|
344
344
|
|
@@ -47,6 +47,9 @@ module Beaker
|
|
47
47
|
subcommand.init
|
48
48
|
expect(mock_options).not_to have_key(:timestamp)
|
49
49
|
end
|
50
|
+
it 'requires hosts flag' do
|
51
|
+
expect{subcommand.init}.to raise_error(NotImplementedError)
|
52
|
+
end
|
50
53
|
end
|
51
54
|
|
52
55
|
context '#provision' do
|
@@ -84,6 +87,10 @@ module Beaker
|
|
84
87
|
expect(yaml_store_mock).to receive(:[]=).with('provisioned', true)
|
85
88
|
subcommand.provision
|
86
89
|
end
|
90
|
+
it 'does not allow hosts to be passed' do
|
91
|
+
subcommand.options = {:hosts => "myhost"}
|
92
|
+
expect{subcommand.provision()}.to raise_error(NotImplementedError)
|
93
|
+
end
|
87
94
|
end
|
88
95
|
|
89
96
|
|
@@ -233,7 +233,7 @@ module Beaker
|
|
233
233
|
allow(ex).to receive(:backtrace).and_return(['path_to_test_file.rb line 1 - blah'])
|
234
234
|
tc.instance_variable_set(:@exception, ex)
|
235
235
|
test_suite_result.add_test_case( tc )
|
236
|
-
expect(
|
236
|
+
expect(test_suite_result.print_test_result(tc)).not_to match(/Test line:/)
|
237
237
|
expect{ test_suite_result.print_test_result(tc) }.to_not raise_error
|
238
238
|
end
|
239
239
|
|
@@ -243,8 +243,7 @@ module Beaker
|
|
243
243
|
allow(ex).to receive(:backtrace).and_return(['path_to_test_file.rb line 1 - blah'])
|
244
244
|
tc.instance_variable_set(:@exception, ex)
|
245
245
|
test_suite_result.add_test_case( tc )
|
246
|
-
|
247
|
-
expect(options[:logger]).to receive(:notify).with(/Test line:/)
|
246
|
+
expect(test_suite_result.print_test_result(tc)).to match(/Test line:/)
|
248
247
|
expect{ test_suite_result.print_test_result(tc) }.to_not raise_error
|
249
248
|
end
|
250
249
|
end
|
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: 3.
|
4
|
+
version: 3.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -678,6 +678,7 @@ files:
|
|
678
678
|
- lib/beaker/network_manager.rb
|
679
679
|
- lib/beaker/options.rb
|
680
680
|
- lib/beaker/options/command_line_parser.rb
|
681
|
+
- lib/beaker/options/homedir_options_file_parser.rb
|
681
682
|
- lib/beaker/options/hosts_file_parser.rb
|
682
683
|
- lib/beaker/options/options_file_parser.rb
|
683
684
|
- lib/beaker/options/options_hash.rb
|