beaker 3.13.0 → 3.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDRiMDdjNTBhMTU4NTljNWFmZDM1MDNhZjk0ZDI1MjJiNWI2YzE5ZQ==
4
+ NjhmMGI0YmEzZmIzMGM1MjM3ZjU5MzZiZWE0OGNmMzYyNTc4MmJjZA==
5
5
  data.tar.gz: !binary |-
6
- NzI4NDM0YTE4ZDMxZWEwODU0YTM1ODQ5YTcwNzIwNjM4YTgzYzU2ZA==
6
+ Y2IzYjA2YjBiZGQ1MmI4MGFlNDgxNDM0NDFlMTlmY2Q5ZTEyOWM5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzQ4NmY3MzljYjJmZTk3ZWU4OTFlODc1Nzk4ZDAxZjAxMjlkZGM0ZTg3ZTQx
10
- MjNlMzQzY2JkNGFmNDU4ZmRiYTE2YjYyNTQyMzRiOGY2NjI1YWYzY2ZjYWIx
11
- ZmFiN2Q3MjFlMTgwOGNkMmM2YzU5ZTAxYTc5YmM0NjU4MjAyYjc=
9
+ OTRlZThiZGY3ODViOWNiZmI0Y2VmZWEwYzRlOGUwZDVkZDQ4ZTdlYTc3NmI3
10
+ NWQ3NzYyYjU3MDA1YTkwYmViYzk1MWZkNGY0NWYyNjM1NGI0ZDU2YzU4ZWJm
11
+ ZGMxMDJlNDc5ZWRmMDZjZmU4NjU0OWI2NWRiNjg2Njk0ZDg1N2M=
12
12
  data.tar.gz: !binary |-
