parallel_calabash 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/bin/parallel_calabash +4 -0
- data/lib/parallel_calabash.rb +1 -1
- data/lib/parallel_calabash/feature_grouper.rb +24 -7
- data/lib/parallel_calabash/version.rb +1 -1
- data/spec/lib/parallel_calabash/feature_grouper_spec.rb +25 -7
- data/spec/test_data/features/aaa.feature +3 -3
- data/spec/test_data/features/bbb.feature +2 -2
- data/spec/test_data/features/ccc.feature +1 -1
- data/spec/test_data/features/ddd.feature +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c1de47f617c12e793aa8b98f2d22bcab741cc0f
|
4
|
+
data.tar.gz: 593c627f3f37adb741ce2b9ea943c86e39c40e96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ebe0e759e48292b1588d3983fd11aeb601cde950e96f9d586d687e4876b0648db8083757ace0e40c966b2bacbfc3c5bf296d0ac95701700f63f6b67af7260e
|
7
|
+
data.tar.gz: 4317dc8ed774b7026e414ad90e73a89ea3d529201c7afdc0a780829b9a321f47d9a4941f3a08e0eafcceb69d7363314abcfcfb325e707e7b0f83ef309588f10a
|
data/README.md
CHANGED
@@ -40,8 +40,9 @@ Example: parallel_calabash -a my.apk -o 'cucumber_opts_like_tags_profile_etc_her
|
|
40
40
|
-d, --distribution-tag tag divide features into groups as per occurrence of given tag
|
41
41
|
-o, --cucumber_opts '[OPTIONS]' execute with those cucumber options
|
42
42
|
--serialize-stdout Serialize stdout output, nothing will be written until everything is done
|
43
|
+
--group-by-scenarios Distribute equally as per scenarios. This uses cucumber dry run
|
43
44
|
--concurrent Run tests concurrently. Each test will run once on each device.
|
44
|
-
|
45
|
+
|
45
46
|
## REPROTING
|
46
47
|
|
47
48
|
use ENV['TEST_PROCESS_NUMBER'] environment variable in your ruby scripts to find out the process number. you can use this for reporting purpose OR process specific action.
|
data/bin/parallel_calabash
CHANGED
@@ -41,6 +41,10 @@ def parse_arguments(arguments)
|
|
41
41
|
options[:concurrent] = true
|
42
42
|
end
|
43
43
|
|
44
|
+
opts.on("--group-by-scenarios", "Distribute equally as per scenarios. This uses cucumber dry run") do
|
45
|
+
options[:group_by_scenarios] = true
|
46
|
+
end
|
47
|
+
|
44
48
|
end
|
45
49
|
|
46
50
|
opt_parser.parse!(arguments)
|
data/lib/parallel_calabash.rb
CHANGED
@@ -26,7 +26,7 @@ module ParallelCalabash
|
|
26
26
|
|
27
27
|
test_results = nil
|
28
28
|
report_time_taken do
|
29
|
-
groups = FeatureGrouper.feature_groups(options
|
29
|
+
groups = FeatureGrouper.feature_groups(options, number_of_processes)
|
30
30
|
threads = groups.size
|
31
31
|
|
32
32
|
test_results = Parallel.map_with_index(groups, :in_threads => threads) do |group, index|
|
@@ -1,14 +1,14 @@
|
|
1
|
+
require 'json'
|
1
2
|
module ParallelCalabash
|
2
3
|
class FeatureGrouper
|
3
4
|
|
4
5
|
class << self
|
5
6
|
|
6
|
-
def feature_groups(
|
7
|
-
if concurrent
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
def feature_groups(options, group_size)
|
8
|
+
return concurrent_feature_groups(options[:feature_folder], group_size) if options[:concurrent]
|
9
|
+
return scenario_groups group_size, options if options[:group_by_scenarios]
|
10
|
+
return feature_groups_by_weight(options[:feature_folder], group_size,options[:distribution_tag]) if options[:distribution_tag]
|
11
|
+
feature_groups_by_feature_files(options[:feature_folder], group_size)
|
12
12
|
end
|
13
13
|
|
14
14
|
def concurrent_feature_groups(feature_folder, number_of_groups)
|
@@ -19,6 +19,11 @@ module ParallelCalabash
|
|
19
19
|
|
20
20
|
def feature_groups_by_feature_files(feature_folder, group_size)
|
21
21
|
files = feature_files_in_folder feature_folder
|
22
|
+
groups = group_creator group_size,files
|
23
|
+
groups.reject(&:empty?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def group_creator group_size, files
|
22
27
|
min_number_files_per_group = files.size/group_size
|
23
28
|
remaining_number_of_files = files.size % group_size
|
24
29
|
groups = Array.new(group_size) { [] }
|
@@ -30,7 +35,19 @@ module ParallelCalabash
|
|
30
35
|
group << files.delete_at(0)
|
31
36
|
end
|
32
37
|
end
|
33
|
-
groups
|
38
|
+
groups
|
39
|
+
end
|
40
|
+
|
41
|
+
def scenario_groups group_size, options
|
42
|
+
generate_dry_run_report options
|
43
|
+
raise "Can not create dry run for scenario distribution" unless File.exists?("parallel_calabash_dry_run.json")
|
44
|
+
distribution_data = JSON.parse(File.read("parallel_calabash_dry_run.json"))
|
45
|
+
all_runnable_scenarios = distribution_data.map { |feature| feature["elements"].map { |scenario| "#{feature["uri"]}:#{scenario["line"]}" } }.flatten
|
46
|
+
groups = group_creator group_size,all_runnable_scenarios
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_dry_run_report options
|
50
|
+
`cucumber #{options[:cucumber_options]} -f usage --dry-run -f json --out parallel_calabash_dry_run.json #{options[:feature_folder].first}`
|
34
51
|
end
|
35
52
|
|
36
53
|
def feature_files_in_folder(feature_dir)
|
@@ -14,37 +14,37 @@ describe ParallelCalabash::FeatureGrouper do
|
|
14
14
|
describe :feature_groups do
|
15
15
|
|
16
16
|
it 'should group all features in only one group' do
|
17
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 1)).to eq \
|
17
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 1)).to eq \
|
18
18
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should divide features in 2 groups' do
|
22
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 2)).to eq \
|
22
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 2)).to eq \
|
23
23
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should divide features in 3 groups' do
|
27
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 3)).to eq \
|
27
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 3)).to eq \
|
28
28
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should divide features in 4 groups' do
|
32
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 4)).to eq \
|
32
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 4)).to eq \
|
33
33
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/eee.feature"], ["spec/test_data/features/bbb.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"]]
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should divide features in 5 groups' do
|
37
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 5)).to eq \
|
37
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 5)).to eq \
|
38
38
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature"]]
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should create 1 group for concurrent 1 process' do
|
42
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 1
|
42
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 1)).to eq \
|
43
43
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should create 2 group for concurrent 2 processes' do
|
47
|
-
expect(ParallelCalabash::FeatureGrouper.feature_groups(['spec/test_data/features'], 2
|
47
|
+
expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 2)).to eq \
|
48
48
|
[["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"],
|
49
49
|
["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]]
|
50
50
|
end
|
@@ -96,5 +96,23 @@ describe ParallelCalabash::FeatureGrouper do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
describe :scenario_groups do
|
100
|
+
it 'should groups all @runnable scenario equally into 2 groups' do
|
101
|
+
expect(ParallelCalabash::FeatureGrouper.scenario_groups(2,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
|
102
|
+
[["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11", "spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]]
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should groups all @runnable scenario equally into 2 groups' do
|
106
|
+
expect(ParallelCalabash::FeatureGrouper.scenario_groups(3,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
|
107
|
+
[["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/ddd.feature:7"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13", "spec/test_data/features/ddd.feature:10"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"]]
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should groups all @runnable scenario equally into 2 groups' do
|
111
|
+
expect(ParallelCalabash::FeatureGrouper.scenario_groups(4,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \
|
112
|
+
[["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"], ["spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]]
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
99
117
|
|
100
118
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_calabash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajdeep
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|