beaker 3.10.0 → 3.11.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
- ZmJlZmIyZTkxMzE4ZDg2YTRkNmU1YTkwZWE3YjM1N2JlZGFiM2E5Ng==
4
+ ZTYxNmZjMGE0NTRhOGYxZWQ0YjI2MWI3MjgwMmU3YmI2YzE5YzRkMg==
5
5
  data.tar.gz: !binary |-
6
- N2ExOTAxZWZhODM5NjcwYjVmYTk2NzcyNzEyMzU3MzNjMDE5ZDhmMw==
6
+ ODljNWVjNDQ1YzExNTU3Y2YwNWM3N2EwZTkwNWE2YTYxZGY1Mzg3YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmQwYTZlMDM0YTBlZWUzMWIyNzU5ZTE4NmMzMzllN2U2ZDA2OThmZWQ1NWNh
10
- MWFlMzUwZDg2N2FlYWQ1OWYwMGZlMmNlNzQ1ODdkNTU1NjRkMGFkZDFkZmQ5
11
- Nzc3YWI5YjE2ZDhlNGY4NDFjYzcxMjg0NmI1OTYwZjk2ODliZDc=
9
+ ZWFiZGJhNTI2M2VmYTBiNWRjODllYmVmYjViYWYwNGI1NDQyY2Q3YTA2OTlh
10
+ NDIyMzE4MDU3MDE3YTg0OTEzYzIyZDEwMjk3ODdlZWUwZTM0OTJkNzg1ZTA1
11
+ OTkwZWVhYjBmNzIwODFjNGZkOGNjNTUwYzkwNTFiZDQ0MTliZDM=
12
12
  data.tar.gz: !binary |-
13
- MmViMTUyYzY3NDY0YzczMGRiZDcwMTJkZTU0MWI3ZTcwY2U2NThiY2MwZTY3
14
- NWY0NmM4YzZkYzE1ZjkzODM1YzQwMWQzMTRjNWNhYzM3ODZkMDU4ODc3Yjk3
15
- NzE5NDY2Nzg2YjA0MWFkYzJjMmFjODM2MWFmYmVhYzBjNDVlYTg=
13
+ NjBjOGMzODJmMjVkZTZkOGU4MDVjMzkzNTI0MGUwNGVhNTU0NjViM2IzMjVk
14
+ NzNlMzVjNTUzOTBlMTNjZWE0MDdiOGQxZjJjZDJmMDcxZjg1ZTg1NTc0YzE2
15
+ NDNmNDQzYTFjZmYzOGRiOGM1ZTY3N2M1OWU5ZTZhNDQ5NzVhZjM=
data/Rakefile CHANGED
@@ -176,6 +176,14 @@ Run the base beaker acceptance tests
176
176
  beaker_test(:base)
177
177
  end
178
178
 
179
+ desc <<-EOS
180
+ Run the subcommand beaker acceptance tests
181
+ #{USAGE}
182
+ EOS
183
+ task :subcommands => 'gen_hosts' do
184
+ beaker_test(:subcommands)
185
+ end
186
+
179
187
  desc <<-EOS
180
188
  Run the hypervisor beaker acceptance tests
181
189
  #{USAGE}
@@ -0,0 +1,4 @@
1
+ {
2
+ :pre_suite => 'acceptance/pre_suite/subcommands/',
3
+ :tests => 'acceptance/tests/subcommands/'
4
+ }.merge(eval File.read('acceptance/config/acceptance-options.rb'))
@@ -44,8 +44,8 @@ end
44
44
 
45
45
  # Returns the contents of a named fixture file, to be found in `fixture_path`.
46
46
  def fixture_contents(fixture)