13
- MTFmYWUzMTQ3NTc1MzZiNmUyYzdmOTBmNmU2YjIxYjBhMTQ2ODI1NmQzMzc4
14
- NzRkODcyYmYwNWZiOTA4NTJiYTZkNTEwMDI3MmU1NzVjNTM3MjY1NzdiNWU5
15
- NGQwOGQ2NGJlYTAxYjExYzRhMTQyOTY3ZmVhMDc2OTk1NjllMzg=
13
+ OGNjYjc4NTY1N2ExYTQ4NzlkYjE3NjJkMmYzM2NhZTI0NDc0MWE1MWYwZmFh
14
+ ODE5OTUwMjA3Mzk0YTJhYWUyZTg3NDkwYTJhYTgyOWYxNjM1Yzk0OTUwZTJk
15
+ ODhiZDA2YzRkN2ZlOTU5ZmZlOGVkMmU0OGJjYzQ2NTQ2OTE2YzI=
@@ -0,0 +1,49 @@
1
+ test_name 'use the destroy subcommand' do
2
+
3
+ def delete_root_folder_contents
4
+ on default, 'rm -rf /root/* /root/.beaker'
5
+ end
6
+
7
+ step 'ensure that `beaker destroy` fails correctly when a configuration has not been initialized' do
8
+ delete_root_folder_contents
9
+ result = on(default, 'beaker destroy', :accept_all_exit_codes => true)
10
+ assert_match(/Please provision an environment/, result.stdout)
11
+ assert_equal(1, result.exit_code, '`beaker destroy` in an uninitialised configuration should return a non-zero exit code')
12
+ end
13
+
14
+ step 'ensure that `beaker help destroy` works' do
15
+ result = on(default, 'beaker help destroy')
16
+ assert_match(/Usage/, result.stdout)
17
+ assert_equal(0, result.exit_code, '`beaker help destroy` should return a zero exit code')
18
+ end
19
+
20
+ step 'ensure that `beaker destroy --help` works' do
21
+ result = on(default, 'beaker destroy --help')
22
+ assert_match(/Usage/, result.stdout)
23
+ assert_equal(0, result.exit_code, '`beaker destroy --help` should return a zero exit code')
24
+ end
25
+
26
+ step 'ensure that `beaker destroy` destroys vmpooler configuration' do
27
+ delete_root_folder_contents
28
+ result = on(default, "beaker init --hosts centos6-64")
29
+ assert_match(/Writing configured options to disk/, result.stdout)
30
+ assert_equal(0, result.exit_code, "`beaker init` should return a zero exit code")
31
+ step 'ensure destroy fails to run against an unprovisioned environment' do
32
+ result = on(default, "beaker destroy", :accept_all_exit_codes => true)
33
+ assert_match(/Please provision an environment/, result.stdout)
34
+ assert_equal(1, result.exit_code, "`beaker destroy` should return a non zero exit code")
35
+ end
36
+ step 'ensure provision provisions, validates, and configures new hosts' do
37
+ result = on(default, "beaker provision")
38
+ assert_match(/Using available host/, result.stdout)
39
+ assert_equal(0, result.exit_code, "`beaker provision` should return a zero exit code")
40
+ end
41
+ step 'ensure destroy will destroy a provisioned environment' do
42
+ result = on(default, 'beaker destroy')
43
+ assert_match(/Handing/, result.stdout)
44
+ assert_equal(0, result.exit_code, "`beaker destroy` should return a zero exit code")
45
+ end
46
+ delete_root_folder_contents
47
+ end
48
+
49
+ end
@@ -0,0 +1,33 @@
1
+ test_name 'use the exec subcommand' do
2
+
3
+ def delete_root_folder_contents
4
+ on default, 'rm -rf /root/* /root/.beaker'
5
+ end
6
+
7
+ step 'ensure the workspace is clean' do
8
+ delete_root_folder_contents
9
+ end
10
+
11
+ step 'run init and provision to set up the system' do
12
+ on default, 'beaker init --hosts centos6-64; beaker provision'
13
+ subcommand_state = on(default, 'cat .beaker/.subcommand_state.yaml').stdout
14
+ subcommand_state = YAML.parse(subcommand_state).to_ruby
15
+ assert_equal(true, subcommand_state['provisioned'])
16
+ end
17
+
18
+ step 'create a test dir and populate it with tests' do
19
+ on default, 'mkdir -p testing_dir'
20
+ end
21
+
22
+ step 'create remote test file' do
23
+ testfile = <<-TESTFILE
24
+ on(agents, 'echo hello world')
25
+ TESTFILE
26
+ create_remote_file(default, '/root/testing_dir/testfile1.rb', testfile)
27
+ end
28
+
29
+ step 'specify that remote file with beaker exec' do
30
+ result = on(default, 'beaker exec testing_dir/testfile1.rb --log-level verbose')
31
+ assert_match(/hello world/, result.stdout)
32
+ end
33
+ end
@@ -1,48 +1,24 @@
1
1
  test_name 'use the init subcommand' do
2
2
 
3
+ SubcommandUtil = Beaker::Subcommands::SubcommandUtil
3
4
  def delete_root_folder_contents
4
5
  on default, 'rm -rf /root/* /root/.beaker'
5
6
  end
6
7
 
7
- step 'ensure that `beaker init` exit value should be 1 when not provided with a supported hypervisor' do
8
- result = on(default, 'beaker init ec2', :accept_all_exit_codes => true)
9
- assert_match(/Invalid hypervisor. Currently supported hypervisors are.+/, result.stdout)
10
- refute_equal(0, result.exit_code, '`beaker init` with an unsupported hypervisor argument should return a non-zero exit code')
11
- end
12
-
13
- step 'ensure that `beaker help init` works' do
14
- result = on(default, 'beaker help init')
15
- assert_match(/Usage+/, result.stdout)
16
- end
17
-
18
- step 'ensure that `beaker init --help` works' do
19
- result = on(default, 'beaker init --help')
20
- assert_match(/Usage.+/, result.stdout)
21
- assert_equal(0, result.exit_code, '`beaker init --help` should return a zero exit code')
22
- end
23
-
24
- step 'ensure that `beaker init` accepts no argument as well as accepts either vmpooler or vagrant hypervisor arguments' do
25
- ['vmpooler', 'vagrant', ''].each do |hypervisor|
26
- result = on(default, "beaker init #{hypervisor}")
27
- assert_match(/Writing host config.+/, result.stdout)
28
- step 'ensure that the Rakefile is present' do
29
- on(default, '[ -e "Rakefile" ]')
30
- end
8
+ step 'ensure beaker init writes YAML configuration files to disk' do
31
9
  delete_root_folder_contents
