beaker 2.18.0 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +699 -2
  3. data/acceptance/lib/beaker/acceptance/install_utils.rb +58 -0
  4. data/acceptance/pre_suite/puppet_gem/install.rb +1 -8
  5. data/acceptance/pre_suite/puppet_git/install.rb +6 -65
  6. data/acceptance/pre_suite/puppet_pkg/install.rb +1 -1
  7. data/acceptance/tests/foss_utils/clone_git_repo_on.rb +49 -0
  8. data/beaker.gemspec +2 -0
  9. data/lib/beaker/command.rb +1 -1
  10. data/lib/beaker/dsl/helpers/puppet_helpers.rb +8 -6
  11. data/lib/beaker/dsl/helpers/web_helpers.rb +2 -1
  12. data/lib/beaker/dsl/install_utils/aio_defaults.rb +0 -3
  13. data/lib/beaker/dsl/install_utils/foss_defaults.rb +19 -0
  14. data/lib/beaker/dsl/install_utils/foss_utils.rb +164 -67
  15. data/lib/beaker/dsl/install_utils/pe_defaults.rb +9 -11
  16. data/lib/beaker/dsl/install_utils/pe_utils.rb +48 -64
  17. data/lib/beaker/dsl/install_utils/puppet_utils.rb +43 -0
  18. data/lib/beaker/dsl/install_utils/windows_utils.rb +144 -0
  19. data/lib/beaker/dsl/roles.rb +20 -3
  20. data/lib/beaker/dsl/structure.rb +14 -3
  21. data/lib/beaker/host/freebsd/pkg.rb +18 -0
  22. data/lib/beaker/host/freebsd.rb +2 -0
  23. data/lib/beaker/host/unix/exec.rb +3 -3
  24. data/lib/beaker/host/unix/pkg.rb +37 -0
  25. data/lib/beaker/host/windows/exec.rb +3 -0
  26. data/lib/beaker/host.rb +38 -9
  27. data/lib/beaker/host_prebuilt_steps.rb +21 -11
  28. data/lib/beaker/hypervisor/aws_sdk.rb +22 -18
  29. data/lib/beaker/hypervisor/docker.rb +7 -0
  30. data/lib/beaker/hypervisor/openstack.rb +1 -0
  31. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +10 -5
  32. data/lib/beaker/hypervisor/vmpooler.rb +4 -0
  33. data/lib/beaker/logger.rb +12 -1
  34. data/lib/beaker/options/command_line_parser.rb +9 -0
  35. data/lib/beaker/options/options_hash.rb +3 -296
  36. data/lib/beaker/options/parser.rb +12 -0
  37. data/lib/beaker/options/presets.rb +0 -1
  38. data/lib/beaker/platform.rb +3 -1
  39. data/lib/beaker/ssh_connection.rb +48 -23
  40. data/lib/beaker/test_case.rb +1 -1
  41. data/lib/beaker/version.rb +1 -1
  42. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +0 -1
  43. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +10 -1
  44. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +247 -49
  45. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +116 -26
  46. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +57 -0
  47. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +132 -0
  48. data/spec/beaker/dsl/roles_spec.rb +36 -5
  49. data/spec/beaker/dsl/structure_spec.rb +9 -2
  50. data/spec/beaker/host/unix/pkg_spec.rb +26 -6
  51. data/spec/beaker/host_prebuilt_steps_spec.rb +3 -2
  52. data/spec/beaker/host_spec.rb +24 -6
  53. data/spec/beaker/hypervisor/aixer_spec.rb +1 -1
  54. data/spec/beaker/hypervisor/aws_sdk_spec.rb +595 -58
  55. data/spec/beaker/hypervisor/docker_spec.rb +2 -1
  56. data/spec/beaker/hypervisor/solaris_spec.rb +1 -0
  57. data/spec/beaker/hypervisor/vagrant_spec.rb +20 -5
  58. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +1 -1
  59. data/spec/beaker/logger_spec.rb +39 -0
  60. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  61. data/spec/beaker/options/options_hash_spec.rb +1 -102
  62. data/spec/beaker/options/parser_spec.rb +19 -0
  63. data/spec/beaker/options/pe_version_scaper_spec.rb +11 -1
  64. data/spec/beaker/options/presets_spec.rb +8 -0
  65. data/spec/beaker/ssh_connection_spec.rb +39 -21
  66. data/spec/helpers.rb +9 -3
  67. data/spec/mocks.rb +2 -0
  68. metadata +35 -11
  69. data/lib/beaker/answers/version20.rb +0 -120
  70. data/lib/beaker/answers/version28.rb +0 -121
  71. data/lib/beaker/answers/version30.rb +0 -227
  72. data/lib/beaker/answers/version32.rb +0 -44
  73. data/lib/beaker/answers/version34.rb +0 -51
  74. data/lib/beaker/answers/version38.rb +0 -29
  75. data/lib/beaker/answers/version40.rb +0 -44
  76. data/lib/beaker/answers.rb +0 -143
  77. data/spec/beaker/answers_spec.rb +0 -547
