beaker 3.15.0 → 3.16.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
- NjRlOGQzYjVmMjI1MDFhYTQzZTRhNzZhOTM0Njg1MzI1ZGY1NmU4Nw==
4
+ MjFkMmNmNDJhOTkxZjJlYmViNDViMGE4N2NjNzllY2U3ZWY5MmVmNw==
5
5
  data.tar.gz: !binary |-
6
- MzUxODYzYWY0ZWQ0YjM5OWU5ODQzNTY4OGFlOWU4YzlhYTQ3NzM2OQ==
6
+ MTI4OWYzMzQ2OGE2NmI3MDY4YzE1M2E2YTgyNzNlNTk1ZGI3ZDU3YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTY1NmExNTVjODU2OGU1Zjg2Yjk4N2NmYmY2ODBjODNiYjIxZWExZjNjYzM2
10
- NDJlNmIwYTcyNTIzOGU3YjUxMTJiODIyOGNjNGYzYTE5NDVlZDBlNzc2NjRj
11
- Yjc5NGFkMzNiMDAxOTY2OGNlZWFiMGVhMTgyYjczMzM0YzljN2I=
9
+ NGY4Y2MwMzU0NzY0ZjgzNmJjYTk0OTZiNTcxODFlMDU2OTJhNTY2MmZkMDRj
10
+ NjA3MDRjMzJjY2QyOGE3NWY2YTVhNmU3ZDBhYjkwNjBkM2VjZTJiNjFkNDVj
11
+ YWU2NDEzOWQ5NzI2NTkxNTlhMTBlODNjYjc3YjJhODQ4YjhlM2E=
12
12
  data.tar.gz: !binary |-
13
- N2QzYTg1NjZiOTAxYWY4YjQ3ODdiYjkyNjViN2Q5ZDg2OTA0MmNmMTRhNWVl
14
- YTk1MTAwZTBmZTlhMzU2Mzk0NjU5OWUwZjU0YjYyODdjMmE4YWZhNDlmOGYz
15
- MzczMjQ5YjVmZWIwMGJmN2RmYTcyNTE3ZjY0YjJlZTViNzY1ZDA=
13
+ MWRkNDY5MTM3OTFlZDcyMzQ3NjdmYjNmMDUzZWUyZTg1NjFjMDhmZmRjMzFh
14
+ ODZlZTM3OGMzY2YzMWVjOWZiNjk1YzA4NTQ3NGE2MTNjNjljNGMxMDgxYjNi
15
+ MTlhYTNjMDM1ZTFlOWFlNzk4NTQwNmViYmQyNDJhOTk4OWJkNmU=
@@ -12,7 +12,7 @@ Beaker uses arguments and settings from a variety of sources to determine how yo
12
12
 
13
13
 
14
14
  ## Environment Variables
15
- ###Supported Environment Variables:
15
+ ### Supported Environment Variables:
16
16
  ```
17
17
  BEAKER VARIABLE NAME => ENVIRONMENT VARIABLE NAME
18
18
  :home => 'HOME',
@@ -81,7 +81,7 @@ $ beaker --debug --tests acceptance/tests/base/host.rb --hosts configs/fusion/wi
81
81
  ```
82
82
  `--debug`, `--tests acceptance/tests/base/host.rb` and `--hosts configs/fusion/winfusion.cfg` are the provided command line values for this test run.
83
83
 
84
- ###Supported Command Line Arguments:
84
+ ### Supported Command Line Arguments:
85
85
  ```
86
86
  $ beaker --help
87
87
  Usage: beaker [options...]
@@ -152,3 +152,15 @@ volume size in MB.
152
152
  size: 10000
153
153
  journal:
154
154
  size: 1000
155
+
156
+
157
+ In the event you're using an OpenStack instance that does not deploy the volume service you can disable that functionality to prevent beaker runs from failing. Either using an ENV variable or setting the following value in the `CONFIG` section of your hosts file(valid values are `true` or `false`):
158
+
159
+ ```
160
+ openstack_volume_support: false
161
+ ```
162
+
163
+ You can also configure this setting via an environment variable:
164
+
165
+ ```
166
+ export OS_VOLUME_SUPPORT=false
@@ -5,6 +5,10 @@ systems.
5
5
  beaker's vmpooler hypervisor interacts with vmpooler to get Systems Under Test
6
6
  (SUTs) for testing purposes.
7
7
 