32
- end
10
+ on(default, 'beaker init')
11
+ subcommand_options = on(default, "cat #{SubcommandUtil::SUBCOMMAND_OPTIONS}").stdout
12
+ subcommand_state = on(default, "cat #{SubcommandUtil::SUBCOMMAND_STATE}").stdout
13
+ assert(YAML.parse(subcommand_options).to_ruby.class == Hash)
14
+ assert(YAML.parse(subcommand_state).to_ruby.class == Hash)
33
15
  end
34
16
 
35
- step 'ensure that a Rakefile is not overwritten if it does exist prior' do
36
- delete_root_folder_contents
37
- on(default, "beaker init vmpooler")
38
- prepended_rakefile = on(default, 'cat Rakefile').stdout
17
+ step 'ensure beaker init saves beaker-run arguments to the subcommand_options.yaml' do
39
18
  delete_root_folder_contents
40
- on(default, 'echo "require \'tempfile\'" >> Rakefile')
41
- on(default, 'beaker init vmpooler', :accept_all_exit_codes => true)
42
- rakefile = on(default, 'cat Rakefile')
43
-
44
- # Assert that the Rakefile contents includes the original and inserted requirements
45
- assert(result.stdout.include?(prepended_rakefile), 'Rakefile should not contain prepended require')
46
- assert(result.stdout.include?("require 'tempfile'"), 'Rakefile should not contain prepended require')
19
+ on(default, 'beaker init --log-level verbose')
20
+ subcommand_options = on(default, "cat #{SubcommandUtil::SUBCOMMAND_OPTIONS}").stdout
21
+ hash = YAML.parse(subcommand_options).to_ruby
22
+ assert_equal('verbose', hash['log_level'])
47
23
  end
48
24
  end
@@ -1,45 +1,19 @@
1
1
  test_name 'use the provision subcommand' do
2
2
 
3
+ SubcommandUtil = Beaker::Subcommands::SubcommandUtil
4
+
3
5
  def delete_root_folder_contents
4
6
  on default, 'rm -rf /root/* /root/.beaker'
5
7
  end
6
8
 
7
- step 'ensure that `beaker provision` fails correctly when a configuration has not been initialized' do
9
+ step 'run beaker init and provision' do
8
10
  delete_root_folder_contents
9
- result = on(default, 'beaker provision', :accept_all_exit_codes => true)
10
- assert_match(/Please initialise a configuration/, result.stdout)
11
- refute_equal(0, result.exit_code, '`beaker provision` in an uninitialised configuration should return a non-zero exit code')
12
- end
13
-
14
- step 'ensure that `beaker help provision` works' do
15
- result = on(default, 'beaker help provision')
16
- assert_match(/Usage/, result.stdout)
17
- assert_equal(0, result.exit_code, '`beaker help provision` should return a zero exit code')
18
- end
11
+ on(default, 'beaker init')
12
+ result = on(default, 'beaker provision --hosts centos6-64')
13
+ assert_match(/Using available host/, result.stdout)
19
14
 
20
- step 'ensure that `beaker provision --help` works' do
21
- result = on(default, 'beaker provision --help')
22
- assert_match(/Usage/, result.stdout)
23
- assert_equal(0, result.exit_code, '`beaker provision --help` should return a zero exit code')
15
+ subcommand_state = on(default, "cat #{SubcommandUtil::SUBCOMMAND_STATE}").stdout
16
+ subcommand_state = YAML.parse(subcommand_state).to_ruby
17
+ assert_equal(true, subcommand_state['provisioned'])
24
18
  end