@@ -0,0 +1,58 @@
1
+ module Beaker
2
+ module Acceptance
3
+ module InstallUtils
4
+
5
+ PLATFORM_PATTERNS = {
6
+ :redhat => /fedora|el|centos/,
7
+ :debian => /debian|ubuntu/,
8
+ :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
9
+ :solaris_10 => /solaris-10/,
10
+ :solaris_11 => /solaris-11/,
11
+ :windows => /windows/,
12
+ :sles => /sles/,
13
+ }.freeze
14
+
15
+ # Installs packages on the hosts.
16
+ #
17
+ # @param hosts [Array<Host>] Array of hosts to install packages to.
18
+ # @param package_hash [Hash{Symbol=>Array<String,Array<String,String>>}]
19
+ # Keys should be a symbol for a platform in PLATFORM_PATTERNS. Values
20
+ # should be an array of package names to install, or of two element
21
+ # arrays where a[0] is the command we expect to find on the platform
22
+ # and a[1] is the package name (when they are different).
23
+ # @param options [Hash{Symbol=>Boolean}]
24
+ # @option options [Boolean] :check_if_exists First check to see if
25
+ # command is present before installing package. (Default false)
26
+ # @return true
27
+ def install_packages_on(hosts, package_hash, options = {})
28
+ return true if hosts == nil
29
+ check_if_exists = options[:check_if_exists]
30
+ hosts = [hosts] unless hosts.kind_of?(Array)
31
+ hosts.each do |host|
32
+ package_hash.each do |platform_key,package_list|
33
+ if pattern = PLATFORM_PATTERNS[platform_key]
34
+ if pattern.match(host['platform'])
35
+ package_list.each do |cmd_pkg|
36
+ if cmd_pkg.kind_of?(Array)
37
+ command, package = cmd_pkg
38
+ else
39
+ command = package = cmd_pkg
40
+ end
41
+ if !check_if_exists || !host.check_for_package(command)
42
+ host.logger.notify("Installing #{package}")
43
+ additional_switches = '--allow-unauthenticated' if platform_key == :debian
44
+ host.install_package(package, additional_switches)
45
+ end
46
+ end
47
+ end
48
+ else
49
+ raise("Unknown platform '#{platform_key}' in package_hash")
50
+ end
51
+ end
52
+ end
53
+ return true
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -1,10 +1,3 @@
1
1
  hosts.each do |host|
2
2
  install_puppet_from_gem(host, {:version => '3.7.5'})
