paraduct 0.0.3 → 1.0.0.beta1

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: 54ba56f517217c8daf695f6b9dedeb5bb3b97298
4
- data.tar.gz: 250d47b666ffb04d0e71e24a8a89f1238dd4ff13
3
+ metadata.gz: a9e503239ff974eb782d8661d709310c4f64dd8d
4
+ data.tar.gz: 51adc18eca955569631ebe3f0ae34300de855fb2
5
5
  SHA512:
6
- metadata.gz: abf174f88e100d94ac89d4819944c57612fdc5dd852d76f409bb2aa00cf726d01e28d15ba70dcd5caecbc834689dd1b40a9d42002076478286a26d3ea7a22de4
7
- data.tar.gz: 3c4511d76ddb57db86cdc1ea71a187b6abf9aaaba9aba4f95a37421992992c41a76e290a4474de93e949f24dc6c5a91ff9ee2d1c7641f9c891c367d43dd14425
6
+ metadata.gz: cd356d9697d2b13fb8d7a3410d43edfd880bc71385e920d077bd01fb36427ad9bc4e7638ed4ff85fd697930672be97aa359ff0380b6d0770f3d657ee6da01fdc
7
+ data.tar.gz: 22ff95122ec9bc3dfe6b2771e3311a4bca5118caf165c6d9e83bf3955dbd8ec308d4f3828c2813eb9b7da3650a5697ae2fefa6160a2baffe0e542cbdc095e1c8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  ## master
2
2
  [full changelog](http://github.com/sue445/paraduct/compare/v0.0.3...master)
3
3
 
4
+ * Stop convert key capitalize
5
+ * https://github.com/sue445/paraduct/pull/77
6
+ * Run under current directory when work_dir is empty
7
+ * https://github.com/sue445/paraduct/pull/78
8
+
4
9
  ## v0.0.3
5
10
  [full changelog](http://github.com/sue445/paraduct/compare/v0.0.2...v0.0.3)
6
11
 
data/README.md CHANGED
@@ -65,18 +65,18 @@ script: |-
65
65
  echo "NAME1=${NAME1}, NAME2=${NAME2}"
66
66
  work_dir: tmp/paraduct_workspace
67
67
  variables:
68
- name1:
68
+ NAME1:
69
69
  - value1a
70
70
  - value1b
71
- name2:
71
+ NAME2:
72
72
  - value2a
73
73
  - value2b
74
74
  max_threads: 4
75
75
  rsync_option:
76
76
  exclude_from: .paraduct_rsync_exclude.txt
77
77
  exclude:
78
- - name1: value1a
79
- name2: value2b
78
+ - NAME1: value1a
79
+ NAME2: value2b
80
80
  ```
81
81
 
82
82
  ### script
@@ -86,14 +86,15 @@ script to run
86
86
  diretory to run
87
87
 
88
88
  * own job is run under `work_dir/$PARADUCT_JOB_NAME`
89
+ * if `work_dir` is empty, own job is run under current directory.
90
+ * rsync is disabled
89
91
 
90
92
  ### variables
91
93
  Parameters to be combined
92
94
 
93
- * key is capitalized (example. `name1` -> `NAME1`)
94
95
  * `$PARADUCT_JOB_NAME` is generated with variables
95
96
 
96
- $PARADUCT_JOB_ID | name1 | name2 | $PARADUCT_JOB_NAME | current directory where the test is performed
97
+ $PARADUCT_JOB_ID | NAME1 | NAME2 | $PARADUCT_JOB_NAME | current directory where the test is performed
97
98
  ------------------ | ------- | ------- | ----------------------------- | --------------------------------------------------
98
99
  1 | value1a | value2a | NAME1_value1a_NAME2_value2a | tmp/paraduct_workspace/NAME1_value1a_NAME2_value2a
99
100
  2 | value1a | value2b | NAME1_value1a_NAME2_value2b | tmp/paraduct_workspace/NAME1_value1a_NAME2_value2b
@@ -30,8 +30,19 @@ module Paraduct
30
30
 
31
31
  # @return [Pathname]
32
32
  def work_dir
33
- _work_dir = config_data[:work_dir] || "tmp/paraduct_workspace"
34
- root_dir.join(_work_dir)
33
+ config_data[:work_dir]
34
+ end
35
+
36
+ def base_job_dir
37
+ if work_dir.blank?
38
+ root_dir
39
+ else
40
+ root_dir.join(work_dir)
41
+ end
42
+ end
43
+
44
+ def enable_rsync?
45
+ !work_dir.blank?
35
46
  end
36
47
 
37
48
  # @return [Pathname]
@@ -8,7 +8,7 @@ module Paraduct
8
8
  # @return [Paraduct::TestResponse]
9
9
  def self.perform_all(script, product_variables)
10
10
  test_response = Paraduct::TestResponse.new
11
- base_job_dir = Paraduct.config.work_dir
11
+ base_job_dir = Paraduct.config.base_job_dir
12
12
  FileUtils.mkdir_p(base_job_dir) unless base_job_dir.exist?
13
13
 
14
14
  Paraduct.logger.info <<-EOS
@@ -27,7 +27,7 @@ START matrix test
27
27
  )
28
28
  pool.process do
29
29
  runner.logger.info "[START] params: #{runner.formatted_params}"
30
- runner.setup_dir
30
+ runner.setup_dir if Paraduct.config.enable_rsync?
31
31
  begin
32
32
  stdout = runner.perform
33
33
  successful = true
@@ -25,7 +25,7 @@ module Paraduct
25
25
  # @return [String] stdout
26
26
  # @raise [Paraduct::Errors::ProcessError] command exited error status
27
27
  def perform
28
- export_variables = key_capitalized_params.merge("PARADUCT_JOB_ID" => @job_id, "PARADUCT_JOB_NAME" => job_name)
28
+ export_variables = @params.reverse_merge("PARADUCT_JOB_ID" => @job_id, "PARADUCT_JOB_NAME" => job_name)
29
29
  variable_string = export_variables.map{ |key, value| %(export #{key}="#{value}";) }.join(" ")
30
30
 
31
31
  Array.wrap(@script).inject("") do |stdout, command|
@@ -39,11 +39,7 @@ module Paraduct
39
39
  end
40
40
 
41
41
  def job_name
42
- key_capitalized_params.map { |key, value| "#{key}_#{value}" }.join("_").gsub(%r([/ ]), "_")
43
- end
44
-
45
- def key_capitalized_params
46
- self.class.capitalize_keys(@params)
42
+ @params.map { |key, value| "#{key}_#{value}" }.join("_").gsub(%r([/ ]), "_")
47
43
  end
48
44
 
49
45
  def formatted_params
@@ -60,13 +56,6 @@ module Paraduct
60
56
  @logger
61
57
  end
62
58
 
63
- def self.capitalize_keys(params)
64
- params.inject({}) do |res, (key, value)|
65
- res[key.upcase] = value
66
- res
67
- end
68
- end
69
-
70
59
  private
71
60
 
72
61
  def run_command(command)
@@ -2,15 +2,15 @@ script: |-
2
2
  echo "NAME1=${NAME1}, NAME2=${NAME2}"
3
3
  work_dir: tmp/paraduct_workspace
4
4
  variables:
5
- name1:
5
+ NAME1:
6
6
  - value1a
7
7
  - value1b
8
- name2:
8
+ NAME2:
9
9
  - value2a
10
10
  - value2b
11
11
  max_threads: 4
12
12
  rsync_option:
13
13
  exclude_from: .paraduct_rsync_exclude.txt
14
14
  exclude:
15
- - name1: value1a
16
- name2: value2b
15
+ - NAME1: value1a
16
+ NAME2: value2b
@@ -1,3 +1,3 @@
1
1
  module Paraduct
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0.beta1"
3
3
  end
data/spec/.paraduct.yml CHANGED
@@ -1,14 +1,14 @@
1
1
  script: ./script/build_success.sh
2
2
  work_dir: tmp/paraduct_workspace
3
3
  variables:
4
- ruby:
4
+ RUBY:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
7
  - 2.1.2
8
- database:
8
+ DATABASE:
9
9
  - mysql
10
10
  - postgresql
11
- rails:
11
+ RAILS:
12
12
  - 3.2.0
13
13
  - 4.0.0
14
14
  - 4.1.0
@@ -26,8 +26,8 @@ describe Paraduct::CLI do
26
26
  script: "./script/build_success.sh",
27
27
  work_dir: "tmp/paraduct_workspace",
28
28
  variables: {
29
- ruby: ["1.9.3", "2.0.0"],
30
- database: ["mysql", "postgresql"],
29
+ "RUBY" => ["1.9.3", "2.0.0"],
30
+ "DATABASE" => ["mysql", "postgresql"],
31
31
  },
32
32
  }
33
33
  end
@@ -35,10 +35,10 @@ describe Paraduct::CLI do
35
35
  let(:script){ "./script/build_success.sh" }
36
36
  let(:product_variables) do
37
37
  [
38
- { "ruby" => "1.9.3", "database" => "mysql" },
39
- { "ruby" => "1.9.3", "database" => "postgresql" },
40
- { "ruby" => "2.0.0", "database" => "mysql" },
41
- { "ruby" => "2.0.0", "database" => "postgresql" },
38
+ { "RUBY" => "1.9.3", "DATABASE" => "mysql" },
39
+ { "RUBY" => "1.9.3", "DATABASE" => "postgresql" },
40
+ { "RUBY" => "2.0.0", "DATABASE" => "mysql" },
41
+ { "RUBY" => "2.0.0", "DATABASE" => "postgresql" },
42
42
  ]
43
43
  end
44
44
 
@@ -60,7 +60,7 @@ describe Paraduct::CLI do
60
60
  script: %q(exit ${STATUS}),
61
61
  work_dir: "tmp/paraduct_workspace",
62
62
  variables: {
63
- status: [0, 1],
63
+ "STATUS" => [0, 1],
64
64
  },
65
65
  }
66
66
  end
@@ -11,17 +11,10 @@ describe Paraduct::Configuration do
11
11
 
12
12
  it "should get variables in .paraduct.yml" do
13
13
  is_expected.to match(
14
- "ruby" => ["1.9.3", "2.0.0", "2.1.2"],
15
- "database" => ["mysql", "postgresql"],
16
- "rails" => ["3.2.0", "4.0.0", "4.1.0"],
14
+ "RUBY" => ["1.9.3", "2.0.0", "2.1.2"],
15
+ "DATABASE" => ["mysql", "postgresql"],
16
+ "RAILS" => ["3.2.0", "4.0.0", "4.1.0"],
17
17
  )
18
18
  end
19
19
  end
20
-
21
- describe "#work_dir" do
22
- subject{ config.work_dir }
23
-
24
- it { should eq spec_dir.join("tmp/paraduct_workspace") }
25
- end
26
-
27
20
  end
@@ -16,20 +16,28 @@ describe Paraduct::ParallelRunner do
16
16
  it { expect(copied_file).to be_exist }
17
17
  end
18
18
 
19
+ shared_examples :dont_create_job_directories do
20
+ let(:job_dir) { temp_dir_path.join("tmp/paraduct_workspace/#{job_name}") }
21
+ let(:copied_file){ job_dir.join("script/build_success.sh") }
22
+
23
+ it { expect(job_dir).not_to be_exist }
24
+ it { expect(copied_file).not_to be_exist }
25
+ end
26
+
19
27
  describe "with script file test" do
20
28
  let(:script){ "./script/build_success.sh" }
21
29
  let(:product_variables) do
22
30
  [
23
- { "ruby" => "1.9", "database" => "mysql" },
24
- { "ruby" => "2.0", "database" => "postgresql" },
31
+ { "RUBY" => "1.9", "DATABASE" => "mysql" },
32
+ { "RUBY" => "2.0", "DATABASE" => "postgresql" },
25
33
  ]
26
34
  end
27
35
 
28
36
  its(:jobs) do
29
37
  should include(
30
38
  job_name: "RUBY_1.9_DATABASE_mysql",
31
- params: { "ruby" => "1.9", "database" => "mysql" },
32
- formatted_params: "ruby=1.9, database=mysql",
39
+ params: { "RUBY" => "1.9", "DATABASE" => "mysql" },
40
+ formatted_params: "RUBY=1.9, DATABASE=mysql",
33
41
  successful: true,
34
42
  stdout: "RUBY=1.9\nDATABASE=mysql\n"
35
43
  )
@@ -38,25 +46,52 @@ describe Paraduct::ParallelRunner do
38
46
  its(:jobs) do
39
47
  should include(
40
48
  job_name: "RUBY_2.0_DATABASE_postgresql",
41
- params: { "ruby" => "2.0", "database" => "postgresql" },
42
- formatted_params: "ruby=2.0, database=postgresql",
49
+ params: { "RUBY" => "2.0", "DATABASE" => "postgresql" },
50
+ formatted_params: "RUBY=2.0, DATABASE=postgresql",
43
51
  successful: true,
44
52
  stdout: "RUBY=2.0\nDATABASE=postgresql\n"
45
53
  )
46
54
  end
47
55
 
48
- describe "should create job directories" do
56
+ context "When work_dir is not empty" do
49
57
  before do
50
- # exercise
51
- subject
58
+ allow(Paraduct.config).to receive(:work_dir) { "tmp/paraduct_workspace" }
52
59
  end
53
60
 
54
- it_behaves_like :create_job_directories do
55
- let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
61
+ describe "should create job directories" do
62
+ before do
63
+ # exercise
64
+ subject
65
+ end
66
+
67
+ it_behaves_like :create_job_directories do
68
+ let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
69
+ end
70
+
71
+ it_behaves_like :create_job_directories do
72
+ let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
73
+ end
56
74
  end
75
+ end
57
76
 
58
- it_behaves_like :create_job_directories do
59
- let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
77
+ context "When work_dir is empty" do
78
+ before do
79
+ allow(Paraduct.config).to receive(:work_dir) { nil }
80
+ end
81
+
82
+ describe "should not create job directories" do
83
+ before do
84
+ # exercise
85
+ subject
86
+ end
87
+
88
+ it_behaves_like :dont_create_job_directories do
89
+ let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
90
+ end
91
+
92
+ it_behaves_like :dont_create_job_directories do
93
+ let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
94
+ end
60
95
  end
61
96
  end
62
97
  end
@@ -65,16 +100,16 @@ describe Paraduct::ParallelRunner do
65
100
  let(:script){ %q(echo "RUBY=${RUBY} DATABASE=${DATABASE}") }
66
101
  let(:product_variables) do
67
102
  [
68
- { "ruby" => "1.9", "database" => "mysql" },
69
- { "ruby" => "2.0", "database" => "postgresql" },
103
+ { "RUBY" => "1.9", "DATABASE" => "mysql" },
104
+ { "RUBY" => "2.0", "DATABASE" => "postgresql" },
70
105
  ]
71
106
  end
72
107
 
73
108
  its(:jobs) do
74
109
  should include(
75
110
  job_name: "RUBY_1.9_DATABASE_mysql",
76
- params: { "ruby" => "1.9", "database" => "mysql" },
77
- formatted_params: "ruby=1.9, database=mysql",
111
+ params: { "RUBY" => "1.9", "DATABASE" => "mysql" },
112
+ formatted_params: "RUBY=1.9, DATABASE=mysql",
78
113
  successful: true,
79
114
  stdout: "RUBY=1.9 DATABASE=mysql\n"
80
115
  )
@@ -83,25 +118,52 @@ describe Paraduct::ParallelRunner do
83
118
  its(:jobs) do
84
119
  should include(
85
120
  job_name: "RUBY_2.0_DATABASE_postgresql",
86
- params: { "ruby" => "2.0", "database" => "postgresql" },
87
- formatted_params: "ruby=2.0, database=postgresql",
121
+ params: { "RUBY" => "2.0", "DATABASE" => "postgresql" },
122
+ formatted_params: "RUBY=2.0, DATABASE=postgresql",
88
123
  successful: true,
89
124
  stdout: "RUBY=2.0 DATABASE=postgresql\n"
90
125
  )
91
126
  end
92
127
 
93
- describe "should create job directories" do
128
+ context "When work_dir is not empty" do
94
129
  before do
95
- # exercise
96
- subject
130
+ allow(Paraduct.config).to receive(:work_dir) { "tmp/paraduct_workspace" }
131
+ end
132
+
133
+ describe "should create job directories" do
134
+ before do
135
+ # exercise
136
+ subject
137
+ end
138
+
139
+ it_behaves_like :create_job_directories do
140
+ let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
141
+ end
142
+
143
+ it_behaves_like :create_job_directories do
144
+ let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
145
+ end
97
146
  end
147
+ end
98
148
 
99
- it_behaves_like :create_job_directories do
100
- let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
149
+ context "When work_dir is empty" do
150
+ before do
151
+ allow(Paraduct.config).to receive(:work_dir) { nil }
101
152
  end
102
153
 
103
- it_behaves_like :create_job_directories do
104
- let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
154
+ describe "should not create job directories" do
155
+ before do
156
+ # exercise
157
+ subject
158
+ end
159
+
160
+ it_behaves_like :dont_create_job_directories do
161
+ let(:job_name){ "RUBY_1.9_DATABASE_mysql" }
162
+ end
163
+
164
+ it_behaves_like :dont_create_job_directories do
165
+ let(:job_name){ "RUBY_2.0_DATABASE_postgresql" }
166
+ end
105
167
  end
106
168
  end
107
169
  end
@@ -19,8 +19,8 @@ describe Paraduct::Runner do
19
19
  subject{ runner.perform }
20
20
 
21
21
  let(:script) { "./script/build_success.sh" }
22
- let(:params) { { "ruby" => "1.9", "database" => "mysql" } }
23
- let(:command){ 'export RUBY="1.9"; export DATABASE="mysql"; export PARADUCT_JOB_ID="1"; export PARADUCT_JOB_NAME="RUBY_1.9_DATABASE_mysql"; ./script/build_success.sh' }
22
+ let(:params) { { "RUBY" => "1.9", "DATABASE" => "mysql" } }
23
+ let(:command){ 'export PARADUCT_JOB_ID="1"; export PARADUCT_JOB_NAME="RUBY_1.9_DATABASE_mysql"; export RUBY="1.9"; export DATABASE="mysql"; ./script/build_success.sh' }
24
24
 
25
25
  context "with mock system" do
26
26
  it "script is call with capitalized variable" do
@@ -37,7 +37,7 @@ describe Paraduct::Runner do
37
37
  it { should match /DATABASE=mysql/ }
38
38
  end
39
39
 
40
- context "when error in script file" do
40
+ context "when error in script file", with_retry do
41
41
  let(:script){ "./script/build_error.sh" }
42
42
 
43
43
  let(:stdout) do
@@ -67,7 +67,7 @@ DATABASE=mysql
67
67
  describe "#job_dir" do
68
68
  subject{ runner.job_dir }
69
69
 
70
- let(:params) { { "ruby" => "1.9", "database" => "mysql" } }
70
+ let(:params) { { "RUBY" => "1.9", "DATABASE" => "mysql" } }
71
71
 
72
72
  it { should eq temp_dir_path.join("RUBY_1.9_DATABASE_mysql") }
73
73
  end
@@ -75,22 +75,22 @@ DATABASE=mysql
75
75
  describe "#formatted_params" do
76
76
  subject{ runner.formatted_params }
77
77
 
78
- let(:params){ { "ruby" => "1.9", "database" => "mysql" } }
78
+ let(:params){ { "RUBY" => "1.9", "DATABASE" => "mysql" } }
79
79
 
80
- it{ should eq "ruby=1.9, database=mysql" }
80
+ it{ should eq "RUBY=1.9, DATABASE=mysql" }
81
81
  end
82
82
 
83
83
  describe "#job_name" do
84
84
  subject{ runner.job_name }
85
85
 
86
86
  context "basic case" do
87
- let(:params) { { "ruby" => "1.9", "database" => "mysql" } }
87
+ let(:params) { { "RUBY" => "1.9", "DATABASE" => "mysql" } }
88
88
 
89
89
  it { should eq "RUBY_1.9_DATABASE_mysql" }
90
90
  end
91
91
 
92
92
  context "containing slash" do
93
- let(:params) { { "ruby" => "1.9", "gemfile" => "gemfiles/rails3_2.gemfile" } }
93
+ let(:params) { { "RUBY" => "1.9", "GEMFILE" => "gemfiles/rails3_2.gemfile" } }
94
94
 
95
95
  it { should eq "RUBY_1.9_GEMFILE_gemfiles_rails3_2.gemfile" }
96
96
  end
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.3
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
@@ -348,9 +348,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
348
348
  version: '0'
349
349
  required_rubygems_version: !ruby/object:Gem::Requirement
350
350
  requirements:
351
- - - ">="
351
+ - - ">"
352
352
  - !ruby/object:Gem::Version
353
- version: '0'
353
+ version: 1.3.1
354
354
  requirements: []
355
355
  rubyforge_project:
356
356
  rubygems_version: 2.5.1