beaker-openstack 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec8d2595a3b94ae10ba8dbc5b29529506c36c5133b3fa56ae93a1f52d07d9686
4
- data.tar.gz: 0d7518b15835c1b50b8a33e58a739e56a4d76a5c6593f17a64daa12592f915f0
3
+ metadata.gz: c5432c86653f848d141b7170b2f434bdd9479268956aad4dd821bfbb4f66eed7
4
+ data.tar.gz: a3e397ec1d79f453858d00e641211feaeef426f55bc95ee99ac3e5bdfcf60151
5
5
  SHA512:
6
- metadata.gz: bc97fe129ef779dd643011e1a5b9f55c99c3f92659d397019a657dadf45da0364872f0eab3b32fb195561ff02e65e63e2a41e2d2a51e25d6bc8c90fbdd58f9a6
7
- data.tar.gz: 14b0b253f8008aa4729257fa46cfc1e47a05436fe9bff420dc92b75040364878e6ce058f7266c0210eb037af3b49febaa38feb07428fbc002195135229538c16
6
+ metadata.gz: 8665d145f7d23bfcbc5fdb5bf504e333570156507b94e8bbbf5c251ca0a7eff95e4924a600dcbdb96b60f569e0068c38eea240c45553fd5738f6b420228d0979
7
+ data.tar.gz: b25f60256f8687260e3ac7f690789ebeec180d4f27fb88b06e9f8b8d0731faf7a899f38ea5e5b1f8842628e27490fbec4b2838a5c782adf678f77845b81db587
@@ -1,8 +1,17 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- time: "13:00"
8
- open-pull-requests-limit: 10
3
+ # raise PRs for gem updates
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: daily
8
+ time: "13:00"
9
+ open-pull-requests-limit: 10
10
+
11
+ # Maintain dependencies for GitHub Actions
12
+ - package-ecosystem: github-actions
13
+ directory: "/"
14
+ schedule:
15
+ interval: daily
16
+ time: "13:00"
17
+ open-pull-requests-limit: 10
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  if: github.repository == 'voxpupuli/beaker-openstack'
11
11
  steps:
12
- - uses: actions/checkout@v2
12
+ - uses: actions/checkout@v4
13
13
  - name: Install Ruby 3.0
14
14
  uses: ruby/setup-ruby@v1
15
15
  with:
@@ -11,19 +11,14 @@ jobs:
11
11
  fail-fast: false
12
12
  matrix:
13
13
  ruby:
14
- - "2.4"
15
- - "2.5"
16
- - "2.6"
17
14
  - "2.7"
18
15
  - "3.0"
19
16
  steps:
20
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v4
21
18
  - name: Install Ruby ${{ matrix.ruby }}
22
19
  uses: ruby/setup-ruby@v1
23
20
  with:
24
21
  ruby-version: ${{ matrix.ruby }}
25
22
  bundler-cache: true
26
- env:
27
- BUNDLE_WITHOUT: release
28
23
  - name: Run tests
