beaker-vmpooler 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NGM3ODk5NTJiZTVlNWUwZjliMjAxMTgyNmM0NWZkYjEzNmUzYmJlNw==
5
- data.tar.gz: !binary |-
6
- ZjI4NTIxYzg4ZmVhYzE3ZTc4NjcxOGUwMDdiMjBhOWNlMjE1MTUyMA==
2
+ SHA1:
3
+ metadata.gz: ce23690ed0df119bf2679dac97287f34dfd93285
4
+ data.tar.gz: 8d391c93b110eaf4033754af2271f6b8d3fc9bce
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzM3NjEyMzAwM2YxN2RhM2Y2MWNiNmIwYjYxNmVhOGFjYWE1NWY2OGI2ZTBh
10
- NmZjMTQ3ZDZiMjk5NDU3NWRiNTk1ZTQ0MmQ4OGQzNDE1ZGVhMGIyNzhiODEx
11
- NDliZWY3N2FkMzRkMDc2ZDIzODQyMTYwMDUyZDZlZTNiOGI0MTI=
12
- data.tar.gz: !binary |-
13
- NmUyYTc2ZDg2YmM4MmI5YzI0NTE1Yjc5YTlhZjFkNDk1NGM4MDIzMzBmNDIx
14
- MzRjMTI3ZDhkMmYwOTQ5NTkwZWMwNjU5OWIyYWMwYmY5YTEzODZlMDBkZjll
15
- YWEzZTI0YWVmM2M0NGFmZjYzNWI1MzJiNDBlMTQ2YzNhZmIwM2I=
6
+ metadata.gz: 6e4f347303be420a526e83b6dc150d14e810829b554c849702c66656ea2065bbdc0ea19ab9d52e291869cd1bd85c70a3a99d80ef84b7161d3d4c546bba307833
7
+ data.tar.gz: 5d183ebff78bf8af5d9f4066525930f64b1acef609e23ec900e3cf7baeaef819e7de8c6678a631c5ca0e37fa43856059794678580858afa94a06966ca12b48cc
data/Gemfile CHANGED
@@ -19,7 +19,6 @@ end
19
19
  # don't want to create a transitive dependency
20
20
  group :acceptance_testing do
21
21
  gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.0')
22
- gem "beaker-abs", *location_for(ENV['ABS_VERSION'] || '~> 0.3.0')
23
22
  end
24
23
 
25
24
 
@@ -20,7 +20,12 @@ Gem::Specification.new do |s|
20
20
  # Testing dependencies
21
21
  s.add_development_dependency 'rspec', '~> 3.0'
22
22
  s.add_development_dependency 'rspec-its'
23
- s.add_development_dependency 'fakefs', '~> 0.6'
23
+ # pin fakefs for Ruby < 2.3
24
+ if RUBY_VERSION < "2.3"
25
+ s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
26
+ else
27
+ s.add_development_dependency 'fakefs', '~> 0.6'
28
+ end
24
29
  s.add_development_dependency 'rake', '~> 10.1'
25
30
  s.add_development_dependency 'simplecov'
26
31
  s.add_development_dependency 'pry', '~> 0.10'
@@ -1,3 +1,3 @@
1
1
  module BeakerVmpooler
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -27,33 +27,21 @@ module Beaker
27
27
 
28
28
  def load_credentials(dot_fog = '.fog')
29
29
  creds = {}
30
-
31
- if fog = read_fog_file(dot_fog)
32
- if fog[:default] && fog[:default][:vmpooler_token]
33
- creds[:vmpooler_token] = fog[:default][:vmpooler_token]
30
+ begin
31
+ fog = get_fog_credentials(dot_fog)
32
+ if fog[:vmpooler_token]
33
+ creds[:vmpooler_token] = fog[:vmpooler_token]
34
34
  else
35
- @logger.warn "Credentials file (#{dot_fog}) is missing a :default section with a :vmpooler_token value; proceeding without authentication"
35
+ @logger.warn "vmpooler_token not found in credentials file (#{dot_fog})\nProceeding without authentication"
36
36
  end
37
- else
38
- @logger.warn "Credentials file (#{dot_fog}) is empty; proceeding without authentication"
37
+ rescue ArgumentError => e
38
+ @logger.warn "Invalid credentials file:\n(#{e.class}) #{e.message}\nProceeding without authentication"
39
39
  end
