onceover 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10cb60864702bbdffbe00089c6f8d931c9d8757c
4
- data.tar.gz: f37afccaec1d4d78edd98d8857db9f33cc629d5a
3
+ metadata.gz: fadf99405e225f596dc733991e921b575ff4ff3d
4
+ data.tar.gz: e64a282077068f8d878e9f0f61553c41279c6c1c
5
5
  SHA512:
6
- metadata.gz: 322b0987cf4f0f50d2f134888a3af34c774a307ff760fe9d2f12d7441f9d0e6a49c60748f468d9950ead2134f8402015b995fb5d27735758d50c16dc5e4a26f2
7
- data.tar.gz: 1f1398ff2c251ca54844e69deb45247e218a4c88db9f1b7282f3425cbf5f25307d53f23ee14ae97a829444e324326474a01f66c3625d5586e56141b16246de60
6
+ metadata.gz: fae38e2a4b3e875f8427df08e09b99420475dce16cf124498ec7151cfdd05294a85d3dbb6dbdf10e3295553375a13b46bd5790f5c7c06c432321c8ba9d2c97f6
7
+ data.tar.gz: e3770b45c7de68659f623b8e37995892a05d4cdf47c3761f3d068ebfa5fda7c33fba95d44a8431b99374f3ceed22e8390a7829da88972a3a3df0f69e4aab43f0
data/README.md CHANGED
@@ -6,6 +6,8 @@ Onceover is a tool to automatically run basic tests on an entire Puppet controlr
6
6
 
7
7
  **NEW FEATURE! REGEX SUPPORT!**
8
8
 
9
+ **NEW NEW FEATURE! Parallel tests, run** `onceover run spec --help` **for more info**
10
+
9
11
  ## Table of Contents
10
12
 