29
24
  run: bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.0.0](https://github.com/voxpupuli/beaker-openstack/tree/2.0.0) (2024-02-03)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/1.0.0...2.0.0)
8
+
9
+ **Breaking changes:**
10
+
11
+ - Drop EoL Ruby 2.4/2.5/2.6 support [\#22](https://github.com/voxpupuli/beaker-openstack/pull/22) ([bastelfreak](https://github.com/bastelfreak))
12
+
13
+ **Implemented enhancements:**
14
+
15
+ - Add parallel instance creation opt-in option [\#20](https://github.com/voxpupuli/beaker-openstack/pull/20) ([canihavethisone](https://github.com/canihavethisone))
16
+
17
+ **Merged pull requests:**
18
+
19
+ - gemspec: Fix typo in Apache-2.0 license name [\#27](https://github.com/voxpupuli/beaker-openstack/pull/27) ([bastelfreak](https://github.com/bastelfreak))
20
+ - Apply best practices for our changelog generator [\#26](https://github.com/voxpupuli/beaker-openstack/pull/26) ([bastelfreak](https://github.com/bastelfreak))
21
+ - Cleanup Gemfile, add beaker as runtime dependency [\#24](https://github.com/voxpupuli/beaker-openstack/pull/24) ([bastelfreak](https://github.com/bastelfreak))
22
+ - dependabot: check for github actions and bundler [\#21](https://github.com/voxpupuli/beaker-openstack/pull/21) ([bastelfreak](https://github.com/bastelfreak))
23
+ - Update fakefs requirement from ~\> 1.3 to ~\> 2.4 [\#19](https://github.com/voxpupuli/beaker-openstack/pull/19) ([dependabot[bot]](https://github.com/apps/dependabot))
24
+
5
25
  ## [1.0.0](https://github.com/voxpupuli/beaker-openstack/tree/1.0.0) (2021-07-09)
6
26
 
7
27
  [Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/0.3.0...1.0.0)
data/Gemfile CHANGED
@@ -2,23 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- def location_for(place, fake_version = nil)
6
- if place =~ /^git:([^#]*)#(.*)/
7
- [fake_version, { :git => $1, :branch => $2, :require => false }].compact
8
- elsif place =~ /^file:\/\/(.*)/
9
- ['>= 0', { :path => File.expand_path($1), :require => false }]
10
- else
11
- [place, { :require => false }]
12
- end
13
- end
14
-
15
-
16
- # We don't put beaker in as a test dependency because we
17
- # don't want to create a transitive dependency
18
- group :acceptance_testing do
19
- gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
20
- end
21
-
22
- group :release do
23
- gem 'github_changelog_generator', :require => false
5
+ group :release, optional: true do
6
+ gem 'faraday-retry', '~> 2.1', require: false
7
+ gem 'github_changelog_generator','~> 1.16', '>= 1.16.4', require: false
24
8
  end
data/README.md CHANGED
@@ -137,6 +137,7 @@ CONFIG:
137
137
  openstack_volume_support: <true/false>
138
138
  security_group: ['default']
139
139
  preserve_hosts: <always/onfail/onpass/never>
140
+ create_in_parallel: true
140
141
  run_in_parallel: ['configure', 'install']
141
142
  type: <foss/git/pe>
142
143
  ```
@@ -154,6 +155,11 @@ Further, you can opt to use a static master by setting the master's hypervisor t
154
155
  ip: <master_ip>
155
156
  ```
156
157
 
158
+ Additionally, you can set instance creation to occur in parallel instead of sequentially via this CONFIG entry:
159
+ ```yaml
160
+ create_in_parallel: true
161
+ ```
162
+
157
163
  Additional parameter information is available at https://github.com/voxpupuli/beaker/blob/master/docs/concepts/argument_processing_and_precedence.md
158
164
 
159
165
  There is a simple rake task to invoke acceptance test for the library once the two environment variables are set:
data/Rakefile CHANGED
@@ -169,13 +169,14 @@ end
169
169
  begin
170
170
  require 'rubygems'
171
171
  require 'github_changelog_generator/task'
172
-
172
+ rescue LoadError
173
+ # github_changelog_generator is an optional group
174
+ else
173
175
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
174
176
  config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
175
- config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog modulesync}
177
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
176
178
  config.user = 'voxpupuli'
177
179
  config.project = 'beaker-openstack'
178
180
  config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
179
181
  end
180
- rescue LoadError
181
182
  end
@@ -10,17 +10,19 @@ Gem::Specification.new do |s|
10
10
  s.homepage = 'https://github.com/voxpupuli/beaker-openstack'
11
11
  s.summary = %q{Beaker DSL Extension Helpers!}
12
12
  s.description = %q{For use for the Beaker acceptance testing tool}
13
- s.license = 'Apache2'
13
+ s.license = 'Apache-2.0'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
+ s.required_ruby_version = '>= 2.7', '< 4'
21
+
20
22
  # Testing dependencies
21
23
  s.add_development_dependency 'rspec', '~> 3.0'
22
24
  s.add_development_dependency 'rspec-its'
23
- s.add_development_dependency 'fakefs', '~> 1.3'
25
+ s.add_development_dependency 'fakefs', '~> 2.4'
24
26
  s.add_development_dependency 'rake', '>= 12.3.3'
25
27
  s.add_development_dependency 'simplecov'
26
28
  s.add_development_dependency 'pry', '~> 0.10'
@@ -33,6 +35,5 @@ Gem::Specification.new do |s|
33
35
  # Run time dependencies
34
36
  s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'
35
37
  s.add_runtime_dependency 'fog-openstack', '~> 1.0.0'
36
-
38
+ s.add_runtime_dependency 'beaker', '~> 5.6'
37
39
  end
38
-
@@ -250,86 +250,123 @@ module Beaker
250
250
  ip
251
251
  end
252
252
 
253
- #Create new instances in OpenStack
253
+ # Create new instances in OpenStack, depending on if create_in_parallel is true or not
254
254
  def provision
255
- @logger.notify "Provisioning OpenStack"
256
-
257
- @hosts.each do |host|
258
- if @options[:openstack_floating_ip]
259
- ip = get_floating_ip
260
- hostname = ip.ip.gsub('.','-')
261
- host[:vmhostname] = hostname + '.rfc1918.puppetlabs.net'
262
- else
263
- hostname = ('a'..'z').to_a.shuffle[0, 10].join
264
- host[:vmhostname] = hostname
265
- end
266
-
267
- create_or_associate_keypair(host, hostname)
268
- @logger.debug "Provisioning #{host.name} (#{host[:vmhostname]})"
269
- options = {
270
- :flavor_ref => flavor(host[:flavor]).id,
271
- :image_ref => image(host[:image]).id,
272
- :nics => [ {'net_id' => network(@options[:openstack_network]).id } ],
273
- :name => host[:vmhostname],
274
- :hostname => host[:vmhostname],
275
- :user_data => host[:user_data] || "#cloud-config\nmanage_etc_hosts: true\n",
276
- :key_name => host[:keyname],
277
- }
278
- options[:security_groups] = security_groups(@options[:security_group]) unless @options[:security_group].nil?
279
- vm = @compute_client.servers.create(options)
280
-
281
- #wait for the new instance to start up
282
- try = 1
283
- attempts = @options[:timeout].to_i / SLEEPWAIT
284
-
285
- while try <= attempts
286
- begin
287
- vm.wait_for(5) { ready? }
288
- break
289
- rescue Fog::Errors::TimeoutError => e
290
- if try >= attempts
291
- @logger.debug "Failed to connect to new OpenStack instance #{host.name} (#{host[:vmhostname]})"
292
- raise e
293
- end
294
- @logger.debug "Timeout connecting to instance #{host.name} (#{host[:vmhostname]}), trying again..."
295
- end
296
- sleep SLEEPWAIT
297
- try += 1
298
- end
255
+ if @options[:create_in_parallel]
256
+ # Enable abort on exception for threads
257
+ Thread.abort_on_exception = true
258
+ @logger.notify "Provisioning OpenStack in parallel"
259
+ provision_parallel
260
+ else
261
+ @logger.notify "Provisioning OpenStack sequentially"
262
+ provision_sequential
263
+ end
264
+ hack_etc_hosts @hosts, @options
265
+ end
299
266
 
300
- if @options[:openstack_floating_ip]
301
- # Associate a public IP to the VM
302
- ip.server = vm
303
- host[:ip] = ip.ip
304
- else
305
- # Get the first address of the VM that was just created just like in the
306
- # OpenStack UI
307
- host[:ip] = vm.addresses.first[1][0]["addr"]
267
+ # Parallel creation wrapper
268
+ def provision_parallel
269
+ # Array to store threads
270
+ threads = @hosts.map do |host|
271
+ Thread.new do
272
+ create_instance_resources(host)
308
273
  end
274
+ end
275
+ # Wait for all threads to finish
276
+ threads.each(&:join)
277
+ end
309
278
 
310
- @logger.debug "OpenStack host #{host.name} (#{host[:vmhostname]}) assigned ip: #{host[:ip]}"
311
-
312
- #set metadata
313
- vm.metadata.update({:jenkins_build_url => @options[:jenkins_build_url].to_s,
314
- :department => @options[:department].to_s,
315
- :project => @options[:project].to_s })
316
- @vms << vm
317
-
318
- # Wait for the host to accept ssh logins
319
- host.wait_for_port(22)
279
+ # Sequential creation wrapper
280
+ def provision_sequential
281
+ @hosts.each do |host|
282
+ create_instance_resources(host)
283
+ end
284
+ end
320
285
 
321
- #enable root if user is not root
322
- enable_root(host)
286
+ # Create the actual instance resources
287
+ def create_instance_resources(host)
288
+ @logger.notify "Provisioning OpenStack"
289
+ if @options[:openstack_floating_ip]
290
+ ip = get_floating_ip
291
+ hostname = ip.ip.gsub('.', '-')
292
+ host[:vmhostname] = hostname + '.rfc1918.puppetlabs.net'
293
+ else
294
+ hostname = ('a'..'z').to_a.shuffle[0, 10].join
295
+ host[:vmhostname] = hostname
296
+ end
323
297
 
324
- provision_storage(host, vm) if @options[:openstack_volume_support]
325
- @logger.notify "OpenStack Volume Support Disabled, can't provision volumes" if not @options[:openstack_volume_support]
298
+ create_or_associate_keypair(host, hostname)
299
+ @logger.debug "Provisioning #{host.name} (#{host[:vmhostname]})"
300
+ options = {
301
+ :flavor_ref => flavor(host[:flavor]).id,
302
+ :image_ref => image(host[:image]).id,
303
+ :nics => [{'net_id' => network(@options[:openstack_network]).id}],
304
+ :name => host[:vmhostname],
305
+ :hostname => host[:vmhostname],
306
+ :user_data => host[:user_data] || "#cloud-config\nmanage_etc_hosts: true\n",
307
+ :key_name => host[:keyname],
308
+ }
309
+ options[:security_groups] = security_groups(@options[:security_group]) unless @options[:security_group].nil?
310
+ vm = @compute_client.servers.create(options)
311
+
312
+ # Wait for the new instance to start up
313
+ try = 1
314
+ attempts = @options[:timeout].to_i / SLEEPWAIT
315
+
316
+ while try <= attempts
317
+ begin
318
+ vm.wait_for(5) { ready? }
319
+ break
320
+ rescue Fog::Errors::TimeoutError => e
321
+ if try >= attempts
322
+ @logger.debug "Failed to connect to new OpenStack instance #{host.name} (#{host[:vmhostname]})"
323
+ raise e
324
+ end
325
+ @logger.debug "Timeout connecting to instance #{host.name} (#{host[:vmhostname]}), trying again..."
326
+ end
327
+ sleep SLEEPWAIT
328
+ try += 1
326
329
  end
327
330
 
328
- hack_etc_hosts @hosts, @options
331
+ if @options[:openstack_floating_ip]
332
+ # Associate a public IP to the VM
333
+ ip.server = vm
334
+ host[:ip] = ip.ip
335
+ else
336
+ # Get the first address of the VM that was just created just like in the
337
+ # OpenStack UI
338
+ host[:ip] = vm.addresses.first[1][0]["addr"]
339
+ end
329
340
 
341
+ @logger.debug "OpenStack host #{host.name} (#{host[:vmhostname]}) assigned ip: #{host[:ip]}"
342
+
343
+ # Set metadata
344
+ vm.metadata.update({:jenkins_build_url => @options[:jenkins_build_url].to_s,
345
+ :department => @options[:department].to_s,
346
+ :project => @options[:project].to_s })
347
+ @vms << vm
348
+
349
+ # Wait for the host to accept SSH logins
350
+ host.wait_for_port(22)
351
+
352
+ # Enable root if the user is not root
353
+ enable_root(host)
354
+
355
+ provision_storage(host, vm) if @options[:openstack_volume_support]
356
+ @logger.notify "OpenStack Volume Support Disabled, can't provision volumes" if not @options[:openstack_volume_support]
357
+
358
+ # Handle exceptions in the thread
359
+ rescue => e
360
+ @logger.error "Thread #{host} failed with error: #{e.message}"
361
+ # Call cleanup function to delete orphaned hosts
362
+ cleanup
363
+ # Pass the error to the main thread to terminate all threads
364
+ Thread.main.raise(e)
365
+ # Terminate the current thread (to prevent hack_etc_hosts trying to run after error raised)
366
+ Thread.kill(Thread.current)
330
367
  end
331
368
 
332
- #Destroy any OpenStack instances
369
+ # Destroy any OpenStack instances
333
370
  def cleanup
334
371
  @logger.notify "Cleaning up OpenStack"
335
372
  @vms.each do |vm|
@@ -361,7 +398,7 @@ module Beaker
361
398
  end
362
399
  end
363
400
 
364
- # enable root on a single host (the current one presumably) but only
401
+ # Enable root on a single host (the current one presumably) but only
365
402
  # if the username isn't 'root'
366
403
  def enable_root(host)
367
404
  if host['user'] != 'root'
@@ -1,3 +1,3 @@
1
1
  module BeakerOpenstack
2
- VERSION = '1.0.0'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2024-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '2.4'
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
- version: '1.3'
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.0.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: beaker
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '5.6'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '5.6'
167
181
  description: For use for the Beaker acceptance testing tool
168
182
  email: voxpupuli@groups.io
169
183
  executables:
@@ -190,7 +204,7 @@ files:
190
204
  - spec/spec_helper.rb
191
205
  homepage: https://github.com/voxpupuli/beaker-openstack
192
206
  licenses:
193
- - Apache2
207
+ - Apache-2.0
194
208
  metadata: {}
195
209
  post_install_message:
196
210
  rdoc_options: []
@@ -200,14 +214,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
214
  requirements:
201
215
  - - ">="
202
216
  - !ruby/object:Gem::Version
203
- version: '0'
217
+ version: '2.7'
218
+ - - "<"
219
+ - !ruby/object:Gem::Version
220
+ version: '4'
204
221
  required_rubygems_version: !ruby/object:Gem::Requirement
205
222
  requirements:
206
223
  - - ">="
207
224
  - !ruby/object:Gem::Version
208
225
  version: '0'
209
226
  requirements: []
210
- rubygems_version: 3.2.22
227
+ rubygems_version: 3.2.33
211
228
  signing_key:
212
229
  specification_version: 4
213
230
  summary: Beaker DSL Extension Helpers!