3
-
4
- if host['platform'] =~ /sles/
5
- host.mkdir_p(host['puppetbindir'])
6
- ['facter', 'hiera', 'puppet'].each do |tool|
7
- on host, "ln -s /usr/bin/#{tool}.ruby* #{host['puppetbindir']}/#{tool}"
8
- end
9
- end
10
- end
3
+ end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require 'beaker/acceptance/install_utils'
3
+ extend Beaker::Acceptance::InstallUtils
4
+ end
5
+ test_name 'Puppet git pre-suite'
6
+
1
7
  install = [
2
8
  'facter#2.1.0',
3
9
  'hiera#1.3.4',
@@ -40,73 +46,8 @@ PACKAGES = {
40
46
  ]
41
47
  }
42
48
 
43
- PLATFORM_PATTERNS = {
44
- :redhat => /fedora|el|centos/,
45
- :debian => /debian|ubuntu/,
46
- :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
47
- :solaris_10 => /solaris-10/,
48
- :solaris_11 => /solaris-11/,
49
- :windows => /windows/,
50
- :sles => /sles/,
51
- }.freeze
52
-
53
- # Installs packages on the hosts.
54
- #
55
- # @param hosts [Array<Host>] Array of hosts to install packages to.
56
- # @param package_hash [Hash{Symbol=>Array<String,Array<String,String>>}]
57
- # Keys should be a symbol for a platform in PLATFORM_PATTERNS. Values
58
- # should be an array of package names to install, or of two element
59
- # arrays where a[0] is the command we expect to find on the platform
60
- # and a[1] is the package name (when they are different).
61
- # @param options [Hash{Symbol=>Boolean}]
62
- # @option options [Boolean] :check_if_exists First check to see if
63
- # command is present before installing package. (Default false)
64
- # @return true
65
- def install_packages_on(hosts, package_hash, options = {})
66
- return true if hosts == nil
67
- check_if_exists = options[:check_if_exists]
68
- hosts = [hosts] unless hosts.kind_of?(Array)
69
- hosts.each do |host|
70
- package_hash.each do |platform_key,package_list|
71
- if pattern = PLATFORM_PATTERNS[platform_key]
72
- if pattern.match(host['platform'])
73
- package_list.each do |cmd_pkg|
74
- if cmd_pkg.kind_of?(Array)
75
- command, package = cmd_pkg
76
- else
77
- command = package = cmd_pkg
78
- end
79
- if !check_if_exists || !host.check_for_package(command)
80
- host.logger.notify("Installing #{package}")
81
- additional_switches = '--allow-unauthenticated' if platform_key == :debian
82
- host.install_package(package, additional_switches)
83
- end
84
- end
85
- end
86
- else
87
- raise("Unknown platform '#{platform_key}' in package_hash")
88
- end
89
- end
90
- end
91
- return true
92
- end
93
-
94
49
  install_packages_on(hosts, PACKAGES, :check_if_exists => true)
95
50
 
96
- def lookup_in_env(env_variable_name, project_name, default)
97
- project_specific_name = "#{project_name.upcase.gsub("-","_")}_#{env_variable_name}"
98
- ENV[project_specific_name] || ENV[env_variable_name] || default
99
- end
100
-
101
- def build_giturl(project_name, git_fork = nil, git_server = nil)
102
- git_fork ||= lookup_in_env('FORK', project_name, 'puppetlabs')
103
- git_server ||= lookup_in_env('GIT_SERVER', project_name, 'github.com')
104
- repo = (git_server == 'github.com') ?
105
- "#{git_fork}/#{project_name}.git" :
106
- "#{git_fork}-#{project_name}.git"
107
- "git://#{git_server}/#{repo}"
108
- end
109
-
110
51
  hosts.each do |host|
111
52
  case host['platform']
112
53
  when /windows/
@@ -1,7 +1,7 @@
1
1
  # the version is required on windows
2
2
  # all versions are required for osx
3
3
  install_puppet({
4
- :version => '3.7.5',
4
+ :version => '3.8.1',
5
5
  :facter_version => '2.1.0',
6
6
  :hiera_version => '1.3.4',
7
7
  })