8
+ **Note** that if you're a puppet-internal user, you'll have to setup your SSH
9
+ keys to communicate with vmpooler SUTs. To do that, refer to our
10
+ [internal doc](https://confluence.puppetlabs.com/display/SRE/SSH+access+to+vmpooler+VMs).
11
+
8
12
  # Tokens
9
13
 
10
14
  Using tokens will allow you to extend your VMs lifetime, as well as interact
@@ -1,3 +1,11 @@
1
+ This doc describes beaker's vSphere hypervisor. This is the interaction layer
2
+ that beaker will use to get Systems Under Test (SUTs) from any vSphere
3
+ infrastructure that you might have.
4
+
5
+ **Note** that if you're a puppet-internal user, or an external user that is
6
+ using the vmpooler hypervisor, please refer to our [vmpooler doc](vmpooler.md)
7
+ for info, as it can be different than the information here.
8
+
1
9
  The harness can use vms and snapshots that live within vSphere as well.
2
10
  To do this create a `~/.fog` file with your vSphere credentials:
3
11
 
@@ -1,11 +1,11 @@
1
- #Beaker for Modules
2
- ##Read the Beaker Docs
1
+ # Beaker for Modules
2
+ ## Read the Beaker Docs
3
3
 
4
4
  [Beaker How To](../tutorials/how_to_beaker.md)
5
5
  [Beaker DSL API](http://rubydoc.info/github/puppetlabs/beaker/frames)
6
6
 
7
- ##Understand the Difference Between beaker and beaker-rspec
7
+ ## Understand the Difference Between beaker and beaker-rspec
8
8
  [beaker vs. beaker-rspec](../concepts/beaker_vs_beaker_rspec.md)
9
9
 
10
- ##beaker-rspec Details
10
+ ## beaker-rspec Details
11
11
  See the [beaker-rspec README](https://github.com/puppetlabs/beaker-rspec/blob/master/README.md) for details on how to use beaker-rspec with modules.
@@ -1,8 +1,8 @@
1
- ##The Task
1
+ ## The Task
2
2
 
3
3
  Consider if mcollectived incorrectly spawned a new process with every puppet agent run on Ubuntu 10.04. We need an acceptance test to check that a new process is not spawned and to ensure that this issue does not regress in new builds.
4
4
 
5
- ##Figure Out Test Steps
5
+ ## Figure Out Test Steps
6
6
 
7
7
  What needs to happen in this test:
8
8
 
@@ -10,10 +10,10 @@ What needs to happen in this test:
10
10
  * Restart mcollective twice
11
11
  * Check to see if more than one mcollective process is running
12
12
 
13
- ##Create a host configuration file
13
+ ## Create a host configuration file
14
14
  $ beaker-hostgenerator redhat7-64ma > redhat7-64ma.yaml
15
15
 
16
- ##Install PE
16
+ ## Install PE
17
17
 
18
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.
19
19
 
@@ -33,19 +33,19 @@ The install.rb script is used in our commandline to beaker, below.
33
33
  We need to create a test file to run.
34
34
 
35
35
  ### Define some test commands to run
36
- ####Restart mcollective twice
36
+ #### Restart mcollective twice
37
37
 
38
38
  Here's our magic command that restarts mcollective:
39
39
 
40
40
  restart_command = "bash -c '[[ -x /etc/init.d/pe-mcollective ]] && /etc/init.d/pe-mcollective restart'"
41
41
 
42
- ####Check to see if more than one mcollective process is running
42
+ #### Check to see if more than one mcollective process is running
43
43
 
44
44
  Here's our magic command that throws an error if more than one mcollective process is running:
45
45
 
46
46
  process_count_check = "bash -c '[[ $(ps auxww | grep [m]collectived | wc -l) -eq 1 ]]'"
47
47
 
48
- ###Put it all together
48
+ ### Put it all together
49
49
 
50
50
  Here's the finished acceptance test.
51
51
 
@@ -1,4 +1,4 @@
1
- #Beaker Quick Start Tasks
1
+ # Beaker Quick Start Tasks
2
2
 
3
3
  We have developed some rake tasks to help new Beaker users get up and running quickly with writing and running tests.
4
4
 
@@ -208,4 +208,4 @@ This task will run the above 3 tasks in sequential order and then execute a Beak
208
208
 
209
209
  You will end up with provisioned hosts with puppet installed and a test check executed to verify that puppet was installed.
210
210
 
211
- For more information on running Beaker tests see - [Test run](test_run.md)
211
+ For more information on running Beaker tests see - [Test run](test_run.md)
@@ -0,0 +1,54 @@
1
+ # Using Subcommands
2
+
3
+ The document gives an overview of the subcommands that beaker supports and
4
+ describes a basic of how to use them.
5
+
6
+ ## Why Subcommands?
7
+
8
+ Subcommands are designed to make test development and iteration simpler by
9
+ separating out all of the phases of a beaker test run*. Instead of requiring the
10
+ entirety of your beaker execution in one command, subcommands allow you to
11
+ execute each phase independently. This allows for faster feedback for potential
12
+ failures and better control for iterating over actual test development.
13
+
14
+ Most subcommands pass through flags to the beaker options. For instance, you can
15
+ pass through `--hosts` to the `init` subcommand and it will parse the `--hosts`
16
+ argument as if you were executing a beaker run*. Please review the
17
+ subcommand specific help for further information. You can see the help for a
18
+ specific subcommand by running `beaker help SUBCOMMAND`.
19
+
20
+ *Please note that in this document, a beaker `run` is standard beaker invocation
21
+ without any subcommands.
22
+ ## Available Subcommands
23
+
24
+ ### beaker init
25
+ Initializes the required `.beaker/` configuration folder. This folder contains a
26
+ `subcommand_options.yaml` file that is user-facing; altering this file will
27
+ alter the options for subcommand execution.
28
+
29
+ ### beaker provision
30
+ Provisions hosts defined in your `subcommand_options file`. You can pass the
31
+ `--hosts` flag here to override any hosts provided there.
32
+
33
+ ### beaker exec
34
+ Run a single file, directory, or beaker suite. If supplied a file or directory,
35
+ that resource will be run in the context of the `tests` suite; if supplied a
36
+ beaker suite, then just that suite will run. If no resource is supplied, then
37
+ this command executes the suites as they are defined in the configuration in the
38
+ `subcommand_options.yaml`.
39
+
40
+ ### beaker destroy
41
+ Execute this command to deprovision your systems under test(SUTs).
42
+
43
+ ## Basic workflow
44
+
45
+ ```
46
+ beaker init -h hosts_file -o options_file --keyfile ssh_key --pre-suite ./setup/pre-suit/my_presuite.rb
47
+ beaker provision
48
+ # Note: do not pass in hosts file, or use the '-t' flag! Just the file
49
+ # or directory. Do not pass GO. Do not collect $200.
50
+ beaker exec ./tests/my_test.rb
51
+ # Repeating the above command as needed
52
+ # When you're done testing using the VM that beaker provisioned
53
+ beaker destroy
54
+ ```
@@ -1,3 +1,4 @@
1
+ # The Command Line
1
2
  * Using the gem
2
3
 
3
4
  $ beaker --log-level debug --hosts sample.cfg --tests test.rb
@@ -6,14 +7,14 @@
6
7
 
7
8
  $ bundle exec beaker --log-level debug --hosts sample.cfg --tests test.rb
8
9
 
9
- ##Useful options
10
+ ## Useful options
10
11
  * `-h, --hosts FILE `, the hosts that you are going to be testing with
11
12
  * `--log-level debug`, for providing verbose logging and full stacktraces on failure
12
13
  * `--[no-]provision`, indicates if beaker should provision new boxes upon test execution. If `no` is selected then beaker will attempt to connect to the hosts as defined in `--hosts FILE` without first creating/running them through their hypervisors
13
14
  * `--preserve-hosts [MODE]`, indicates what should be done with the testing boxes after tests are complete. If `always` is selected then the boxes will be preserved and left running post-testing. If `onfail` is selected then the boxes will be preserved only if tests fail, otherwise they will be shut down and destroyed. If `never` is selected then the boxes will be shut down and destroyed no matter the testing results.
14
15
  * `--parse-only`, read and parse all command line options, environment options and file options; report the parsed options and exit.
15
16
 
16
- ##The Rest
17
+ ## The Rest
17
18
  See all options with
18
19
  * Using the gem
19
20
 
@@ -75,7 +75,7 @@ module Cisco
75
75
  end
76
76
 
77
77
  prepend_cmds = 'source /etc/profile;'
78
- prepend_cmds << " sudo sh -c \"" if self[:user] != 'root'
78
+ prepend_cmds << " sudo -E sh -c \"" if self[:user] != 'root'
79
79
  if self[:vrf]
80
80
  prepend_cmds << "ip netns exec #{self[:vrf]} "
81
81
  end
@@ -28,7 +28,14 @@ module Unix::Pkg
28
28
  result = execute("zypper se -i --match-exact #{name}", opts) { |result| result }
29
29
  result.stdout =~ /No packages found/ ? (return false) : (return result.exit_code == 0)
30
30
  when /sles-/
31
- result = execute("zypper se -i --match-exact #{name}", opts) { |result| result }
31
+ if !self[:sles_rpmkeys_nightly_pl_imported]
32
+ # The `:sles_rpmkeys_nightly_pl_imported` key is only read here at this
33
+ # time. It's just to make sure that we only do the key import once, &
34
+ # isn't for setting or use outside of beaker.
35
+ execute('rpmkeys --import http://nightlies.puppetlabs.com/07BB6C57', opts)
36
+ self[:sles_rpmkeys_nightly_pl_imported] = true
37
+ end
38
+ result = execute("zypper --gpg-auto-import-keys se -i --match-exact #{name}", opts) { |result| result }
32
39
  when /el-4/
33
40
  @logger.debug("Package query not supported on rhel4")
34
41
  return false
@@ -63,6 +63,11 @@ module Beaker
63
63
  raise "Unable to create OpenStack Network instance (api_key: #{@options[:openstack_api_key]}, username: #{@options[:openstack_username]}, auth_url: #{@options[:openstack_auth_url]}, tenant: #{@options[:openstack_tenant]})"
64
64
  end
65
65
 
66
+ # Validate openstack_volume_support setting value, reset to boolean if passed via ENV value string
67
+ @options[:openstack_volume_support] = true if @options[:openstack_volume_support].to_s.match(/\btrue\b/i)
68
+ @options[:openstack_volume_support] = false if @options[:openstack_volume_support].to_s.match(/\bfalse\b/i)
69
+ [true,false].include? @options[:openstack_volume_support] or raise "Invalid openstack_volume_support setting, current: @options[:openstack_volume_support]"
70
+
66
71
  end
67
72
 
68
73
  #Provided a flavor name return the OpenStack id for that flavor
@@ -229,7 +234,6 @@ module Beaker
229
234
  vm = @compute_client.servers.create(options)
230
235
 
231
236
  #wait for the new instance to start up
232
- start = Time.now
233
237
  try = 1
234
238
  attempts = @options[:timeout].to_i / SLEEPWAIT
235
239
 
@@ -266,7 +270,8 @@ module Beaker
266
270
  #enable root if user is not root
267
271
  enable_root(host)
268
272
 
269
- provision_storage(host, vm)
273
+ provision_storage(host, vm) if @options[:openstack_volume_support]
274
+ @logger.notify "OpenStack Volume Support Disabled, can't provision volumes" if not @options[:openstack_volume_support]
270
275
  end
271
276
 
272
277
  hack_etc_hosts @hosts, @options
@@ -277,7 +282,7 @@ module Beaker
277
282
  def cleanup
278
283
  @logger.notify "Cleaning up OpenStack"
279
284
  @vms.each do |vm|
280
- cleanup_storage(vm)
285
+ cleanup_storage(vm) if @options[:openstack_volume_support]
281
286
  @logger.debug "Release floating IPs for OpenStack host #{vm.name}"
282
287
  floating_ips = vm.all_addresses # fetch and release its floating IPs
283
288
  floating_ips.each do |address|
@@ -134,6 +134,7 @@ module Beaker
134
134
  :openstack_keyname => ENV['OS_KEYNAME'],
135
135
  :openstack_network => ENV['OS_NETWORK'],
136
136
  :openstack_region => ENV['OS_REGION'],
137
+ :openstack_volume_support => ENV['OS_VOLUME_SUPPORT'] || true,
137
138
  :jenkins_build_url => nil,
138
139
  :validate => true,
139
140
  :configure => true,
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.15.0'
3
+ STRING = '3.16.0'
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ module Cisco
28
28
 
29
29
  it 'uses `sudo` if not root' do
30
30
  @options = { :user => 'notroot' }
31
- answer_correct = "source /etc/profile; sudo sh -c \""
31
+ answer_correct = "source /etc/profile; sudo -E sh -c \""
32
32
  answer_test = host.prepend_commands( 'fake_command' )
33
33
  expect( answer_test ).to be === answer_correct
34
34
  end
@@ -14,6 +14,10 @@ module Beaker
14
14
  @hash[k]
15
15
  end
16
16
 
17
+ def []=(k, v)
18
+ @hash[k] = v
19
+ end
20
+
17
21
  def to_s
18
22
  "me"
19
23
  end
@@ -93,8 +97,9 @@ module Beaker
93
97
  it "checks correctly on sles" do
94
98
  @opts = {'platform' => 'sles-is-me'}
95
99
  pkg = 'sles_package'
96
- expect( Beaker::Command ).to receive(:new).with("zypper se -i --match-exact #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
97
- expect( instance ).to receive(:exec).with('', :accept_all_exit_codes => true).and_return(generate_result("hello", {:exit_code => 0}))
100
+ expect( Beaker::Command ).to receive( :new ).with( /^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything ).and_return('').ordered.once
101
+ expect( Beaker::Command ).to receive(:new).with("zypper --gpg-auto-import-keys se -i --match-exact #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('').ordered.once
102
+ expect( instance ).to receive(:exec).with('', :accept_all_exit_codes => true).and_return(generate_result("hello", {:exit_code => 0})).exactly(2).times
98
103
  expect( instance.check_for_package(pkg) ).to be === true
99
104
  end
100
105
 
@@ -20,167 +20,219 @@ module Beaker
20
20
  allow( Fog::Network ).to receive( :new ).and_return( @network_client )
21
21
  end
22
22
 
23
- it 'check openstack options during initialization' do
24
- options = openstack.instance_eval('@options')
25
- expect(options['openstack_api_key']).to eq('P1as$w0rd')
26
- expect(options['openstack_username']).to eq('user')
27
- expect(options['openstack_auth_url']).to eq('http://openstack_hypervisor.labs.net:5000/v2.0/tokens')
28
- expect(options['openstack_tenant']).to eq('testing')
29
- expect(options['openstack_network']).to eq('testing')
30
- expect(options['openstack_keyname']).to eq('nopass')
31
- expect(options['security_group']).to eq(['my_sg', 'default'])
32
- expect(options['floating_ip_pool']).to eq('my_pool')
33
- end
34
-
35
- it 'check hosts options during initialization' do
36
- hosts = openstack.instance_eval('@hosts')
37
- @hosts.each do |host|
38
- expect(host['image']).to eq('default_image')
39
- expect(host['flavor']).to eq('m1.large')
40
- expect(host['user_data']).to eq('#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"')
23
+ context 'keystone version support' do
24
+ it 'supports keystone v2' do
25
+ credentials = openstack.instance_eval('@credentials')
26
+ expect(credentials[:openstack_user_domain]).to be_nil
27
+ expect(credentials[:openstack_project_domain]).to be_nil
41
28
  end
42
- end
43
29
 
44
- it 'check host options during server creation' do
30
+ it 'supports keystone v3 with implicit arguments' do
31
+ v3_options = options
32
+ v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
45
33
 
46
- mock_flavor = Object.new
47
- allow( mock_flavor ).to receive( :id ).and_return( 12345 )
48
- allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
49
- expect( openstack ).to receive( :flavor ).with( 'm1.large' )
50
-
51
- mock_image = Object.new
52
- allow( mock_image ).to receive( :id ).and_return( 54321 )
53
- allow( openstack ).to receive( :image ).and_return( mock_image )
54
- expect( openstack ).to receive( :image ).with( 'default_image' )
55
-
56
- mock_servers = double().as_null_object
57
- allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
34
+ credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
35
+ expect(credentials[:openstack_user_domain]).to eq('Default')
36
+ expect(credentials[:openstack_project_domain]).to eq('Default')
37
+ end
58
38
 
59
- expect(mock_servers).to receive(:create).with(hash_including(
60
- :user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"',
61
- :flavor_ref => 12345,
62
- :image_ref => 54321)
63
- )
39
+ it 'supports keystone v3 with explicit arguments' do
40
+ v3_options = options
41
+ v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
42
+ v3_options[:openstack_user_domain] = 'acme.com'
43
+ v3_options[:openstack_project_domain] = 'R&D'
64
44
 
65
- @hosts.each do |host|
66
- allow(host).to receive(:wait_for_port).and_return(true)
45
+ credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
46
+ expect(credentials[:openstack_user_domain]).to eq('acme.com')
47
+ expect(credentials[:openstack_project_domain]).to eq('R&D')
67
48
  end
68
-
69
- openstack.provision
70
49
  end
71
50
 
72
- it 'generates valid keynames during server creation' do
73
- # Simulate getting a dynamic IP from OpenStack to test key generation code
74
- # after provisioning. See _validate_new_key_pair in openstack/nova for reference
75
- mock_ip = double().as_null_object
76
- allow( openstack ).to receive( :get_ip ).and_return( mock_ip )
77
- allow( mock_ip ).to receive( :ip ).and_return( '172.16.0.1' )
78
- openstack.instance_eval('@options')['openstack_keyname'] = nil
79
-
80
- @hosts.each do |host|
81
- allow(host).to receive(:wait_for_port).and_return(true)
51
+ describe '#provision' do
52
+
53
+ it 'check openstack options during initialization' do
54
+ options = openstack.instance_eval('@options')
55
+ expect(options['openstack_api_key']).to eq('P1as$w0rd')
56
+ expect(options['openstack_username']).to eq('user')
57
+ expect(options['openstack_auth_url']).to eq('http://openstack_hypervisor.labs.net:5000/v2.0/tokens')
58
+ expect(options['openstack_tenant']).to eq('testing')
59
+ expect(options['openstack_network']).to eq('testing')
60
+ expect(options['openstack_keyname']).to eq('nopass')
61
+ expect(options['security_group']).to eq(['my_sg', 'default'])
62
+ expect(options['floating_ip_pool']).to eq('my_pool')
82
63
  end
83
64
 
84
- openstack.provision
85
-
86
- @hosts.each do |host|
87
- expect(host[:keyname]).to match(/^[_\-0-9a-zA-Z]+$/)
65
+ it 'check hosts options during initialization' do
66
+ @hosts.each do |host|
67
+ expect(host['image']).to eq('default_image')
68
+ expect(host['flavor']).to eq('m1.large')
69
+ expect(host['user_data']).to eq('#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"')
70
+ end
88
71
  end
89
- end
90
72
 
91
- it 'get_ip always allocates a new floatingip' do
92
- # Assume beaker is being executed in parallel N times by travis (or similar).
93
- # IPs are allocated (but not associated) before an instance is created; it is
94
- # hightly possible the first instance will allocate a new IP and create an ssh
95
- # key. While the instance is being created the other N-1 instances come along,
96
- # find the unused IP and try to use it as well which causes keyname clashes
97
- # and other IP related shenannigans. Ensure we allocate a new IP each and every
98
- # time
99
- mock_addresses = double().as_null_object
100
- mock_ip = double().as_null_object
101
- allow(@compute_client).to receive(:addresses).and_return(mock_addresses)
102
- allow(mock_addresses).to receive(:create).and_return(mock_ip)
103
- expect(mock_addresses).to receive(:create).exactly(3).times
104
- (1..3).each { openstack.get_ip }
105
- end
73
+ it 'check host options during server creation' do
106
74
 
107
- it 'creates volumes with cinder v1' do
108
- # Mock a volume
109
- allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
75
+ mock_flavor = Object.new
76
+ allow( mock_flavor ).to receive( :id ).and_return( 12345 )
77
+ allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
78
+ expect( openstack ).to receive( :flavor ).with( 'm1.large' )
110
79
 
111
- # Stub out the call to create the client and hard code the return value
112
- allow(openstack).to receive(:volume_client_create).and_return(nil)
113
- client = double().as_null_object
114
- openstack.instance_variable_set(:@volume_client, client)
115
- allow(openstack).to receive(:get_volume_api_version).and_return(1)
80
+ mock_image = Object.new
81
+ allow( mock_image ).to receive( :id ).and_return( 54321 )
82
+ allow( openstack ).to receive( :image ).and_return( mock_image )
83
+ expect( openstack ).to receive( :image ).with( 'default_image' )
116
84
 
117
- # Check the parameters are valid, correct 'name' parameter and correct size conversion
118
- mock_volume = double().as_null_object
119
- expect(client).to receive(:create).with(:display_name => 'volume1', :description => 'Beaker volume: host=alan volume=volume1', :size => 1000).and_return(mock_volume)
120
- allow(mock_volume).to receive(:wait_for).and_return(nil)
85
+ mock_servers = double().as_null_object
86
+ allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
121
87
 
122
- # Perform the test!
123
- mock_vm = double().as_null_object
124
- allow(mock_volume).to receive(:id).and_return('Fake ID')
125
- expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
88
+ expect(mock_servers).to receive(:create).with(hash_including(
89
+ :user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"',
90
+ :flavor_ref => 12345,
91
+ :image_ref => 54321)
92
+ )
126
93
 
127
- mock_host = double().as_null_object
128
- allow(mock_host).to receive(:name).and_return('alan')
94
+ @hosts.each do |host|
95
+ allow(host).to receive(:wait_for_port).and_return(true)
96
+ end
129
97
 
130
- openstack.provision_storage mock_host, mock_vm
131
- end
98
+ openstack.provision
99
+ end
132
100
 
133
- it 'creates volumes with cinder v2' do
134
- # Mock a volume
135
- allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
101
+ it 'generates valid keynames during server creation' do
102
+ # Simulate getting a dynamic IP from OpenStack to test key generation code
103
+ # after provisioning. See _validate_new_key_pair in openstack/nova for reference
104
+ mock_ip = double().as_null_object
105
+ allow( openstack ).to receive( :get_ip ).and_return( mock_ip )
106
+ allow( mock_ip ).to receive( :ip ).and_return( '172.16.0.1' )
107
+ openstack.instance_eval('@options')['openstack_keyname'] = nil
136
108
 
137
- # Stub out the call to create the client and hard code the return value
138
- allow(openstack).to receive(:volume_client_create).and_return(nil)
139
- client = double().as_null_object
140
- openstack.instance_variable_set(:@volume_client, client)
141
- allow(openstack).to receive(:get_volume_api_version).and_return(-1)
109
+ @hosts.each do |host|
110
+ allow(host).to receive(:wait_for_port).and_return(true)
111
+ end
142
112
 
143
- # Check the parameters are valid, correct 'name' parameter and correct size conversion
144
- mock_volume = double().as_null_object
145
- expect(client).to receive(:create).with(:name => 'volume1', :description => 'Beaker volume: host=alan volume=volume1', :size => 1000).and_return(mock_volume)
146
- allow(mock_volume).to receive(:wait_for).and_return(nil)
113
+ openstack.provision
147
114
 
148
- # Perform the test!
149
- mock_vm = double().as_null_object
150
- allow(mock_volume).to receive(:id).and_return('Fake ID')
151
- expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
115
+ @hosts.each do |host|
116
+ expect(host[:keyname]).to match(/^[_\-0-9a-zA-Z]+$/)
117
+ end
118
+ end
152
119
 
153
- mock_host = double().as_null_object
154
- allow(mock_host).to receive(:name).and_return('alan')
120
+ it 'get_ip always allocates a new floatingip' do
121
+ # Assume beaker is being executed in parallel N times by travis (or similar).
122
+ # IPs are allocated (but not associated) before an instance is created; it is
123
+ # hightly possible the first instance will allocate a new IP and create an ssh
124
+ # key. While the instance is being created the other N-1 instances come along,
125
+ # find the unused IP and try to use it as well which causes keyname clashes
126
+ # and other IP related shenannigans. Ensure we allocate a new IP each and every
127
+ # time
128
+ mock_addresses = double().as_null_object
129
+ mock_ip = double().as_null_object
130
+ allow(@compute_client).to receive(:addresses).and_return(mock_addresses)
131
+ allow(mock_addresses).to receive(:create).and_return(mock_ip)
132
+ expect(mock_addresses).to receive(:create).exactly(3).times
133
+ (1..3).each { openstack.get_ip }
134
+ end
155
135
 
156
- openstack.provision_storage mock_host, mock_vm
136
+ context 'volume creation option' do
137
+ it 'provisions volume by default' do
138
+ mock_flavor = Object.new
139
+ allow( mock_flavor ).to receive( :id ).and_return( 12345 )
140
+ allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
141
+ mock_image = Object.new
142
+ allow( mock_image ).to receive( :id ).and_return( 54321 )
143
+ allow( openstack ).to receive( :image ).and_return( mock_image )
144
+ mock_servers = double().as_null_object
145
+ allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
146
+
147
+ @hosts.each do |host|
148
+ allow(host).to receive(:wait_for_port).and_return(true)
149
+ expect(openstack).to receive(:provision_storage)
150
+ end
151
+
152
+ openstack.provision
153
+ end
154
+
155
+ it 'skips provisioning when disabled' do
156
+ mock_flavor = Object.new
157
+ allow( mock_flavor ).to receive( :id ).and_return( 12345 )
158
+ allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
159
+ mock_image = Object.new
160
+ allow( mock_image ).to receive( :id ).and_return( 54321 )
161
+ allow( openstack ).to receive( :image ).and_return( mock_image )
162
+ mock_servers = double().as_null_object
163
+ allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
164
+
165
+ openstack.instance_eval('@options')['openstack_volume_support'] = false
166
+
167
+ @hosts.each do |host|
168
+ allow(host).to receive(:wait_for_port).and_return(true)
169
+ expect(openstack).not_to receive(:provision_storage)
170
+ end
171
+
172
+ openstack.provision
173
+ end
174
+ end
157
175
  end
158
176
 
159
- it 'supports keystone v2' do
160
- credentials = openstack.instance_eval('@credentials')
161
- expect(credentials[:openstack_user_domain]).to be_nil
162
- expect(credentials[:openstack_project_domain]).to be_nil
163
- end
177
+ describe '#provision_storage' do
164
178
 
165
- it 'supports keystone v3 with implicit arguments' do
166
- v3_options = options
167
- v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
179
+ it 'creates volumes with cinder v1' do
180
+ # Mock a volume
181
+ allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
168
182
 
169
- credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
170
- expect(credentials[:openstack_user_domain]).to eq('Default')
171
- expect(credentials[:openstack_project_domain]).to eq('Default')
172
- end
183
+ # Stub out the call to create the client and hard code the return value
184
+ allow(openstack).to receive(:volume_client_create).and_return(nil)
185
+ client = double().as_null_object
186
+ openstack.instance_variable_set(:@volume_client, client)
187
+ allow(openstack).to receive(:get_volume_api_version).and_return(1)
173
188
 
174
- it 'supports keystone v3 with explicit arguments' do
175
- v3_options = options
176
- v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
177
- v3_options[:openstack_user_domain] = 'acme.com'
178
- v3_options[:openstack_project_domain] = 'R&D'
189
+ # Check the parameters are valid, correct 'name' parameter and correct size conversion
190
+ mock_volume = double().as_null_object
191
+ expect(client).to receive(:create).with(:display_name => 'volume1',
192
+ :description => 'Beaker volume: host=alan volume=volume1',
193
+ :size => 1000
194
+ ).and_return(mock_volume)
195
+ allow(mock_volume).to receive(:wait_for).and_return(nil)
179
196
 
180
- credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
181
- expect(credentials[:openstack_user_domain]).to eq('acme.com')
182
- expect(credentials[:openstack_project_domain]).to eq('R&D')
183
- end
197
+ # Perform the test!
198
+ mock_vm = double().as_null_object
199
+ allow(mock_volume).to receive(:id).and_return('Fake ID')
200
+ expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
201
+
202
+ mock_host = double().as_null_object
203
+ allow(mock_host).to receive(:name).and_return('alan')
204
+
205
+ openstack.provision_storage mock_host, mock_vm
206
+ end
184
207
 
208
+ it 'creates volumes with cinder v2' do
209
+ # Mock a volume
210
+ allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
211
+
212
+ # Stub out the call to create the client and hard code the return value
213
+ allow(openstack).to receive(:volume_client_create).and_return(nil)
214
+ client = double().as_null_object
215
+ openstack.instance_variable_set(:@volume_client, client)
216
+ allow(openstack).to receive(:get_volume_api_version).and_return(-1)
217
+
218
+ # Check the parameters are valid, correct 'name' parameter and correct size conversion
219
+ mock_volume = double().as_null_object
220
+ expect(client).to receive(:create).with(:name => 'volume1',
221
+ :description => 'Beaker volume: host=alan volume=volume1',
222
+ :size => 1000
223
+ ).and_return(mock_volume)
224
+ allow(mock_volume).to receive(:wait_for).and_return(nil)
225
+
226
+ # Perform the test!
227
+ mock_vm = double().as_null_object
228
+ allow(mock_volume).to receive(:id).and_return('Fake ID')
229
+ expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
230
+
231
+ mock_host = double().as_null_object
232
+ allow(mock_host).to receive(:name).and_return('alan')
233
+
234
+ openstack.provision_storage mock_host, mock_vm
235
+ end
236
+ end
185
237
  end
186
238
  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.15.0
4
+ version: 3.16.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-04-19 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -583,6 +583,7 @@ files:
583
583
  - docs/tutorials/installation.md
584
584
  - docs/tutorials/lets_write_a_test.md
585
585
  - docs/tutorials/quick_start_rake_tasks.md
586
+ - docs/tutorials/subcommands.md
586
587
  - docs/tutorials/test_run.md
587
588
  - docs/tutorials/test_suites.md
588
589
  - docs/tutorials/the_command_line.md