knapsack_pro 0.25.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +57 -1
- data/lib/knapsack_pro/client/connection.rb +2 -1
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/tasks/install.rake +7 -2
- data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
- data/spec/integration/api/build_subsets_create_spec.rb +1 -0
- 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: 7703c67b5430e96304f84ffe6180d2724ced2024
|
4
|
+
data.tar.gz: 42504a31a204cbec81297226b1106a5a93b3c97e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b30a77c07bb4b62bcb67b767f279062d4ae0a7497f8da5d411a9b2f834ef2f48c1afe4562a3a339c869e81888a3f086256064b0154e3bc28526560f113e36cc6
|
7
|
+
data.tar.gz: 8099e1690a714695f646dd1dc3617554f257dea090b3b384f1a3407e693891d2f577b78c5678ae6c45b2f77f8362abbeaa99af6505bbc86451ebb5800b3d0f65
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
* TODO
|
4
4
|
|
5
|
+
### 0.26.0
|
6
|
+
|
7
|
+
* Add info how to allow FakeWeb to connect with Knapsack Pro API in install rake task.
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.25.0...v0.26.0
|
10
|
+
|
5
11
|
### 0.25.0
|
6
12
|
|
7
13
|
* Queue mode retry (remember queue split on retry CI node).
|
data/README.md
CHANGED
@@ -96,6 +96,8 @@ The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test sui
|
|
96
96
|
- [Info for snap-ci.com users](#info-for-snap-cicom-users)
|
97
97
|
- [FAQ](#faq)
|
98
98
|
- [How to run tests for particular CI node in your development environment](#how-to-run-tests-for-particular-ci-node-in-your-development-environment)
|
99
|
+
- [for knapack_pro regular mode](#for-knapack_pro-regular-mode)
|
100
|
+
- [for knapsack_pro queue mode](#for-knapsack_pro-queue-mode)
|
99
101
|
- [What happens when Knapsack Pro API is not available/not reachable temporarily?](#what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily)
|
100
102
|
- [How can I change log level?](#how-can-i-change-log-level)
|
101
103
|
- [How to split tests based on test level instead of test file level?](#how-to-split-tests-based-on-test-level-instead-of-test-file-level)
|
@@ -145,7 +147,9 @@ You can read next section only if you want to better understand optional gem con
|
|
145
147
|
|
146
148
|
## How to set up
|
147
149
|
|
148
|
-
If you
|
150
|
+
If you use [VCR](https://github.com/vcr/vcr), [WebMock](https://github.com/bblimke/webmock) or [FakeWeb](https://github.com/chrisk/fakeweb) gems then you need to allow them to make requests to Knapsack Pro API.
|
151
|
+
|
152
|
+
For VCR add Knapsack Pro API subdomain to [ignore hosts](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request):
|
149
153
|
|
150
154
|
```ruby
|
151
155
|
# spec/spec_helper.rb or wherever is your VCR configuration
|
@@ -159,6 +163,10 @@ end
|
|
159
163
|
# add below when you hook into webmock
|
160
164
|
require 'webmock/rspec'
|
161
165
|
WebMock.disable_net_connect!(:allow => ['api.knapsackpro.com'])
|
166
|
+
|
167
|
+
# add below when you use FakeWeb
|
168
|
+
require 'fakeweb'
|
169
|
+
FakeWeb.allow_net_connect = %r[^https?://api\.knapsackpro\.com]
|
162
170
|
```
|
163
171
|
|
164
172
|
Ensure you have require false for webmock gem when VCR is hook into it. Thanks to that webmock configuration in `spec_helper.rb` is loaded properly.
|
@@ -169,6 +177,7 @@ Ensure you have require false for webmock gem when VCR is hook into it. Thanks t
|
|
169
177
|
group :test do
|
170
178
|
gem 'vcr'
|
171
179
|
gem 'webmock', require: false
|
180
|
+
gem 'fakeweb', require: false # example when you use fakeweb
|
172
181
|
end
|
173
182
|
```
|
174
183
|
|
@@ -642,6 +651,8 @@ Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as gl
|
|
642
651
|
|
643
652
|
### How to run tests for particular CI node in your development environment
|
644
653
|
|
654
|
+
#### for knapack_pro regular mode
|
655
|
+
|
645
656
|
In your development environment you can debug tests that were run on the particular CI node.
|
646
657
|
For instance to run subset of tests for the first CI node with specified seed you can do.
|
647
658
|
|
@@ -653,6 +664,51 @@ For instance to run subset of tests for the first CI node with specified seed yo
|
|
653
664
|
bundle exec rake "knapsack_pro:rspec[--seed 123]"
|
654
665
|
|
655
666
|
Above example is for RSpec. You can use respectively rake task name and token environment variable when you want to run tests for minitest, cucumber or spinach.
|
667
|
+
It should work when all CI nodes finished work and sent time execution data to Knapsack Pro API.
|
668
|
+
You can visit [user dashboard](https://knapsackpro.com/dashboard) to preview particular CI build and ensure time execution data were collected from all CI nodes.
|
669
|
+
If at least one CI node has not sent time execution data to the Knapsack Pro API then you should check below solution.
|
670
|
+
|
671
|
+
Check test runner output on particular CI node you would like to retry in development. You should see at the beginning of rspec command an output that can
|
672
|
+
be copied and executed in development.
|
673
|
+
|
674
|
+
/Users/ubuntu/.rvm/gems/ruby-2.4.0/gems/rspec-core-3.4.4/exe/rspec spec/foo_spec.rb spec/bar_spec.rb --default-path spec
|
675
|
+
|
676
|
+
Command similar to above can be executed in your development this way:
|
677
|
+
|
678
|
+
bundle exec rspec spec/foo_spec.rb spec/bar_spec.rb --default-path spec
|
679
|
+
|
680
|
+
If you were running your tests with `--order random` on your CI then you can additionaly pass seed param with proper value in above command (`--seed 123`).
|
681
|
+
|
682
|
+
#### for knapsack_pro queue mode
|
683
|
+
|
684
|
+
To retry the particular CI node do this on your machine:
|
685
|
+
|
686
|
+
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=token \
|
687
|
+
KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
|
688
|
+
KNAPSACK_PRO_PROJECT_DIR=~/projects/rails-app \
|
689
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 \
|
690
|
+
KNAPSACK_PRO_CI_NODE_INDEX=0 \
|
691
|
+
KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true \
|
692
|
+
bundle exec rake "knapsack_pro:queue:rspec"
|
693
|
+
|
694
|
+
If you were running your tests with `--order random` on your CI like this:
|
695
|
+
|
696
|
+
bundle exec rake "knapsack_pro:queue:rspec[--order random]"
|
697
|
+
|
698
|
+
Then you can find the seed number visible in rspec output:
|
699
|
+
|
700
|
+
(...)
|
701
|
+
Randomized with seed 123
|
702
|
+
|
703
|
+
You can pass the seed in your local environment to reproduce the tests in the same order as they were executed on CI node:
|
704
|
+
|
705
|
+
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=token \
|
706
|
+
KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
|
707
|
+
KNAPSACK_PRO_PROJECT_DIR=~/projects/rails-app \
|
708
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 \
|
709
|
+
KNAPSACK_PRO_CI_NODE_INDEX=0 \
|
710
|
+
KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true \
|
711
|
+
bundle exec rake "knapsack_pro:queue:rspec[--seed 123]"
|
656
712
|
|
657
713
|
### What happens when Knapsack Pro API is not available/not reachable temporarily?
|
658
714
|
|
@@ -2,6 +2,7 @@ module KnapsackPro
|
|
2
2
|
module Client
|
3
3
|
class Connection
|
4
4
|
TIMEOUT = 30
|
5
|
+
REQUEST_RETRY_TIMEBOX = 2
|
5
6
|
|
6
7
|
def initialize(action)
|
7
8
|
@action = action
|
@@ -103,7 +104,7 @@ module KnapsackPro
|
|
103
104
|
logger.warn(e.inspect)
|
104
105
|
retries += 1
|
105
106
|
if retries < 5
|
106
|
-
wait = retries *
|
107
|
+
wait = retries * REQUEST_RETRY_TIMEBOX
|
107
108
|
logger.warn("Wait #{wait}s and retry request to Knapsack Pro API.")
|
108
109
|
sleep wait
|
109
110
|
retry
|
data/lib/knapsack_pro/version.rb
CHANGED
data/lib/tasks/install.rake
CHANGED
@@ -43,7 +43,7 @@ KnapsackPro::Adapters::SpinachAdapter.bind
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def step_for_vcr(prompt)
|
46
|
-
prompt.say "Step for VCR
|
46
|
+
prompt.say "Step for VCR/WebMock/FakeWeb gems", color: :yellow
|
47
47
|
prompt.say "Add Knapsack Pro API subdomain to ignore hosts"
|
48
48
|
prompt.say "in spec/spec_helper.rb or wherever is your VCR configuration:"
|
49
49
|
|
@@ -57,6 +57,10 @@ end
|
|
57
57
|
# add below when you hook into webmock
|
58
58
|
require 'webmock/rspec'
|
59
59
|
WebMock.disable_net_connect!(:allow => ['api.knapsackpro.com'])
|
60
|
+
|
61
|
+
# add below when you use FakeWeb
|
62
|
+
require 'fakeweb'
|
63
|
+
FakeWeb.allow_net_connect = %r[^https?://api\.knapsackpro\.com]
|
60
64
|
}, color: :cyan
|
61
65
|
|
62
66
|
puts
|
@@ -67,6 +71,7 @@ WebMock.disable_net_connect!(:allow => ['api.knapsackpro.com'])
|
|
67
71
|
group :test do
|
68
72
|
gem 'vcr'
|
69
73
|
gem 'webmock', require: false
|
74
|
+
gem 'fakeweb', require: false # example when you use fakeweb
|
70
75
|
end
|
71
76
|
}, color: :cyan
|
72
77
|
end
|
@@ -271,7 +276,7 @@ namespace :knapsack_pro do
|
|
271
276
|
answers[:testing_tools] = prompt.multi_select("Choose your testing tools:", TESTING_TOOLS_CHOICES)
|
272
277
|
end
|
273
278
|
|
274
|
-
answers[:has_vcr] = prompt.yes?('Do you use VCR gem?')
|
279
|
+
answers[:has_vcr] = prompt.yes?('Do you use VCR, WebMock or FakeWeb gem?')
|
275
280
|
|
276
281
|
CI_PROVIDER_CHOICES = {
|
277
282
|
'https://circleci.com' => :circle,
|
@@ -62,6 +62,7 @@ describe 'Request API /v1/build_distributions/subset' do
|
|
62
62
|
|
63
63
|
it do
|
64
64
|
stub_const('KnapsackPro::Client::Connection::TIMEOUT', 0.01)
|
65
|
+
stub_const('KnapsackPro::Client::Connection::REQUEST_RETRY_TIMEBOX', 0.01)
|
65
66
|
VCR.use_cassette('api/v1/build_distributions/subset/timeout') do
|
66
67
|
response = connection.call
|
67
68
|
puts response
|
@@ -64,6 +64,7 @@ describe 'Request API /v1/build_subsets' do
|
|
64
64
|
|
65
65
|
it do
|
66
66
|
stub_const('KnapsackPro::Client::Connection::TIMEOUT', 0.01)
|
67
|
+
stub_const('KnapsackPro::Client::Connection::REQUEST_RETRY_TIMEBOX', 0.01)
|
67
68
|
VCR.use_cassette('api/v1/build_subsets/create/timeout') do
|
68
69
|
response = connection.call
|
69
70
|
puts response
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -363,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
363
363
|
version: '0'
|
364
364
|
requirements: []
|
365
365
|
rubyforge_project:
|
366
|
-
rubygems_version: 2.
|
366
|
+
rubygems_version: 2.6.8
|
367
367
|
signing_key:
|
368
368
|
specification_version: 4
|
369
369
|
summary: Knapsack Pro splits tests across CI nodes and makes sure that tests will
|