47
- fixture_file = File.join(fixture_path, "#{fixture}.txt")
48
- File.read(fixture_file)
47
+ fixture_file = Dir.entries(fixture_path).find { |e| /^#{fixture}$|#{fixture}\.[a-z]/ =~ e }
48
+ File.read("#{fixture_path}/#{fixture_file}")
49
49
  end
50
50
 
51
51
  # Create a file on `host` in the `remote_path` with file name `filename`,
@@ -5,3 +5,4 @@ Collection of pre-suites for SUT configuration before test execution.
5
5
  Options:
6
6
  * install PE
7
7
  * install FOSS Puppet
8
+ * install beaker itself on a SUT
@@ -0,0 +1,32 @@
1
+ test_name 'Install and configure Ruby 2.2.5 on the SUT' do
2
+
3
+ step 'Ensure that the default system is an el-based system' do
4
+ # The pre-suite currently only supports el systems, and we should
5
+ #fail early if the default platform is not a supported platform
6
+ assert(default.platform.variant == 'el',
7
+ "Expected the platform variant to be 'el', not #{default.platform.variant}")
8
+ end
9
+
10
+ step 'clean out current ruby and its dependencies' do
11
+ on default, 'yum remove ruby ruby-devel -y'
12
+ end
13
+
14
+ # These steps install git, openssl, and wget
15
+ step 'install development dependencies' do
16
+ on default, 'yum groupinstall "Development Tools" -y'
17
+ on default, 'yum install openssl-devel -y'
18
+ on default, 'yum install wget -y'
19
+ end
20
+
21
+ step 'download and install ruby 2.2.5' do
22
+ on default, 'wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.gz'
23
+ on default, 'tar xvfz ruby-2.2.5.tar.gz'
24
+ on default, 'cd ruby-2.2.5;./configure'
25
+ on default, 'cd ruby-2.2.5;make'
26
+ on default, 'cd ruby-2.2.5;make install'
27
+ end
28
+
29
+ step 'update gem on the SUT and install bundler' do
30
+ on default, 'gem update --system;gem install bundler'
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ test_name 'Install beaker and checkout branch if necessary' do
2
+
3
+ step 'Download the beaker git repo' do
4
+ on default, 'git clone https://github.com/puppetlabs/beaker.git /opt/beaker/'
5
+ end
6
+
7
+ step 'Detect if checking out branch for testing and checkout' do
8
+ if ENV['BEAKER_PULL_ID']
9
+ logger.notify "Pull Request detected, checking out PR branch"
10
+ on(default, 'cd /opt/beaker/;git -c core.askpass=true fetch --tags --progress https://github.com/puppetlabs/beaker.git +refs/pull/*:refs/remotes/origin/pr/*')
11
+ on(default, "cd /opt/beaker/;git merge origin/pr/#{ENV['BEAKER_PULL_ID']}/head --no-edit")
12
+ else
13
+ logger.notify 'No PR branch detected, building from master'
14
+ end
15
+ end
16
+
17
+ step 'Build the gem and install it on the local system' do
18
+ build_output = on(default, 'cd /opt/beaker/;gem build beaker.gemspec').stdout
19
+ version = build_output.match(/^ File: (.+)$/)[1]
20
+ on(default, "cd /opt/beaker/;gem install #{version} --no-rdoc --no-ri")
21
+ end
22
+ end
@@ -316,3 +316,17 @@ step "Ensure scp errors close the ssh connection" do
316
316
  on default, 'true'
317
317
  end
318
318
  end
319
+
320
+ step 'Ensure that a long 128+ character string with UTF-8 characters does not break net-ssh' do
321
+ long_string = 'a' * 128 + "\u06FF"
322
+ on(default, "mkdir /tmp/#{long_string}")
323
+ result = on(default, 'ls /tmp')
324
+ assert(result.stdout.include?(long_string), 'Error in folder creation with long string + UTF-8 characters')
325
+
326
+ # remove the folder
327
+ on(default, "rm -rf /tmp/#{long_string}")
328
+ result = on(default, 'ls /tmp')
329
+ assert(!result.stdout.include?(long_string), 'Error in folder deletion with long string + UTF-8 characters')
330
+
331
+ end
332
+
@@ -0,0 +1,47 @@
1
+ test_name 'use the init subcommand' do
2
+
3
+ def delete_root_folder_contents
4
+ on default, 'rm -rf /root/*'
5
+ end
6
+
7
+ step 'ensure that `beaker init` fails correctly when not provided a hypervisor' do
8
+ expect_failure('it should return a non-zero code when it fails') do
9
+ result = on(default, 'beaker init', :accept_all_exit_codes => true)
10
+ refute_equal(0, result.exit_code, '`beaker init` without a hypervisor argument should return a non-zero exit code')
11
+ end
12
+ end
13
+
14
+ step 'ensure that `beaker help init` works' do
15
+ result = on(default, 'beaker help init')
16
+ assert_equal(0, result.exit_code, '`beaker help init` should return a zero exit code')
17
+ end
18
+
19
+ step 'ensure that `beaker init` accepts both vmpooler and vagrant hypervisor arguments' do
20
+
21
+ ['vmpooler', 'vagrant'].each do |hypervisor|
22
+ result = on(default, "beaker init --hypervisor=#{hypervisor}")
23
+ assert_match(/Writing default host config/, result.stdout)
24
+ assert_equal(0, result.exit_code, "`beaker init --hypervisor=#{hypervisor}` should return a zero exit code")
25
+ step 'ensure that the Rakefile is present' do
26
+ on(default, '[ -e "Rakefile" ]')
27
+ end
28
+ delete_root_folder_contents
29
+ end
30
+ end
31
+
32
+
33
+ step 'ensure that a Rakefile is not overwritten if it does exist prior' do
34
+ delete_root_folder_contents
35
+ on(default, "beaker init --hypervisor=vmpooler")
36
+ prepended_rakefile = on(default, 'cat Rakefile').stdout
37
+ delete_root_folder_contents
38
+ on(default, 'echo "require \'tempfile\'" >> Rakefile')
39
+ on(default, 'beaker init --hypervisor=vmpooler', :accept_all_exit_codes => true)
40
+ rakefile = on(default, 'cat Rakefile')
41
+
42
+ # Assert that the Rakefile contents includes the original and inserted requirements
43
+ assert(result.stdout.include?(prepended_rakefile), 'Rakefile should not contain prepended require')
44
+ assert(result.stdout.include?("require 'tempfile'"), 'Rakefile should not contain prepended require')
45
+ end
46
+ end
47
+
data/beaker.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency 'minitar', '~> 0.5.4'
35
35
 
36
36
  s.add_runtime_dependency 'hocon', '~> 1.0'
37
- s.add_runtime_dependency 'net-ssh', '3.3.0.beta1'
37
+ s.add_runtime_dependency 'net-ssh', '~> 4.0'
38
38
  s.add_runtime_dependency 'net-scp', '~> 1.2'
39
39
  s.add_runtime_dependency 'inifile', '~> 2.0'
40
40
  ## inifile: keep <3.0, breaks puppet_helpers.rb:puppet_conf_for when updated
@@ -23,7 +23,7 @@ In order to have Beaker support a masterless Puppet setup, you have to do a few
23
23
 
24
24
  ## What is Beaker Doing by Default?
25
25
 
26
- Be default (without the masterless flag), when someone calls for a host of a particular role, using the `Beaker::DSL::Roles` module's methods (ie. `master`, `dashboard`, etc), Beaker checks to verify that a host was given with that role.
26
+ By default (without the masterless flag), when someone calls for a host of a particular role, using the `Beaker::DSL::Roles` module's methods (ie. `master`, `dashboard`, etc), Beaker checks to verify that a host was given with that role.
27
27
 
28
28
  If no host was given with this role, then Beaker throws a `DSL::Outcomes::FailTest` Error, which causes that test case to fail.
29
29
 
@@ -123,3 +123,32 @@ user their own pool. It's used in allocating new IPs. It's an options
123
123
  parameter in the CONFIG section of the host file:
124
124
 
125
125
  floating_ip_pool: 'my_pool_name'
126
+
127
+ ### Volumes
128
+
129
+ Attaching volumes to a VM is supported via the Cinder service. All versions are transparently
130
+ supported to cater for differences in the APIs. To create and attach volumes simply add hash
131
+ called 'volumes' to a host in the HOSTS section. Each key is the name given to the volume upon
132
+ resource creation. The value is a hash with a single integer parameter 'size' which defines the
133
+ volume size in MB.
134
+
135
+ **Example OpenStack hosts file with volumes**
136
+
137
+ HOSTS:
138
+ ceph:
139
+ roles:
140
+ - master
141
+ platform: ubuntu-16.04-amd64
142
+ hypervisor: openstack
143
+ flavor: m1.large
144
+ image: xenial-server-cloudimg-amd64-scsi
145
+ user: ubuntu
146
+ volumes:
147
+ osd0:
148
+ size: 10000
149
+ osd1:
150
+ size: 10000
151
+ osd2:
152
+ size: 10000
153
+ journal:
154
+ size: 1000
@@ -29,7 +29,7 @@ what files you might need from your SUTs, and exploration might be necessary.
29
29
 
30
30
  Note that where you decide to use this option will affect its precedence. You
31
31
  can learn more about this in our
32
- [argument processing & precedence doc](../topics/argument_processing_and_precedence.md).
32
+ [argument processing & precedence doc](../concepts/argument_processing_and_precedence.md).
33
33
 
34
34
  ### Command-Line Option
35
35
 
@@ -54,11 +54,11 @@ You can also provide a value for this option wherever you can provide a value
54
54
  that gets merged into beaker's global options hash. The two ways to do this are
55
55
  to provide it in a local options file, or in the global `CONFIG` section of your
56
56
  hosts file. To learn more about how to set these options, check out the
57
- [Options File Values](../topics/argument_processing_and_precedence.md#options-file-values)
57
+ [Options File Values](../concepts/argument_processing_and_precedence.md#options-file-values)
58
58
  and the
59
- [`CONFIG` Section of a Hosts File](../topics/argument_processing_and_precedence.md#config-section-of-hosts-file)
59
+ [`CONFIG` Section of a Hosts File](../concepts/argument_processing_and_precedence.md#config-section-of-hosts-file)
60
60
  sections of the
61
- [argument processing & precedence doc](../topics/argument_processing_and_precedence.md).
61
+ [argument processing & precedence doc](../concepts/argument_processing_and_precedence.md).
62
62
 
63
63
  Either way, the underlying property name that you will have to set if you use
64
64
  these options is `:preserve_hosts`.
@@ -94,5 +94,5 @@ symlink, as mentioned at the beginning of this section.
94
94
  For subsequent runs, if you want to set something, you'll have to pay attention
95
95
  to the precedence of your arguments, to be sure that you are overriding what is
96
96
  set in the preserved hosts file. Checkout the
97
- [argument processing & precedence doc](../topics/argument_processing_and_precedence.md)
97
+ [argument processing & precedence doc](../concepts/argument_processing_and_precedence.md)
98
98
  for more details on the precedence order of options parsing.
@@ -676,7 +676,10 @@ module Beaker
676
676
  def sleep_until_puppetdb_started(host, nonssl_port = nil, ssl_port = nil)
677
677
  nonssl_port = options[:puppetdb_port_nonssl] if nonssl_port.nil?
678
678
  ssl_port = options[:puppetdb_port_ssl] if ssl_port.nil?
679
- curl_with_retries("start puppetdb", host, "http://localhost:#{nonssl_port}", 0, 120)
679
+ endpoint = 'status/v1/services/puppetdb-status'
680
+ retry_on(host,
681
+ "curl -m 1 http://localhost:#{nonssl_port}/#{endpoint} | grep '\"state\":\"running\"'",
682
+ {:max_retries => 120})
680
683
  curl_with_retries("start puppetdb (ssl)",
681
684
  host, "https://#{host.node_name}:#{ssl_port}", [35, 60])
682
685
  end
@@ -754,14 +757,15 @@ module Beaker
754
757
  end
755
758
 
756
759
  #wait for a given host to appear in the dashboard
760
+ # @deprecated this method should be removed in the next release since we don't believe the check is necessary.
757
761
  def wait_for_host_in_dashboard(host)
762
+
758
763
  hostname = host.node_name
759
- if host['platform'] =~ /aix/ then
760
- curl_opts = '--tlsv1 -I'
761
- else
762
- curl_opts = '--tlsv1 -k -I'
763
- end
764
- retry_on(dashboard, "! curl #{curl_opts} https://#{dashboard}/nodes/#{hostname} | grep '404 Not Found'")
764
+ hostcert = dashboard.puppet['hostcert']
765
+ key = dashboard.puppet['hostprivkey']
766
+ cacert = dashboard.puppet['localcacert']
767
+ retry_on(dashboard, "curl --cert #{hostcert} --key #{key} --cacert #{cacert}\
768
+ https://#{dashboard}:4433/classifier-api/v1/nodes | grep '\"name\":\"#{hostname}\"'")
765
769
  end
766
770
 
767
771
  # Ensure the host has requested a cert, then sign it
@@ -409,10 +409,14 @@ module Beaker
409
409
  def enable_root_login host, opts
410
410
  logger = opts[:logger]
411
411
  block_on host do |host|
412
- logger.debug "Update /etc/ssh/sshd_config to allow root login"
412
+ logger.debug "Update sshd_config to allow root login"
413
413
  if host['platform'] =~ /osx/
414
- host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /etc/sshd_config"))
415
- host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /etc/sshd_config"))
414
+ # If osx > 10.10 use '/private/etc/ssh/sshd_config', else use '/etc/sshd_config'
415
+ ssh_config_file = '/private/etc/ssh/sshd_config'
416
+ ssh_config_file = '/etc/sshd_config' if host['platform'] =~ /^osx-10\.(9|10)/i
417
+
418
+ host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' #{ssh_config_file}"))
419
+ host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' #{ssh_config_file}"))
416
420
  elsif host['platform'] =~ /freebsd/
417
421
  host.exec(Command.new("sudo sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true} )
418
422
  elsif host['platform'] =~ /openbsd/
@@ -811,7 +811,18 @@ module Beaker
811
811
  ssh_string = public_key()
812
812
  region.key_pairs.import(pair_name, ssh_string)
813
813
  kp = region.key_pairs[pair_name]
814
- if kp.exists?
814
+
815
+ exists = false
816
+ for tries in 1..5
817
+ if kp.exists?
818
+ exists = true
819
+ break
820
+ end
821
+ @logger.debug("AWS key pair doesn't appear to exist yet, sleeping before retry ")
822
+ backoff_sleep(tries)
823
+ end
824
+
825
+ if exists
815
826
  @logger.debug("aws-sdk: key pair #{pair_name} imported")
816
827
  kp
817
828
  else
@@ -122,6 +122,22 @@ module Beaker
122
122
  end
123
123
  end
124
124
 
125
+ # Get a hash of volumes from the host
126
+ def get_volumes host
127
+ return host['volumes'] if host['volumes']
128
+ {}
129
+ end
130
+
131
+ # Get the API version
132
+ def get_volume_api_version
133
+ case @volume_client
134
+ when Fog::Volume::OpenStack::V1
135
+ 1
136
+ else
137
+ -1
138
+ end
139
+ end
140
+
125
141
  # Create and attach dynamic volumes
126
142
  #
127
143
  # Creates an array of volumes and attaches them to the current host.
@@ -133,23 +149,34 @@ module Beaker
133
149
  # @param host [Hash] thet current host defined in the nodeset
134
150
  # @param vm [Fog::Compute::OpenStack::Server] the server to attach to
135
151
  def provision_storage host, vm
136
- if host['volumes']
152
+ volumes = get_volumes(host)
153
+ if !volumes.empty?
137
154
  # Lazily create the volume client if needed
138
155
  volume_client_create
139
- host['volumes'].keys.each_with_index do |volume, index|
156
+ volumes.keys.each_with_index do |volume, index|
140
157
  @logger.debug "Creating volume #{volume} for OpenStack host #{host.name}"
141
158
 
142
159
  # The node defintion file defines volume sizes in MB (due to precedent
143
160
  # with the vagrant virtualbox implementation) however OpenStack requires
144
161
  # this translating into GB
145
- openstack_size = host['volumes'][volume]['size'].to_i / 1000
162
+ openstack_size = volumes[volume]['size'].to_i / 1000
163
+
164
+ # Set up the volume creation arguments
165
+ args = {
166
+ :size => openstack_size,
167
+ :description => "Beaker volume: host=#{host.name} volume=#{volume}",
168
+ }
169
+
170
+ # Between version 1 and subsequent versions the API was updated to
171
+ # rename 'display_name' to just 'name' for better consistency
172
+ if get_volume_api_version == 1
173
+ args[:display_name] = volume
174
+ else
175
+ args[:name] = volume
176
+ end
146
177
 
147
178
  # Create the volume and wait for it to become available
148
- vol = @volume_client.volumes.create(
149
- :size => openstack_size,
150
- :display_name => volume,
151
- :description => "Beaker volume: host=#{host.name} volume=#{volume}",
152
- )
179
+ vol = @volume_client.volumes.create(**args)
153
180
  vol.wait_for { ready? }
154
181
 
155
182
  # Fog needs a device name to attach as, so invent one. The guest
@@ -309,7 +336,24 @@ module Beaker
309
336
  @options[:openstack_keyname]
310
337
  else
311
338
  @logger.debug "Generate a new rsa key"
312
- key = OpenSSL::PKey::RSA.new 2048
339
+
340
+ # There is apparently an error that can occur when generating RSA keys, probably
341
+ # due to some timing issue, probably similar to the issue described here:
342
+ # https://github.com/negativecode/vines/issues/34
343
+ # In order to mitigate this error, we will simply try again up to three times, and
344
+ # then fail if we continue to error out.
345
+ begin
346
+ retries ||= 0
347
+ key = OpenSSL::PKey::RSA.new 2048
348
+ rescue OpenSSL::PKey::RSAError => e
349
+ retries += 1
350
+ if retries > 2
351
+ @logger.notify "error generating RSA key #{retries} times, exiting"
352
+ raise e
353
+ end
354
+ retry
355
+ end
356
+
313
357
  type = key.ssh_type
314
358
  data = [ key.to_blob ].pack('m0')
315
359
  @logger.debug "Creating Openstack keypair for public key '#{type} #{data}'"
@@ -8,6 +8,13 @@ class Beaker::VagrantLibvirt < Beaker::Vagrant
8
8
  attr_reader :memory
9
9
  end
10
10
 
11
+ # Return a random mac address with colons
12
+ #
13
+ # @return [String] a random mac address
14
+ def randmac
15
+ "08:00:27:" + (1..3).map{"%0.2X"%rand(256)}.join(':')
16
+ end
17
+
11
18
  def provision(provider = 'libvirt')
12
19
  super
13
20
  end
@@ -1,5 +1,7 @@
1
1
  require 'beaker-hostgenerator'
2
2
 
3
+ CONFIG_DIR = '.beaker/acceptance/config'
4
+
3
5
  VAGRANT = ['ubuntu1404-64default.mdcal-ubuntu1404-64af', '--hypervisor=vagrant',
4
6
  '--global-config={box_url=https://vagrantcloud.com/puppetlabs/boxes/ubuntu-14.04-64-nocm,box=puppetlabs/ubuntu-14.04-64-nocm}']
5
7
 
@@ -9,17 +11,17 @@ namespace :beaker_quickstart do
9
11
 
10
12
  desc 'Generate Default Beaker Host Config File, valid options are: vmpooler or vagrant.'
11
13
  task :gen_hosts, [:hypervisor] do |t, args|
12
- hosts_file = "acceptance/config/default_#{args[:hypervisor]}_hosts.yaml"
14
+ hosts_file = "#{CONFIG_DIR}/default_#{args[:hypervisor]}_hosts.yaml"
13
15
  if args[:hypervisor] == 'vagrant'
14
16
  cli = VAGRANT
15
17
  elsif args[:hypervisor] == 'vmpooler'
16
18
  cli = VMPOOLER
17
19
  else
18
20
  puts "No hypervisor provided, defaulting to vagrant."
19
- hosts_file = "acceptance/config/default_vagrant_hosts.yaml"
21
+ hosts_file = "#{CONFIG_DIR}/default_vagrant_hosts.yaml"
20
22
  cli = VAGRANT
21
23
  end
22
- FileUtils.mkdir_p('acceptance/config') # -p ignores when dir already exists
24
+ FileUtils.mkdir_p("#{CONFIG_DIR}") # -p creates intermediate directories as required
23
25
  puts "About to run - beaker-hostgenerator #{cli.to_s.delete!('[]"')}"
24
26
  if !File.exist?(hosts_file) then
25
27
  puts "Writing default host config to file - #{hosts_file}"
@@ -90,4 +92,4 @@ def beaker_command(system_args)
90
92
  cmd_parts << "--pre-suite #{system_args[:pre_suite]}"
91
93
  cmd_parts << "--tests #{system_args[:tests]}"
92
94
  cmd_parts.flatten.join(" ")
93
- end
95
+ end
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.10.0'
3
+ STRING = '3.11.0'
4
4
  end
5
5
  end
@@ -1096,14 +1096,14 @@ describe ClassMixedWithDSLHelpers do
1096
1096
 
1097
1097
  it 'uses the default ports if none given' do
1098
1098
  host = hosts[0]
1099
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8080/, anything(), anything() ).once.ordered
1099
+ expect( subject ).to receive( :retry_on ).with( anything(), /8080/, anything() ).once.ordered
1100
1100
  expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1101
1101
  subject.sleep_until_puppetdb_started( host )
1102
1102
  end
1103
1103
 
1104
1104
  it 'allows setting the nonssl_port' do
1105
1105
  host = hosts[0]
1106
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8084/, anything(), anything() ).once.ordered
1106
+ expect( subject ).to receive( :retry_on ).with( anything(), /8084/, anything() ).once.ordered
1107
1107
  expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1108
1108
  subject.sleep_until_puppetdb_started( host, 8084 )
1109
1109
 
@@ -1111,7 +1111,7 @@ describe ClassMixedWithDSLHelpers do
1111
1111
 
1112
1112
  it 'allows setting the ssl_port' do
1113
1113
  host = hosts[0]
1114
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8080/, anything(), anything() ).once.ordered
1114
+ expect( subject ).to receive( :retry_on ).with( anything(), /8080/, anything() ).once.ordered
1115
1115
  expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8085/, anything() ).once.ordered
1116
1116
  subject.sleep_until_puppetdb_started( host, nil, 8085 )
1117
1117
  end
@@ -51,11 +51,21 @@ describe Beaker do
51
51
  "sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""
52
52
  ], true
53
53
 
54
- it_should_behave_like 'enables_root_login', 'osx', [
54
+ it_should_behave_like 'enables_root_login', 'osx-10.10', [
55
55
  "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /etc/sshd_config",
56
56
  "sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /etc/sshd_config"
57
57
  ]
58
58
 
59
+ it_should_behave_like 'enables_root_login', 'osx-10.11', [
60
+ "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
61
+ "sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config"
62
+ ]
63
+
64
+ it_should_behave_like 'enables_root_login', 'osx-10.12', [
65
+ "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
66
+ "sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config"
67
+ ]
68
+
59
69
  # Solaris
60
70
  it_should_behave_like 'enables_root_login', 'solaris-10', [
61
71
  "sudo -E svcadm restart network/ssh",
@@ -538,8 +548,16 @@ describe Beaker do
538
548
  context "set_env" do
539
549
  subject { dummy_class.new }
540
550
 
541
- it "permits user environments on an OS X host" do
542
- test_host_ssh_permit_user_environment('osx')
551
+ it "permits user environments on an OS X 10.10 host" do
552
+ test_host_ssh_permit_user_environment('osx-10.10')
553
+ end
554
+
555
+ it "permits user environments on an OS X 10.11 host" do
556
+ test_host_ssh_permit_user_environment('osx-10.11')
557
+ end
558
+
559
+ it "permits user environments on an OS X 10.12 host" do
560
+ test_host_ssh_permit_user_environment('osx-10.12')
543
561
  end
544
562
 
545
563
  it "permits user environments on an ssh-based linux host" do
@@ -571,8 +589,16 @@ describe Beaker do
571
589
  end
572
590
 
573
591
 
574
- it "sets user ssh environment on an OS X host" do
575
- test_host_ssh_set_user_environment('osx')
592
+ it "sets user ssh environment on an OS X 10.10 host" do
593
+ test_host_ssh_set_user_environment('osx-10.10')
594
+ end
595
+
596
+ it "sets user ssh environment on an OS X 10.11 host" do
597
+ test_host_ssh_set_user_environment('osx-10.11')
598
+ end
599
+
600
+ it "sets user ssh environment on an OS X 10.12 host" do
601
+ test_host_ssh_set_user_environment('osx-10.12')
576
602
  end
577
603
 
578
604
  it "sets user ssh environment on an ssh-based linux host" do
@@ -839,12 +839,13 @@ module Beaker
839
839
  end
840
840
 
841
841
  it 'imports the key given from public_key' do
842
- expect(pair).to receive(:exists?).and_return (true)
842
+ expect(pair).to receive(:exists?).and_return(true)
843
843
  aws.create_new_key_pair(region, pair_name)
844
844
  end
845
845
 
846
846
  it 'raises an exception if subsequent keypair check is false' do
847
- expect(pair).to receive(:exists?).and_return (false)
847
+ expect(pair).to receive(:exists?).and_return(false).exactly(5).times
848
+ expect(aws).to receive(:backoff_sleep).exactly(5).times
848
849
  expect { aws.create_new_key_pair(region, pair_name) }.
849
850
  to raise_error(RuntimeError,
850
851
  "AWS key pair #{pair_name} can not be queried, even after import")
@@ -104,5 +104,57 @@ module Beaker
104
104
  (1..3).each { openstack.get_ip }
105
105
  end
106
106
 
107
+ it 'creates volumes with cinder v1' do
108
+ # Mock a volume
109
+ allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
110
+
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)
116
+
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)
121
+
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')
126
+
127
+ mock_host = double().as_null_object
128
+ allow(mock_host).to receive(:name).and_return('alan')
129
+
130
+ openstack.provision_storage mock_host, mock_vm
131
+ end
132
+
133
+ it 'creates volumes with cinder v2' do
134
+ # Mock a volume
135
+ allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
136
+
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)
142
+
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)
147
+
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')
152
+
153
+ mock_host = double().as_null_object
154
+ allow(mock_host).to receive(:name).and_return('alan')
155
+
156
+ openstack.provision_storage mock_host, mock_vm
157
+ end
158
+
107
159
  end
108
160
  end
@@ -29,7 +29,6 @@ describe Beaker::VagrantLibvirt do
29
29
  before(:each) do
30
30
  FakeFS.activate!
31
31
  path = vagrant.instance_variable_get( :@vagrant_path )
32
- allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
33
32
 
34
33
  vagrant.make_vfile( @hosts, options )
35
34
  @vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
@@ -53,5 +52,10 @@ describe Beaker::VagrantLibvirt do
53
52
  expect( @vagrantfile.split("\n").map(&:strip) )
54
53
  .to include("node.uri = 'qemu+ssh://root@host/system'")
55
54
  end
55
+
56
+ it "has a mac address in the proper format" do
57
+ expect( @vagrantfile.split("\n").map(&:strip) )
58
+ .to include(/:mac => "08:00:27:\h{2}:\h{2}:\h{2}"/)
59
+ end
56
60
  end
57
61
  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.10.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: 3.3.0.beta1
145
+ version: '4.0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: 3.3.0.beta1
152
+ version: '4.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: net-scp
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -416,13 +416,14 @@ files:
416
416
  - acceptance/config/puppetgit/acceptance-options.rb
417
417
  - acceptance/config/puppetpe/acceptance-options.rb
418
418
  - acceptance/config/puppetpkg/acceptance-options.rb
419
+ - acceptance/config/subcommands/acceptance-options.rb
419
420
  - acceptance/fixtures/README.md
420
421
  - acceptance/fixtures/files/failing_shell_script.txt
421
422
  - acceptance/fixtures/files/retry_script.txt
422
423
  - acceptance/fixtures/files/shell_script_with_output.txt
423
424
  - acceptance/fixtures/files/simple_text_file.txt
424
- - acceptance/fixtures/files/sles-11-x86_64.repo.txt
425
- - acceptance/fixtures/files/sles-12-x86_64.repo.txt
425
+ - acceptance/fixtures/files/sles-11-x86_64.repo
426
+ - acceptance/fixtures/files/sles-12-x86_64.repo
426
427
  - acceptance/fixtures/module/Gemfile
427
428
  - acceptance/fixtures/module/README.md
428
429
  - acceptance/fixtures/module/Rakefile
@@ -476,6 +477,8 @@ files:
476
477
  - acceptance/pre_suite/puppet_gem/install.rb
477
478
  - acceptance/pre_suite/puppet_git/install.rb
478
479
  - acceptance/pre_suite/puppet_pkg/install.rb
480
+ - acceptance/pre_suite/subcommands/05_install_ruby.rb
481
+ - acceptance/pre_suite/subcommands/08_install_beaker.rb
479
482
  - acceptance/tests/base/README.md
480
483
  - acceptance/tests/base/dsl/helpers/configuration_test.rb
481
484
  - acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb
@@ -520,6 +523,7 @@ files:
520
523
  - acceptance/tests/puppet/stub_host.rb
521
524
  - acceptance/tests/puppet/web_helpers_test.rb
522
525
  - acceptance/tests/puppet/with_puppet_running_on.rb
526
+ - acceptance/tests/subcommands/init.rb
523
527
  - beaker.gemspec
524
528
  - bin/beaker
525
529
  - docs/README.md