knapsack 1.0.1 → 1.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/.travis.yml +2 -4
- data/CHANGELOG.md +4 -0
- data/README.md +23 -13
- data/lib/knapsack/distributors/base_distributor.rb +1 -1
- data/lib/knapsack/distributors/report_distributor.rb +11 -0
- data/lib/knapsack/presenter.rb +3 -0
- data/lib/knapsack/version.rb +1 -1
- data/spec/knapsack/distributors/report_distributor_spec.rb +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e65fdc9823d7ad10bb38a4d96663526897528565
|
4
|
+
data.tar.gz: ac938b8d273c278c79b87b961a48edd716c0f8a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67cfb99f75768e27301dc1d0446c5950b8d97640eec3f98062832004d0c2be2931cc2f0421c641817ed50c713fb464a3ee059208fb4bb18d0e58065015f16a18
|
7
|
+
data.tar.gz: 70bf4d8fe18658b1dbeece948208c7b1d2d147384fe59564546976d2b8a1775638ae0cd113d3fc873143b5e3259f5d4e69355ae69d087ba13a6939a15f140c40
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -116,6 +116,12 @@ Commit generated report `knapsack_rspec_report.json` or `knapsack_cucumber_repor
|
|
116
116
|
|
117
117
|
This report should be updated only after you add a lot of new slow tests or you change existing ones which causes a big time execution difference between CI nodes. Either way, you will get time offset warning at the end of the rspec/cucumber results which reminds you when it’s a good time to regenerate the knapsack report.
|
118
118
|
|
119
|
+
#### Adding or removing tests
|
120
|
+
|
121
|
+
There is no need to regenerate the report every time when you add/remove test file. If you remove a test file then Knapsack will ignore its entry in report. In case when you add a new file and it doesn't already exist in report, the test file will be assigned to one of the CI node.
|
122
|
+
|
123
|
+
You'll want to regenerate your execution report whenever you remove or add a test file with a long time execution time that would affect one of the CI nodes. You will get Knapsack notification whenever is good time to regenerate report.
|
124
|
+
|
119
125
|
## Setup your CI server
|
120
126
|
|
121
127
|
On your CI server run this command for the first CI node. Update `CI_NODE_INDEX` for the next one.
|
@@ -213,11 +219,12 @@ Now everything should works. You will get warning at the end of rspec/cucumber r
|
|
213
219
|
For the first time run all tests at once with enabled report generator. Edit `.travis.yml`
|
214
220
|
|
215
221
|
```yaml
|
216
|
-
|
217
|
-
|
222
|
+
script:
|
223
|
+
# Step for RSpec
|
224
|
+
- "KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec"
|
218
225
|
|
219
|
-
# Step for Cucumber
|
220
|
-
|
226
|
+
# Step for Cucumber
|
227
|
+
- "KNAPSACK_GENERATE_REPORT=true bundle exec cucumber features"
|
221
228
|
```
|
222
229
|
|
223
230
|
After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber results. Save it into your repository as `knapsack_rspec_report.json` or `knapsack_cucumber_report.json` file and commit.
|
@@ -227,11 +234,12 @@ After tests pass your should copy knapsack json report which is rendered at the
|
|
227
234
|
You can parallel your builds across virtual machines with [travis matrix feature](http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines). Edit `.travis.yml`
|
228
235
|
|
229
236
|
```yaml
|
230
|
-
|
231
|
-
|
237
|
+
script:
|
238
|
+
# Step for RSpec
|
239
|
+
- "bundle exec rake knapsack:rspec"
|
232
240
|
|
233
|
-
# Step for Cucumber
|
234
|
-
|
241
|
+
# Step for Cucumber
|
242
|
+
- "bundle exec rake knapsack:cucumber"
|
235
243
|
|
236
244
|
env:
|
237
245
|
- CI_NODE_TOTAL=2 CI_NODE_INDEX=0
|
@@ -241,11 +249,12 @@ env:
|
|
241
249
|
If you want to have some global ENVs and matrix of ENVs then do it like this:
|
242
250
|
|
243
251
|
```yaml
|
244
|
-
|
245
|
-
|
252
|
+
script:
|
253
|
+
# Step for RSpec
|
254
|
+
- "bundle exec rake knapsack:rspec"
|
246
255
|
|
247
|
-
# Step for Cucumber
|
248
|
-
|
256
|
+
# Step for Cucumber
|
257
|
+
- "bundle exec rake knapsack:cucumber"
|
249
258
|
|
250
259
|
env:
|
251
260
|
global:
|
@@ -341,5 +350,6 @@ Many thanks to [Małgorzata Nowak](https://github.com/informatykgosia) for beaut
|
|
341
350
|
## Mentions
|
342
351
|
|
343
352
|
* Lunar Logic Blog | [Parallel your specs and don’t waste time](http://blog.lunarlogic.io/2014/parallel-your-specs-and-dont-waste-time/)
|
344
|
-
* Travis CI | [Parallelizing RSpec
|
353
|
+
* Travis CI | [Parallelizing RSpec and Cucumber on multiple VMs](http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-RSpec-and-Cucumber-on-multiple-VMs)
|
345
354
|
* Semaphore | [Running RSpec specs in parallel](https://semaphoreapp.com/docs/running-rspec-specs-in-threads.html)
|
355
|
+
* Semaphore | [Running Cucumber scenarios in parallel](https://semaphoreapp.com/docs/running-cucumber-scenarios-in-threads.html)
|
@@ -22,6 +22,17 @@ module Knapsack
|
|
22
22
|
def post_assign_test_files_to_node
|
23
23
|
assign_slow_test_files
|
24
24
|
assign_remaining_test_files
|
25
|
+
sort_assigned_test_files
|
26
|
+
end
|
27
|
+
|
28
|
+
def sort_assigned_test_files
|
29
|
+
ci_node_total.times do |index|
|
30
|
+
# sort by first key (file name)
|
31
|
+
# reverse it and then sort by second key (time) in reverse order
|
32
|
+
node_tests[index][:test_files_with_time].sort!.reverse!.sort! do |x, y|
|
33
|
+
y[1] <=> x[1]
|
34
|
+
end
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
38
|
def post_tests_for_node(node_index)
|
data/lib/knapsack/presenter.rb
CHANGED
@@ -52,6 +52,9 @@ or bump time_offset_in_seconds setting.}
|
|
52
52
|
Global time execution for this CI node is fine.
|
53
53
|
Happy testing!}
|
54
54
|
end
|
55
|
+
str << "\n=================================================\n"
|
56
|
+
str << %{Sign up for beta Knapsack Pro here:
|
57
|
+
http://knapsack.launchrock.com}
|
55
58
|
str << "\n=================================================\n"
|
56
59
|
str
|
57
60
|
end
|
data/lib/knapsack/version.rb
CHANGED
@@ -147,8 +147,8 @@ describe Knapsack::Distributors::ReportDistributor do
|
|
147
147
|
:test_files_with_time => [
|
148
148
|
["f_spec.rb", 3.5],
|
149
149
|
["d_spec.rb", 2.5],
|
150
|
-
["
|
151
|
-
["
|
150
|
+
["b_spec.rb", 1.5],
|
151
|
+
["a_spec.rb", 1.0]
|
152
152
|
]
|
153
153
|
})
|
154
154
|
end
|
@@ -158,9 +158,9 @@ describe Knapsack::Distributors::ReportDistributor do
|
|
158
158
|
:node_index => 2,
|
159
159
|
:time_left => 0.5,
|
160
160
|
:test_files_with_time => [
|
161
|
+
["i_spec.rb", 3.0],
|
161
162
|
["h_spec.rb", 3.0],
|
162
|
-
["c_spec.rb", 2.0]
|
163
|
-
["i_spec.rb", 3.0]
|
163
|
+
["c_spec.rb", 2.0]
|
164
164
|
]
|
165
165
|
})
|
166
166
|
end
|
@@ -172,8 +172,8 @@ describe Knapsack::Distributors::ReportDistributor do
|
|
172
172
|
expect(distributor.tests_for_node(1)).to eql([
|
173
173
|
'f_spec.rb',
|
174
174
|
'd_spec.rb',
|
175
|
-
'
|
176
|
-
'
|
175
|
+
'b_spec.rb',
|
176
|
+
'a_spec.rb'
|
177
177
|
])
|
178
178
|
end
|
179
179
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
218
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.4.5
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: Knapsack splits tests across CI nodes and makes sure that tests will run
|