25
-
26
- step 'ensure that `beaker provision` provisions vmpooler configuration' do
27
- result = on(default, "beaker init vmpooler")
28
- assert_match(/Writing host config/, result.stdout)
29
- assert_equal(0, result.exit_code, "`beaker init vmpooler` should return a zero exit code")
30
- step 'ensure that the Rakefile is present' do
31
- on(default, '[ -e "Rakefile" ]')
32
- end
33
- step 'ensure provision provisions, validates, and configures new hosts' do
34
- result = on(default, "beaker provision")
35
- assert_equal(0, result.exit_code, "`beaker provision` should return a zero exit code")
36
- end
37
- step 'ensure provision will not provision new hosts if hosts have already been provisioned' do
38
- result = on(default, 'beaker provision')
39
- assert_match(/Hosts have already been provisioned/, result.stdout)
40
- assert_equal(0, result.exit_code, "`beaker provision` should return a zero exit code")
41
- end
42
- delete_root_folder_contents
43
- end
44
-
45
19
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency 'fakefs', '~> 0.6'
26
26
  s.add_development_dependency 'simplecov'
27
27
  s.add_development_dependency 'pry', '~> 0.10'
28
+ s.add_development_dependency 'rake', '~> 10.0'
28
29
 
29
30
  # Documentation dependencies
30
31
  s.add_development_dependency 'yard', '< 0.9.6'
@@ -38,11 +39,10 @@ Gem::Specification.new do |s|
38
39
  s.add_runtime_dependency 'net-scp', '~> 1.2'
39
40
  s.add_runtime_dependency 'inifile', '~> 3.0'
40
41
 
41
- s.add_runtime_dependency 'rake', '~> 10.0'
42
42
  s.add_runtime_dependency 'rsync', '~> 1.0.9'
43
43
  s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
44
44
  s.add_runtime_dependency 'in-parallel', '~> 0.1'
45
- s.add_runtime_dependency 'thor', '0.19.1'
45
+ s.add_runtime_dependency 'thor', '~> 0.19'
46
46
 
47
47
  # Run time dependencies that are Beaker libraries
48
48
  s.add_runtime_dependency 'stringify-hash', '~> 0.0'
data/bin/beaker CHANGED
@@ -6,7 +6,7 @@ require 'beaker'
6
6
  if Beaker::Subcommands::SubcommandUtil.execute_subcommand?(ARGV[0])
7
7
  Beaker::Subcommand.start(ARGV)
8
8
  else
9
- Beaker::CLI.new.parse_options.execute!
9
+ Beaker::CLI.new.parse_options.provision.execute!
10
10
  puts "Beaker completed successfully, thanks."
11
11
  end
12
12
 
@@ -0,0 +1,3 @@
1
+ # Cloning private repos
2
+
3
+ If you need to clone private repos when running Beaker acceptance tests, please refer to the [enabling cross SUT access](enabling_cross_sut_access.md) document
@@ -0,0 +1,23 @@
1
+ # Enabling access bewteen SUTs during an acceptance test run
2
+
3
+ If you are running acceptance tests for Beaker that, at some point, will perform one of the following:
4
+
5
+ * SSH between SUTs
6
+ * Clone private repos
7
+
8
+ You will need to run an SSH agent, and add the SSH key for accessing your SUTs/private repos, prior to running the tests.
9
+
10
+ To load the SSH agent and add your SSH key, run the following:
11
+
12
+ ~~~bash
13
+ eval `ssh-agent`
14
+ ssh-add <SSH key file path>
15
+ ~~~
16
+
17
+ A common example of where this functionality would be required for beaker developers, is in testing subcommands. There, we setup multiple SUTs that need to communicate between themselves. To run our subcommand testing to verify that you have agent forwarding setup correctly, run the following:
18
+
19
+ ~~~bash
20
+ beaker --tests acceptance/tests/subcommands/ --log-level debug --preserve-hosts onfail --pre-suite acceptance/pre_suite/subcommands/ --load-path acceptance/lib --keyfile ~/.ssh/id_rsa-acceptance
21
+ ~~~
22
+
23
+ And Beaker will be able to SSH between SUTs and clone private repos
@@ -29,3 +29,7 @@ vcsrepo { '/var/www/app':
29
29
  user => 'deploy'
30
30
  }
