beaker 1.10.0 → 1.11.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.
- checksums.yaml +8 -8
- data/.travis.yml +2 -2
- data/Rakefile +14 -1
- data/beaker.gemspec +2 -1
- data/lib/beaker/answers/version20.rb +7 -7
- data/lib/beaker/answers/version28.rb +7 -7
- data/lib/beaker/answers/version30.rb +10 -9
- data/lib/beaker/dsl/helpers.rb +137 -6
- data/lib/beaker/dsl/install_utils.rb +60 -45
- data/lib/beaker/host/unix/pkg.rb +7 -7
- data/lib/beaker/host/windows.rb +4 -0
- data/lib/beaker/host_prebuilt_steps.rb +9 -2
- data/lib/beaker/hypervisor.rb +3 -1
- data/lib/beaker/hypervisor/docker.rb +154 -0
- data/lib/beaker/hypervisor/ec2_helper.rb +1 -1
- data/lib/beaker/hypervisor/google_compute_helper.rb +1 -1
- data/lib/beaker/options/parser.rb +7 -0
- data/lib/beaker/options/presets.rb +72 -52
- data/lib/beaker/test_case.rb +1 -14
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +40 -27
- data/spec/beaker/dsl/helpers_spec.rb +114 -7
- data/spec/beaker/dsl/install_utils_spec.rb +17 -15
- data/spec/beaker/hypervisor/docker_spec.rb +212 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
- data/spec/beaker/options/parser_spec.rb +2 -3
- data/spec/helpers.rb +1 -1
- metadata +21 -4
data/lib/beaker/test_case.rb
CHANGED
@@ -108,7 +108,7 @@ module Beaker
|
|
108
108
|
@logger = logger
|
109
109
|
@options = options
|
110
110
|
@path = path
|
111
|
-
@usr_home =
|
111
|
+
@usr_home = options[:home]
|
112
112
|
@test_status = :pass
|
113
113
|
@exception = nil
|
114
114
|
@runtime = nil
|
@@ -182,18 +182,5 @@ module Beaker
|
|
182
182
|
hash
|
183
183
|
end
|
184
184
|
|
185
|
-
# This method retrieves the forge hostname from either:
|
186
|
-
# * The environment variable 'forge_host'
|
187
|
-
# * The parameter 'forge_host' from the CONFIG hash in a node definition
|
188
|
-
#
|
189
|
-
# If none of these are available, it falls back to the static
|
190
|
-
# 'vulcan-acceptance.delivery.puppetlabs.net' hostname
|
191
|
-
#
|
192
|
-
# @return [String] hostname of test forge
|
193
|
-
def forge
|
194
|
-
ENV['forge_host'] ||
|
195
|
-
@options['forge_host'] ||
|
196
|
-
'vulcan-acceptance.delivery.puppetlabs.net'
|
197
|
-
end
|
198
185
|
end
|
199
186
|
end
|
data/lib/beaker/version.rb
CHANGED
data/spec/beaker/answers_spec.rb
CHANGED
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Beaker
|
4
4
|
describe Answers do
|
5
5
|
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
6
|
+
let( :options ) { Beaker::Options::Presets.env_vars }
|
6
7
|
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
7
8
|
basic_hosts[1]['platform'] = 'windows'
|
8
9
|
basic_hosts }
|
@@ -16,42 +17,43 @@ module Beaker
|
|
16
17
|
|
17
18
|
it 'generates 3.2 answers for 3.2 hosts' do
|
18
19
|
@ver = '3.2'
|
19
|
-
Beaker::Answers::Version32.should_receive( :answers ).with( hosts, master_certname,
|
20
|
-
subject.answers( @ver, hosts, master_certname,
|
20
|
+
Beaker::Answers::Version32.should_receive( :answers ).with( hosts, master_certname, options ).once
|
21
|
+
subject.answers( @ver, hosts, master_certname, options )
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'generates 3.0 answers for 3.1 hosts' do
|
24
25
|
@ver = '3.1'
|
25
|
-
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname,
|
26
|
-
subject.answers( @ver, hosts, master_certname,
|
26
|
+
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, options ).once
|
27
|
+
subject.answers( @ver, hosts, master_certname, options )
|
27
28
|
end
|
28
29
|
|
29
30
|
it 'generates 3.0 answers for 3.0 hosts' do
|
30
31
|
@ver = '3.0'
|
31
|
-
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname,
|
32
|
-
subject.answers( @ver, hosts, master_certname,
|
32
|
+
Beaker::Answers::Version30.should_receive( :answers ).with( hosts, master_certname, options ).once
|
33
|
+
subject.answers( @ver, hosts, master_certname, options )
|
33
34
|
end
|
34
35
|
|
35
36
|
it 'generates 2.8 answers for 2.8 hosts' do
|
36
37
|
@ver = '2.8'
|
37
|
-
Beaker::Answers::Version28.should_receive( :answers ).with( hosts, master_certname,
|
38
|
-
subject.answers( @ver, hosts, master_certname,
|
38
|
+
Beaker::Answers::Version28.should_receive( :answers ).with( hosts, master_certname, options ).once
|
39
|
+
subject.answers( @ver, hosts, master_certname, options )
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'generates 2.0 answers for 2.0 hosts' do
|
42
43
|
@ver = '2.0'
|
43
|
-
Beaker::Answers::Version20.should_receive( :answers ).with( hosts, master_certname,
|
44
|
-
subject.answers( @ver, hosts, master_certname,
|
44
|
+
Beaker::Answers::Version20.should_receive( :answers ).with( hosts, master_certname, options ).once
|
45
|
+
subject.answers( @ver, hosts, master_certname, options )
|
45
46
|
end
|
46
47
|
|
47
48
|
it 'raises an error for an unknown version' do
|
48
49
|
@ver = 'x.x'
|
49
|
-
expect{ subject.answers( @ver, hosts, master_certname,
|
50
|
+
expect{ subject.answers( @ver, hosts, master_certname, options ) }.to raise_error( NotImplementedError )
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
module Answers
|
54
55
|
describe Version32 do
|
56
|
+
let( :options ) { Beaker::Options::Presets.env_vars }
|
55
57
|
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
|
56
58
|
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
|
57
59
|
basic_hosts[1]['roles'] = ['dashboard', 'agent']
|
@@ -63,17 +65,17 @@ module Beaker
|
|
63
65
|
# master certname to the dashboard answers
|
64
66
|
it 'should add q_puppetmaster_certname to the dashboard answers' do
|
65
67
|
@ver = '3.2'
|
66
|
-
expect( subject.answers( hosts, master_certname,
|
68
|
+
expect( subject.answers( hosts, master_certname, options )['vm2']).to include :q_puppetmaster_certname
|
67
69
|
end
|
68
70
|
|
69
71
|
it 'should add q_upgrade_with_unknown_disk_space to the dashboard on upgrade' do
|
70
72
|
@ver = '3.2'
|
71
|
-
expect( subject.answers( hosts, master_certname, {:type => :upgrade} )['vm2']).to include :q_upgrade_with_unknown_disk_space
|
73
|
+
expect( subject.answers( hosts, master_certname, options.merge( {:type => :upgrade} ) )['vm2']).to include :q_upgrade_with_unknown_disk_space
|
72
74
|
end
|
73
75
|
|
74
76
|
it 'should add answers to the host objects' do
|
75
77
|
@ver = '3.2'
|
76
|
-
answers = subject.answers( hosts, master_certname,
|
78
|
+
answers = subject.answers( hosts, master_certname, options )
|
77
79
|
hosts.each do |host|
|
78
80
|
expect( host[:answers] ).to be === answers[host.name]
|
79
81
|
end
|
@@ -81,6 +83,7 @@ module Beaker
|
|
81
83
|
end
|
82
84
|
|
83
85
|
describe Version30 do
|
86
|
+
let( :options ) { Beaker::Options::Presets.env_vars }
|
84
87
|
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
85
88
|
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
86
89
|
basic_hosts[1]['platform'] = 'windows'
|
@@ -89,24 +92,26 @@ module Beaker
|
|
89
92
|
|
90
93
|
it 'uses simple answers for upgrade from 3.0.x to 3.0.x' do
|
91
94
|
@ver = '3.0'
|
92
|
-
expect( subject.answers( hosts, master_certname, { :type => :upgrade } )).to be === { "vm2"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm1"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm3"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" } }
|
95
|
+
expect( subject.answers( hosts, master_certname, options.merge({ :type => :upgrade }) )).to be === { "vm2"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm1"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" }, "vm3"=>{ :q_install=>"y", :q_install_vendor_packages=>"y" } }
|
93
96
|
end
|
94
97
|
|
95
98
|
it 'sets correct answers for an agent' do
|
96
|
-
expect( subject.answers( hosts, master_certname,
|
99
|
+
expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"n", :q_all_in_one_install=>"n", :q_puppet_enterpriseconsole_install=>"n", :q_puppetdb_install=>"n", :q_database_install=>"n" }
|
97
100
|
end
|
98
101
|
|
99
102
|
it 'sets correct answers for a master' do
|
100
|
-
|
103
|
+
@ver = '3.0'
|
104
|
+
expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_verify_packages=>"y", :q_puppet_symlinks_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>master_certname, :q_puppetmaster_install=>"y", :q_all_in_one_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetdb_install=>"y", :q_database_install=>"y", :q_puppetdb_hostname=>hosts[0], :q_puppetdb_port=>8081, :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_certname=>"master_certname", :q_puppetdb_database_name=>"pe-puppetdb", :q_puppetdb_database_user=>"mYpdBu3r", :q_puppetdb_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_database_host=>hosts[0], :q_database_port=>5432, :q_pe_database=>"y", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_database_root_password=>"'=ZYdjiP3jCwV5eo9s1MBd'", :q_database_root_user=>"pe-postgres" }
|
101
105
|
end
|
102
106
|
|
103
107
|
it 'generates nil answers for a windows host' do
|
104
|
-
|
108
|
+
@ver = '3.0'
|
109
|
+
expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
|
105
110
|
end
|
106
111
|
|
107
112
|
it 'should add answers to the host objects' do
|
108
113
|
@ver = '3.0'
|
109
|
-
answers = subject.answers( hosts, master_certname,
|
114
|
+
answers = subject.answers( hosts, master_certname, options )
|
110
115
|
hosts.each do |host|
|
111
116
|
expect( host[:answers] ).to be === answers[host.name]
|
112
117
|
end
|
@@ -114,6 +119,7 @@ module Beaker
|
|
114
119
|
end
|
115
120
|
|
116
121
|
describe Version28 do
|
122
|
+
let( :options ) { Beaker::Options::Presets.env_vars }
|
117
123
|
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
118
124
|
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
119
125
|
basic_hosts[1]['platform'] = 'windows'
|
@@ -121,20 +127,23 @@ module Beaker
|
|
121
127
|
let( :master_certname ) { 'master_certname' }
|
122
128
|
|
123
129
|
it 'sets correct answers for an agent' do
|
124
|
-
|
130
|
+
@ver = '2.8'
|
131
|
+
expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
|
125
132
|
end
|
126
133
|
|
127
134
|
it 'sets correct answers for a master' do
|
128
|
-
|
135
|
+
@ver = '2.8'
|
136
|
+
expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
|
129
137
|
end
|
130
138
|
|
131
139
|
it 'generates nil answers for a windows host' do
|
132
|
-
|
140
|
+
@ver = '2.8'
|
141
|
+
expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
|
133
142
|
end
|
134
143
|
|
135
144
|
it 'should add answers to the host objects' do
|
136
145
|
@ver = '2.8'
|
137
|
-
answers = subject.answers( hosts, master_certname,
|
146
|
+
answers = subject.answers( hosts, master_certname, options )
|
138
147
|
hosts.each do |host|
|
139
148
|
expect( host[:answers] ).to be === answers[host.name]
|
140
149
|
end
|
@@ -142,6 +151,7 @@ module Beaker
|
|
142
151
|
|
143
152
|
end
|
144
153
|
describe Version20 do
|
154
|
+
let( :options ) { Beaker::Options::Presets.env_vars }
|
145
155
|
let( :basic_hosts ) { make_hosts( { 'pe_ver' => @ver } ) }
|
146
156
|
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'database', 'dashboard']
|
147
157
|
basic_hosts[1]['platform'] = 'windows'
|
@@ -149,20 +159,23 @@ module Beaker
|
|
149
159
|
let( :master_certname ) { 'master_certname' }
|
150
160
|
|
151
161
|
it 'sets correct answers for an agent' do
|
152
|
-
|
162
|
+
@ver = '2.0'
|
163
|
+
expect( subject.answers( hosts, master_certname, options )['vm3'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[2], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"n", :q_puppet_enterpriseconsole_install=>"n" }
|
153
164
|
end
|
154
165
|
|
155
166
|
it 'sets correct answers for a master' do
|
156
|
-
|
167
|
+
@ver = '2.0'
|
168
|
+
expect( subject.answers( hosts, master_certname, options )['vm1'] ).to be === { :q_install=>"y", :q_puppetagent_install=>"y", :q_puppet_cloud_install=>"y", :q_puppet_symlinks_install=>"y", :q_vendor_packages_install=>"y", :q_puppetagent_certname=>hosts[0], :q_puppetagent_server=>hosts[0], :q_puppetmaster_install=>"y", :q_puppet_enterpriseconsole_install=>"y", :q_puppetmaster_certname=>"master_certname", :q_puppetmaster_dnsaltnames=>"master_certname,puppet,#{hosts[0][:ip]}", :q_puppetmaster_enterpriseconsole_hostname=>hosts[0], :q_puppetmaster_enterpriseconsole_port=>443, :q_puppetmaster_forward_facts=>"y", :q_puppet_enterpriseconsole_database_install=>"y", :q_puppet_enterpriseconsole_auth_database_name=>"console_auth", :q_puppet_enterpriseconsole_auth_database_user=>"mYu7hu3r", :q_puppet_enterpriseconsole_auth_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_name=>"console", :q_puppet_enterpriseconsole_database_user=>"mYc0nS03u3r", :q_puppet_enterpriseconsole_database_root_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_database_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_inventory_hostname=>hosts[0], :q_puppet_enterpriseconsole_inventory_certname=>hosts[0], :q_puppet_enterpriseconsole_inventory_dnsaltnames=>hosts[0], :q_puppet_enterpriseconsole_inventory_port=>8140, :q_puppet_enterpriseconsole_master_hostname=>hosts[0], :q_puppet_enterpriseconsole_auth_user_email=>"'admin@example.com'", :q_puppet_enterpriseconsole_auth_password=>"'~!@\#$%^*-/ aZ'", :q_puppet_enterpriseconsole_httpd_port=>443, :q_puppet_enterpriseconsole_smtp_host=>"'vm1'", :q_puppet_enterpriseconsole_smtp_use_tls=>"'n'", :q_puppet_enterpriseconsole_smtp_port=>"'25'", :q_puppet_enterpriseconsole_auth_user=>"'admin@example.com'" }
|
157
169
|
end
|
158
170
|
|
159
171
|
it 'generates nil answers for a windows host' do
|
160
|
-
|
172
|
+
@ver = '2.0'
|
173
|
+
expect( subject.answers( hosts, master_certname, options )['vm2'] ).to be === nil
|
161
174
|
end
|
162
175
|
|
163
176
|
it 'should add answers to the host objects' do
|
164
177
|
@ver = '2.0'
|
165
|
-
answers = subject.answers( hosts, master_certname,
|
178
|
+
answers = subject.answers( hosts, master_certname, options )
|
166
179
|
hosts.each do |host|
|
167
180
|
expect( host[:answers] ).to be === answers[host.name]
|
168
181
|
end
|
@@ -11,6 +11,7 @@ class ClassMixedWithDSLHelpers
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe ClassMixedWithDSLHelpers do
|
14
|
+
let( :opts ) { Beaker::Options::Presets.env_vars }
|
14
15
|
let( :command ) { 'ls' }
|
15
16
|
let( :host ) { double.as_null_object }
|
16
17
|
let( :result ) { Beaker::Result.new( host, command ) }
|
@@ -127,26 +128,26 @@ describe ClassMixedWithDSLHelpers do
|
|
127
128
|
end
|
128
129
|
|
129
130
|
it 'yields self' do
|
130
|
-
subject.on host, command do
|
131
|
+
subject.on host, command do
|
131
132
|
expect( subject ).
|
132
133
|
to be_an_instance_of( ClassMixedWithDSLHelpers )
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
137
|
it 'provides access to stdout' do
|
137
|
-
subject.on host, command do
|
138
|
+
subject.on host, command do
|
138
139
|
expect( subject.stdout ).to be == 'stdout'
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
143
|
it 'provides access to stderr' do
|
143
|
-
subject.on host, command do
|
144
|
+
subject.on host, command do
|
144
145
|
expect( subject.stderr ).to be == 'stderr'
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
148
149
|
it 'provides access to exit_code' do
|
149
|
-
subject.on host, command do
|
150
|
+
subject.on host, command do
|
150
151
|
expect( subject.exit_code ).to be == 0
|
151
152
|
end
|
152
153
|
end
|
@@ -513,7 +514,7 @@ describe ClassMixedWithDSLHelpers do
|
|
513
514
|
|
514
515
|
describe '#stub_forge_on' do
|
515
516
|
it 'stubs forge.puppetlabs.com with the value of `forge`' do
|
516
|
-
subject.
|
517
|
+
subject.stub( :options ).and_return( {} )
|
517
518
|
Resolv.should_receive( :getaddress ).
|
518
519
|
with( 'my_forge.example.com' ).and_return( '127.0.0.1' )
|
519
520
|
subject.should_receive( :stub_hosts_on ).
|
@@ -521,15 +522,16 @@ describe ClassMixedWithDSLHelpers do
|
|
521
522
|
subject.should_receive( :stub_hosts_on ).
|
522
523
|
with( 'my_host', 'forgeapi.puppetlabs.com' => '127.0.0.1' )
|
523
524
|
|
524
|
-
subject.stub_forge_on( 'my_host' )
|
525
|
+
subject.stub_forge_on( 'my_host', 'my_forge.example.com' )
|
525
526
|
end
|
526
527
|
end
|
527
528
|
|
528
529
|
describe "#stub_forge" do
|
529
530
|
it "delegates to #stub_forge_on with the default host" do
|
531
|
+
subject.stub( :options ).and_return( {} )
|
530
532
|
subject.stub( :hosts ).and_return( hosts )
|
531
533
|
|
532
|
-
subject.should_receive( :stub_forge_on ).with( master ).once
|
534
|
+
subject.should_receive( :stub_forge_on ).with( master, nil ).once
|
533
535
|
|
534
536
|
subject.stub_forge( )
|
535
537
|
|
@@ -878,4 +880,109 @@ describe ClassMixedWithDSLHelpers do
|
|
878
880
|
end
|
879
881
|
end
|
880
882
|
|
883
|
+
|
884
|
+
describe 'copy_root_module_to' do
|
885
|
+
def source_to_scp (source, target, items)
|
886
|
+
subject.stub(:parse_for_moduleroot).and_return('/totalfake/testmodule')
|
887
|
+
Dir.stub(:getpwd).and_return('/totalfake/testmodule')
|
888
|
+
|
889
|
+
items = [items] unless items.kind_of?(Array)
|
890
|
+
File.stub(:exists?).with(any_args()).and_return(false)
|
891
|
+
File.stub(:directory?).with(any_args()).and_return(false)
|
892
|
+
items.each do |item|
|
893
|
+
source_item = File.join(source,item)
|
894
|
+
File.stub(:exists?).with(source_item).and_return(true)
|
895
|
+
options = {}
|
896
|
+
if ['manifests','lib','templates','files'].include? item
|
897
|
+
File.stub(:directory?).with(source_item).and_return(true)
|
898
|
+
options = {:mkdir => true}
|
899
|
+
end
|
900
|
+
master.should_receive(:do_scp_to).with(source_item,target,options).ordered
|
901
|
+
end
|
902
|
+
end
|
903
|
+
it 'should call scp with the correct info, with only providing host' do
|
904
|
+
files = ['manifests','lib','templates','metadata.json','Modulefile','files']
|
905
|
+
source_to_scp '/totalfake/testmodule',"#{master['puppetpath']}/modules/testmodule",files
|
906
|
+
subject.stub(:parse_for_modulename).with(any_args()).and_return("testmodule")
|
907
|
+
subject.copy_root_module_to(master)
|
908
|
+
end
|
909
|
+
it 'should call scp with the correct info, when specifying the modulename' do
|
910
|
+
files = ['manifests','lib','metadata.json','Modulefile']
|
911
|
+
source_to_scp '/totalfake/testmodule',"#{master['puppetpath']}/modules/bogusmodule",files
|
912
|
+
subject.stub(:parse_for_modulename).and_return('testmodule')
|
913
|
+
subject.copy_root_module_to(master,{:module_name =>"bogusmodule"})
|
914
|
+
end
|
915
|
+
it 'should call scp with the correct info, when specifying the target to a different path' do
|
916
|
+
files = ['manifests','lib','templates','metadata.json','Modulefile','files']
|
917
|
+
target = "/opt/shared/puppet/modules"
|
918
|
+
source_to_scp '/totalfake/testmodule',"#{target}/testmodule",files
|
919
|
+
subject.stub(:parse_for_modulename).and_return('testmodule')
|
920
|
+
subject.copy_root_module_to(master,{:target_module_path => target})
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
describe 'split_author_modulename' do
|
925
|
+
it 'should return a correct modulename' do
|
926
|
+
result = subject.split_author_modulename('myname-test_43_module')
|
927
|
+
expect(result[:author]).to eq('myname')
|
928
|
+
expect(result[:module]).to eq('test_43_module')
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
describe 'get_module_name' do
|
933
|
+
it 'should return a has of author and modulename' do
|
934
|
+
expect(subject.get_module_name('myname-test_43_module')).to eq('test_43_module')
|
935
|
+
end
|
936
|
+
it 'should return nil for invalid names' do
|
937
|
+
expect(subject.get_module_name('myname-')).to eq(nil)
|
938
|
+
end
|
939
|
+
end
|
940
|
+
|
941
|
+
describe 'parse_for_modulename' do
|
942
|
+
directory = '/testfilepath/myname-testmodule'
|
943
|
+
it 'should return name from metadata.json' do
|
944
|
+
File.stub(:exists?).with("#{directory}/metadata.json").and_return(true)
|
945
|
+
File.stub(:read).with("#{directory}/metadata.json").and_return(" {\"name\":\"myname-testmodule\"} ")
|
946
|
+
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from metadata.json")
|
947
|
+
subject.logger.should_not_receive(:debug).with('Unable to determine name, returning null')
|
948
|
+
subject.parse_for_modulename(directory).should eq('testmodule')
|
949
|
+
end
|
950
|
+
it 'should return name from Modulefile' do
|
951
|
+
File.stub(:exists?).with("#{directory}/metadata.json").and_return(false)
|
952
|
+
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
953
|
+
File.stub(:read).with("#{directory}/Modulefile").and_return("name 'myname-testmodule' \nauthor 'myname'")
|
954
|
+
subject.logger.should_receive(:debug).with("Attempting to parse Modulename from Modulefile")
|
955
|
+
subject.logger.should_not_receive(:debug).with("Unable to determine name, returning null")
|
956
|
+
expect(subject.parse_for_modulename(directory)).to eq('testmodule')
|
957
|
+
end
|
958
|
+
end
|
959
|
+
|
960
|
+
describe 'parse_for_module_root' do
|
961
|
+
directory = '/testfilepath/myname-testmodule'
|
962
|
+
it 'should recersively go up the directory to find the module files' do
|
963
|
+
File.stub(:exists?).with("#{directory}/acceptance/Modulefile").and_return(false)
|
964
|
+
File.stub(:exists?).with("#{directory}/Modulefile").and_return(true)
|
965
|
+
subject.logger.should_not_receive(:debug).with("At root, can't parse for another directory")
|
966
|
+
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}/acceptance, moving up")
|
967
|
+
expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
|
968
|
+
end
|
969
|
+
it 'should recersively go up the directory to find the module files' do
|
970
|
+
File.stub(:exists?).and_return(false)
|
971
|
+
subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}, moving up")
|
972
|
+
subject.logger.should_receive(:error).with("At root, can't parse for another directory")
|
973
|
+
expect(subject.parse_for_moduleroot(directory)).to eq(nil)
|
974
|
+
end
|
975
|
+
|
976
|
+
end
|
977
|
+
end
|
978
|
+
|
979
|
+
module FakeFS
|
980
|
+
class File < StringIO
|
981
|
+
def self.absolute_path(filepath)
|
982
|
+
RealFile.absolute_path(filepath)
|
983
|
+
end
|
984
|
+
def self.expand_path(filepath)
|
985
|
+
RealFile.expand_path(filepath)
|
986
|
+
end
|
987
|
+
end
|
881
988
|
end
|
@@ -7,19 +7,20 @@ class ClassMixedWithDSLInstallUtils
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe ClassMixedWithDSLInstallUtils do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
let(:opts) { Beaker::Options::Presets.env_vars }
|
11
|
+
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
12
|
+
:platform => 'linux',
|
13
|
+
:roles => [ 'agent' ] } ) }
|
14
|
+
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
15
|
+
basic_hosts[1][:platform] = 'windows'
|
16
|
+
basic_hosts }
|
17
|
+
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
18
|
+
:pe_ver => '3.0',
|
19
|
+
:working_dir => '/tmp' } ) }
|
20
|
+
let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
|
17
21
|
:pe_ver => '3.0',
|
18
|
-
:working_dir => '/tmp'
|
19
|
-
|
20
|
-
:pe_ver => '3.0',
|
21
|
-
:working_dir => '/tmp',
|
22
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
22
|
+
:working_dir => '/tmp',
|
23
|
+
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
23
24
|
|
24
25
|
|
25
26
|
context 'extract_repo_info_from' do
|
@@ -257,7 +258,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
257
258
|
subject.should_receive( :wait_for_host_in_dashboard ).with( hosts[2] ).once
|
258
259
|
#run puppet agent now that installation is complete
|
259
260
|
subject.should_receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
260
|
-
subject.do_install( hosts )
|
261
|
+
subject.do_install( hosts, opts )
|
261
262
|
end
|
262
263
|
end
|
263
264
|
|
@@ -326,9 +327,10 @@ describe ClassMixedWithDSLInstallUtils do
|
|
326
327
|
describe 'install_pe' do
|
327
328
|
|
328
329
|
it 'calls do_install with sorted hosts' do
|
330
|
+
subject.stub( :options ).and_return( {} )
|
329
331
|
subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
|
330
332
|
subject.stub( :do_install ).and_return( true )
|
331
|
-
subject.should_receive( :do_install ).with( hosts )
|
333
|
+
subject.should_receive( :do_install ).with( hosts, {} )
|
332
334
|
subject.install_pe
|
333
335
|
end
|
334
336
|
|
@@ -340,7 +342,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
340
342
|
subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
|
341
343
|
subject.stub( :options ).and_return( {} )
|
342
344
|
subject.stub( :do_install ).and_return( true )
|
343
|
-
subject.should_receive( :do_install ).with( hosts )
|
345
|
+
subject.should_receive( :do_install ).with( hosts, {} )
|
344
346
|
subject.install_pe
|
345
347
|
hosts.each do |h|
|
346
348
|
expect( h['pe_ver'] ).to be === '2.8'
|