@@ -0,0 +1,49 @@
1
+ begin
2
+ require 'beaker/acceptance/install_utils'
3
+ extend Beaker::Acceptance::InstallUtils
4
+ end
5
+ test_name 'Clone from git'
6
+
7
+ PACKAGES = {
8
+ :redhat => [
9
+ 'git',
10
+ ],
11
+ :debian => [
12
+ ['git', 'git-core'],
13
+ ],
14
+ :solaris_11 => [
15
+ ['git', 'developer/versioning/git'],
16
+ ],
17
+ :solaris_10 => [
18
+ 'coreutils',
19
+ 'curl', # update curl to fix "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!" issue
20
+ 'git',
21
+ ],
22
+ :windows => [
23
+ 'git',
24
+ ],
25
+ :sles => [
26
+ 'git-core',
27
+ ]
28
+ }
29
+
30
+ install_packages_on(hosts, PACKAGES, :check_if_exists => true)
31
+
32
+ # build_giturl implicitly looks these up
33
+ ENV['HIERA_FORK']='puppetlabs'
34
+ ENV['FORK']='fail'
35
+
36
+ # implicitly tests build_giturl() and lookup_in_env()
37
+ hosts.each do |host|
38
+ on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts"
39
+ testdir = create_tmpdir_on(host, File.basename(__FILE__))
40
+
41
+ step 'should find fork name from the correct environment variable'
42
+ results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('puppet')))
43
+ assert_match( /github\.com:fail/, result.cmd, 'Did not find correct fork name')
44
+ assert_equal( 1, result.exit_code, 'Did not produce error exit_code of 1')
45
+
46
+ step 'should clone hiera from correct fork'
47
+ results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('hiera')))
48
+ assert_match( /From github\.com:puppetlabs\/hiera/, result.output, 'Did not find clone')
49
+ end
data/beaker.gemspec CHANGED
@@ -39,6 +39,8 @@ Gem::Specification.new do |s|
39
39
  s.add_runtime_dependency 'inifile', '~> 2.0'
40
40
  s.add_runtime_dependency 'rsync', '~> 1.0.9'
41
41
  s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
42
+ s.add_runtime_dependency 'beaker-answers', '~> 0.0'
43
+ s.add_runtime_dependency 'stringify-hash', '~> 0.0'
42
44
 
43
45
  # Optional provisioner specific support
44
46
  s.add_runtime_dependency 'rbvmomi', '~> 1.8'
@@ -197,7 +197,7 @@ module Beaker
197
197
  # @return a new {SedCommand} object
198
198
  def initialize platform, expression, filename, opts = {}
199
199
  command = "sed -i -e \"#{expression}\" #{filename}"
200
- if platform =~ /solaris|aix|osx/
200
+ if platform =~ /solaris|aix|osx|openbsd/
201
201
  command.slice! '-i '
202
202
  temp_file = opts[:temp_file] ? opts[:temp_file] : "#{filename}.tmp"
203
203
  command << " > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}"
@@ -623,13 +623,15 @@ module Beaker
623
623
  end
624
624
  end
625
625
 
626
- # The agent service is `pe-puppet` everywhere EXCEPT certain linux distros on PE 2.8
627
- # In all the case that it is different, this init script will exist. So we can assume
628
- # that if the script doesn't exist, we should just use `pe-puppet`
629
- agent_service = 'pe-puppet-agent'
630
- agent_service = 'pe-puppet' unless agent.file_exist?('/etc/init.d/pe-puppet-agent')
631
626
  # In 4.0 this was changed to just be `puppet`
632
- agent_service = 'puppet' unless version_is_less(agent['pe_ver'], '4.0')
627
+ agent_service = 'puppet'
628
+ if !aio_version?(agent)
629
+ # The agent service is `pe-puppet` everywhere EXCEPT certain linux distros on PE 2.8
630
+ # In all the case that it is different, this init script will exist. So we can assume
631
+ # that if the script doesn't exist, we should just use `pe-puppet`
632
+ agent_service = 'pe-puppet-agent'
633
+ agent_service = 'pe-puppet' unless agent.file_exist?('/etc/init.d/pe-puppet-agent')
634
+ end
633
635
 