40
-
41
40
  creds
42
-
43
- rescue TypeError, Psych::SyntaxError => e
44
- @logger.warn "#{e.class}: Credentials file (#{dot_fog}) has invalid syntax; proceeding without authentication"
45
- creds
46
- rescue Errno::ENOENT
47
- @logger.warn "Credentials file (#{dot_fog}) not found; proceeding without authentication"
48
- creds
49
- end
50
-
51
- def read_fog_file(dot_fog = '.fog')
52
- YAML.load_file(dot_fog)
53
41
  end
54
42
 
55
43
  def connection_preference(host)
56
- ['vmhostname', 'ip', 'hostname']
44
+ [:vmhostname, :ip, :hostname]
57
45
  end
58
46
 
59
47
  def check_url url
@@ -4,10 +4,6 @@ module Beaker
4
4
  describe Vmpooler do
5
5
 
6
6
  before :each do
7
- vms = make_hosts()
8
- MockVsphereHelper.set_config( fog_file_contents )
9
- MockVsphereHelper.set_vms( vms )
10
- stub_const( "VsphereHelper", MockVsphereHelper )
11
7
  stub_const( "Net", MockNet )
12
8
  allow( JSON ).to receive( :parse ) do |arg|
13
9
  arg
@@ -147,20 +143,15 @@ module Beaker
147
143
  describe "#cleanup" do
148
144
 
149
145
  it "cleans up hosts in the pool" do
150
- MockVsphereHelper.powerOn
151
-
146
+ mock_http = MockNet::HTTP.new( "host", "port" )
152
147
  vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
153
- allow( vmpooler ).to receive( :require ).and_return( true )
154
- allow( vmpooler ).to receive( :sleep ).and_return( true )
155
148
  vmpooler.provision
156
- vmpooler.cleanup
149
+ vm_count = vmpooler.instance_variable_get( :@hosts ).count
157
150
 
158
- hosts = vmpooler.instance_variable_get( :@hosts )
159
- hosts.each do | host |
160
- name = host.name
161
- vm = MockVsphereHelper.find_vm( name )
162
- expect( vm.runtime.powerState ).to be === "poweredOn" #handed back to the pool, stays on
163
- end
151
+ expect( Net::HTTP ).to receive( :new ).exactly( vm_count ).times.and_return( mock_http )
152
+ expect( mock_http ).to receive( :request ).exactly( vm_count ).times
153
+ expect( Net::HTTP::Delete ).to receive( :new ).exactly( vm_count ).times
154
+ expect{ vmpooler.cleanup }.to_not raise_error
164
155
  end
165
156
  end
166
157
  end
@@ -168,10 +159,6 @@ module Beaker
168
159
  describe Vmpooler do
169
160
 
170
161
  before :each do
171
- vms = make_hosts()
172
- MockVsphereHelper.set_config( fog_file_contents )
173
- MockVsphereHelper.set_vms( vms )
174
- stub_const( "VsphereHelper", MockVsphereHelper )
175
162
  stub_const( "Net", MockNet )
176
163
  allow( JSON ).to receive( :parse ) do |arg|
177
164
  arg
@@ -181,95 +168,38 @@ module Beaker
181
168
 
182
169
  describe "#load_credentials" do
183
170
 
184
- it 'continues without credentials when fog file is missing' do
185
- allow_any_instance_of( Beaker::Vmpooler ).to \
186
- receive(:read_fog_file).and_raise(Errno::ENOENT.new)
187
-
188
- vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
189
- expect( vmpooler.credentials ).to be == {}
190
- end
191
-
192
- it 'continues without credentials when fog file is empty' do
193
- allow_any_instance_of( Beaker::Vmpooler ).to \
194
- receive(:read_fog_file).and_return(false)
195
-
196
- vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
197
- expect( vmpooler.credentials ).to be == {}
198
- end
199
-
200
- it 'continues without credentials when fog file contains no :default section' do
201
- data = { :some => { :other => :data } }
171
+ it 'loads credentials from a fog file' do
172
+ credentials = { :vmpooler_token => "example_token" }
173
+ make_opts = { :dot_fog => '.fog' }
202
174
 
203
- allow_any_instance_of( Beaker::Vmpooler ).to \
204
- receive(:read_fog_file).and_return(data)
175
+ expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_return(credentials)
205
176
 
206
177
  vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
