beaker 2.52.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +27034 -2
  3. data/acceptance/tests/base/external_resources_test.rb +7 -25
  4. data/acceptance/tests/base/host/host_test.rb +106 -0
  5. data/beaker.gemspec +13 -12
  6. data/docs/concepts/shared_options_for_executing_beaker_commands.md +1 -1
  7. data/docs/how_to/hypervisors/openstack.md +9 -0
  8. data/docs/how_to/test_arbitrary_beaker_versions.md +46 -0
  9. data/docs/how_to/upgrade_from_2_to_3.md +76 -0
  10. data/docs/tutorials/README.md +82 -0
  11. data/lib/beaker/dsl.rb +0 -2
  12. data/lib/beaker/dsl/helpers/puppet_helpers.rb +2 -1
  13. data/lib/beaker/dsl/install_utils/windows_utils.rb +27 -1
  14. data/lib/beaker/host.rb +16 -1
  15. data/lib/beaker/host/unix/exec.rb +4 -4
  16. data/lib/beaker/host/unix/pkg.rb +3 -2
  17. data/lib/beaker/host_prebuilt_steps.rb +2 -46
  18. data/lib/beaker/hypervisor.rb +1 -1
  19. data/lib/beaker/hypervisor/openstack.rb +19 -34
  20. data/lib/beaker/options/presets.rb +1 -5
  21. data/lib/beaker/version.rb +1 -1
  22. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +18 -4
  23. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +26 -4
  24. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +47 -1
  25. data/spec/beaker/host/unix/pkg_spec.rb +1 -0
  26. data/spec/beaker/host_prebuilt_steps_spec.rb +2 -33
  27. data/spec/beaker/host_spec.rb +14 -2
  28. data/spec/beaker/hypervisor/hypervisor_spec.rb +0 -15
  29. data/spec/beaker/hypervisor/openstack_spec.rb +5 -0
  30. data/spec/helpers.rb +1 -0
  31. metadata +15 -105
  32. data/lib/beaker/hypervisor/aixer.rb +0 -48
  33. data/lib/beaker/hypervisor/solaris.rb +0 -59
  34. data/spec/beaker/hypervisor/aixer_spec.rb +0 -34
  35. data/spec/beaker/hypervisor/solaris_spec.rb +0 -40
@@ -1,34 +1,16 @@
1
1
  test_name 'External Resources Test' do
2
- step 'Verify EPEL is correct' do
3
- def epel_url_test(el_version, arch, pkg_key)
4
- url = "#{@options[:epel_url]}/#{el_version}/#{arch}/#{@options[pkg_key]}"
2
+ step 'Verify EPEL resources are up and available' do
3
+ def epel_url_test(el_version)
4
+ url = "#{options[:epel_url]}/epel-release-latest-#{el_version}.noarch.rpm"
5
5
  curl_headers_result = default.exec(Command.new("curl -I #{url}"))
6
6
  assert_match(/200 OK/, curl_headers_result.stdout, "EPEL #{el_version} should be reachable")
7
7
  end
8
8
 
9
- step 'arch is i386' do
10
- @arch = 'i386'
11
- # epel-7 does not provide packages for i386
12
- step 'EPEL 6' do
13
- epel_url_test(6, @arch, :epel_6_pkg)
14
- end
15
- step 'EPEL 5' do
16
- epel_url_test(5, @arch, :epel_5_pkg)
9
+ step 'Verify el_version numbers 5,6,7 are found on the epel resource' do
10
+ [5,6,7].each do |el_version|
11
+ epel_url_test(el_version)
17
12
  end
18
13
  end
19
14
 
20
- step 'arch is x86_64' do
21
- @arch = 'x86_64'
22
- step 'EPEL 7' do
23
- # note: interpolation gets around URL change for epel 7
24
- epel_url_test(7, "#{@arch}/e", :epel_7_pkg)
25
- end
26
- step 'EPEL 6' do
27
- epel_url_test(6, @arch, :epel_6_pkg)
28
- end
29
- step 'EPEL 5' do
30
- epel_url_test(5, @arch, :epel_5_pkg)
31
- end
32
- end
33
15
  end
