beaker 2.11.0 → 2.12.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
- YjcxZmM2NGE2YTM1ZjAwZmU4MDI4M2U0NzZmOTk4MzMxZDg3NDRiOQ==
4
+ MDViYzc2MGNjNDgxMjczMmE4MmQ2NzY3NTNhOWI5ZWU1NGYxNjA4Zg==
5
5
  data.tar.gz: !binary |-
6
- Y2M3MmViODg0MTdiZDIxZWZjNjIyYmExMWMwMGFkMzA4OTViZmQxOQ==
6
+ MmExY2UzMTI0ZDA2MzkzYzgwOGNhZTVmZDVhNWIxMDFlOWI0OGM5Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2VjY2E2NmM2N2E3MGUyOTBkY2FlZTM3MjUwZjY5YjE0OGU4N2JjYTI1OWNi
10
- MWM1YzIyYzgzOWM2ZWJhNjdjNmIxMzAyMmZkMzk3Njk3Mzc4ZWQwM2ZjYWZj
11
- MzhiZTVmYTQ0NzE0YTU2MTVhZjg4NDBjYjlhNTk0YTQ4ZGNjMDk=
9
+ NDY5MjdhMGYwMWRmN2FiZGY4Y2YxYzAyNmNmYjYwOGYzZmZkN2YzYWJkY2Uy
10
+ YjQ3MmY2NjE1ODgyZTEyNzkxOWI4ZWRjOTk2MTFjODI0YWQzMDBkOTMwNzI5
11
+ ZWI4NGFjMTE5YjdjZTdmY2NjY2U5MTM1MGQ1OGRiNTU2ZGYxZTY=
12
12
  data.tar.gz: !binary |-
13
- ZmRjZDhkNjU5ODQyMjY3YjZlNTc2NTIyYmYwMzNlOTA1YmJhZmFhZmQ2Y2Y3
14
- ODEyODVkMzZhMjcxMTQ0NTYzYjNmYmVlZThjZWMzNmQwNWJkMTAyY2RlYzVk
15
- MTNkYmQ3NjE5OTNkMTJkODk5ZGE0ZWFmNjVlODI4YjYyMTUyNzk=
13
+ NjBmYzBhZDcyMzA3NDdjMzUwZDVjYmFlMTEwMjllZDFhNWViMzI0NWFlNjBh
14
+ NDQwYTc5NGJjNGRlY2RhNzZiMThkOTU3MmU0ZmEwMmNiMTJlZDMwNzEwZmEx
15
+ MmE0MTE5ZmVhYTc5ZDFhZWY0NDJiNjE5ZDY1NTQ0MzEyMzcxZGM=
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # default - History
2
2
  ## Tags