634
636
  # Under a number of stupid circumstances, we can't stop the
635
637
  # agent using puppet. This is usually because of issues with
@@ -33,7 +33,7 @@ module Beaker
33
33
  #
34
34
  # @param [String] base_url The base url from which to recursively download
35
35
  # files.
36
- # @param [String] file_name The trailing name compnent of both the source url
36
+ # @param [String] file_name The trailing name component of both the source url
37
37
  # and the destination file.
38
38
  # @param [String] dst_dir The local destination directory.
39
39
  #
@@ -44,6 +44,7 @@ module Beaker
44
44
  require 'open-uri'
45
45
  require 'open_uri_redirections'
46
46
  FileUtils.makedirs(dst_dir)
47
+ base_url.chomp!('/')
47
48
  src = "#{base_url}/#{file_name}"
48
49
  dst = File.join(dst_dir, file_name)
49
50
  if File.exists?(dst)
@@ -10,7 +10,6 @@ module Beaker
10
10
  #
11
11
  AIO_DEFAULTS = {
12
12
  'unix' => {
13
- 'puppetservice' => 'pe-puppetserver',
14
13
  'puppetbindir' => '/opt/puppetlabs/bin',
15
14
  'privatebindir' => '/opt/puppetlabs/puppet/bin',
16
15
  'distmoduledir' => '/etc/puppetlabs/code/modules',
@@ -37,7 +36,6 @@ module Beaker
37
36
  else
38
37
  host['group'] = 'puppet'
39
38
  end
40
- host['type'] = 'aio'
41
39
  end
42
40
 
43
41
  # Add the appropriate aio defaults to an array of hosts
@@ -61,7 +59,6 @@ module Beaker
61
59
  AIO_DEFAULTS[platform].each_pair do |key, val|
62
60
  host.delete(key)
63
61
  end
64
- host['type'] = nil
65
62
  host['group'] = nil
66
63
  end
67
64
 
@@ -34,6 +34,21 @@ module Beaker
34
34
  'distmoduledir' => '/usr/local/etc/puppet/modules',
35
35
  'sitemoduledir' => '/usr/share/puppet/modules',
36
36
  },
37
+ 'openbsd' => {
38
+ 'puppetserver-confdir' => '/etc/puppetserver/conf.d',
39
+ 'puppetservice' => 'puppetmaster',
40
+ 'puppetpath' => '/etc/puppet/modules',
41
+ 'puppetvardir' => '/var/puppet',
42
+ 'puppetbin' => '/usr/local/bin/puppet',
43
+ 'puppetbindir' => '/usr/local/bin',
44
+ 'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
45
+ 'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
46
+ 'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
47
+ 'hieradatadir' => '/etc/puppet/hieradata',
48
+ 'hieraconf' => '/etc/puppet/hiera.yaml',
49
+ 'distmoduledir' => '/etc/puppet/modules',
50
+ 'sitemoduledir' => '/usr/local/share/puppet/modules',
51
+ },
37
52
  'mac' => {
38
53
  'puppetserver-confdir' => '/etc/puppetserver/conf.d',
39
54
  'puppetservice' => 'puppetmaster',
@@ -123,6 +138,8 @@ module Beaker
123
138
  platform = 'unix'
124
139
  when /freebsd/
125
140
  platform = 'freebsd'
141
+ when /openbsd/
142
+ platform = 'openbsd'
126
143
  when /mac/
127
144
  platform = 'mac'
128
145
  when /pswindows/
@@ -155,6 +172,8 @@ module Beaker
155
172
  platform = 'unix'
156
173
  when /freebsd/
157
174
  platform = 'freebsd'
175
+ when /openbsd/
176
+ platform = 'openbsd'
158
177
  when /mac/
159
178
  platform = 'mac'
160
179
  when /pswindows/