34
- end
16
+ end
@@ -27,6 +27,112 @@ hosts.each do |host|
27
27
  end
28
28
  end
29
29
 
30
+ step "#get_env_var : can get a specific environment variable"
31
+ hosts.each do |host|
32
+ env_prefix = 'BEAKER' + SecureRandom.hex(4).upcase
33
+ env_param1 = "#{env_prefix}_p1"
34
+ env_value1 = "#{env_prefix}_v1"
35
+
36
+ host.clear_env_var(env_param1)
37
+ host.add_env_var(env_param1,env_value1)
38
+
39
+ val = host.get_env_var(env_param1)
40
+
41
+ assert_match(/^#{env_param1}=#{env_value1}$/, val, "get_env_var can get a specific environment variable")
42
+ end
43
+
44
+ step "#get_env_var : should not match a partial env key name"
45
+ hosts.each do |host|
46
+ env_id = 'BEAKER' + SecureRandom.hex(4).upcase
47
+ # Used as a prefix
48
+ env_param1 = "#{env_id}_pre"
49
+ env_value1 = "#{env_id}_pre"
50
+ # Used as a suffix
51
+ env_param2 = "suf_#{env_id}"
52
+ env_value2 = "suf_#{env_id}"
53
+ # Used as a infix
54
+ env_param3 = "in_#{env_id}_in"
55
+ env_value3 = "in_#{env_id}_in"
56
+
57
+ host.clear_env_var(env_param1)
58
+ host.clear_env_var(env_param2)
59
+ host.clear_env_var(env_param3)
60
+ host.add_env_var(env_param1,env_value1)
61
+ host.add_env_var(env_param1,env_value2)
62
+ host.add_env_var(env_param1,env_value3)
63
+
64
+ val = host.get_env_var(env_id)
65
+ assert('' == val,'get_env_var should not match a partial env key name')
66
+ end
67
+
68
+ step "#get_env_var : should not return a match from a key\'s value"
69
+ hosts.each do |host|
70
+ env_prefix = 'BEAKER' + SecureRandom.hex(4).upcase
71
+ env_param1 = "#{env_prefix}_p1"
72
+ env_value1 = "#{env_prefix}_v1"
73
+
74
+ host.clear_env_var(env_param1)
75
+ host.add_env_var(env_param1,env_value1)
76
+
77
+ val = host.get_env_var(env_value1)
78
+ assert('' == val,'get_env_var should not return a match from a key\'s value')
79
+ end
80
+
81
+ step "#clear_env_var : should only remove the specified key"
82
+ hosts.each do |host|
83
+ # Note - Must depend on `SecureRandom.hex(4)` creating a unique key as unable to depend on the function under test `clear_env_var`
84
+ env_id = 'BEAKER' + SecureRandom.hex(4).upcase
85
+ # Use env_id as a suffix
86
+ env_param1 = "p1_#{env_id}"
87
+ env_value1 = "v1_#{env_id}"
88
+ # Use env_id as a prefix
89
+ env_param2 = "#{env_id}_p2"
90
+ env_value2 = "#{env_id}_v2"
91
+ # Use env_id a key to delete
92
+ env_param3 = "#{env_id}"
93
+ env_value3 = "#{env_id}"
94
+
95
+ host.add_env_var(env_param1,env_value1)
96
+ host.add_env_var(env_param2,env_value2)
97
+ host.add_env_var(env_param3,env_value3)
98
+
99
+ host.clear_env_var(env_param3)
100
+
101
+ val = host.get_env_var(env_param1)
102
+ assert_match(/^#{env_param1}=#{env_value1}$/, val, "#{env_param1} should exist after calling clear_env_var")
103
+ val = host.get_env_var(env_param2)
104
+ assert_match(/^#{env_param2}=#{env_value2}$/, val, "#{env_param2} should exist after calling clear_env_var")
105
+ val = host.get_env_var(env_param3)
106
+ assert('' == val,"#{env_param3} should not exist after calling clear_env_var")
107
+ end
108
+
109
+ step "#add_env_var : can add a unique environment variable"
110
+ hosts.each do |host|
111
+ env_id = 'BEAKER' + SecureRandom.hex(4).upcase
112
+ env_param1 = "#{env_id}"
113
+ env_value1 = "#{env_id}"
114
+ # Use env_id as a prefix
115
+ env_param2 = "#{env_id}_pre"
116
+ env_value2 = "#{env_id}_pre"
117
+ # Use env_id as a suffix
118
+ env_param3 = "suf_#{env_id}"
119
+ env_value3 = "suf_#{env_id}"
120
+
121
+ host.clear_env_var(env_param1)
122
+ host.clear_env_var(env_param2)
123
+ host.clear_env_var(env_param3)
124
+ host.add_env_var(env_param1,env_value1)
125
+ host.add_env_var(env_param2,env_value2)
126
+ host.add_env_var(env_param3,env_value3)
127
+
128
+ val = host.get_env_var(env_param1)
129
+ assert_match(/^#{env_param1}=#{env_value1}$/, val, "#{env_param1} should exist")
130
+ val = host.get_env_var(env_param2)
131
+ assert_match(/^#{env_param2}=#{env_value2}$/, val, "#{env_param2} should exist")
132
+ val = host.get_env_var(env_param3)
133
+ assert_match(/^#{env_param3}=#{env_value3}$/, val, "#{env_param3} should exist")
134
+ end
135
+
30
136
  step "#add_env_var : can add an environment variable"
31
137
  hosts.each do |host|
32
138
  host.clear_env_var("test")
data/beaker.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency 'rspec', '~> 3.0'
22
22
  s.add_development_dependency 'rspec-its'
23
23
  s.add_development_dependency 'fakefs', '~> 0.6'
24
- s.add_development_dependency 'rake', '~> 10.1'
24
+ s.add_development_dependency 'rake', '~> 11.2'
25
25
  s.add_development_dependency 'simplecov'
26
26
  s.add_development_dependency 'pry', '~> 0.10'
27
27
 
@@ -31,34 +31,35 @@ Gem::Specification.new do |s|
31
31
  # Run time dependencies
32
32
  s.add_runtime_dependency 'minitest', '~> 5.4'
33
33
  s.add_runtime_dependency 'json', '~> 1.8'
34
+ ## json: will stay <2.0 while aws-sdk-v1 is in use
35
+ ## aws-sdk-2 doesn't require json, so we can give this up when we move
36
+
34
37
  s.add_runtime_dependency 'hocon', '~> 1.0'
35
- s.add_runtime_dependency 'net-ssh', '~> 2.9'
38
+ s.add_runtime_dependency 'net-ssh', '~> 3.2'
36
39
  s.add_runtime_dependency 'net-scp', '~> 1.2'
37
40
  s.add_runtime_dependency 'inifile', '~> 2.0'
41
+ ## inifile: keep <3.0, breaks puppet_helpers.rb:puppet_conf_for when updated
42
+ ## will need to fix that to upgrade this gem
43
+ ## indicating test from puppet acceptance:
44
+ ## tests/security/cve-2013-1652_improper_query_params.rb
45
+
38
46
  s.add_runtime_dependency 'rsync', '~> 1.0.9'
39
47
  s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
40
48
  s.add_runtime_dependency 'in-parallel', '~> 0.1'
41
49
 
42
50
  # Run time dependencies that are Beaker libraries
43
- s.add_runtime_dependency 'beaker-answers', '~> 0.0'
44
51
  s.add_runtime_dependency 'stringify-hash', '~> 0.0'
45
52
  s.add_runtime_dependency 'beaker-hiera', '~> 0.0'
46
- s.add_runtime_dependency 'beaker-pe', '~> 0.0'
47
53
  s.add_runtime_dependency 'beaker-hostgenerator'
48
54
 
49
55
  # Optional provisioner specific support
50
- s.add_runtime_dependency 'rbvmomi', ['~> 1.8', '< 1.9.0']
56
+ s.add_runtime_dependency 'rbvmomi', '~> 1.9'
51
57
  s.add_runtime_dependency 'fission', '~> 0.4'
52
- s.add_runtime_dependency 'google-api-client', ['~> 0.8', '< 0.9.5'] # dropped ruby 1.9 rupport in 0.9.5
58
+ s.add_runtime_dependency 'google-api-client', '~> 0.9'
53
59
  s.add_runtime_dependency 'aws-sdk-v1', '~> 1.57'
54
60
  s.add_runtime_dependency 'docker-api'
55
- s.add_runtime_dependency 'mime-types', '~> 2.99' if RUBY_VERSION < '2.0' # dropped ruby 1.9 rupport in 3.0
56
- s.add_runtime_dependency 'fog-google', '~> 0.0.9' # dropped ruby 1.9 support in 0.1
57
- s.add_runtime_dependency 'fog', ['~> 1.25', '< 1.35.0']
61
+ s.add_runtime_dependency 'fog', '~> 1.38'
58
62
 
59
63
  # So fog doesn't always complain of unmet AWS dependencies
60
64
  s.add_runtime_dependency 'unf', '~> 0.1'
61
- # public_suffix is required by addressable, so make sure it pulls a version
62
- # that still supports ruby 1.9.3
63
- s.add_runtime_dependency 'public_suffix', ' < 1.5.0'
64
65
  end
@@ -42,7 +42,7 @@ Specifies standard input to be provided to the command post execution. Defaults
42
42
 
43
43
  on host, "this command takes input", {:stdin => "hiya"}
44
44
 
45
- ## [:run_in_parallel](how_to/run_in_parallel.md)
45
+ ## [:run_in_parallel](../how_to/run_in_parallel.md)
46
46
 
47
47
  Execute the command against all hosts in parallel
48
48
 
@@ -114,3 +114,12 @@ in the `CONFIG` section of your hosts file:
114
114
  security_group: ['my_sg', 'default']
115
115
 
116
116
  This is an optional config parameter.
117
+
118
+ ### Floating IP Pool
119
+
120
+ The name of the floating IP pool that a VM can grab IPs from. This is useful
121
+ if your organization doesn't have a public pool of floating IPs, or give each
122
+ user their own pool. It's used in allocating new IPs. It's an options
123
+ parameter in the CONFIG section of the host file:
124
+
125
+ floating_ip_pool: 'my_pool_name'
@@ -0,0 +1,46 @@
1
+ # Test arbitrary beaker versions without modifying test code
2
+
3
+ In order to adjust the beaker version used without commiting a change to a Gemfile,
4
+ we at Puppet often use a method in our code that changes the dependency based on the
5
+ existence of ENV variables in the shell that beaker is executing from. The code
6
+ itself looks like this:
7
+
8
+ ```ruby
9
+
10
+ def location_for(place, fake_version = nil)
11
+ if place =~ /^(git[:@][^#]*)#(.*)/
12
+ [fake_version, { :git => $1, :branch => $2, :require => false }].compact
13
+ elsif place =~ /^file:\/\/(.*)/
14
+ ['>= 0', { :path => File.expand_path($1), :require => false }]
15
+ else
16
+ [place, { :require => false }]
17
+ end
18
+ end
19
+
20
+ ```
21
+
22
+ Once this method definition is in place in the Gemfile, we can call it in a gem command, like
23
+ this:
24
+
25
+ ```ruby
26
+
27
+ gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 2.0')
28
+ ```
29
+
30
+ ## Example BEAKER_VERSIONs
31
+
32
+ ### git locations
33
+
34
+ ```
35
+ git@github.com:puppetlabs/beaker.git#master
36
+ git://github.com/puppetlabs/beaker.git#master
37
+ ```
38
+
39
+ ### file locations
40
+ ```
41
+ file://../relative/path/to/beaker
42
+ ```
43
+ By adjusting the shell environment that beaker is running in, we can modify what version of
44
+ beaker is installed by bundler on your test coordinator without modifying any of the test
45
+ code. This strategy can be used for any gem dependency, and is often used when testing
46
+ [beaker libraries](../concepts/beaker_libraries.md) at Puppet.
@@ -0,0 +1,76 @@
1
+ # How To Upgrade from 2.y to 3.0
2
+
3
+ This is a guide detailing all the issues to be aware of, and to help people make
4
+ any changes that you might need to move from beaker 2.y to 3.0. To test out
5
+ beaker 3.0.0, we recommend implementing the strategy outlined [here](test_arbitrary_beaker_versions.md)
6
+ to ensure this new major release does not break your existing testing.
7
+
8
+ ## Locally Cached Files
9
+
10
+ This is a change of the `:cache_files_locally` preset from `true` to `false`.
11
+
12
+ At this time, the `:cache_files_locally` setting only affects the
13
+ [`fetch_http_file` method](https://github.com/puppetlabs/beaker/blob/master/lib/beaker/dsl/helpers/web_helpers.rb#L44).
14
+ This is an internal method used in both Puppet Enterprise (PE) and Open Source
15
+ Puppet install helpers to download files from the internet to the Beaker
16
+ coordinator.
17
+
18
+ If a file with the same destination name already exists on the coordinator,
19
+ Beaker would not fetch the file and use the cached copy instead. In general,
20
+ this wasn't a big problem because we typically have our version numbers in our
21
+ install artifacts, so file name matching is enough. In our Windows MSI
22
+ installers, however, we would many times not have versions built into the file
23
+ name. Since that's the case, you could get an old version installed because it
24
+ was already on your coordinator filesystem. The `:cache_files_locally` setting
25
+ allows you to set whether you want to use a local file cache, or get fresh
26
+ installers every time. This setting is now set to false, and will get installers
27
+ from the online source every time.
28
+
29
+ If you'd like to keep this setting the way it was in 2.y, then just set the
30
+ global option `:cache_files_locally` to `false`. Checkout the
31
+ [Argument Processing and Precedence](../concepts/argument_processing_and_precedence.md)
32
+ doc for info on how to do this.
33
+
34
+ ## EPEL package update
35
+
36
+ In beaker < 3.0.0, the epel package names had hardcoded defaults listed in the
37
+ presets default; in beaker >= 3.0.0, beaker utilizes the `release-latest` file
38
+ provided on epel mirrors for el versions 5, 6, and 7. Since only the latest epel
39
+ packages are available on epel mirrors, beaker only supports installation of
40
+ that latest version.
41
+
42
+ ## Solaris and AIX Hypervisors removed
43
+
44
+ Special cased hypervisor support for Solaris and AIX have been removed in favor
45
+ of a `hypervisor=none` workflow where the provisioning of SUTs is handled separately
46
+ outside of beaker itself. Solaris and AIX are still of course supported as `platform`
47
+ strings; only these special-cased hypervisors have been removed.
48
+
49
+ ## Environment Variable DSL Methods
50
+
51
+ In [BKR-914](https://tickets.puppetlabs.com/browse/BKR-914) we fixed our host
52
+ methods that deal with environment variables (
53
+ [#add_env_var](http://www.rubydoc.info/github/puppetlabs/beaker/Unix/Exec#add_env_var-instance_method),
54
+ [#get_env_var](http://www.rubydoc.info/github/puppetlabs/beaker/Unix/Exec#get_env_var-instance_method),
55
+ and
56
+ [#clear_env_var](http://www.rubydoc.info/github/puppetlabs/beaker/Unix/Exec#clear_env_var-instance_method)).
57
+
58
+ Before, these methods used regular expressions that were too loose. This means
59
+ that in an example of a call like `get_env_var('abc')`, the environment variables
60
+ `abc=123`, `xx_abc_xx=123`, and `123=abc` would all be matched, where the intent
61
+ is to get `abc=123` alone. From Beaker 3.0 forward, this will be the case.
62
+
63
+ ## beaker-pe Import Changes
64
+
65
+ Starting in beaker 3.0, there is no explicit beaker-pe requirement in beaker. This
66
+ separates the two, meaning that you'll have to explicitly require beaker-pe if you
67
+ do need it in your testing. And if you don't need it, you won't get it, limiting
68
+ your dependencies & exposure to unnecessary code.
69
+
70
+ Luckily, if you do need it, this shouldn't be hard to update. These are the steps
71
+ needed to use beaker-pe with beaker 3.0:
72
+
73
+ 1. put a dependency on beaker-pe in your Gemfile as a sibling to your beaker
74
+ requirement (make sure beaker-pe is >= 1.0)
75
+ 2. put a `require 'beaker-pe'` statement where you'd like to use beaker-pe-specific
76
+ functionality
@@ -0,0 +1,82 @@
1
+ # Tutorials
2
+
3
+ This doc is here to help you get acquainted with beaker
4
+ and how we run our acceptance tests at Puppet. We'll go
5
+ over the purpose of each doc, giving you an idea of when
6
+ you might need each one. The list has been organized as
7
+ a learning guide for someone new to using beaker, so be
8
+ aware of that if you're just dipping into a topic.
9
+
10
+ For more high level & motivation topics, checkout our
11
+ [concepts docs](../concepts). If you're looking for
12
+ more details on a topic than what is provided in the
13
+ tutorials, checkout our [how to docs](../how_to). And
14
+ if you'd like API level details, feel free to skip on
15
+ over to our
16
+ [Rubydocs](http://www.rubydoc.info/github/puppetlabs/beaker/frames).
17
+ And without further pre-amble, we beaker!
18
+
19
+ ## Installation
20
+
21
+ If you haven't installed beaker yet, your guide to doing
22
+ so can be found [here](installation.md).
23
+
24
+ ## Quick Start
25
+
26
+ As a completely new beaker user, the
27
+ [quick start rake tasks doc](quick_start_rake_tasks.md)
28
+ will take you through getting beaker running for the
29
+ first time.
30
+
31
+ ## OK, We're Running. Now What?
32
+
33
+ This is where things get interesting. There are a
34
+ number of directions you can go, based on your needs.
35
+ Here's a list of the common directions people take at
36
+ this point.
37
+
38
+ ### Test Writing
39
+
40
+ Most people reading this doc are in Quality orgs, or
41
+ are developers who need to get some testing done for
42
+ their current work. If getting a particular bit of
43
+ testing done is your next step, this is the direction
44
+ for you.
45
+
46
+ Checkout our [let's write a test](lets_write_a_test.md)
47
+ to start with test writing!
48
+
49
+ ### Running Beaker Itself
50
+
51
+ For the quick start guide, we resorted to using rake
52
+ tasks to get beaker running quickly and easily. In
53
+ the real world, people need much more customization
54
+ out of their testing environments. One of the main
55
+ ways people provide these options is through
56
+ command line arguments.
57
+
58
+ If you want to find out more about running beaker
59
+ itself, checkout [the command line](the_command_line.md).
60
+
61
+ ### Environment Details
62
+
63
+ If you don't need to get your tests running _anywhere_,
64
+ but need them on a ton of Operating Systems (OSes),
65
+ then your next stop is setting up your test environment.
66
+
67
+ Our
68
+ [creating a test environment doc](creating_a_test_environment.md)
69
+ is the next spot for you!
70
+
71
+ ### High Level Execution Details
72
+
73
+ For a higher level look at what happens during beaker
74
+ execution, which we call a _run_, checkout our
75
+ [test run doc](test_run.md). A _run_ is an entire
76
+ beaker execution cycle, from when the command is run
77
+ until beaker exits.
78
+
79
+ As one phase of a test run, the test suites are executed.
80
+ To get more information about the test suites that
81
+ are available, and how you configure them, you can
82
+ checkout our [test suites doc](test_suites.md).
data/lib/beaker/dsl.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require "beaker/dsl/#{lib}"
4
4
  end
5
5
 
6
- require 'beaker-pe'
7
6
  module Beaker
8
7
  # This is a catch all module for including Puppetlabs home grown testing
9
8
  # DSL. This module is mixed into {Beaker::TestCase} and can be
@@ -80,7 +79,6 @@ module Beaker
80
79
  include Beaker::DSL::Helpers
81
80
  include Beaker::DSL::InstallUtils
82
81
  include Beaker::DSL::Patterns
83
- include Beaker::DSL::PE
84
82
 
85
83
  def self.register(helper_module)
86
84
  include helper_module