31
31
  ~~~
32
+
33
+ ## Cross SUT access
34
+
35
+ If you need to be able to SSH between SUTs while running Beaker acceptance tests, please refer to the [enabling cross SUT access](enabling_cross_sut_access.md) document
@@ -9,7 +9,7 @@ module Beaker
9
9
  | V |
10
10
  | | | "
11
11
 
12
- attr_reader :logger
12
+ attr_reader :logger, :options, :network_manager
13
13
  def initialize
14
14
  @timestamp = Time.now
15
15
  # Initialize a logger object prior to parsing; this should be overwritten whence
@@ -71,16 +71,29 @@ module Beaker
71
71
 
72
72
  #Provision, validate and configure all hosts as defined in the hosts file
73
73
  def provision
74
+ # return self if only invoking the OptionsParser help
75
+ return self if @options[:help]
76
+
74
77
  begin
75
78
  @hosts = []
76
- @network_manager = Beaker::NetworkManager.new(@options, @logger)
77
- @hosts = @network_manager.provision
79
+ initialize_network_manager
78
80
  @network_manager.proxy_package_manager
79
81
  @network_manager.validate
80
82
  @network_manager.configure
81
83
  rescue => e
82
84
  report_and_raise(@logger, e, "CLI.provision")
83
85
  end
86
+ self
87
+ end
88
+
89
+ #Initialize the network manager so it can initialize hosts for testing for subcommands
90
+ def initialize_network_manager
91
+ begin
92
+ @network_manager = Beaker::NetworkManager.new(@options, @logger)
93
+ @hosts = @network_manager.provision
94
+ rescue => e
95
+ report_and_raise(@logger, e, "CLI.initialize_network_manager")
96
+ end
84
97
  end
85
98
 
86
99
  #Run Beaker tests.
@@ -103,8 +116,6 @@ module Beaker
103
116
  exit(1)
104
117
  end
105
118
 
106
- provision
107
-
108
119
  # Setup perf monitoring if needed
109
120
  if @options[:collect_perf_data].to_s =~ /(aggressive)|(normal)/
110
121
  @perf = Beaker::Perf.new( @hosts, @options )
@@ -194,6 +205,18 @@ module Beaker
194
205
  ).run_and_raise_on_failure
195
206
  end
196
207
 
208
+ # Get the list of options that are not equal to presets.
209
+ # @return Beaker::Options::OptionsHash
210
+ def configured_options
211
+ result = Beaker::Options::OptionsHash.new
212
+ @attribution.each do |attribute, setter|
213
+ if setter != 'preset'
214
+ result[attribute] = @options[attribute]
215
+ end
216
+ end
217
+ result
218
+ end
219
+
197
220
  # Sets aside the current hosts file for re-use with the --no-provision flag.
198
221
  # This is originally intended for use on a successful tests where the hosts
199
222
  # are preserved (the --preserve-hosts option is set accordingly).
@@ -211,6 +234,22 @@ module Beaker
211
234
  @options[:pre_cleanup] = []
212
235
  preserved_hosts_filename = File.join(@options[:log_dated_dir], 'hosts_preserved.yml')
213
236
 
