snap_ci-parallel_tests 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +8 -8
- data/bin/snap-ci-parallel-partition +7 -0
- data/bin/{snap_ci-parallel_rspec → snap-ci-parallel-rspec} +0 -0
- data/bin/{snap_ci-parallel_test → snap-ci-parallel-test} +0 -0
- data/lib/snap_ci/parallel_tests/cli.rb +20 -4
- data/lib/snap_ci/parallel_tests/grouper.rb +21 -0
- data/lib/snap_ci/parallel_tests/partition/cli_helper.rb +35 -0
- data/lib/snap_ci/parallel_tests/partition/runner.rb +33 -0
- data/lib/snap_ci/parallel_tests/rspec/cli_helper.rb +8 -8
- data/lib/snap_ci/parallel_tests/rspec/runner.rb +4 -0
- data/lib/snap_ci/parallel_tests/test/cli_helper.rb +9 -9
- data/lib/snap_ci/parallel_tests/test/runner.rb +5 -19
- data/lib/snap_ci/parallel_tests/version.rb +1 -1
- data/lib/snap_ci/parallel_tests.rb +7 -13
- data/snap_ci-parallel_tests.gemspec +1 -1
- data/spec/snap_ci/parallel_tests_spec.rb +88 -25
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9a82a7f30c6776d93df92ed4fe8e3672a31a19
|
4
|
+
data.tar.gz: 9bb5b4e69777aaa30185b0527ed769945b3b28b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4133669bf0b3a6696a15d24225b739960904a27b32b7e0516754f8703022910920027bdc35ad8210efb7ce346647f74ef30c3540fa0da94738d6aad3bc9671ca
|
7
|
+
data.tar.gz: 020b61c12f3632dfa24e22e76f37388daafa729d2c70c9c67661d26eca750fa3d3151f34881971fcd8979b971fae734e924e2cf0409efdf592bcdf86067ab1cf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
snap_ci-parallel_tests (0.0.
|
4
|
+
snap_ci-parallel_tests (0.0.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -68,7 +68,7 @@ PLATFORMS
|
|
68
68
|
ruby
|
69
69
|
|
70
70
|
DEPENDENCIES
|
71
|
-
bundler (~> 1.
|
71
|
+
bundler (~> 1.4)
|
72
72
|
rake
|
73
73
|
rspec (>= 2.12.0)
|
74
74
|
rspec-rails (>= 2.12.0)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# SnapCI::ParallelTests
|
1
|
+
# SnapCI::ParallelTests [](https://snap-ci.com/snap-ci/parallel-tests/branch/master)
|
2
2
|
|
3
3
|
Run Test::Unit / RSpec in parallel across multiple workers on [Snap CI](https://snap-ci.com).
|
4
4
|
|
@@ -22,23 +22,23 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Depending on the framework of your choice -
|
24
24
|
|
25
|
-
$ bundle exec
|
26
|
-
$ bundle exec
|
25
|
+
$ bundle exec snap-ci-parallel-rspec [options] [files or directories] [-- [rspec options]]
|
26
|
+
$ bundle exec snap-ci-parallel-test [options] [files or directories] [-- [Test::Unit or MiniTest options]]
|
27
27
|
|
28
28
|
|
29
29
|
## Setup for Rails
|
30
30
|
|
31
|
-
Ensure that 'parallel_tests' is present in your development group
|
31
|
+
Ensure that 'snap_ci-parallel_tests' is present in your development group
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
# Gemfile
|
35
|
-
gem "parallel_tests", :group => :development
|
35
|
+
gem "snap_ci-parallel_tests", :group => :development
|
36
36
|
```
|
37
37
|
|
38
38
|
### Run
|
39
39
|
|
40
|
-
$ bundle exec
|
41
|
-
$ bundle exec
|
40
|
+
$ bundle exec snap-ci-parallel-rspec [options] [files or directories] [-- [rspec options]]
|
41
|
+
$ bundle exec snap-ci-parallel-test [options] [files or directories] [-- [Test::Unit or MiniTest options]]
|
42
42
|
|
43
43
|
Alternatively -
|
44
44
|
|
@@ -53,7 +53,7 @@ $ bundle exec rake -T snap-parallel # to list all tasks
|
|
53
53
|
|
54
54
|
## Contributing
|
55
55
|
|
56
|
-
1. Fork it ( https://github.com/[my-github-username]/
|
56
|
+
1. Fork it ( https://github.com/[my-github-username]/parallel-tests/fork )
|
57
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
58
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
59
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
|
3
|
+
require 'snap_ci/parallel_tests'
|
4
|
+
require 'snap_ci/parallel_tests/cli'
|
5
|
+
require 'snap_ci/parallel_tests/partition/runner'
|
6
|
+
|
7
|
+
SnapCI::ParallelTests::CLI.new(SnapCI::ParallelTests::Partition::Runner.new, ARGV).run
|
File without changes
|
File without changes
|
@@ -73,6 +73,7 @@ module SnapCI
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def report_number_of_tests(tests, total_workers)
|
76
|
+
return unless runner.report_test_partitioning?
|
76
77
|
name = runner.test_file_name
|
77
78
|
num_tests = tests.size
|
78
79
|
$stderr.puts "#{total_workers} workers for #{num_tests} #{name}s, ~ #{(num_tests.to_f/total_workers).ceil} #{name}s per process"
|
@@ -84,20 +85,35 @@ module SnapCI
|
|
84
85
|
options[:group_by] = :filename
|
85
86
|
|
86
87
|
parser = OptionParser.new do |opts|
|
87
|
-
runner.cli_helper.render_header(opts)
|
88
|
+
runner.cli_helper.render_header(opts, options)
|
88
89
|
opts.separator 'supported options:'
|
89
90
|
|
90
|
-
runner.cli_helper.render_options(opts)
|
91
|
+
runner.cli_helper.render_options(opts, options)
|
91
92
|
|
92
93
|
opts.on('-g', '--group-by TYPE', <<-TEXT) do |type|
|
93
94
|
group tests by:
|
94
95
|
filename - order of finding files(default)
|
95
96
|
filesize - by size of the file
|
96
97
|
TEXT
|
97
|
-
|
98
|
+
|
99
|
+
allowed_group_values = %w(filename filesize)
|
100
|
+
raise "Group option only supports #{allowed_group_values.join(', ')}. You passed #{type}" unless allowed_group_values.include?(type)
|
101
|
+
|
98
102
|
options[:group_by] = type.to_sym
|
99
103
|
end
|
100
104
|
|
105
|
+
opts.on('-d', '--distribution TYPE', <<-TEXT) do |type|
|
106
|
+
after grouping tests, distribute tests across workers by:
|
107
|
+
roundrobin - distribute files one at a time to each worker (default)
|
108
|
+
chunk - slice tests
|
109
|
+
TEXT
|
110
|
+
|
111
|
+
allowed_distribution_values = %w(roundrobin chunk)
|
112
|
+
raise "Distribution option only supports #{allowed_distribution_values.join(', ')}. You passed #{type}" unless allowed_distribution_values.include?(type)
|
113
|
+
|
114
|
+
options[:distribution] = type.to_sym
|
115
|
+
end
|
116
|
+
|
101
117
|
opts.on('-v', '--version', 'Show Version') do
|
102
118
|
puts "SnapCI Parallel Tests v#{SnapCI::ParallelTests::VERSION}"
|
103
119
|
exit
|
@@ -112,7 +128,7 @@ group tests by:
|
|
112
128
|
exit
|
113
129
|
end
|
114
130
|
|
115
|
-
runner.cli_helper.render_footer(opts)
|
131
|
+
runner.cli_helper.render_footer(opts, options)
|
116
132
|
end
|
117
133
|
|
118
134
|
parser.parse!(argv)
|
@@ -9,6 +9,27 @@ module SnapCI
|
|
9
9
|
def group_by_filesize(things)
|
10
10
|
things.sort { |a, b| File.size(a) <=> File.size(b) }
|
11
11
|
end
|
12
|
+
|
13
|
+
def distribute_by_round_robin(things, total_workers, current_worker_index)
|
14
|
+
result = []
|
15
|
+
|
16
|
+
# pick up things on a round-robin basis to distribute them evenly
|
17
|
+
index = current_worker_index - 1
|
18
|
+
while index <= things.count do
|
19
|
+
result << things[index]
|
20
|
+
index += total_workers
|
21
|
+
end
|
22
|
+
result.compact!
|
23
|
+
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def distribute_by_chunk(things, total_workers, current_worker_index)
|
28
|
+
thing_count = things.count
|
29
|
+
specs_per_worker = (thing_count.to_f/total_workers).ceil
|
30
|
+
|
31
|
+
things.each_slice(specs_per_worker).to_a[current_worker_index-1] || []
|
32
|
+
end
|
12
33
|
end
|
13
34
|
end
|
14
35
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SnapCI
|
2
|
+
module ParallelTests
|
3
|
+
module Partition
|
4
|
+
module CLIHelper
|
5
|
+
def render_header(optparser, options)
|
6
|
+
optparser.banner = <<BANNER
|
7
|
+
Partition a list of files/directories and print them
|
8
|
+
|
9
|
+
Usage: #{optparser.program_name} [options] [files or directories]
|
10
|
+
|
11
|
+
Example: #{optparser.program_name} test/models test/controllers/foo_controller_test.rb
|
12
|
+
|
13
|
+
Can typically be used as -
|
14
|
+
|
15
|
+
$ your-test-runner $(snap-ci-parallel-partition location/of/test/files)
|
16
|
+
|
17
|
+
BANNER
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_options(optparser, options)
|
21
|
+
optparser.on('-p', '--pattern [PATTERN]', 'only find files matching this pattern') do |pattern|
|
22
|
+
options[:pattern] = /#{pattern}/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_footer(optparser, options)
|
27
|
+
optparser.separator ''
|
28
|
+
end
|
29
|
+
|
30
|
+
extend CLIHelper
|
31
|
+
end #CLIHelper
|
32
|
+
|
33
|
+
end #RSpec
|
34
|
+
end #ParallelTests
|
35
|
+
end #SnapCI
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'snap_ci/parallel_tests/partition/cli_helper'
|
3
|
+
|
4
|
+
module SnapCI
|
5
|
+
module ParallelTests
|
6
|
+
module Partition
|
7
|
+
class Runner
|
8
|
+
|
9
|
+
def execute(test_files, options)
|
10
|
+
$stdout.puts(test_files.collect {|f| f.dump }.join(' '))
|
11
|
+
end
|
12
|
+
|
13
|
+
def report_test_partitioning?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def cli_helper
|
18
|
+
CLIHelper
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_suffix
|
22
|
+
//
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_file_name
|
26
|
+
'file'
|
27
|
+
end
|
28
|
+
|
29
|
+
end #Runner
|
30
|
+
|
31
|
+
end #Partition
|
32
|
+
end #ParallelTests
|
33
|
+
end #SnapCI
|
@@ -2,22 +2,22 @@ module SnapCI
|
|
2
2
|
module ParallelTests
|
3
3
|
module RSpec
|
4
4
|
module CLIHelper
|
5
|
-
def render_header(
|
6
|
-
|
7
|
-
Usage: #{
|
5
|
+
def render_header(optparser, options)
|
6
|
+
optparser.banner = <<BANNER
|
7
|
+
Usage: #{optparser.program_name} [options] [files or directories] [-- [rspec options]]
|
8
8
|
|
9
|
-
Example: #{
|
9
|
+
Example: #{optparser.program_name} spec/models spec/controllers/foo_controller_spec.rb -- --format documentation --fail-fast
|
10
10
|
BANNER
|
11
11
|
end
|
12
12
|
|
13
|
-
def render_options(
|
14
|
-
|
13
|
+
def render_options(optparser, options)
|
14
|
+
optparser.on('-p', '--pattern [PATTERN]', 'run tests matching this pattern') do |pattern|
|
15
15
|
options[:pattern] = /#{pattern}/
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def render_footer(
|
20
|
-
|
19
|
+
def render_footer(optparser, options)
|
20
|
+
optparser.separator "\nRun `rspec --help' for supported rspec options."
|
21
21
|
end
|
22
22
|
|
23
23
|
extend CLIHelper
|
@@ -2,27 +2,27 @@ module SnapCI
|
|
2
2
|
module ParallelTests
|
3
3
|
module Test
|
4
4
|
module CLIHelper
|
5
|
-
def render_header(
|
6
|
-
|
7
|
-
Usage: #{
|
5
|
+
def render_header(optparser, options)
|
6
|
+
optparser.banner = <<BANNER
|
7
|
+
Usage: #{optparser.program_name} [options] [files or directories] [-- [Test::Unit or MiniTest options]]
|
8
8
|
|
9
|
-
Example: #{
|
9
|
+
Example: #{optparser.program_name} test/models test/controllers/foo_controller_test.rb -- --verbose --seed 10
|
10
10
|
BANNER
|
11
11
|
end
|
12
12
|
|
13
|
-
def render_options(
|
14
|
-
|
13
|
+
def render_options(optparser, options)
|
14
|
+
optparser.on('-p', '--pattern [PATTERN]', 'run tests matching this pattern') do |pattern|
|
15
15
|
options[:pattern] = /#{pattern}/
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def render_footer(
|
20
|
-
|
19
|
+
def render_footer(optparser, options)
|
20
|
+
optparser.separator "\nRun `ruby -r test/test_helper -e1 --help' for supported Test::Unit or MiniTest options."
|
21
21
|
end
|
22
22
|
|
23
23
|
extend CLIHelper
|
24
24
|
end #CLIHelper
|
25
25
|
|
26
|
-
end #
|
26
|
+
end #Test
|
27
27
|
end #ParallelTests
|
28
28
|
end #SnapCI
|
@@ -16,6 +16,10 @@ module SnapCI
|
|
16
16
|
exec(cmd)
|
17
17
|
end
|
18
18
|
|
19
|
+
def report_test_partitioning?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
19
23
|
def cli_helper
|
20
24
|
CLIHelper
|
21
25
|
end
|
@@ -28,26 +32,8 @@ module SnapCI
|
|
28
32
|
'test'
|
29
33
|
end
|
30
34
|
|
31
|
-
private
|
32
|
-
|
33
|
-
def output_of(cmd)
|
34
|
-
`#{cmd}`
|
35
|
-
end
|
36
|
-
|
37
|
-
def rspec_2_color
|
38
|
-
'--color --tty' if $stdout.tty?
|
39
|
-
end
|
40
|
-
|
41
|
-
def rspec_1_color
|
42
|
-
if $stdout.tty?
|
43
|
-
{ 'RSPEC_COLOR' => '1' }
|
44
|
-
else
|
45
|
-
{}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
35
|
end #Runner
|
50
36
|
|
51
|
-
end #
|
37
|
+
end #Test
|
52
38
|
end #ParallelTests
|
53
39
|
end #SnapCI
|
@@ -10,29 +10,23 @@ module SnapCI
|
|
10
10
|
#
|
11
11
|
# ==== Options
|
12
12
|
# +things+ - the things to partition
|
13
|
-
# +total_workers+ - the total number of workers, defaults to ParallelTests.total_workers
|
14
|
-
# +current_worker_index+ - the current worker index (1 based, NOT 0 based), defaults to ParallelTests.worker_index
|
15
|
-
# +group_by+ - either :filename or :filesize (defaults to :filename). Determines how files are sorted before being
|
13
|
+
# +total_workers+ - the total number of workers, defaults to ParallelTests.total_workers.
|
14
|
+
# +current_worker_index+ - the current worker index (1 based, NOT 0 based), defaults to ParallelTests.worker_index.
|
15
|
+
# +group_by+ - either :filename or :filesize (defaults to :filename). Determines how files are sorted before being distributed into partitions/
|
16
|
+
# +distribution+ - either :round_robin or :chunk (defaults to :roundrobin). Determines how files are distributed across workers, after they are sorted.
|
16
17
|
def partition(options={})
|
17
18
|
things = options[:things]
|
18
19
|
total_workers = options[:total_workers] || ParallelTests.total_workers
|
19
20
|
current_worker_index = options[:current_worker_index] || ParallelTests.worker_index
|
20
21
|
group_by = options[:group_by] || :filename
|
22
|
+
distribution = options[:distribution] || :round_robin
|
21
23
|
|
22
24
|
return [] if things.nil? || things.empty?
|
23
25
|
things = Grouper.send("group_by_#{group_by}", things)
|
24
26
|
|
25
|
-
|
27
|
+
things = Grouper.send("distribute_by_#{distribution}", things, total_workers, current_worker_index)
|
26
28
|
|
27
|
-
|
28
|
-
index = current_worker_index - 1
|
29
|
-
while index <= things.count do
|
30
|
-
result << things[index]
|
31
|
-
index += total_workers
|
32
|
-
end
|
33
|
-
result.compact!
|
34
|
-
|
35
|
-
result
|
29
|
+
things
|
36
30
|
end
|
37
31
|
|
38
32
|
def total_workers
|
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.4"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
end
|
@@ -3,41 +3,104 @@ require 'spec_helper'
|
|
3
3
|
describe SnapCI::ParallelTests do
|
4
4
|
include SnapCI::ParallelTests
|
5
5
|
|
6
|
-
|
7
|
-
things = (1..10).to_a
|
6
|
+
describe 'default (round robin) distribution behavior, when distribution option is not passed' do
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3)
|
8
|
+
it 'should create uniform partitions of things based on count and index' do
|
9
|
+
things = (1..10).to_a
|
12
10
|
|
13
|
-
|
11
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1)
|
12
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2)
|
13
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3)
|
14
|
+
|
15
|
+
expect(partition1 + partition2 + partition3).to contain_exactly(*things)
|
16
|
+
|
17
|
+
expect(partition1).to eq([1, 4, 7, 10])
|
18
|
+
expect(partition2).to eq([2, 5, 8])
|
19
|
+
expect(partition3).to eq([3, 6, 9])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should create empty partitions if things are empty' do
|
23
|
+
things = []
|
24
|
+
|
25
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1)
|
26
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2)
|
27
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3)
|
28
|
+
|
29
|
+
expect(partition1).to eq([])
|
30
|
+
expect(partition2).to eq([])
|
31
|
+
expect(partition3).to eq([])
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should create empty partitions at end if partitions are more than number of things' do
|
35
|
+
things = [1, 2]
|
36
|
+
|
37
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1)
|
38
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2)
|
39
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3)
|
40
|
+
|
41
|
+
expect(partition1).to eq([1])
|
42
|
+
expect(partition2).to eq([2])
|
43
|
+
expect(partition3).to eq([])
|
44
|
+
end
|
14
45
|
|
15
|
-
expect(partition1).to eq([1, 4, 7, 10])
|
16
|
-
expect(partition2).to eq([2, 5, 8])
|
17
|
-
expect(partition3).to eq([3, 6, 9])
|
18
46
|
end
|
19
47
|
|
20
|
-
|
21
|
-
things
|
48
|
+
describe 'round robin distribution, when distribution option is not passed' do
|
49
|
+
it 'should create uniform partitions of things based on count and index' do
|
50
|
+
things = (1..10).to_a
|
22
51
|
|
23
|
-
|
24
|
-
|
25
|
-
|
52
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1, distribution: :round_robin)
|
53
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2, distribution: :round_robin)
|
54
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3, distribution: :round_robin)
|
26
55
|
|
27
|
-
|
28
|
-
|
29
|
-
|
56
|
+
expect(partition1 + partition2 + partition3).to contain_exactly(*things)
|
57
|
+
|
58
|
+
expect(partition1).to eq([1, 4, 7, 10])
|
59
|
+
expect(partition2).to eq([2, 5, 8])
|
60
|
+
expect(partition3).to eq([3, 6, 9])
|
61
|
+
end
|
30
62
|
end
|
31
63
|
|
32
|
-
|
33
|
-
|
64
|
+
describe 'chunk distribution' do
|
65
|
+
|
66
|
+
it 'should create uniform partitions of things based on count and index' do
|
67
|
+
things = (1..10).to_a
|
34
68
|
|
35
|
-
|
36
|
-
|
37
|
-
|
69
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1, distribution: :chunk)
|
70
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2, distribution: :chunk)
|
71
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3, distribution: :chunk)
|
72
|
+
|
73
|
+
expect(partition1 + partition2 + partition3).to contain_exactly(*things)
|
74
|
+
|
75
|
+
expect(partition1).to eq([1, 2, 3, 4])
|
76
|
+
expect(partition2).to eq([5, 6, 7, 8])
|
77
|
+
expect(partition3).to eq([9, 10])
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should create empty partitions if things are empty' do
|
81
|
+
things = []
|
82
|
+
|
83
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1, distribution: :chunk)
|
84
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2, distribution: :chunk)
|
85
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3, distribution: :chunk)
|
86
|
+
|
87
|
+
expect(partition1).to eq([])
|
88
|
+
expect(partition2).to eq([])
|
89
|
+
expect(partition3).to eq([])
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should create empty partitions at end if partitions are more than number of things' do
|
93
|
+
things = [1, 2]
|
94
|
+
|
95
|
+
partition1 = partition(things: things, total_workers: 3, current_worker_index: 1, distribution: :chunk)
|
96
|
+
partition2 = partition(things: things, total_workers: 3, current_worker_index: 2, distribution: :chunk)
|
97
|
+
partition3 = partition(things: things, total_workers: 3, current_worker_index: 3, distribution: :chunk)
|
98
|
+
|
99
|
+
expect(partition1).to eq([1])
|
100
|
+
expect(partition2).to eq([2])
|
101
|
+
expect(partition3).to eq([])
|
102
|
+
end
|
38
103
|
|
39
|
-
expect(partition1).to eq([1])
|
40
|
-
expect(partition2).to eq([2])
|
41
|
-
expect(partition3).to eq([])
|
42
104
|
end
|
105
|
+
|
43
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snap_ci-parallel_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ketan Padegaonkar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,8 +42,9 @@ description: Run Test::Unit / RSpec in parallel across multiple workers on Snap
|
|
42
42
|
email:
|
43
43
|
- KetanPadegaonkar@gmail.com
|
44
44
|
executables:
|
45
|
-
-
|
46
|
-
-
|
45
|
+
- snap-ci-parallel-partition
|
46
|
+
- snap-ci-parallel-rspec
|
47
|
+
- snap-ci-parallel-test
|
47
48
|
extensions: []
|
48
49
|
extra_rdoc_files: []
|
49
50
|
files:
|
@@ -56,11 +57,14 @@ files:
|
|
56
57
|
- LICENSE.txt
|
57
58
|
- README.md
|
58
59
|
- Rakefile
|
59
|
-
- bin/
|
60
|
-
- bin/
|
60
|
+
- bin/snap-ci-parallel-partition
|
61
|
+
- bin/snap-ci-parallel-rspec
|
62
|
+
- bin/snap-ci-parallel-test
|
61
63
|
- lib/snap_ci/parallel_tests.rb
|
62
64
|
- lib/snap_ci/parallel_tests/cli.rb
|
63
65
|
- lib/snap_ci/parallel_tests/grouper.rb
|
66
|
+
- lib/snap_ci/parallel_tests/partition/cli_helper.rb
|
67
|
+
- lib/snap_ci/parallel_tests/partition/runner.rb
|
64
68
|
- lib/snap_ci/parallel_tests/railtie.rb
|
65
69
|
- lib/snap_ci/parallel_tests/rspec/cli_helper.rb
|
66
70
|
- lib/snap_ci/parallel_tests/rspec/runner.rb
|
@@ -91,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
95
|
version: '0'
|
92
96
|
requirements: []
|
93
97
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.0.14
|
95
99
|
signing_key:
|
96
100
|
specification_version: 4
|
97
101
|
summary: Run Test::Unit / RSpec in parallel across multiple workers on Snap CI
|