207
- expect( vmpooler.credentials ).to be == { }
178
+ expect( vmpooler.credentials ).to be == credentials
208
179
  end
209
180
 
210
- it 'continues without credentials when fog file :default section has no :vmpooler_token' do
211
- data = { :default => { :something_else => "TOKEN" } }
181
+ it 'continues without credentials when there are problems loading the fog file' do
182
+ logger = double( 'logger' )
183
+ make_opts = { :logger => logger, :dot_fog => '.fog' }
212
184
 
213
- allow_any_instance_of( Beaker::Vmpooler ).to \
214
- receive(:read_fog_file).and_return(data)
185
+ expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_raise( ArgumentError, 'something went wrong' )
186
+ expect( logger ).to receive( :warn ).with( /Invalid credentials file.*something went wrong.*Proceeding without authentication/m )
215
187
 
216
188
  vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
217
- expect( vmpooler.credentials ).to be == { }
218
- end
219
-
220
- it 'continues without credentials when there are formatting errors in the fog file' do
221
- data = { "'default'" => { :vmpooler_token => "b2wl8prqe6ddoii70md" } }
222
-
223
- allow_any_instance_of( Beaker::Vmpooler ).to \
224
- receive(:read_fog_file).and_return(data)
225
-
226
- logger = double('logger')
227
189
 
228
- expect(logger).to receive(:warn).with(/is missing a :default section with a :vmpooler_token value/)
229
- make_opts = {:logger => logger}
230
-
231
- vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
232
- expect( vmpooler.credentials ).to be == { }
190
+ expect( vmpooler.credentials ).to be == {}
233
191
  end
234
192
 
235
- it 'throws a TypeError and continues without credentials when there are syntax errors in the fog file' do
236
- data = "'default'\n :vmpooler_token: z2wl8prqe0ddoii70ad"
193
+ it 'continues without credentials when fog file has no vmpooler_token' do
194
+ logger = double( 'logger' )
195
+ make_opts = { :logger => logger, :dot_fog => '.fog' }
237
196
 
238
- allow( File ).to receive( :open ).and_yield( StringIO.new(data) )
239
- logger = double('logger')
240
-
241
- expect(logger).to receive(:warn).with(/TypeError: .* has invalid syntax/)
242
- make_opts = {:logger => logger}
197
+ expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_return( {} )
198
+ expect( logger ).to receive( :warn ).with( /vmpooler_token not found in credentials file.*Proceeding without authentication/m )
243
199
 
244
200
  vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
245
201
 
246
- expect( vmpooler.credentials ).to be == { }
247
- end
248
-
249
- it 'throws a Psych::SyntaxError and continues without credentials when there are syntax errors in the fog file' do
250
-
251
- data = ";default;\n :vmpooler_token: z2wl8prqe0ddoii707d"
252
-
253
- allow( File ).to receive( :open ).and_yield( StringIO.new(data) )
254
-
255
- logger = double('logger')
256
-
257
- expect(logger).to receive(:warn).with(/Psych::SyntaxError: .* invalid syntax/)
258
- make_opts = {:logger => logger}
259
-
260
- vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
261
-
262
- expect( vmpooler.credentials ).to be == { }
263
- end
264
-
265
- it 'stores vmpooler token when found in fog file' do
266
- data = { :default => { :vmpooler_token => "TOKEN" } }
267
-
268
- allow_any_instance_of( Beaker::Vmpooler ).to \
269
- receive(:read_fog_file).and_return(data)
270
-
271
- vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
272
- expect( vmpooler.credentials ).to be == { :vmpooler_token => "TOKEN" }
202
+ expect( vmpooler.credentials ).to be == {}
273
203
  end
274
204
  end
275
205
  end
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-vmpooler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rishi Javia, Kevin Imber, Tony Vu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-its
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fakefs
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.10'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.10'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: markdown
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: thin
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: stringify-hash
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.0.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.0.0
153
153
  description: For use for the Beaker acceptance testing tool
@@ -158,9 +158,9 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
- - .gitignore
162
- - .rspec
163
- - .simplecov
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".simplecov"
164
164
  - Gemfile
165
165
  - LICENSE
166
166
  - README.md
@@ -182,17 +182,17 @@ require_paths:
182
182
  - lib
183
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ! '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.4.8
195
+ rubygems_version: 2.5.1
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Beaker DSL Extension Helpers!