paraduct 0.0.1.beta4 → 0.0.1.beta5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/paraduct.rb +12 -7
- data/lib/paraduct/cli.rb +2 -2
- data/lib/paraduct/configuration.rb +5 -0
- data/lib/paraduct/errors.rb +10 -8
- data/lib/paraduct/parallel_runner.rb +41 -34
- data/lib/paraduct/runner.rb +2 -2
- data/lib/paraduct/templates/.paraduct.yml.tt +1 -0
- data/lib/paraduct/version.rb +1 -1
- data/paraduct.gemspec +1 -0
- data/spec/.paraduct.yml +1 -0
- data/spec/paraduct/cli_spec.rb +1 -1
- data/spec/paraduct/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +19 -3
data/README.md
CHANGED
@@ -65,6 +65,7 @@ variables:
|
|
65
65
|
name2:
|
66
66
|
- value2a
|
67
67
|
- value2b
|
68
|
+
max_threads: 4
|
68
69
|
```
|
69
70
|
|
70
71
|
### script
|
@@ -88,6 +89,9 @@ value1a | value2b | NAME1_value1a_NAME2_value2b | tmp/paraduct_workspace/NAME1
|
|
88
89
|
value1b | value2a | NAME1_value1b_NAME2_value2a | tmp/paraduct_workspace/NAME1_value1b_NAME2_value2a
|
89
90
|
value1b | value2b | NAME1_value1b_NAME2_value2b | tmp/paraduct_workspace/NAME1_value1b_NAME2_value2b
|
90
91
|
|
92
|
+
### max_threads
|
93
|
+
maximum concurrent execution number of jobs
|
94
|
+
|
91
95
|
## Contributing
|
92
96
|
|
93
97
|
1. Fork it ( https://github.com/sue445/paraduct/fork )
|
data/lib/paraduct.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
require "active_support"
|
2
2
|
require "active_support/deprecation"
|
3
3
|
require "active_support/core_ext"
|
4
|
-
require "paraduct/version"
|
5
|
-
require "paraduct/configuration"
|
6
|
-
require "paraduct/variable_converter"
|
7
|
-
require "paraduct/runner"
|
8
|
-
require "paraduct/parallel_runner"
|
9
|
-
require "paraduct/errors"
|
10
|
-
require "paraduct/test_response"
|
11
4
|
require "pathname"
|
12
5
|
|
13
6
|
module Paraduct
|
7
|
+
autoload :Configuration , 'paraduct/configuration'
|
8
|
+
autoload :Errors , 'paraduct/errors'
|
9
|
+
autoload :ParallelRunner , 'paraduct/parallel_runner'
|
10
|
+
autoload :Runner , 'paraduct/runner'
|
11
|
+
autoload :TestResponse , 'paraduct/test_response'
|
12
|
+
autoload :VariableConverter, 'paraduct/variable_converter'
|
13
|
+
autoload :Version , 'paraduct/version'
|
14
|
+
|
14
15
|
class << self
|
15
16
|
def configuration
|
16
17
|
Paraduct::Configuration.instance
|
17
18
|
end
|
18
19
|
alias :config :configuration
|
20
|
+
|
21
|
+
def logger
|
22
|
+
@logger ||= ActiveSupport::Logger.new(STDOUT)
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
data/lib/paraduct/cli.rb
CHANGED
@@ -15,8 +15,8 @@ module Paraduct
|
|
15
15
|
|
16
16
|
product_variables = Paraduct::VariableConverter.product(variables)
|
17
17
|
test_response = Paraduct::ParallelRunner.perform_all(script, product_variables)
|
18
|
-
|
19
|
-
raise Paraduct::TestFailureError if test_response.failure?
|
18
|
+
Paraduct.logger.info test_response.detail_message
|
19
|
+
raise Paraduct::Errors::TestFailureError if test_response.failure?
|
20
20
|
end
|
21
21
|
|
22
22
|
desc "generate", "generate .paraduct.yml"
|
data/lib/paraduct/errors.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Paraduct
|
2
|
-
|
2
|
+
module Errors
|
3
|
+
class TestFailureError < StandardError; end
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
class ProcessError < StandardError
|
6
|
+
attr_reader :status
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
# @param message [String] stdout and stderr
|
9
|
+
# @param status [Process::Status]
|
10
|
+
def initialize(message, status)
|
11
|
+
super(message)
|
12
|
+
@status = status
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -1,58 +1,65 @@
|
|
1
1
|
module Paraduct
|
2
|
+
require "thread/pool"
|
3
|
+
|
2
4
|
class ParallelRunner
|
3
5
|
# run script with arguments
|
4
6
|
# @param script [String, Array<String>] script file, script(s)
|
5
7
|
# @param product_variables [Array<Hash{String => String}>]
|
6
8
|
# @return [Paraduct::TestResponse]
|
7
9
|
def self.perform_all(script, product_variables)
|
8
|
-
threads = []
|
9
10
|
test_response = Paraduct::TestResponse.new
|
10
11
|
base_job_dir = Paraduct.config.work_dir
|
11
12
|
FileUtils.mkdir_p(base_job_dir) unless base_job_dir.exist?
|
12
13
|
|
13
|
-
|
14
|
+
Paraduct.logger.info <<-EOS
|
14
15
|
======================================================
|
15
16
|
START matrix test
|
16
17
|
EOS
|
17
18
|
product_variables.each do |params|
|
18
|
-
|
19
|
+
Paraduct.logger.info "params: #{params}"
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
pool = Thread.pool(Paraduct.config.max_threads)
|
23
|
+
begin
|
24
|
+
product_variables.each do |params|
|
25
|
+
pool.process do
|
26
|
+
runner = Paraduct::Runner.new(
|
27
|
+
script: script,
|
28
|
+
params: params,
|
29
|
+
base_job_dir: base_job_dir,
|
30
|
+
)
|
31
|
+
|
32
|
+
runner.setup_dir
|
33
|
+
begin
|
34
|
+
stdout = runner.perform
|
35
|
+
successful = true
|
36
|
+
rescue Paraduct::Errors::ProcessError => e
|
37
|
+
stdout = e.message
|
38
|
+
successful = false
|
39
|
+
end
|
36
40
|
|
37
|
-
|
41
|
+
Paraduct.logger.info <<-EOS
|
38
42
|
======================================================
|
39
|
-
params: #{
|
40
|
-
job_name: #{
|
41
|
-
job_dir: #{
|
42
|
-
|
43
|
-
#{stdout}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
params: #{runner.formatted_params}
|
44
|
+
job_name: #{runner.job_name}
|
45
|
+
job_dir: #{runner.job_dir}
|
46
|
+
|
47
|
+
#{stdout}
|
48
|
+
EOS
|
49
|
+
|
50
|
+
test_response.jobs_push(
|
51
|
+
job_name: runner.job_name,
|
52
|
+
params: runner.params,
|
53
|
+
formatted_params: runner.formatted_params,
|
54
|
+
successful: successful,
|
55
|
+
stdout: stdout,
|
56
|
+
)
|
57
|
+
end
|
53
58
|
end
|
59
|
+
|
60
|
+
ensure
|
61
|
+
pool.shutdown
|
54
62
|
end
|
55
|
-
threads.map(&:join)
|
56
63
|
|
57
64
|
test_response
|
58
65
|
end
|
data/lib/paraduct/runner.rb
CHANGED
@@ -22,7 +22,7 @@ module Paraduct
|
|
22
22
|
|
23
23
|
# run script with params
|
24
24
|
# @return [String] stdout
|
25
|
-
# @raise [Paraduct::ProcessError] command exited error status
|
25
|
+
# @raise [Paraduct::Errors::ProcessError] command exited error status
|
26
26
|
def perform
|
27
27
|
variable_string = key_capitalized_params.map{ |key, value| %(export #{key}="#{value}";) }.join(" ")
|
28
28
|
|
@@ -72,7 +72,7 @@ module Paraduct
|
|
72
72
|
private
|
73
73
|
def run_command(command)
|
74
74
|
stdout, stderr, status = Open3.capture3(command)
|
75
|
-
raise Paraduct::ProcessError.new("#{stdout}\n#{stderr}", status) unless status.success?
|
75
|
+
raise Paraduct::Errors::ProcessError.new("#{stdout}\n#{stderr}", status) unless status.success?
|
76
76
|
stdout
|
77
77
|
end
|
78
78
|
end
|
data/lib/paraduct/version.rb
CHANGED
data/paraduct.gemspec
CHANGED
data/spec/.paraduct.yml
CHANGED
data/spec/paraduct/cli_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe Paraduct::CLI do
|
|
51
51
|
allow(Paraduct.config).to receive(:variables){ { status: [0, 1] } }
|
52
52
|
end
|
53
53
|
|
54
|
-
it { expect{ subject }.to raise_error Paraduct::TestFailureError }
|
54
|
+
it { expect{ subject }.to raise_error Paraduct::Errors::TestFailureError }
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paraduct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thread
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: bundler
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -313,7 +329,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
313
329
|
version: '0'
|
314
330
|
segments:
|
315
331
|
- 0
|
316
|
-
hash:
|
332
|
+
hash: 981450971291940130
|
317
333
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
318
334
|
none: false
|
319
335
|
requirements:
|