11
13
  - [Overview](#overview)
@@ -409,7 +411,23 @@ Here we are specifying custom commands to run for starting, stopping and checkin
409
411
 
410
412
  ## Extra Tooling
411
413
 
412
- Is this all too simple for you? Great! This is supposed to be a gateway to writing your own super-awesome really complicated tests using more traditional tools. If you want to ditch this tool in favour of doing it yourself, go ahead, but take these ruby methods as a parting gift:
414
+ ### Inspecting and updating the Puppetfile
415
+
416
+ Onceover comes with some extra commands for interacting with the Puppetfile in useful ways. These are:
417
+
418
+ `onceover show puppetfile`
419
+
420
+ This will display all the current versions of all modules that are in the Puppetfile alongside the latest versions and whether or not they are out of date. This is a useful took for making sure your modules don't get too stale.
421
+
422
+ `onceover update puppetfile`
423
+
424
+ This takes your Puppetfile and actually modifies all of the module versions in there to the latest versions and saves the file. This is useful for setting up automated Puppetfile updates, just get Jenkins or Bamboo to:
425
+
426
+ 1. Check out the Controlrepo
427
+ 2. Run onceover to get a passing baseline
428
+ 3. Update the Puppetfile with the latest versions of all modules
429
+ 4. Run Onceover agan
430
+ 5. Create a pull request if all tests pass
413
431
 
414
432
  ### Accessing Onceover in a traditional RSpec test
415
433
 
@@ -38,6 +38,8 @@ This includes deploying using r10k and running all custom tests.
38
38
  usage 'spec'
39
39
  summary 'Runs spec tests'
40
40
 
41
+ optional :p, :parallel, 'Runs spec tests in parallel. This increases speed at the cost of poorly formatted logs and irrelevant junit output.'
42
+
41
43
  run do |opts, args, cmd|
42
44
  repo = Onceover::Controlrepo.new(opts)
43
45
  runner = Onceover::Runner.new(repo,Onceover::TestConfig.new(repo.onceover_yaml, opts), :spec)
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'yaml'
5
5
  require 'find'
6
6
  require 'pathname'
7
+ require 'thread'
7
8
  require 'onceover/beaker'
8
9
  require 'onceover/logger'
9
10
  include Onceover::Logger
@@ -196,32 +197,37 @@ class Onceover
196
197
  puppetfile.load!
197
198
 
198
199
  output_array = []
200
+ threads = []
199
201
  puppetfile.modules.each do |mod|
200
- return_hash = {}
201
- logger.debug "Loading data for #{mod.full_name}"
202
- return_hash[:full_name] = mod.full_name
203
- if mod.is_a?(R10K::Module::Forge)
204
- return_hash[:current_version] = mod.expected_version
205
- return_hash[:latest_version] = mod.v3_module.current_release.version
206
- current = Versionomy.parse(return_hash[:current_version])
207
- latest = Versionomy.parse(return_hash[:latest_version])
208
- if current.major < latest.major
209
- return_hash[:out_of_date] = "Major".red
210
- elsif current.minor < latest.minor
211
- return_hash[:out_of_date] = "Minor".yellow
212
- elsif current.tiny < latest.tiny
213
- return_hash[:out_of_date] = "Tiny".green
202
+ threads << Thread.new do
203
+ return_hash = {}
204
+ logger.debug "Loading data for #{mod.full_name}"
205
+ return_hash[:full_name] = mod.full_name
206
+ if mod.is_a?(R10K::Module::Forge)
207
+ return_hash[:current_version] = mod.expected_version
208
+ return_hash[:latest_version] = mod.v3_module.current_release.version
209
+ current = Versionomy.parse(return_hash[:current_version])
210
+ latest = Versionomy.parse(return_hash[:latest_version])
211
+ if current.major < latest.major
212
+ return_hash[:out_of_date] = "Major".red
213
+ elsif current.minor < latest.minor
214
+ return_hash[:out_of_date] = "Minor".yellow
215
+ elsif current.tiny < latest.tiny
216
+ return_hash[:out_of_date] = "Tiny".green
217
+ else
218
+ return_hash[:out_of_date] = "No".green
219
+ end
214
220
  else
215
- return_hash[:out_of_date] = "No".green
221
+ return_hash[:current_version] = "N/A"
222
+ return_hash[:latest_version] = "N/A"
223
+ return_hash[:out_of_date] = "N/A"
216
224
  end
217
- else
218
- return_hash[:current_version] = "N/A"
219
- return_hash[:latest_version] = "N/A"
220
- return_hash[:out_of_date] = "N/A"
225
+ output_array << return_hash
221
226
  end
222
- output_array << return_hash
223
227
  end
224
228
 
229
+ threads.map(&:join)
230
+
225
231
  tp output_array, \
226
232
  {:full_name => {:display_name => "Full Name"}}, \
227
233
  {:current_version => {:display_name => "Current Version"}}, \
@@ -239,12 +245,30 @@ class Onceover
239
245
 
240
246
  # TODO: Make sure we can deal with :latest
241
247
 
248
+ # Create threading resources
249
+ threads = []
250
+ queue = Queue.new
251
+ queue.push(puppetfile_string)
252
+
242
253
  puppetfile.modules.keep_if {|m| m.is_a?(R10K::Module::Forge)}
243
254
  puppetfile.modules.each do |mod|
244
- line_index = puppetfile_string.index {|l| l =~ /^\s*[^#]*#{mod.owner}[\/-]#{mod.name}/}
245
- logger.debug "Getting latest version of #{mod.full_name}"
246
- puppetfile_string[line_index].gsub!(mod.expected_version,mod.v3_module.current_release.version)
255
+ threads << Thread.new do
256
+ logger.debug "Getting latest version of #{mod.full_name}"
257
+ latest_version = mod.v3_module.current_release.version
258
+
259
+ # Get the data off the queue, or wait if something else is using it
260
+ puppetfile_string_temp = queue.pop
261
+ line_index = puppetfile_string_temp.index {|l| l =~ /^\s*[^#]*#{mod.owner}[\/-]#{mod.name}/}
262
+ puppetfile_string_temp[line_index].gsub!(mod.expected_version,latest_version)
263
+
264
+ # Put the data back into the queue once we are done with it
265
+ queue.push(puppetfile_string_temp)
266
+ end
247
267
  end
268
+
269
+ threads.map(&:join)
270
+ puppetfile_string = queue.pop
271
+
248
272
  File.open(@puppetfile, 'w') {|f| f.write(puppetfile_string.join("\n")) }
249
273
  puts "#{'changed'.yellow} #{@puppetfile}"
250
274
  end
@@ -76,8 +76,13 @@ class Onceover
76
76
  Dir.chdir(@repo.tempdir) do
77
77
  #`bundle install --binstubs`
78
78
  #`bin/rake spec_standalone`
79
- logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}"
80
- exec("#{@command_prefix}rake spec_standalone")
79
+ if @config.opts[:parallel]
80
+ logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
81
+ exec("#{@command_prefix}rake parallel_spec")
82
+ else
83
+ logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}"
84
+ exec("#{@command_prefix}rake spec_standalone")
85
+ end
81
86
  end
82
87
  end
83
88
 
data/onceover.gemspec CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "onceover"
6
- s.version = "3.1.0"
6
+ s.version = "3.1.1"
7
7
  s.authors = ["Dylan Ratcliffe"]
8
8
  s.email = ["dylan.ratcliffe@puppet.com"]
9
9
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_runtime_dependency 'json', '>= 1.8.2'
22
22
  s.add_runtime_dependency 'beaker-rspec'
23
23
  s.add_runtime_dependency 'rspec-puppet', ">= 2.4.0"
24
+ s.add_runtime_dependency 'parallel_tests', ">= 2.0.0"
24
25
  s.add_runtime_dependency 'puppetlabs_spec_helper', ">= 0.4.0"
25
26
  s.add_runtime_dependency 'rspec-puppet-utils', '>= 2.0.0'
26
27
  s.add_runtime_dependency 'rspec', '>= 3.0.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: parallel_tests
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: puppetlabs_spec_helper
71
85
  requirement: !ruby/object:Gem::Requirement