3
- * [LATEST - 6 May, 2015 (50128ac0)](#LATEST)
3
+ * [LATEST - 20 May, 2015 (88efb0d6)](#LATEST)
4
+ * [2.11.0 - 6 May, 2015 (b775cc73)](#2.11.0)
4
5
  * [2.10.0 - 22 Apr, 2015 (c4f37479)](#2.10.0)
5
6
  * [2.9.0 - 9 Apr, 2015 (b161d325)](#2.9.0)
6
7
  * [beaker2.8.0 - 26 Mar, 2015 (2d25d06d)](#beaker2.8.0)
@@ -79,7 +80,88 @@
79
80
  * [pe1.2 - 6 Sep, 2011 (ba3dadd2)](#pe1.2)
80
81
 
81
82
  ## Details
82
- ### <a name = "LATEST">LATEST - 6 May, 2015 (50128ac0)
83
+ ### <a name = "LATEST">LATEST - 20 May, 2015 (88efb0d6)
84
+
85
+ * (GEM) update beaker version to 2.12.0 (88efb0d6)
86
+
87
+ * Merge pull request #790 from kevpl/bkr76_acceptance_addpresuite (4d43e91d)
88
+
89
+
90
+ ```
91
+ Merge pull request #790 from kevpl/bkr76_acceptance_addpresuite
92
+
93
+ (BKR-76) created first pre-suite acceptance tests
94
+ ```
95
+ * Merge pull request #814 from kevpl/bkr186_test_addaccessors2 (121ee9f8)
96
+
97
+
98
+ ```
99
+ Merge pull request #814 from kevpl/bkr186_test_addaccessors2
100
+
101
+ (BKR-186) added current test info accessors to DSL
102
+ ```
103
+ * Merge pull request #815 from kevpl/bkr232_option_noprovision_implies_no_configure_validate (f60724a6)
104
+
105
+
106
+ ```
107
+ Merge pull request #815 from kevpl/bkr232_option_noprovision_implies_no_configure_validate
108
+
109
+ (BKR-232) --no-provision now implies --no-configure & --no-validate
110
+ ```
111
+ * Merge pull request #816 from petems/BKR-276-fix_freebsd_file_making (158273ef)
112
+
113
+
114
+ ```
115
+ Merge pull request #816 from petems/BKR-276-fix_freebsd_file_making
116
+
117
+ (BKR-276) Fixes `#echo_to_file` for FreeBSD
118
+ ```
119
+ * (BKR-276) Fixes `#echo_to_file` for FreeBSD (d1e36080)
120
+
121
+
122
+ ```
123
+ (BKR-276) Fixes `#echo_to_file` for FreeBSD
124
+
125
+ Previous command didn't wrap printf string in `"`
126
+ Stops command working:
127
+
128
+
129
+
130
+
131
+ freebsd-9-x64 executed in 0.04 seconds
132
+ Warning: ssh connection to 10.255.52.108 has been terminated
133
+
134
+ freebsd-9-x64 20:12:47$ printf 127.0.0.1\tlocalhost localhost.localdomain\n10.255.52.108\tfreebsd-9-x64\n > /etc/hosts
135
+ Attempting ssh connection to 10.255.52.108, user: root, opts: {:config=>"/var/folders/nn/408ddhln26s1b356ry19q6yr0000gp/T/freebsd-9-x6420150518-65951-3jag0b"}
136
+ printf: missing format character
137
+
138
+
139
+ ```
140
+ * (BKR-232) --no-provision now implies --no-configure & --no-validate (e2200d2e)
141
+
142
+ * (BKR-76) sles: fixed git & gem install issues (d0d0b95d)
143
+
144
+ * (BKR-76) fixed solaris 11 issues with git install (8909ff3b)
145
+
146
+ * Merge pull request #799 from sschneid/vmpooler_tokens (3e545182)
147
+
148
+
149
+ ```
150
+ Merge pull request #799 from sschneid/vmpooler_tokens
151
+
152
+ (BKR-218) Support using vmpooler API tokens
153
+ ```
154
+ * (BKR-76) added windows ruby setup steps (1f45fc57)
155
+
156
+ * (BKR-186) added current test info accessors to DSL (76b07a5a)
157
+
158
+ * (BKR-218) Support using vmpooler API tokens (4c860f93)
159
+
160
+ * (BKR-76) created first pre-suite acceptance tests (b5d1dd1f)
161
+
162
+ ### <a name = "2.11.0">2.11.0 - 6 May, 2015 (b775cc73)
163
+
164
+ * (HISTORY) update beaker history for gem release 2.11.0 (b775cc73)
83
165
 
84
166
  * (GEM) update beaker version to 2.11.0 (50128ac0)
85
167
 
@@ -0,0 +1 @@
1
+ install_pe
@@ -0,0 +1,10 @@
1
+ hosts.each do |host|
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
@@ -0,0 +1,151 @@
1
+ install = [
2
+ 'facter#stable',
3
+ 'hiera#stable',
4
+ 'puppet#3.7.5'
5
+ ]
6
+
7
+ SourcePath = Beaker::DSL::InstallUtils::SourcePath
8
+
9
+ PACKAGES = {
10
+ :redhat => [
11
+ 'git',
12
+ 'ruby',
13
+ 'rubygem-json', # :add_el_extras is required to find this package
14
+ ],
15
+ :debian => [
16
+ ['git', 'git-core'],
17
+ 'ruby',
18
+ ],
19
+ :debian_ruby18 => [
20
+ 'libjson-ruby',
21
+ ],
22
+ :solaris_11 => [
23
+ ['git', 'developer/versioning/git'],
24
+ ['ruby', 'runtime/ruby-18'],
25
+ ],
26
+ :solaris_10 => [
27
+ 'coreutils',
28
+ 'curl', # update curl to fix "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!" issue
29
+ 'git',
30
+ 'ruby19',
31
+ 'ruby19_dev',
32
+ 'gcc4core',
33
+ ],
34
+ :windows => [
35
+ 'git',
36
+ # there isn't a need for json on windows because it is bundled in ruby 1.9
37
+ ],
38
+ :sles => [
39
+ 'git-core',
40
+ ]
41
+ }
42
+
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
+ install_packages_on(hosts, PACKAGES, :check_if_exists => true)
95
+
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
+ hosts.each do |host|
111
+ case host['platform']
112
+ when /windows/
113
+ arch = host[:ruby_arch] || 'x86'
114
+ step "#{host} Selected architecture #{arch}"
115
+
116
+ revision = if arch == 'x64'
117
+ '2.0.0-x64'
118
+ else
119
+ '1.9.3-x86'
120
+ end
121
+
122
+ step "#{host} Install ruby from git using revision #{revision}"
123
+ # TODO remove this step once we are installing puppet from msi packages
124
+ install_from_git(host, "/opt/puppet-git-repos",
125
+ :name => 'puppet-win32-ruby',
126
+ :path => build_giturl('puppet-win32-ruby'),
127
+ :rev => revision)
128
+ on host, 'cd /opt/puppet-git-repos/puppet-win32-ruby; cp -r ruby/* /'
129
+ on host, 'cd /lib; icacls ruby /grant "Everyone:(OI)(CI)(RX)"'
130
+ on host, 'cd /lib; icacls ruby /reset /T'
131
+ on host, 'cd /; icacls bin /grant "Everyone:(OI)(CI)(RX)"'
132
+ on host, 'cd /; icacls bin /reset /T'
133
+ on host, 'ruby --version'
134
+ on host, 'cmd /c gem list'
135
+ when /solaris/
136
+ on host, 'gem install json'
137
+ end
138
+ end
139
+
140
+ tmp_repos = []
141
+ install.each do |reponame|
142
+ tmp_repos << extract_repo_info_from("https://github.com/puppetlabs/#{reponame}")
143
+ end
144
+
145
+ repos = order_packages(tmp_repos)
146
+
147
+ hosts.each do |host|
148
+ repos.each do |repo|
149
+ install_from_git(host, SourcePath, repo)
150
+ end
151
+ end
@@ -0,0 +1,7 @@
1
+ # the version is required on windows
2
+ # all versions are required for osx
3
+ install_puppet({
4
+ :version => '3.7.5',
5
+ :facter_version => '2.1.0',
6
+ :hiera_version => '1.3.4',
7
+ })
@@ -0,0 +1,21 @@
1
+ test_name "puppet install smoketest"
2
+
3
+ step 'puppet install smoketest: verify \'facter --help\' can be successfully called on all hosts'
4
+ hosts.each do |host|
5
+ on host, facter('--help')
6
+ end
7
+
8
+ step 'puppet install smoketest: verify \'hiera --help\' can be successfully called on all hosts'
9
+ hosts.each do |host|
10
+ on host, hiera('--help')
11
+ end
12
+
13
+ step 'puppet install smoketest: verify \'puppet help\' can be successfully called on all hosts'
14
+ hosts.each do |host|
15
+ on host, puppet('help')
16
+ end
17
+
18
+ step "puppet install smoketest: can get a configprint of the puppet server setting on all hosts"
19
+ hosts.each do |host|
20
+ assert(!host.puppet['server'].empty?, "can get a configprint of the puppet server setting")
21
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- [ 'facter', 'hiera', 'host', 'puppet', 'tk', 'web' ].each do |lib|
2
+ [ 'facter', 'hiera', 'host', 'puppet', 'test', 'tk', 'web' ].each do |lib|
3
3
  require "beaker/dsl/helpers/#{lib}_helpers"
4
4
  end
5
5
 
@@ -25,6 +25,7 @@ module Beaker
25
25
  include Beaker::DSL::Helpers::HieraHelpers
26
26
  include Beaker::DSL::Helpers::HostHelpers
27
27
  include Beaker::DSL::Helpers::PuppetHelpers
28
+ include Beaker::DSL::Helpers::TestHelpers
28
29
  include Beaker::DSL::Helpers::TKHelpers
29
30
  include Beaker::DSL::Helpers::WebHelpers
30
31
  end
@@ -0,0 +1,72 @@
1
+ module Beaker
2
+ module DSL
3
+ module Helpers
4
+ # Methods that help you query the state of your tests, these
5
+ # methods do not require puppet to be installed to execute correctly
6
+ module TestHelpers
7
+
8
+ # Gets the currently executing test's name, which is set in a test
9
+ # using the {Beaker::DSL::Structure#test_name} method.
10
+ #
11
+ # @return [String] Test name, or nil if it hasn't been set
12
+ def current_test_name()
13
+ @metadata[:case] && @metadata[:case][:name] ? @metadata[:case][:name] : nil
14
+ end
15
+
16
+ # Gets the currently executing test's filename, which is set from the
17
+ # +@path+ variable passed into the {Beaker::TestCase#initialize} method,
18
+ # not including the '.rb' extension
19
+ #
20
+ # @example if the path variable was man/plan/canal.rb, then the filename would be:
21
+ # canal
22
+ #
23
+ # @return [String] Test filename, or nil if it hasn't been set
24
+ def current_test_filename()
25
+ @metadata[:case] && @metadata[:case][:file_name] ? @metadata[:case][:file_name] : nil
26
+ end
27
+
28
+ # Gets the currently executing test's currently executing step name.
29
+ # This is set using the {Beaker::DSL::Structure#step} method.
30
+ #
31
+ # @return [String] Step name, or nil if it hasn't been set
32
+ def current_step_name()
33
+ @metadata[:step] && @metadata[:step][:name] ? @metadata[:step][:name] : nil
34
+ end
35
+
36
+ # Sets the currently executing test's name.
37
+ #
38
+ # @param [String] name Name of the test
39
+ #
40
+ # @return nil
41
+ # @api private
42
+ def set_current_test_name(name)
43
+ @metadata[:case] ||= {}
44
+ @metadata[:case][:name] = name
45
+ end
46
+
47
+ # Sets the currently executing test's filename.
48
+ #
49
+ # @param [String] filename Name of the file being tested
50
+ #
51
+ # @return nil
52
+ # @api private
53
+ def set_current_test_filename(filename)
54
+ @metadata[:case] ||= {}
55
+ @metadata[:case][:file_name] = filename
56
+ end
57
+
58
+ # Sets the currently executing step's name.
59
+ #
60
+ # @param [String] name Name of the step
61
+ #
62
+ # @return nil
63
+ # @api private
64
+ def set_current_step_name(name)
65
+ @metadata[:step] ||= {}
66
+ @metadata[:step][:name] = name
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
@@ -37,6 +37,7 @@ module Beaker
37
37
  # @param [Proc] block The actions to be performed in this step.
38
38
  def step step_name, &block
39
39
  logger.notify "\n * #{step_name}\n"
40
+ set_current_step_name(step_name)
40
41
  yield if block_given?
41
42
  end
42
43
 
@@ -47,6 +48,7 @@ module Beaker
47
48
  #
48
49
  def test_name my_name, &block
49
50
  logger.notify "\n#{my_name}\n"
51
+ set_current_test_name(my_name)
50
52
  yield if block_given?
51
53
  end
52
54
 
@@ -5,6 +5,6 @@ module FreeBSD::Exec
5
5
  # FreeBSD gets weird about special characters, we have to go a little OTT here
6
6
  escaped_str = str.gsub(/\t/,'\\t').gsub(/\n/,'\\n')
7
7
 
8
- exec(Beaker::Command.new("printf #{escaped_str} > #{filename}"))
8
+ exec(Beaker::Command.new("printf \"#{escaped_str}\" > #{filename}"))
9
9
  end
10
10
  end
@@ -19,6 +19,22 @@ module Beaker
19
19
  @options = options
20
20
  @logger = options[:logger]
21
21
  @hosts = vmpooler_hosts
22
+ @credentials = load_credentials(@options[:dot_fog])
23
+ end
24
+
25
+ def load_credentials(dot_fog = '.fog')
26
+ creds = {}
27
+
28
+ begin
29
+ fog = YAML.load_file(dot_fog)
30
+ default = fog[:default]
31
+
32
+ creds[:vmpooler_token] = default[:vmpooler_token]
33
+ rescue Errno::ENOENT
34
+ @logger.warn "Credentials file (#{@options[:dot_fog]}) not found; proceeding without authentication"
35
+ end
36
+
37
+ creds
22
38
  end
23
39
 
24
40
  def check_url url
@@ -62,8 +78,6 @@ module Beaker
62
78
  request_payload[h['template']] = (request_payload[h['template']].to_i + 1).to_s
63
79
  end
64
80
 
65
- @logger.notify "Requesting VM set from vmpooler"
66
-
67
81
  last_wait, wait = 0, 1
68
82
  waited = 0 #the amount of time we've spent waiting for this host to provision
69
83
  begin
@@ -72,6 +86,13 @@ module Beaker
72
86
  http = Net::HTTP.new(uri.host, uri.port)
73
87
  request = Net::HTTP::Post.new(uri.request_uri)
74
88
 
89
+ if @credentials[:vmpooler_token]
90
+ request['X-AUTH-TOKEN'] = @credentials[:vmpooler_token]
91
+ @logger.notify "Requesting VM set from vmpooler (with authentication token)"
92
+ else
93
+ @logger.notify "Requesting VM set from vmpooler"
94
+ end
95
+
75
96
  request.body = request_payload.to_json
76
97
 
77
98
  response = http.request(request)
@@ -64,6 +64,10 @@ module Beaker
64
64
  'Do not provision vm images before testing',
65
65
  '(default: true)' do |bool|
66
66
  @cmd_options[:provision] = bool
67
+ unless bool
68
+ @cmd_options[:validate] = false
69
+ @cmd_options[:configure] = false
70
+ end
67
71
  end
68
72
 
69
73
  opts.on '--[no-]configure',
@@ -97,6 +97,8 @@ module Beaker
97
97
  @exception = nil
98
98
  @runtime = nil
99
99
  @teardown_procs = []
100
+ @metadata = {}
101
+ set_current_test_filename(@path ? File.basename(@path, '.rb') : nil)
100
102
 
101
103
 
102
104
  #
@@ -107,6 +109,8 @@ module Beaker
107
109
  @logger.start_sublog
108
110
  @logger.last_result = nil
109
111
 
112
+ set_current_step_name(nil)
113
+
110
114
  #add arbitrary role methods
111
115
  roles = []
112
116
  @hosts.each do |host|
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.11.0'
3
+ STRING = '2.12.0'
4
4
  end
5
5
  end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLHelpers
4
+ include Beaker::DSL::Helpers
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Roles
7
+ include Beaker::DSL::Patterns
8
+
9
+ def logger
10
+ RSpec::Mocks::Double.new('logger').as_null_object
11
+ end
12
+
13
+ end
14
+
15
+ describe ClassMixedWithDSLHelpers do
16
+ let(:metadata) { @metadata ? @metadata : {} }
17
+
18
+ describe '#current_test_name' do
19
+ it 'returns nil if the case is undefined' do
20
+ subject.instance_variable_set( :@metadata, metadata )
21
+ expect( subject.current_test_name ).to be_nil
22
+ end
23
+
24
+ it 'returns nil if the name is undefined' do
25
+ @metadata = { :case => {} }
26
+ subject.instance_variable_set( :@metadata, metadata )
27
+ expect( subject.current_test_name ).to be_nil
28
+ end
29
+
30
+ it 'returns the set value' do
31
+ name = 'holyGrail_testName'
32
+ @metadata = { :case => { :name => name } }
33
+ subject.instance_variable_set( :@metadata, metadata )
34
+ expect( subject.current_test_name ).to be === name
35
+ end
36
+ end
37
+
38
+ describe '#current_test_filename' do
39
+ it 'returns nil if the case is undefined' do
40
+ subject.instance_variable_set( :@metadata, metadata )
41
+ expect( subject.current_test_filename ).to be_nil
42
+ end
43
+
44
+ it 'returns nil if the name is undefined' do
45
+ @metadata = { :case => {} }
46
+ subject.instance_variable_set( :@metadata, metadata )
47
+ expect( subject.current_test_filename ).to be_nil
48
+ end
49
+
50
+ it 'returns the set value' do
51
+ name = 'holyGrail_testFilename'
52
+ @metadata = { :case => { :file_name => name } }
53
+ subject.instance_variable_set( :@metadata, metadata )
54
+ expect( subject.current_test_filename ).to be === name
55
+ end
56
+ end
57
+
58
+ describe '#current_step_name' do
59
+ it 'returns nil if the step is undefined' do
60
+ subject.instance_variable_set( :@metadata, metadata )
61
+ expect( subject.current_step_name ).to be_nil
62
+ end
63
+
64
+ it 'returns nil if the name is undefined' do
65
+ @metadata = { :step => {} }
66
+ subject.instance_variable_set( :@metadata, metadata )
67
+ expect( subject.current_step_name ).to be_nil
68
+ end
69
+
70
+ it 'returns the set value' do
71
+ name = 'holyGrail_stepName'
72
+ @metadata = { :step => { :name => name } }
73
+ subject.instance_variable_set( :@metadata, metadata )
74
+ expect( subject.current_step_name ).to be === name
75
+ end
76
+ end
77
+ end
@@ -86,6 +86,7 @@ describe ClassMixedWithDSLInstallUtils do
86
86
  expect( subject ).to receive( :on ).with( host, cmd ).and_yield
87
87
  expect( subject ).to receive( :stdout ).and_return( '2' )
88
88
 
89
+ subject.instance_variable_set( :@metadata, {} )
89
90
  version = subject.find_git_repo_versions( host, path, repository )
90
91
 
91
92
  expect( version ).to be == { 'name' => '2' }
@@ -132,6 +133,7 @@ describe ClassMixedWithDSLInstallUtils do
132
133
  expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
133
134
  expect( subject ).to receive( :on ).exactly( 4 ).times
134
135
 
136
+ subject.instance_variable_set( :@metadata, {} )
135
137
  subject.install_from_git( host, path, repo )
136
138
  end
137
139
 
@@ -152,6 +154,7 @@ describe ClassMixedWithDSLInstallUtils do
152
154
  expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}" ).exactly( 1 ).times
153
155
  expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi" ).exactly( 1 ).times
154
156
 
157
+ subject.instance_variable_set( :@metadata, {} )
155
158
  subject.install_from_git( host, path, repo )
156
159
  end
157
160
 
@@ -173,6 +176,7 @@ describe ClassMixedWithDSLInstallUtils do
173
176
  expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}" ).exactly( 1 ).times
174
177
  expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi" ).exactly( 1 ).times
175
178
 
179
+ subject.instance_variable_set( :@metadata, {} )
176
180
  subject.install_from_git( host, path, repo )
177
181
  end
178
182
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  class ClassMixedWithDSLStructure
4
4
  include Beaker::DSL::Structure
5
+ include Beaker::DSL::Helpers::TestHelpers
5
6
  end
6
7
 
7
8
  describe ClassMixedWithDSLStructure do
@@ -13,19 +14,32 @@ describe ClassMixedWithDSLStructure do
13
14
  end
14
15
 
15
16
  it 'notifies the logger' do
17
+ subject.instance_variable_set(:@metadata, {})
18
+ allow( subject ).to receive( :set_current_step_name )
16
19
  expect( subject ).to receive( :logger ).and_return( logger )
17
20
  expect( logger ).to receive( :notify )
18
21
  subject.step 'blah'
19
22
  end
20
23
 
21
24
  it 'yields if a block is given' do
25
+ subject.instance_variable_set(:@metadata, {})
22
26
  expect( subject ).to receive( :logger ).and_return( logger )
27
+ allow( subject ).to receive( :set_current_step_name )
23
28
  expect( logger ).to receive( :notify )
24
29
  expect( subject ).to receive( :foo )
25
30
  subject.step 'blah' do
26
31
  subject.foo
27
32
  end
28
33
  end
34
+
35
+ it 'sets the metadata' do
36
+ subject.instance_variable_set(:@metadata, {})
37
+ allow( subject ).to receive( :logger ).and_return( logger )
38
+ allow( logger ).to receive( :notify )
39
+ step_name = 'pierceBrosnanTests'
40
+ subject.step step_name
41
+ expect( subject.instance_variable_get(:@metadata)[:step][:name] ).to be === step_name
42
+ end
29
43
  end
30
44
 
31
45
  describe '#test_name' do
@@ -34,12 +48,14 @@ describe ClassMixedWithDSLStructure do
34
48
  end
35
49
 
36
50
  it 'notifies the logger' do
51
+ subject.instance_variable_set(:@metadata, {})
37
52
  expect( subject ).to receive( :logger ).and_return( logger )
38
53
  expect( logger ).to receive( :notify )
39
54
  subject.test_name 'blah'
40
55
  end
41
56
 
42
57
  it 'yields if a block is given' do
58
+ subject.instance_variable_set(:@metadata, {})
43
59
  expect( subject ).to receive( :logger ).and_return( logger )
44
60
  expect( logger ).to receive( :notify )
45
61
  expect( subject ).to receive( :foo )
@@ -47,6 +63,15 @@ describe ClassMixedWithDSLStructure do
47
63
  subject.foo
48
64
  end
49
65
  end
66
+
67
+ it 'sets the metadata' do
68
+ subject.instance_variable_set(:@metadata, {})
69
+ allow( subject ).to receive( :logger ).and_return( logger )
70
+ allow( logger ).to receive( :notify )
71
+ test_name = '15-05-08\'s weather is beautiful'
72
+ subject.test_name test_name
73
+ expect( subject.instance_variable_get(:@metadata)[:case][:name] ).to be === test_name
74
+ end
50
75
  end
51
76
 
52
77
  describe '#teardown' do
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Beaker
4
+ describe FreeBSD::Exec do
5
+ class FreeBSDExecTest
6
+ include FreeBSD::Exec
7
+
8
+ def initialize(hash, logger)
9
+ @hash = hash
10
+ @logger = logger
11
+ end
12
+
13
+ def [](k)
14
+ @hash[k]
15
+ end
16
+
17
+ def to_s
18
+ "me"
19
+ end
20
+ end
21
+
22
+ let (:opts) { @opts || {} }
23
+ let (:logger) { double( 'logger' ).as_null_object }
24
+ let (:instance) { FreeBSDExecTest.new(opts, logger) }
25
+
26
+ context "echo_to_file" do
27
+
28
+ it "runs the correct echo command" do
29
+ expect( Beaker::Command ).to receive(:new).with('printf "127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n" > /etc/hosts').and_return('')
30
+ expect( instance ).to receive(:exec).with('').and_return(generate_result("hello", {:exit_code => 0}))
31
+ instance.echo_to_file('127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n', '/etc/hosts')
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+
@@ -13,6 +13,7 @@ module Beaker
13
13
  arg
14
14
  end
15
15
  allow( Socket ).to receive( :getaddrinfo ).and_return( true )
16
+ allow_any_instance_of( Beaker::Vmpooler ).to receive(:load_credentials).and_return(fog_file_contents)
16
17
  end
17
18
 
18
19
  describe '#get_template_url' do
@@ -6,12 +6,18 @@ module Beaker
6
6
 
7
7
  let(:parser) {Beaker::Options::CommandLineParser.new}
8
8
  let(:test_opts) {["-h", "vcloud.cfg", "--debug", "--tests", "test.rb", "--help"]}
9
- let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants"]}
10
- let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :type => "pe", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :version=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants"}}
9
+ let(:full_opts_in) {["--hosts", "host.cfg", "--options", "opts_file", "--type", "pe", "--helper", "path_to_helper", "--load-path", "load_path", "--tests", "test1.rb,test2.rb,test3.rb", "--pre-suite", "pre_suite.rb", "--post-suite", "post_suite.rb", "--no-provision", "--preserve-hosts", "always", "--root-keys", "--keyfile", "../.ssh/id_rsa", "--install", "gitrepopath", "-m", "module", "-q", "--dry-run", "--no-ntp", "--repo-proxy", "--add-el-extras", "--config", "anotherfile.cfg", "--fail-mode", "fast", "--no-color", "--version", "--log-level", "info", "--package-proxy", "http://192.168.100.1:3128", "--collect-perf-data", "--parse-only", "--validate", "--timeout", "40", "--log-prefix", "pants", "--configure"]}
10
+ let(:full_opts_out) {{:hosts_file=>"anotherfile.cfg",:options_file=>"opts_file", :type => "pe", :helper => "path_to_helper", :load_path => "load_path", :tests => "test1.rb,test2.rb,test3.rb", :pre_suite => "pre_suite.rb", :post_suite => "post_suite.rb", :provision=>false, :preserve_hosts => "always", :root_keys=>true, :keyfile => "../.ssh/id_rsa", :install => "gitrepopath", :modules=>"module", :quiet=>true, :dry_run=>true, :timesync=>false, :repo_proxy=>true, :add_el_extras=>true, :fail_mode => "fast", :color=>false, :version=>true, :log_level => "info", :package_proxy => "http://192.168.100.1:3128", :collect_perf_data=>true, :parse_only=>true, :validate=>true, :timeout => "40", :log_prefix => "pants", :configure => true}}
11
11
  let(:validate_true) {["--validate"]}
12
12
  let(:validate_false) {["--no-validate"]}
13
13
  let(:configure_true) {['--configure']}
14
14
  let(:configure_false) {['--no-configure']}
15
+ let(:provision_false) {['--no-provision']}
16
+ let(:provision_other) {{:provision => false, :configure => false, :validate => false}}
17
+ let(:provision_both_in) {['--no-provision', '--configure', '--validate']}
18
+ let(:provision_both_out) {{:provision => false, :configure => true, :validate => true}}
19
+ let(:provision_half_in) {['--no-provision', '--configure']}
20
+ let(:provision_half_out) {{:provision => false, :configure => true, :validate => false}}
15
21
 
16
22
 
17
23
  it "can correctly read command line input" do
@@ -36,6 +42,20 @@ module Beaker
36
42
  expect{parser.usage}.to_not raise_error
37
43
  end
38
44
 
45
+ context '--no-provision flag effects other options' do
46
+ it 'sets --no-validate/configure when --no-provision is set' do
47
+ expect(parser.parse(provision_false)).to be === provision_other
48
+ end
49
+
50
+ it 'can still have --validate & --configure set correctly when --no-provision is set' do
51
+ expect(parser.parse(provision_both_in)).to be === provision_both_out
52
+ end
53
+
54
+ it 'can override just one of the two flags when --no-provision is set' do
55
+ expect(parser.parse(provision_half_in)).to be === provision_half_out
56
+ end
57
+ end
58
+
39
59
  end
40
60
  end
41
61
  end
@@ -96,5 +96,35 @@ module Beaker
96
96
  end
97
97
  end
98
98
 
99
+ context 'metadata' do
100
+ it 'sets the filename correctly from the path' do
101
+ answer = 'jacket'
102
+ path = "#{answer}.rb"
103
+ File.open(path, 'w') do |f|
104
+ f.write ""
105
+ end
106
+ @path = path
107
+ testcase.run_test
108
+ metadata = testcase.instance_variable_get(:@metadata)
109
+ expect(metadata[:case][:file_name]).to be === answer
110
+ end
111
+
112
+ it 'resets the step name' do
113
+ path = 'test.rb'
114
+ File.open(path, 'w') do |f|
115
+ f.write ""
116
+ end
117
+ @path = path
118
+ # we have to create a TestCase by hand, so that we can set old
119
+ tc = TestCase.new({}, logger, {}, path)
120
+ # metadata on it, so that we can test that it's being reset correctly
121
+ old_metadata = { :step => { :name => 'CharlieBrown' } }
122
+ tc.instance_variable_set(:@metadata, old_metadata)
123
+ tc.run_test
124
+ metadata = tc.instance_variable_get(:@metadata)
125
+ expect(metadata[:step][:name]).to be_nil
126
+ end
127
+ end
128
+
99
129
  end
100
130
  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: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -377,9 +377,14 @@ files:
377
377
  - acceptance/fixtures/module/tests/init.pp
378
378
  - acceptance/fixtures/module/vendor/bundle/ruby/gems.txt
379
379
  - acceptance/pre_suite/README.md
380
+ - acceptance/pre_suite/pe/install.rb
381
+ - acceptance/pre_suite/puppet_gem/install.rb
382
+ - acceptance/pre_suite/puppet_git/install.rb
383
+ - acceptance/pre_suite/puppet_pkg/install.rb
380
384
  - acceptance/tests/base/README.md
381
385
  - acceptance/tests/base/host.rb
382
386
  - acceptance/tests/puppet/README.md
387
+ - acceptance/tests/puppet/install_smoke.rb
383
388
  - beaker.gemspec
384
389
  - bin/beaker
385
390
  - ext/completion/beaker-completion.bash
@@ -402,6 +407,7 @@ files:
402
407
  - lib/beaker/dsl/helpers/hiera_helpers.rb
403
408
  - lib/beaker/dsl/helpers/host_helpers.rb
404
409
  - lib/beaker/dsl/helpers/puppet_helpers.rb
410
+ - lib/beaker/dsl/helpers/test_helpers.rb
405
411
  - lib/beaker/dsl/helpers/tk_helpers.rb
406
412
  - lib/beaker/dsl/helpers/web_helpers.rb
407
413
  - lib/beaker/dsl/install_utils.rb
@@ -501,6 +507,7 @@ files:
501
507
  - spec/beaker/dsl/helpers/hiera_helpers_spec.rb
502
508
  - spec/beaker/dsl/helpers/host_helpers_spec.rb
503
509
  - spec/beaker/dsl/helpers/puppet_helpers_spec.rb
510
+ - spec/beaker/dsl/helpers/test_helpers_spec.rb
504
511
  - spec/beaker/dsl/helpers/tk_helpers_spec.rb
505
512
  - spec/beaker/dsl/helpers/web_helpers_spec.rb
506
513
  - spec/beaker/dsl/install_utils/module_utils_spec.rb
@@ -510,6 +517,7 @@ files:
510
517
  - spec/beaker/dsl/roles_spec.rb
511
518
  - spec/beaker/dsl/structure_spec.rb
512
519
  - spec/beaker/dsl/wrappers_spec.rb
520
+ - spec/beaker/host/freebsd/exec_spec.rb
513
521
  - spec/beaker/host/mac/group_spec.rb
514
522
  - spec/beaker/host/mac/user_spec.rb
515
523
  - spec/beaker/host/unix/pkg_spec.rb