knapsack_pro 0.30.0 → 0.31.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 +10 -0
- data/README.md +185 -10
- data/lib/knapsack_pro.rb +0 -6
- data/lib/knapsack_pro/adapters/base_adapter.rb +2 -2
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +1 -1
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +1 -1
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +1 -1
- data/lib/knapsack_pro/adapters/spinach_adapter.rb +1 -1
- data/lib/knapsack_pro/client/connection.rb +4 -4
- data/lib/knapsack_pro/config/env.rb +5 -3
- data/lib/knapsack_pro/report.rb +1 -1
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +2 -2
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -2
- data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +1 -1
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +1 -1
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +1 -1
- data/spec/knapsack_pro/client/connection_spec.rb +9 -9
- data/spec/knapsack_pro/config/env_spec.rb +28 -4
- data/spec/knapsack_pro/report_spec.rb +1 -1
- data/spec/knapsack_pro_spec.rb +1 -1
- 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: 897d3324c8c5701fb4508d0382716c3bbbe6ed0c
|
4
|
+
data.tar.gz: 6ebf2904dde98152e80e12dfd855e5080f41233a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c23494c6858da7833fea766e2f3de502967150219657b3b35cb1fc6b4eb0481bbc6062a76c0a0944092d2b70585443cc3d99954d3a11eed676cba12d01c743d
|
7
|
+
data.tar.gz: f89bf84f3194baacf28b3396ed701d20a2b83d22ece58d2debd8cae591d599ec85605f39b5d9884d9c79e321de04b7d789751924f9a6db20ccbd75374e012730
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
* TODO
|
4
4
|
|
5
|
+
### 0.31.0
|
6
|
+
|
7
|
+
* Add supported for log levels `fatal` and `error` by `KNAPSACK_PRO_LOG_LEVEL` environment variable.
|
8
|
+
* Allow `KNAPSACK_PRO_LOG_LEVEL` case insensitive.
|
9
|
+
* Move all messages related to requests to Knapsack Pro API in log `debug` level and keep `info` level only for important messages like how to retry tests in development or info why something works this way or the other (for instance why tests were not executed on the CI node).
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/29
|
12
|
+
|
13
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.30.0...v0.31.0
|
14
|
+
|
5
15
|
### 0.30.0
|
6
16
|
|
7
17
|
* Update license to MIT.
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test sui
|
|
45
45
|
|
46
46
|
# Requirements
|
47
47
|
|
48
|
-
|
48
|
+
`>= Ruby 2.0.0`
|
49
49
|
|
50
50
|
# Table of Contents
|
51
51
|
|
@@ -119,6 +119,10 @@ The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test sui
|
|
119
119
|
- [How many API keys I need?](#how-many-api-keys-i-need)
|
120
120
|
- [What is optimal order of test commands?](#what-is-optimal-order-of-test-commands)
|
121
121
|
- [Why my tests are executed twice in queue mode? Why CI node runs whole test suite again?](#why-my-tests-are-executed-twice-in-queue-mode-why-ci-node-runs-whole-test-suite-again)
|
122
|
+
- [How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?](#how-to-set-beforesuite-and-aftersuite-rspec-hooks-in-queue-mode-percyio-example)
|
123
|
+
- [How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?](#how-to-call-beforesuite-and-aftersuite-rspec-hooks-only-once-in-queue-mode)
|
124
|
+
- [How to fix capybara-screenshot fail with `SystemStackError: stack level too deep` when using Queue Mode for RSpec?](#how-to-fix-capybara-screenshot-fail-with-systemstackerror-stack-level-too-deep-when-using-queue-mode-for-rspec)
|
125
|
+
- [How to run knapsack_pro with parallel_tests gem?](#how-to-run-knapsack_pro-with-parallel_tests-gem)
|
122
126
|
- [Gem tests](#gem-tests)
|
123
127
|
- [Spec](#spec)
|
124
128
|
- [Contributing](#contributing)
|
@@ -255,9 +259,11 @@ You can change default Knapsack Pro configuration for RSpec, Cucumber, Minitest
|
|
255
259
|
# you can use your own logger
|
256
260
|
require 'logger'
|
257
261
|
KnapsackPro.logger = Logger.new(STDOUT)
|
258
|
-
KnapsackPro.logger.level = Logger::
|
262
|
+
KnapsackPro.logger.level = Logger::DEBUG
|
259
263
|
```
|
260
264
|
|
265
|
+
Debug is default log level and it is recommended as default. [Read more](#how-can-i-change-log-level).
|
266
|
+
|
261
267
|
### Setup your CI server (How to set up 2 of 3)
|
262
268
|
|
263
269
|
#### Set API key token
|
@@ -349,12 +355,7 @@ If above command fails then you may need to explicitly pass an argument to requi
|
|
349
355
|
Note if you will run queue mode command for the first time it might be slower.
|
350
356
|
The second build should have better optimal test suite split.
|
351
357
|
|
352
|
-
If you
|
353
|
-
|
354
|
-
unless ENV['KNAPSACK_PRO_RSPEC_DEPENDENCIES_LOADED']
|
355
|
-
ENV['KNAPSACK_PRO_RSPEC_DEPENDENCIES_LOADED'] = 'true'
|
356
|
-
require 'capybara-screenshot/rspec'
|
357
|
-
end
|
358
|
+
If you use capybara-screenshot gem then please [follow this step](#how-to-fix-capybara-screenshot-fail-with-systemstackerror-stack-level-too-deep-when-using-queue-mode-for-rspec).
|
358
359
|
|
359
360
|
### Additional info about queue mode
|
360
361
|
|
@@ -549,6 +550,8 @@ If you are using circleci.com you can omit `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNA
|
|
549
550
|
Here is an example for test configuration in your `circleci.yml` file.
|
550
551
|
|
551
552
|
```yaml
|
553
|
+
# CircleCI 1.0
|
554
|
+
|
552
555
|
machine:
|
553
556
|
environment:
|
554
557
|
# Tokens should be set in CircleCI settings to avoid expose tokens in build logs
|
@@ -575,6 +578,20 @@ test:
|
|
575
578
|
parallel: true # Caution: there are 8 spaces indentation!
|
576
579
|
```
|
577
580
|
|
581
|
+
Here is another example for CircleCI 2.0 platform.
|
582
|
+
|
583
|
+
```YAML
|
584
|
+
# CircleCI 2.0
|
585
|
+
|
586
|
+
# some tests that are not balanced and executed only on first CI node
|
587
|
+
- run: case $CIRCLE_NODE_INDEX in 0) npm test ;; esac
|
588
|
+
|
589
|
+
# auto-balancing CI build time execution to be flat and optimal (as fast as possible).
|
590
|
+
# Queue Mode does dynamic tests allocation so the previous not balanced run command won't
|
591
|
+
# create a bottleneck on the CI node
|
592
|
+
- run: bundle exec rake knapsack_pro:queue:rspec
|
593
|
+
```
|
594
|
+
|
578
595
|
Please remember to add additional containers for your project in CircleCI settings.
|
579
596
|
|
580
597
|
#### Info for Travis users
|
@@ -662,6 +679,11 @@ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKI
|
|
662
679
|
|
663
680
|
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
|
664
681
|
|
682
|
+
Here you can find article [how to set up a new pipeline for your project in Buildkite and configure Knapsack Pro](http://docs.knapsackpro.com/2017/auto-balancing-7-hours-tests-between-100-parallel-jobs-on-ci-buildkite-example) and 2 example repositories for Ruby/Rails projects:
|
683
|
+
|
684
|
+
* [Buildkite Rails Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-parallel-example-with-knapsack_pro)
|
685
|
+
* [Buildkite Rails Docker Parallel Example with Knapsack Pro](https://github.com/KnapsackPro/buildkite-rails-docker-parallel-example-with-knapsack_pro)
|
686
|
+
|
665
687
|
#### Info for snap-ci.com users
|
666
688
|
|
667
689
|
Knapsack Pro supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`. The only thing you need to do is to configure number of workers for your project in configuration settings in order to enable parallelism. Next thing is to set below commands to be executed in your stage:
|
@@ -832,9 +854,14 @@ knapack_pro gem will retry requests to Knapsack Pro API multiple times every few
|
|
832
854
|
|
833
855
|
You can change log level by specifying the `KNAPSACK_PRO_LOG_LEVEL` environment variable.
|
834
856
|
|
835
|
-
KNAPSACK_PRO_LOG_LEVEL=
|
857
|
+
KNAPSACK_PRO_LOG_LEVEL=info bundle exec rake knapsack_pro:rspec
|
858
|
+
|
859
|
+
Available values are `debug` (default), `info`, `warn`, `error` and `fatal`.
|
860
|
+
|
861
|
+
Recommended log levels you can use:
|
836
862
|
|
837
|
-
|
863
|
+
* `debug` is default log level and it is recommended to log details about requests to Knapsack Pro API. Thanks to that you can debug things or ensure everything works. For instance in [user dashboard](https://knapsackpro.com/dashboard) you can find tips referring to debug logs.
|
864
|
+
* `info` level shows message like how to retry tests in development or info why something works this way or the other (for instance why tests were not executed on the CI node). You can use `info` level when you really don't want to see all debug messages from default log level.
|
838
865
|
|
839
866
|
### How to split tests based on test level instead of test file level?
|
840
867
|
|
@@ -995,6 +1022,8 @@ Note:
|
|
995
1022
|
|
996
1023
|
### What is optimal order of test commands?
|
997
1024
|
|
1025
|
+
__Tip 1:__
|
1026
|
+
|
998
1027
|
I recommend to run first the test commands in the regular mode and later the commands in the queue mode.
|
999
1028
|
|
1000
1029
|
* Step 1. `bundle exec rake knapsack_pro:cucumber` (regular mode)
|
@@ -1002,12 +1031,158 @@ I recommend to run first the test commands in the regular mode and later the com
|
|
1002
1031
|
|
1003
1032
|
Thanks to that when for some reason the tests executed for cucumber in regular mode will not be well balanced across CI nodes (for instance when one of CI node has bad performance) then the rspec tests executed later in the queue mode will autobalance your build.
|
1004
1033
|
|
1034
|
+
__Tip 2:__
|
1035
|
+
|
1036
|
+
When you have short test suite, for instance in javascript then you could distribute tests this way:
|
1037
|
+
|
1038
|
+
* CI 0
|
1039
|
+
* Step 1: `npm test`
|
1040
|
+
* Step 2: `bundle exec rake knapsack_pro:queue:rspec`
|
1041
|
+
|
1042
|
+
* CI 1
|
1043
|
+
* Step 1: `bundle exec rake knapsack_pro:queue:rspec`
|
1044
|
+
|
1045
|
+
You will run your javascript tests on single CI node and the knapack_pro will auto-balance CI build with Queue Mode. Thanks to that CI build time execution will be flat and optimal (as fast as possible).
|
1046
|
+
|
1005
1047
|
### Why my tests are executed twice in queue mode? Why CI node runs whole test suite again?
|
1006
1048
|
|
1007
1049
|
This may happen when one of your CI node started work later when all other CI nodes already executed whole test suite.
|
1008
1050
|
The slow CI node will initialize a new queue hence the tests executed twice. To solve this problem you should set `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`.
|
1009
1051
|
Please [read this](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node).
|
1010
1052
|
|
1053
|
+
### How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?
|
1054
|
+
|
1055
|
+
Some tools like [Percy.io](https://percy.io/docs/clients/ruby/capybara-rails) requires to set hooks for RSpec `before(:suite)` and `after(:suite)`.
|
1056
|
+
Knapsack Pro Queue Mode runs subset of test files from the work queue many times. This means the RSpec hooks `before(:suite)` and `after(:suite)` will execute multiple times. If you want to run some code only once before Queue Mode starts work and after it finishes then you should do it this way:
|
1057
|
+
|
1058
|
+
```ruby
|
1059
|
+
# spec_helper.rb or rails_helper.rb
|
1060
|
+
|
1061
|
+
# executes before Queue Mode starts work
|
1062
|
+
Percy::Capybara.initialize_build
|
1063
|
+
|
1064
|
+
# executes after Queue Mode finishes work
|
1065
|
+
at_exit { Percy::Capybara.finalize_build }
|
1066
|
+
```
|
1067
|
+
|
1068
|
+
### How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?
|
1069
|
+
|
1070
|
+
Knapsack Pro Queue Mode runs subset of test files from the work queue many times. This means the RSpec hooks `before(:suite)` and `after(:suite)` will be executed multiple times. If you want to run some code only once before Queue Mode starts work and after it finishes then you should do it this way:
|
1071
|
+
|
1072
|
+
```ruby
|
1073
|
+
# spec_helper.rb or rails_helper.rb
|
1074
|
+
|
1075
|
+
RSpec.configure do |config|
|
1076
|
+
config.before(:suite) do
|
1077
|
+
unless ENV['KNAPSACK_PRO_RSPEC_BEFORE_SUITE_LOADED']
|
1078
|
+
ENV['KNAPSACK_PRO_RSPEC_BEFORE_SUITE_LOADED'] = 'true'
|
1079
|
+
|
1080
|
+
# this will be called only once before the tests started on the CI node
|
1081
|
+
end
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
at_exit do
|
1085
|
+
# this will be called only once at the end when the CI node finished tests
|
1086
|
+
end
|
1087
|
+
end
|
1088
|
+
```
|
1089
|
+
|
1090
|
+
### How to fix capybara-screenshot fail with `SystemStackError: stack level too deep` when using Queue Mode for RSpec?
|
1091
|
+
|
1092
|
+
Please use fixed version of capybara-screenshot.
|
1093
|
+
|
1094
|
+
```
|
1095
|
+
# Gemfile
|
1096
|
+
group :test do
|
1097
|
+
gem 'capybara-screenshot', github: 'ArturT/capybara-screenshot', branch: 'fix-reporter_module-loaded-twice'
|
1098
|
+
end
|
1099
|
+
```
|
1100
|
+
|
1101
|
+
Here is [fix PR](https://github.com/mattheworiordan/capybara-screenshot/pull/205) to official capybara-screenshot repository and the explanation of the problem.
|
1102
|
+
|
1103
|
+
### How to run knapsack_pro with parallel_tests gem?
|
1104
|
+
|
1105
|
+
You can run knapsack_pro with [parallel_tests](https://github.com/grosser/parallel_tests) gem to run multiple concurrent knapsack_pro commands per CI node.
|
1106
|
+
|
1107
|
+
Let's consider this example. We have 2 CI node. On each CI node we want to run 2 concurrent knapsack_pro commands by parallel_tests gem (`PARALLEL_TESTS_CONCURRENCY=2`).
|
1108
|
+
This means we would have 4 parallel knapack_pro commands in total across all CI nodes. So from knapsack_pro perspective you will have 4 nodes in total.
|
1109
|
+
|
1110
|
+
Create in your project directory an executable file `bin/parallel_tests`:
|
1111
|
+
|
1112
|
+
```
|
1113
|
+
#!/bin/bash
|
1114
|
+
# This file should be in bin/parallel_tests
|
1115
|
+
|
1116
|
+
# updates CI node total based on parallel_tests concurrency
|
1117
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=$(( $PARALLEL_TESTS_CONCURRENCY * $KNAPSACK_PRO_CI_NODE_TOTAL ))
|
1118
|
+
|
1119
|
+
if [ "$TEST_ENV_NUMBER" == "" ]; then
|
1120
|
+
PARALLEL_TESTS_CONCURRENCY_INDEX=0
|
1121
|
+
else
|
1122
|
+
PARALLEL_TESTS_CONCURRENCY_INDEX=$(( $TEST_ENV_NUMBER - 1 ))
|
1123
|
+
fi
|
1124
|
+
|
1125
|
+
KNAPSACK_PRO_CI_NODE_INDEX=$(( $PARALLEL_TESTS_CONCURRENCY_INDEX + ($PARALLEL_TESTS_CONCURRENCY * $KNAPSACK_PRO_CI_NODE_INDEX) ))
|
1126
|
+
|
1127
|
+
# logs info about ENVs to ensure everything works
|
1128
|
+
echo KNAPSACK_PRO_CI_NODE_TOTAL=$KNAPSACK_PRO_CI_NODE_TOTAL KNAPSACK_PRO_CI_NODE_INDEX=$KNAPSACK_PRO_CI_NODE_INDEX PARALLEL_TESTS_CONCURRENCY=$PARALLEL_TESTS_CONCURRENCY
|
1129
|
+
|
1130
|
+
# you can customize your knapsack_pro command here to use regular or queue mode
|
1131
|
+
bundle exec rake knapsack_pro:queue:rspec
|
1132
|
+
```
|
1133
|
+
|
1134
|
+
Now you need to set parallel_tests command per CI node:
|
1135
|
+
|
1136
|
+
* CI node 0 (first CI node):
|
1137
|
+
|
1138
|
+
```
|
1139
|
+
export PARALLEL_TESTS_CONCURRENCY=2; # this must be export
|
1140
|
+
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx \
|
1141
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=$YOUR_CI_NODE_TOTAL \
|
1142
|
+
KNAPSACK_PRO_CI_NODE_INDEX=$YOUR_CI_NODE_INDEX \
|
1143
|
+
bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests'
|
1144
|
+
```
|
1145
|
+
|
1146
|
+
* CI node 1 (second CI node):
|
1147
|
+
|
1148
|
+
```
|
1149
|
+
export PARALLEL_TESTS_CONCURRENCY=2; # this must be export
|
1150
|
+
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx \
|
1151
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=$YOUR_CI_NODE_TOTAL \
|
1152
|
+
KNAPSACK_PRO_CI_NODE_INDEX=$YOUR_CI_NODE_INDEX \
|
1153
|
+
bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests'
|
1154
|
+
```
|
1155
|
+
|
1156
|
+
Please note you need to update `$YOUR_CI_NODE_TOTAL` and `$YOUR_CI_NODE_INDEX` to the ENVs provided by your CI provider. For instance in case of CircleCI it would be `$CIRCLE_NODE_TOTAL` and `$CIRCLE_NODE_INDEX`. Below is an example for CircleCI configuration:
|
1157
|
+
|
1158
|
+
```
|
1159
|
+
# circle.yml for CircleCI 1.0
|
1160
|
+
# KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx can be set in CircleCI ENV settings
|
1161
|
+
test:
|
1162
|
+
override:
|
1163
|
+
- export PARALLEL_TESTS_CONCURRENCY=2; KNAPSACK_PRO_CI_NODE_TOTAL=$CIRCLE_NODE_TOTAL KNAPSACK_PRO_CI_NODE_INDEX=$CIRCLE_NODE_INDEX bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests':
|
1164
|
+
parallel: true # Caution: there are 8 spaces indentation!
|
1165
|
+
```
|
1166
|
+
|
1167
|
+
In summary, the `bin/parallel_tests` script will calculate a new values for `KNAPSAKC_PRO_*` environment variables and then run knapsack_pro command with them.
|
1168
|
+
To ensure everything works you can check output for each CI node.
|
1169
|
+
|
1170
|
+
* Expected output for CI node 0 (first CI node):
|
1171
|
+
|
1172
|
+
```
|
1173
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=4 KNAPSACK_PRO_CI_NODE_INDEX=1 PARALLEL_TESTS_CONCURRENCY=2
|
1174
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=4 KNAPSACK_PRO_CI_NODE_INDEX=0 PARALLEL_TESTS_CONCURRENCY=2
|
1175
|
+
(tests output here)
|
1176
|
+
```
|
1177
|
+
|
1178
|
+
* Expected output for CI node 1 (second CI node):
|
1179
|
+
|
1180
|
+
```
|
1181
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=4 KNAPSACK_PRO_CI_NODE_INDEX=2 PARALLEL_TESTS_CONCURRENCY=2
|
1182
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=4 KNAPSACK_PRO_CI_NODE_INDEX=3 PARALLEL_TESTS_CONCURRENCY=2
|
1183
|
+
(tests output here)
|
1184
|
+
```
|
1185
|
+
|
1011
1186
|
## Gem tests
|
1012
1187
|
|
1013
1188
|
### Spec
|
data/lib/knapsack_pro.rb
CHANGED
@@ -12,13 +12,13 @@ module KnapsackPro
|
|
12
12
|
|
13
13
|
def bind
|
14
14
|
if KnapsackPro::Config::Env.recording_enabled?
|
15
|
-
KnapsackPro.logger.
|
15
|
+
KnapsackPro.logger.debug('Test suite time execution recording enabled.')
|
16
16
|
bind_time_tracker
|
17
17
|
bind_save_report
|
18
18
|
end
|
19
19
|
|
20
20
|
if KnapsackPro::Config::Env.queue_recording_enabled?
|
21
|
-
KnapsackPro.logger.
|
21
|
+
KnapsackPro.logger.debug('Test suite time execution queue recording enabled.')
|
22
22
|
bind_time_tracker
|
23
23
|
bind_save_queue_report
|
24
24
|
end
|
@@ -90,13 +90,13 @@ module KnapsackPro
|
|
90
90
|
|
91
91
|
request_uuid = http_response.header['X-Request-Id']
|
92
92
|
|
93
|
-
logger.
|
94
|
-
logger.
|
95
|
-
logger.
|
93
|
+
logger.debug("API request UUID: #{request_uuid}")
|
94
|
+
logger.debug("Test suite split seed: #{seed}") if has_seed?
|
95
|
+
logger.debug('API response:')
|
96
96
|
if errors?
|
97
97
|
logger.error(response)
|
98
98
|
else
|
99
|
-
logger.
|
99
|
+
logger.debug(response)
|
100
100
|
end
|
101
101
|
|
102
102
|
response
|
@@ -148,10 +148,12 @@ module KnapsackPro
|
|
148
148
|
|
149
149
|
def log_level
|
150
150
|
{
|
151
|
-
'
|
152
|
-
'
|
151
|
+
'fatal' => ::Logger::FATAL,
|
152
|
+
'error' => ::Logger::ERROR,
|
153
153
|
'warn' => ::Logger::WARN,
|
154
|
-
|
154
|
+
'info' => ::Logger::INFO,
|
155
|
+
'debug' => ::Logger::DEBUG,
|
156
|
+
}[ENV['KNAPSACK_PRO_LOG_LEVEL'].to_s.downcase] || ::Logger::DEBUG
|
155
157
|
end
|
156
158
|
|
157
159
|
private
|
data/lib/knapsack_pro/report.rb
CHANGED
@@ -56,7 +56,7 @@ module KnapsackPro
|
|
56
56
|
response = connection.call
|
57
57
|
if connection.success?
|
58
58
|
raise ArgumentError.new(response) if connection.errors?
|
59
|
-
KnapsackPro.logger.
|
59
|
+
KnapsackPro.logger.debug('Saved time execution report on API server.')
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -38,7 +38,7 @@ describe KnapsackPro::Adapters::BaseAdapter do
|
|
38
38
|
it do
|
39
39
|
logger = instance_double(Logger)
|
40
40
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
41
|
-
expect(logger).to receive(:
|
41
|
+
expect(logger).to receive(:debug).with('Test suite time execution recording enabled.')
|
42
42
|
end
|
43
43
|
it { expect(subject).to receive(:bind_time_tracker) }
|
44
44
|
it { expect(subject).to receive(:bind_save_report) }
|
@@ -55,7 +55,7 @@ describe KnapsackPro::Adapters::BaseAdapter do
|
|
55
55
|
it do
|
56
56
|
logger = instance_double(Logger)
|
57
57
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
58
|
-
expect(logger).to receive(:
|
58
|
+
expect(logger).to receive(:debug).with('Test suite time execution queue recording enabled.')
|
59
59
|
end
|
60
60
|
it { expect(subject).to receive(:bind_time_tracker) }
|
61
61
|
it { expect(subject).to receive(:bind_save_queue_report) }
|
@@ -91,7 +91,7 @@ describe KnapsackPro::Adapters::CucumberAdapter do
|
|
91
91
|
expect(::Kernel).to receive(:at_exit).and_yield
|
92
92
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
93
93
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
94
|
-
expect(logger).to receive(:
|
94
|
+
expect(logger).to receive(:debug).with(global_time)
|
95
95
|
|
96
96
|
subject.bind_time_tracker
|
97
97
|
end
|
@@ -114,7 +114,7 @@ describe KnapsackPro::Adapters::CucumberAdapter do
|
|
114
114
|
expect(::Kernel).to receive(:at_exit).and_yield
|
115
115
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
116
116
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
117
|
-
expect(logger).to receive(:
|
117
|
+
expect(logger).to receive(:debug).with(global_time)
|
118
118
|
|
119
119
|
subject.bind_time_tracker
|
120
120
|
end
|
@@ -95,7 +95,7 @@ describe KnapsackPro::Adapters::MinitestAdapter do
|
|
95
95
|
|
96
96
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
97
97
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
98
|
-
expect(logger).to receive(:
|
98
|
+
expect(logger).to receive(:debug).with(global_time)
|
99
99
|
|
100
100
|
subject.bind_time_tracker
|
101
101
|
end
|
@@ -96,7 +96,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
96
96
|
|
97
97
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
98
98
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
99
|
-
expect(logger).to receive(:
|
99
|
+
expect(logger).to receive(:debug).with(global_time)
|
100
100
|
|
101
101
|
subject.bind_time_tracker
|
102
102
|
end
|
@@ -42,7 +42,7 @@ describe KnapsackPro::Adapters::SpinachAdapter do
|
|
42
42
|
expect(Spinach.hooks).to receive(:after_run).and_yield
|
43
43
|
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
44
44
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
45
|
-
expect(logger).to receive(:
|
45
|
+
expect(logger).to receive(:debug).with(global_time)
|
46
46
|
|
47
47
|
subject.bind_time_tracker
|
48
48
|
end
|
@@ -52,8 +52,8 @@ describe KnapsackPro::Client::Connection do
|
|
52
52
|
|
53
53
|
before do
|
54
54
|
expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
|
55
|
-
expect(logger).to receive(:
|
56
|
-
expect(logger).to receive(:
|
55
|
+
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
56
|
+
expect(logger).to receive(:debug).with('API response:')
|
57
57
|
end
|
58
58
|
|
59
59
|
it do
|
@@ -72,15 +72,15 @@ describe KnapsackPro::Client::Connection do
|
|
72
72
|
|
73
73
|
before do
|
74
74
|
expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
|
75
|
-
expect(logger).to receive(:
|
76
|
-
expect(logger).to receive(:
|
77
|
-
expect(logger).to receive(:
|
75
|
+
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
76
|
+
expect(logger).to receive(:debug).with("Test suite split seed: seed-uuid")
|
77
|
+
expect(logger).to receive(:debug).with('API response:')
|
78
78
|
end
|
79
79
|
|
80
80
|
it do
|
81
81
|
parsed_response = { 'build_distribution_id' => 'seed-uuid' }
|
82
82
|
|
83
|
-
expect(logger).to receive(:
|
83
|
+
expect(logger).to receive(:debug).with(parsed_response)
|
84
84
|
|
85
85
|
expect(subject).to eq(parsed_response)
|
86
86
|
expect(connection.success?).to be true
|
@@ -93,12 +93,12 @@ describe KnapsackPro::Client::Connection do
|
|
93
93
|
|
94
94
|
before do
|
95
95
|
expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
|
96
|
-
expect(logger).to receive(:
|
97
|
-
expect(logger).to receive(:
|
96
|
+
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
97
|
+
expect(logger).to receive(:debug).with('API response:')
|
98
98
|
end
|
99
99
|
|
100
100
|
it do
|
101
|
-
expect(logger).to receive(:
|
101
|
+
expect(logger).to receive(:debug).with('')
|
102
102
|
|
103
103
|
expect(subject).to eq('')
|
104
104
|
expect(connection.success?).to be true
|
@@ -551,14 +551,38 @@ describe KnapsackPro::Config::Env do
|
|
551
551
|
describe '.log_level' do
|
552
552
|
subject { described_class.log_level }
|
553
553
|
|
554
|
-
context 'when ENV
|
555
|
-
let(:log_level) { '
|
554
|
+
context 'when ENV set to fatal' do
|
555
|
+
let(:log_level) { 'fatal' }
|
556
556
|
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
557
|
-
it { should eql ::Logger::
|
557
|
+
it { should eql ::Logger::FATAL }
|
558
558
|
end
|
559
559
|
|
560
|
-
context
|
560
|
+
context 'when ENV set to error' do
|
561
|
+
let(:log_level) { 'error' }
|
562
|
+
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
563
|
+
it { should eql ::Logger::ERROR }
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'when ENV set to warn' do
|
567
|
+
let(:log_level) { 'warn' }
|
568
|
+
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
569
|
+
it { should eql ::Logger::WARN }
|
570
|
+
end
|
571
|
+
|
572
|
+
context 'when ENV set to info' do
|
573
|
+
let(:log_level) { 'info' }
|
574
|
+
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
561
575
|
it { should eql ::Logger::INFO }
|
562
576
|
end
|
577
|
+
|
578
|
+
context 'when ENV set with capital letters' do
|
579
|
+
let(:log_level) { 'WARN' }
|
580
|
+
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
581
|
+
it { should eql ::Logger::WARN }
|
582
|
+
end
|
583
|
+
|
584
|
+
context "when ENV doesn't exist" do
|
585
|
+
it { should eql ::Logger::DEBUG }
|
586
|
+
end
|
563
587
|
end
|
564
588
|
end
|
@@ -130,7 +130,7 @@ describe KnapsackPro::Report do
|
|
130
130
|
it do
|
131
131
|
logger = instance_double(Logger)
|
132
132
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
133
|
-
expect(logger).to receive(:
|
133
|
+
expect(logger).to receive(:debug).with('Saved time execution report on API server.')
|
134
134
|
subject
|
135
135
|
end
|
136
136
|
end
|
data/spec/knapsack_pro_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe KnapsackPro do
|
|
18
18
|
|
19
19
|
before do
|
20
20
|
expect(Logger).to receive(:new).with(STDOUT).and_return(logger)
|
21
|
-
expect(logger).to receive(:level=).with(Logger::
|
21
|
+
expect(logger).to receive(:level=).with(Logger::DEBUG)
|
22
22
|
expect(KnapsackPro::LoggerWrapper).to receive(:new).with(logger).and_return(logger_wrapper)
|
23
23
|
end
|
24
24
|
|
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.31.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-
|
11
|
+
date: 2017-04-08 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.6.
|
366
|
+
rubygems_version: 2.6.11
|
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
|