rspec-system 2.7.2 → 2.8.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/CHANGELOG.md +18 -0
- data/Gemfile +2 -1
- data/README.md +25 -0
- data/lib/rspec-system/node_set/openstack.rb +124 -0
- data/rspec-system.gemspec +5 -1
- data/spec/unit/openstack_spec.rb +361 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2FhYjg3NDZkZWFkNGZlMDY5NGRkMThhOTFmNDk0MTlkZmY5MDBiMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2ZmZWIyYTI0MDkyMjQyOTAwZGIyYjNmZDczNWYzZTZiNjlhY2YwOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTFiMGZjODQ5ZGQ1YmQ2OGI5MTMxODBjOTk0OGI0ZmMyMzE2Y2Y1MjQ3Yjgx
|
10
|
+
OGM1M2VjOTdhZTMwMmM3MjI1ZWVhY2Q0YzQ0MjE2OGJiNTA5ZGVkMGMxYzJm
|
11
|
+
NWQ3N2M0YTUwYzBmNTg4ODFmMDNiNWNkNzBlY2Q5NDgwZWEyMDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDUzNzJhNzI0OTA1OThlY2UzNThlOTc0M2JiYmMzN2NkZjlmMDk3MWUxYjg1
|
14
|
+
YjgxMjY5MjdlM2JiMjhkY2ViOThhNzgwMGNlOTBhMzdmYmQxZTU2M2NlNDEz
|
15
|
+
ZWJlMTZkMmZmOGY0MmY1NDA4MzBkNGYxZmJiNGU0MjVmZjFiNDI=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
2.8.0
|
2
|
+
=====
|
3
|
+
|
4
|
+
This feature release includes the new Openstack provider, which allows you to
|
5
|
+
now use an Openstack installation for provisioning test nodes. Thanks to Hawk
|
6
|
+
Newton for providing this contribution.
|
7
|
+
|
8
|
+
Consult the README.md file for more information on this provider.
|
9
|
+
|
10
|
+
As this functionality is fairly new, YMMV - but please test away and let us
|
11
|
+
know if you find any issues.
|
12
|
+
|
13
|
+
#### Detailed Changes
|
14
|
+
|
15
|
+
* Openstack provider (Hawk Newton)
|
16
|
+
|
17
|
+
-------------------------------
|
18
|
+
|
1
19
|
2.7.2
|
2
20
|
=====
|
3
21
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -306,6 +306,31 @@ Set these variables, and run the usual rake command specifying the provider:
|
|
306
306
|
|
307
307
|
In Jenkins, set the authentication variables above using environment variable injection. I recommend using the private environment variables feature for user & pass however so these do not get displayed in the console output. As with the vagrant provider however, turn RS\_SET into a test matrix, containing all the sets you want to test against.
|
308
308
|
|
309
|
+
#### OpenStack
|
310
|
+
|
311
|
+
You may also use [OpenStack](http://www.openstack.org/) as a virtualization provider.
|
312
|
+
|
313
|
+
RS_PROVIDER=openstack
|
314
|
+
|
315
|
+
All parameters are required and case sensitive.
|
316
|
+
|
317
|
+
* *RS_OPENSTACK_ENDPOINT* -- Your openstack token url, something like `http://your.openstack.url:5000/v2.0/tokens`
|
318
|
+
* *RS_OPENSTACK_USERNAME* -- Your openstack username
|
319
|
+
* *RS_OPENSTACK_API_KEY* -- password
|
320
|
+
* *RS_OPENSTACK_KEYPAIR_NAME* -- ssh keypair name
|
321
|
+
* *RS_OPENSTACK_FLAVOR_NAME* -- flavor name
|
322
|
+
* *RS_OPENSTACK_IMAGE_NAME* -- image name
|
323
|
+
* *RS_OPENSTACK_NETWORK_NAME* -- network name
|
324
|
+
* *RS_OPENSTACK_NODE_TIMEOUT* -- Number of seconds to wait for openstack instances to be created
|
325
|
+
* *RS_OPENSTACK_SSH_KEYS* -- Full path to ssh private keys, colin (:) delimited
|
326
|
+
|
327
|
+
|
328
|
+
##### OpenStack TODO
|
329
|
+
* Support `RSPEC_DESTROY=no` and destroying abandoned instances by persisting the server ids in .rspec_system
|
330
|
+
* Provide support for floating ips
|
331
|
+
* Support explicit tenant ids
|
332
|
+
* No custom option support
|
333
|
+
|
309
334
|
### Plugins to rspec-system
|
310
335
|
|
311
336
|
Right now we have two types of plugins, the framework is in a state of flux as to how one writes these things but here we go.
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
require 'net/scp'
|
3
|
+
require 'fog'
|
4
|
+
require 'rspec-system/node_set/base'
|
5
|
+
|
6
|
+
module RSpecSystem
|
7
|
+
class NodeSet::Openstack < NodeSet::Base
|
8
|
+
PROVIDER_TYPE = 'openstack'
|
9
|
+
attr_accessor :vmconf
|
10
|
+
|
11
|
+
CONFIG_KEYS = [
|
12
|
+
:node_timeout,
|
13
|
+
:username,
|
14
|
+
:flavor_name,
|
15
|
+
:image_name,
|
16
|
+
:endpoint,
|
17
|
+
:keypair_name,
|
18
|
+
:network_name,
|
19
|
+
:ssh_keys,
|
20
|
+
:api_key
|
21
|
+
]
|
22
|
+
|
23
|
+
def initialize(name, config, custom_prefabs_path, options)
|
24
|
+
super
|
25
|
+
@vmconf = read_config
|
26
|
+
@now = Time.now.strftime '%Y%m%d-%H:%M:%S.%L'
|
27
|
+
RSpec.configuration.rs_storage[:nodes] ||= {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def launch
|
31
|
+
nodes.each do |k,v|
|
32
|
+
storage = RSpec.configuration.rs_storage[:nodes][k] ||= {}
|
33
|
+
options = {
|
34
|
+
:flavor_ref => flavor.id,
|
35
|
+
:image_ref => image.id,
|
36
|
+
:name => "#{k}-#{@now}",
|
37
|
+
:key_name => vmconf[:keypair_name]
|
38
|
+
}
|
39
|
+
options[:nics] = [{'net_id' => nic.id}] if vmconf[:network_name]
|
40
|
+
log.info "Launching openstack instance #{k}"
|
41
|
+
result = compute.servers.create options
|
42
|
+
storage[:server] = result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def connect
|
47
|
+
nodes.each do |k,v|
|
48
|
+
server = RSpec.configuration.rs_storage[:nodes][k][:server]
|
49
|
+
before = Time.new.to_i
|
50
|
+
while true
|
51
|
+
begin
|
52
|
+
server.wait_for(5) { ready? }
|
53
|
+
break
|
54
|
+
rescue ::Fog::Errors::TimeoutError
|
55
|
+
raise if Time.new.to_i - before > vmconf[:node_timeout]
|
56
|
+
log.info "Timeout connecting to instance, trying again..."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
chan = ssh_connect(:host => k, :user => 'root', :net_ssh_options => {
|
61
|
+
:keys => vmconf[:ssh_keys].split(':'),
|
62
|
+
:host_name => server.addresses[vmconf[:network_name]].first['addr'],
|
63
|
+
:paranoid => false
|
64
|
+
})
|
65
|
+
RSpec.configuration.rs_storage[:nodes][k][:ssh] = chan
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def teardown
|
70
|
+
nodes.keys.each do |k|
|
71
|
+
server = RSpec.configuration.rs_storage[:nodes][k][:server]
|
72
|
+
log.info "Destroying server #{server.name}"
|
73
|
+
server.destroy
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def compute
|
78
|
+
@compute || @compute = Fog::Compute.new({
|
79
|
+
:provider => :openstack,
|
80
|
+
:openstack_username => vmconf[:username],
|
81
|
+
:openstack_api_key => vmconf[:api_key],
|
82
|
+
:openstack_auth_url => vmconf[:endpoint],
|
83
|
+
})
|
84
|
+
end
|
85
|
+
|
86
|
+
def network
|
87
|
+
@network || @network = Fog::Network.new({
|
88
|
+
:provider => :openstack,
|
89
|
+
:openstack_username => vmconf[:username],
|
90
|
+
:openstack_api_key => vmconf[:api_key],
|
91
|
+
:openstack_auth_url => vmconf[:endpoint],
|
92
|
+
})
|
93
|
+
end
|
94
|
+
private
|
95
|
+
|
96
|
+
def flavor
|
97
|
+
log.info "Looking up flavor #{vmconf[:flavor_name]}"
|
98
|
+
compute.flavors.find { |x| x.name == vmconf[:flavor_name] } || raise("Couldn't find flavor: #{vmconf[:flavor_name]}")
|
99
|
+
end
|
100
|
+
|
101
|
+
def image
|
102
|
+
log.info "Looking up image #{vmconf[:image_name]}"
|
103
|
+
compute.images.find { |x| x.name == vmconf[:image_name] } || raise("Couldn't find image: #{vmconf[:image_name]}")
|
104
|
+
end
|
105
|
+
|
106
|
+
def nic
|
107
|
+
log.info "Looking up network #{vmconf[:network_name]}"
|
108
|
+
network.networks.find { |x| x.name == vmconf[:network_name] } || raise("Couldn't find network: #{vmconf[:network_name]}")
|
109
|
+
end
|
110
|
+
|
111
|
+
def read_config
|
112
|
+
conf = ENV.inject({}) do |memo,(k,v)|
|
113
|
+
if k =~ /^RS_OPENSTACK_(.+)/
|
114
|
+
var = $1.downcase.to_sym
|
115
|
+
memo[var] = v if ([var] & CONFIG_KEYS).any?
|
116
|
+
end
|
117
|
+
memo
|
118
|
+
end
|
119
|
+
|
120
|
+
conf[:node_timeout] = conf[:node_timeout].to_i unless conf[:node_timeout].nil?
|
121
|
+
conf
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/rspec-system.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
# Metadata
|
4
4
|
s.name = "rspec-system"
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.8.0"
|
6
6
|
s.authors = ["Ken Barber"]
|
7
7
|
s.email = ["info@puppetlabs.com"]
|
8
8
|
s.homepage = "https://github.com/puppetlabs/rspec-system"
|
@@ -25,4 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_runtime_dependency "rbvmomi", '~>1.6'
|
26
26
|
# It seems 1.6.0 relies on ruby 1.9.2, so lets pin it for now
|
27
27
|
s.add_runtime_dependency "nokogiri", '~>1.5.10'
|
28
|
+
s.add_runtime_dependency 'fog', '~> 1.18'
|
29
|
+
# 2.0 drops 1.8.7 support
|
30
|
+
s.add_runtime_dependency 'mime-types', '~> 1.16'
|
31
|
+
|
28
32
|
end
|
@@ -0,0 +1,361 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec-system/node_set/openstack'
|
3
|
+
|
4
|
+
describe RSpecSystem::NodeSet::Openstack do
|
5
|
+
subject { described_class.new(setname, config, custom_prefabs_path, options) }
|
6
|
+
|
7
|
+
let(:setname) { 'set name' }
|
8
|
+
let(:config) do
|
9
|
+
{
|
10
|
+
'nodes' => {
|
11
|
+
'main-test1' => { 'prefab' => 'centos-64-x64' },
|
12
|
+
'main-test2' => { 'prefab' => 'centos-59-x64' }
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:custom_prefabs_path) { '' }
|
18
|
+
let(:options) { { } }
|
19
|
+
let(:api_key) { 'test-api_key' }
|
20
|
+
let(:node_timeout) { 120 }
|
21
|
+
let(:username) { 'test-username' }
|
22
|
+
let(:image_name) { 'test-image_name' }
|
23
|
+
let(:flavor_name) { 'test-flavor_name' }
|
24
|
+
let(:endpoint) { 'http://token.url/tokens' }
|
25
|
+
let(:keypair_name) { 'test-keypair_name' }
|
26
|
+
let(:ssh_username) { 'test-ssh_username' }
|
27
|
+
let(:network_name) { 'test-network_name' }
|
28
|
+
let(:ssh_keys) { 'test-ssh_key' }
|
29
|
+
|
30
|
+
let(:env_vars) do
|
31
|
+
{
|
32
|
+
'RS_OPENSTACK_NODE_TIMEOUT' => node_timeout,
|
33
|
+
'RS_OPENSTACK_USERNAME' => username,
|
34
|
+
'RS_OPENSTACK_API_KEY' => api_key,
|
35
|
+
'RS_OPENSTACK_IMAGE_NAME' => image_name,
|
36
|
+
'RS_OPENSTACK_FLAVOR_NAME' => flavor_name,
|
37
|
+
'RS_OPENSTACK_ENDPOINT' => endpoint,
|
38
|
+
'RS_OPENSTACK_KEYPAIR_NAME' => keypair_name,
|
39
|
+
'RS_OPENSTACK_SSH_USERNAME' => ssh_username,
|
40
|
+
'RS_OPENSTACK_NETWORK_NAME' => network_name,
|
41
|
+
'RS_OPENSTACK_SSH_KEYS' => ssh_keys
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:rs_storage) do
|
46
|
+
{ }
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:log) do
|
50
|
+
log = stub :log
|
51
|
+
log.stubs :info
|
52
|
+
log
|
53
|
+
end
|
54
|
+
|
55
|
+
before do
|
56
|
+
env_vars.each { |k,v| ENV[k] = v.to_s }
|
57
|
+
RSpec.configuration.stubs(:rs_storage).returns rs_storage
|
58
|
+
described_class.any_instance.stubs(:log).returns log
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have the PROVIDER_TYPE openstack' do
|
62
|
+
expect(described_class::PROVIDER_TYPE).to eq 'openstack'
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#vmconf' do
|
66
|
+
subject { described_class.new(setname, config, custom_prefabs_path, options).vmconf }
|
67
|
+
context 'given env config variables' do
|
68
|
+
|
69
|
+
it 'should read node_timeout from the environment' do
|
70
|
+
expect(subject[:node_timeout]).to eq node_timeout
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should read username from the environment' do
|
74
|
+
expect(subject[:username]).to eq username
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should read flavor from the environment' do
|
78
|
+
expect(subject[:flavor_name]).to eq flavor_name
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should read image from the environment' do
|
82
|
+
expect(subject[:image_name]).to eq image_name
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should read endpoint url from the environment' do
|
86
|
+
expect(subject[:endpoint]).to eq endpoint
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should read keypair name from the environment' do
|
90
|
+
expect(subject[:keypair_name]).to eq keypair_name
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should read network name from the environment' do
|
94
|
+
expect(subject[:network_name]).to eq network_name
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should read private key from the environment' do
|
98
|
+
expect(subject[:ssh_keys]).to eq ssh_keys
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should read api key from the environment' do
|
102
|
+
expect(subject[:api_key]).to eq api_key
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#compute' do
|
108
|
+
subject { described_class.new(setname, config, custom_prefabs_path, options).compute }
|
109
|
+
let(:connection) { Object.new }
|
110
|
+
|
111
|
+
it 'should retrieve connection to openstack compute' do
|
112
|
+
Fog::Compute.expects(:new).with({
|
113
|
+
:provider => :openstack,
|
114
|
+
:openstack_username => username,
|
115
|
+
:openstack_api_key => api_key,
|
116
|
+
:openstack_auth_url => endpoint,
|
117
|
+
}).returns connection
|
118
|
+
expect(subject).to equal connection
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should cache openstack connections' do
|
122
|
+
Fog::Compute.expects(:new).with({
|
123
|
+
:provider => :openstack,
|
124
|
+
:openstack_username => username,
|
125
|
+
:openstack_api_key => api_key,
|
126
|
+
:openstack_auth_url => endpoint,
|
127
|
+
}).once.returns connection
|
128
|
+
c = described_class.new(setname, config, custom_prefabs_path, options)
|
129
|
+
c.compute
|
130
|
+
c.compute
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#network' do
|
135
|
+
subject { described_class.new(setname, config, custom_prefabs_path, options).network }
|
136
|
+
let(:connection) { Object.new }
|
137
|
+
|
138
|
+
it 'should retrieve connection to openstack network' do
|
139
|
+
Fog::Network.expects(:new).with({
|
140
|
+
:provider => :openstack,
|
141
|
+
:openstack_username => username,
|
142
|
+
:openstack_api_key => api_key,
|
143
|
+
:openstack_auth_url => endpoint,
|
144
|
+
}).returns connection
|
145
|
+
expect(subject).to equal connection
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should cache connections' do
|
149
|
+
Fog::Network.expects(:new).with({
|
150
|
+
:provider => :openstack,
|
151
|
+
:openstack_username => username,
|
152
|
+
:openstack_api_key => api_key,
|
153
|
+
:openstack_auth_url => endpoint,
|
154
|
+
}).once.returns connection
|
155
|
+
c = described_class.new(setname, config, custom_prefabs_path, options)
|
156
|
+
c.network
|
157
|
+
c.network
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#launch' do
|
162
|
+
subject { described_class.new(setname, config, custom_prefabs_path, options) }
|
163
|
+
|
164
|
+
let(:compute) do
|
165
|
+
stub({
|
166
|
+
:flavors => [ stub(:id => flavor_id, :name => flavor_name) ],
|
167
|
+
:images => [ stub(:id => image_id, :name => image_name) ],
|
168
|
+
:servers => mock('servers')
|
169
|
+
})
|
170
|
+
end
|
171
|
+
|
172
|
+
let(:create_returns) do
|
173
|
+
{ 'id' => machine_id }
|
174
|
+
end
|
175
|
+
|
176
|
+
let(:network) do
|
177
|
+
stub(:networks => [ stub(:id => network_id, :name => network_name) ])
|
178
|
+
end
|
179
|
+
|
180
|
+
let(:flavor_id) { 'flavor_123' }
|
181
|
+
let(:image_id) { 'image_123' }
|
182
|
+
let(:network_id) { 'network_123' }
|
183
|
+
let(:machine_id) { 'machine_123' }
|
184
|
+
|
185
|
+
before do
|
186
|
+
compute.servers.stubs(:create).returns create_returns
|
187
|
+
subject.stubs(:compute).returns compute
|
188
|
+
subject.stubs(:network).returns network
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should use the node\'s name' do
|
192
|
+
num = 1
|
193
|
+
compute.servers.expects(:create).with do |options|
|
194
|
+
expect(options[:name]).to match /^main-test#{num}-.+/
|
195
|
+
num += 1
|
196
|
+
end.twice.returns create_returns
|
197
|
+
subject.launch
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should lookup the flavor' do
|
201
|
+
compute.servers.expects(:create).twice.with do |options|
|
202
|
+
expect(options[:flavor_ref]).to eq flavor_id
|
203
|
+
end.returns create_returns
|
204
|
+
subject.launch
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should lookup the image' do
|
208
|
+
compute.servers.expects(:create).twice.with do |options|
|
209
|
+
expect(options[:image_ref]).to eq image_id
|
210
|
+
end.returns create_returns
|
211
|
+
subject.launch
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should use the correct ssh keypair name' do
|
215
|
+
compute.servers.expects(:create).twice.with do |options|
|
216
|
+
expect(options[:key_name]).to eq keypair_name
|
217
|
+
end.returns create_returns
|
218
|
+
subject.launch
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should use the correct network id' do
|
222
|
+
compute.servers.expects(:create).twice.with do |options|
|
223
|
+
nics = options[:nics]
|
224
|
+
expect(nics[0]['net_id']).to eq network_id
|
225
|
+
end.returns create_returns
|
226
|
+
subject.launch
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should assign server to rs_storage' do
|
230
|
+
subject.launch
|
231
|
+
expect(rs_storage[:nodes]['main-test1'][:server]).to equal create_returns
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe '#connect' do
|
236
|
+
let(:servers) do
|
237
|
+
[
|
238
|
+
stub(:addresses => { 'test-network_name' => [{'addr' => 'address1'}]}),
|
239
|
+
stub(:addresses => { 'test-network_name' => [{'addr' => 'address2'}]})
|
240
|
+
]
|
241
|
+
end
|
242
|
+
|
243
|
+
let(:rs_storage) do
|
244
|
+
{
|
245
|
+
:nodes =>
|
246
|
+
{
|
247
|
+
'main-test1' => {},
|
248
|
+
'main-test2' => {}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
end
|
252
|
+
|
253
|
+
before do
|
254
|
+
rs_storage[:nodes]['main-test1'][:server] = servers[0]
|
255
|
+
rs_storage[:nodes]['main-test2'][:server] = servers[1]
|
256
|
+
|
257
|
+
servers.each do |x|
|
258
|
+
x.stubs(:wait_for).returns true
|
259
|
+
end
|
260
|
+
subject.stubs(:ssh_connect)
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'should call ready? for each server' do
|
264
|
+
servers[0].expects(:wait_for).returns true
|
265
|
+
servers[1].expects(:wait_for).returns true
|
266
|
+
|
267
|
+
subject.connect
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'should retry if Fog throws a timeout' do
|
271
|
+
servers[0].expects(:wait_for).raises(::Fog::Errors::TimeoutError.new).then.returns true
|
272
|
+
subject.connect
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'with node timeout = 1' do
|
276
|
+
let(:node_timeout) { 1 }
|
277
|
+
it 'should give up after more than 1 second' do
|
278
|
+
servers[0].stubs(:wait_for).with do
|
279
|
+
sleep 1.25
|
280
|
+
raise ::Fog::Errors::TimeoutError.new
|
281
|
+
end
|
282
|
+
|
283
|
+
expect {subject.connect}.to raise_error ::Fog::Errors::TimeoutError
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'should retry after less than 1 second' do
|
287
|
+
first_time = true
|
288
|
+
called_twice = false
|
289
|
+
servers[0].stubs(:wait_for).with do
|
290
|
+
if first_time
|
291
|
+
first_time = false
|
292
|
+
raise ::Fog::Errors::TimeoutError.new
|
293
|
+
else
|
294
|
+
called_twice = true
|
295
|
+
end
|
296
|
+
end
|
297
|
+
subject.connect
|
298
|
+
expect(called_twice).to be_true
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should connect though ssh as root' do
|
302
|
+
subject.expects(:ssh_connect).with do |options|
|
303
|
+
expect(options[:user]).to eq 'root'
|
304
|
+
end
|
305
|
+
subject.connect
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'should disable ssh paranoid' do
|
309
|
+
subject.expects(:ssh_connect).with do |options|
|
310
|
+
expect(options[:net_ssh_options][:paranoid]).to eq false
|
311
|
+
end
|
312
|
+
subject.connect
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'should connect though ssh using the private key' do
|
316
|
+
subject.expects(:ssh_connect).with do |options|
|
317
|
+
expect(options[:net_ssh_options][:keys]).to eq [ssh_keys]
|
318
|
+
end
|
319
|
+
subject.connect
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'should connect through ssh to each node\'s address' do
|
323
|
+
subject.expects(:ssh_connect).with do |options|
|
324
|
+
if options[:host] == 'main-test1'
|
325
|
+
address = 'address1'
|
326
|
+
else
|
327
|
+
address = 'address2'
|
328
|
+
end
|
329
|
+
expect(options[:net_ssh_options][:host_name]).to eq address
|
330
|
+
end
|
331
|
+
subject.connect
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe '#teardown' do
|
337
|
+
let(:servers) do
|
338
|
+
[
|
339
|
+
stub(:name => 'server 1'),
|
340
|
+
stub(:name => 'server 2')
|
341
|
+
]
|
342
|
+
end
|
343
|
+
|
344
|
+
let(:rs_storage) do
|
345
|
+
{
|
346
|
+
:nodes =>
|
347
|
+
{
|
348
|
+
'main-test1' => {:server => servers[0]},
|
349
|
+
'main-test2' => {:server => servers[1]}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should call #destroy on each server' do
|
355
|
+
servers[0].expects(:destroy)
|
356
|
+
servers[1].expects(:destroy)
|
357
|
+
|
358
|
+
subject.teardown
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Barber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.5.10
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fog
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.18'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.18'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mime-types
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.16'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.16'
|
111
139
|
description:
|
112
140
|
email:
|
113
141
|
- info@puppetlabs.com
|
@@ -144,6 +172,7 @@ files:
|
|
144
172
|
- lib/rspec-system/node.rb
|
145
173
|
- lib/rspec-system/node_set.rb
|
146
174
|
- lib/rspec-system/node_set/base.rb
|
175
|
+
- lib/rspec-system/node_set/openstack.rb
|
147
176
|
- lib/rspec-system/node_set/vagrant_base.rb
|
148
177
|
- lib/rspec-system/node_set/vagrant_virtualbox.rb
|
149
178
|
- lib/rspec-system/node_set/vagrant_vmware_fusion.rb
|
@@ -171,6 +200,7 @@ files:
|
|
171
200
|
- spec/unit/helper_spec.rb
|
172
201
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
173
202
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
203
|
+
- spec/unit/openstack_spec.rb
|
174
204
|
- spec/unit/result_spec.rb
|
175
205
|
- spec/unit/utils_spec.rb
|
176
206
|
homepage: https://github.com/puppetlabs/rspec-system
|
@@ -205,5 +235,6 @@ test_files:
|
|
205
235
|
- spec/unit/helper_spec.rb
|
206
236
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
207
237
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
238
|
+
- spec/unit/openstack_spec.rb
|
208
239
|
- spec/unit/result_spec.rb
|
209
240
|
- spec/unit/utils_spec.rb
|