Skip to content

Commit

Permalink
Run multiple node diffs in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgeJ authored and John Edge committed Aug 9, 2018
1 parent 89d93f1 commit f0582a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/octocatalog-diff/cli.rb
Expand Up @@ -11,6 +11,7 @@
require_relative 'version'

require 'logger'
require 'parallel'
require 'socket'

module OctocatalogDiff
Expand Down Expand Up @@ -118,7 +119,9 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
# Compile catalogs and do catalog-diff
node_set = options.delete(:node)
all_diffs = []
node_set.each do |node|

# run multiple node diffs in parallel
Parallel.map(node_set) do |node|
options[:node] = node
catalog_diff = OctocatalogDiff::API::V1.catalog_diff(options.merge(logger: logger))
diffs = catalog_diff.diffs
Expand All @@ -131,8 +134,8 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
all_diffs << diffs
end

# Return the resulting diff object if requested (generally for testing) or otherwise return exit code
return catalog_diff if opts[:INTEGRATION]
# Return the resulting diff objects if requested (generally for testing) or otherwise return exit code
return all_diffs if opts[:INTEGRATION]
all_diffs.any? ? EXITCODE_SUCCESS_WITH_DIFFS : EXITCODE_SUCCESS_NO_DIFFS
end

Expand Down
1 change: 1 addition & 0 deletions octocatalog-diff.gemspec
Expand Up @@ -27,6 +27,7 @@ EOF
s.add_runtime_dependency 'diffy', '>= 3.1.0'
s.add_runtime_dependency 'httparty', '>= 0.11.0'
s.add_runtime_dependency 'hashdiff', '>= 0.3.0'
s.add_runtime_dependency 'parallel'
s.add_runtime_dependency 'rugged', '>= 0.25.0b2'

s.add_development_dependency 'rspec', '~> 3.4.0'
Expand Down

0 comments on commit f0582a2

Please sign in to comment.