237
+ hosts_yaml = @options
238
+ hosts_yaml['HOSTS'] = combined_instance_and_options_hosts
239
+ hosts_yaml['CONFIG'] = Beaker::Options::OptionsHash.new.merge(hosts_yaml['CONFIG'] || {})
240
+ # save the rest of the options, excepting the HOSTS that we have already processed
241
+ hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,v| k =~ dontpreserve })
242
+ # remove copy of HOSTS information
243
+ hosts_yaml['CONFIG']['provision'] = false
244
+ File.open(preserved_hosts_filename, 'w') do |file|
245
+ YAML.dump(hosts_yaml, file)
246
+ end
247
+ @options[:hosts_preserved_yaml_file] = preserved_hosts_filename
248
+ end
249
+
250
+ # Return a host_hash that is a merging of options host hashes with instance host objects
251
+ # @return Hash
252
+ def combined_instance_and_options_hosts
214
253
  hosts_yaml = @options
215
254
  newly_keyed_hosts_entries = {}
216
255
  hosts_yaml['HOSTS'].each do |host_name, file_host_hash|
@@ -223,16 +262,7 @@ module Beaker
223
262
  end
224
263
  end
225
264
  end
226
- hosts_yaml['HOSTS'] = newly_keyed_hosts_entries
227
- hosts_yaml['CONFIG'] = Beaker::Options::OptionsHash.new.merge(hosts_yaml['CONFIG'] || {})
228
- # save the rest of the options, excepting the HOSTS that we have already processed
229
- hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,v| k =~ dontpreserve })
230
- # remove copy of HOSTS information
231
- hosts_yaml['CONFIG']['provision'] = false
232
- File.open(preserved_hosts_filename, 'w') do |file|
233
- YAML.dump(hosts_yaml, file)
234
- end
235
- @options[:hosts_preserved_yaml_file] = preserved_hosts_filename
265
+ newly_keyed_hosts_entries
236
266
  end
237
267
 
238
268
  # Prints all information required to reproduce the current run & results to the log
@@ -139,7 +139,7 @@ module Beaker
139
139
  host_hash[k] = v
140
140
  end
141
141
 
142
- # Does this host have this key? Either as defined in the host itself, or globally?
142
+ # Does this host have this key? Either as defined in the host itself, or globally?
143
143
  def [] k
144
144
  host_hash[k] || options[k]
145
145
  end
@@ -20,6 +20,7 @@ module Beaker
20
20
  def self.create(type, hosts_to_provision, options)
21
21
  @logger = options[:logger]
22
22
  @logger.notify("Beaker::Hypervisor, found some #{type} boxes to create")
23
+
23
24
  hyper_class = case type
24
25
  when /^aix$/
25
26
  Beaker::Aixer
@@ -74,7 +75,7 @@ module Beaker
74
75
  end
75
76
 
76
77
  hypervisor = hyper_class.new(hosts_to_provision, options)
77
- hypervisor.provision
78
+ hypervisor.provision if options[:provision]
78
79
 
79
80
  hypervisor
80
81
  end
@@ -21,6 +21,8 @@ module Beaker
21
21
  (command_line_says && host_says) or (host['hypervisor'] =~/(vagrant|docker)/)
22
22
  end
23
23
 
24
+ attr_accessor :hosts, :hypervisors
25
+
24
26
  def initialize(options, logger)
25
27
  @logger = logger
26
28
  @options = options
@@ -56,7 +58,9 @@ module Beaker
56
58
  @options['HOSTS'].each_key do |name|
57
59
  host_hash = @options['HOSTS'][name]
58
60
  hypervisor = host_hash['hypervisor']
59
- hypervisor = provision?(@options, host_hash) ? host_hash['hypervisor'] : 'none'
61
+ if @options[:provision]
62
+ hypervisor = provision?(@options, host_hash) ? host_hash['hypervisor'] : 'none'
63
+ end
60
64
  @logger.debug "Hypervisor for #{name} is #{hypervisor}"
61
65
  @machines[hypervisor] = [] unless @machines[hypervisor]
62
66
  hostless_options[:timesync] = host_hash[:timesync] if host_hash[:timesync]!=nil