knapsack_pro 1.22.0 → 2.1.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 +46 -0
- data/README.md +33 -6
- data/lib/knapsack_pro/base_allocator_builder.rb +6 -1
- data/lib/knapsack_pro/client/connection.rb +5 -1
- data/lib/knapsack_pro/config/ci/github_actions.rb +3 -2
- data/lib/knapsack_pro/config/env.rb +4 -0
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +1 -1
- data/lib/knapsack_pro/slow_test_file_determiner.rb +9 -4
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +9 -6
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/client/connection_spec.rb +40 -7
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +8 -1
- data/spec/knapsack_pro/config/env_spec.rb +14 -0
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +25 -0
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +1 -1
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fccaa38fe31152f32d7cdd09f7b42eb7e487c7e1c277fb498dc36b13a3356bc4
|
4
|
+
data.tar.gz: 8611e4cf6c14f3eb86c7b45a2c90df7e33c3500b6f30e86fd1ba596635585479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd0174542079eab755f963314a17fe804cedce37366074fabc0e169547af7a89f27516f2c48e2052c21b2aa86d24703d17d19d40b8ac29eaacab51f030d51de6
|
7
|
+
data.tar.gz: 21010bce7d72dc251d85b8d4d04949ceb8f2931eab99be18df2cbafa1479ff062f0e159b599b8b8bde9ef78f71400d2ce0b1724647509ded42018b952a0511ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,51 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 2.1.0
|
4
|
+
|
5
|
+
* Add `KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX` to customize prefix for generating test examples report when using RSpec split by test examples
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/118
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.0.0...v2.1.0
|
10
|
+
|
11
|
+
### 2.0.0
|
12
|
+
|
13
|
+
* Add support for CI build ID for Github Actions
|
14
|
+
|
15
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/116
|
16
|
+
|
17
|
+
__Migration path for Github Actions users - required__
|
18
|
+
|
19
|
+
If you use Github Actions and Knapsack Pro Queue Mode then you must set in Github Actions environment variable: `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`. Thanks to that when you retry CI build then tests will run based on previously recorded tests. This solves problem mentioned in the [PR](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/116).
|
20
|
+
|
21
|
+
__Migration path for other users__ - just update `knapsack_pro` gem. Nothing to change in your code :)
|
22
|
+
|
23
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.22.3...v2.0.0
|
24
|
+
|
25
|
+
### 1.22.3
|
26
|
+
|
27
|
+
* Support for non-delimited formatting params of RSpec like `-fMyCustomFormatter`
|
28
|
+
|
29
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/115
|
30
|
+
|
31
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.22.2...v1.22.3
|
32
|
+
|
33
|
+
### 1.22.2
|
34
|
+
|
35
|
+
* Log when next retry request to Knapsack Pro API happens before starting Fallback Mode
|
36
|
+
|
37
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/114
|
38
|
+
|
39
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.22.1...v1.22.2
|
40
|
+
|
41
|
+
### 1.22.1
|
42
|
+
|
43
|
+
* Fix for an auto split of slow RSpec test files by test examples when using `KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true` and `parallel_tests` gem. Save the JSON reports with unique file names with the CI node index in the name to avoid accidentally overriding the files on the same disk.
|
44
|
+
|
45
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/113
|
46
|
+
|
47
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.22.0...v1.22.1
|
48
|
+
|
3
49
|
### 1.22.0
|
4
50
|
|
5
51
|
* Increase request retry timebox from 4s to 8s to not flood Knapsack Pro API with too many requests in a short period of time and to give time for API server to autoscale and add additional machines to serve traffic
|
data/README.md
CHANGED
@@ -84,6 +84,7 @@ We keep this old FAQ in README to not break old links spread across the web. You
|
|
84
84
|
- [Supported test runners in queue mode](#supported-test-runners-in-queue-mode)
|
85
85
|
- [Split test files by test cases](#split-test-files-by-test-cases)
|
86
86
|
- [RSpec split test files by test examples (by individual `it`s)](#rspec-split-test-files-by-test-examples-by-individual-its)
|
87
|
+
- [Why I see error: Don't know how to build task 'knapsack_pro:rspec_test_example_detector'?](#why-i-see-error-dont-know-how-to-build-task-knapsack_prorspec_test_example_detector)
|
87
88
|
- [How to manually define a list of slow test files to be split by test cases](#how-to-manually-define-a-list-of-slow-test-files-to-be-split-by-test-cases)
|
88
89
|
- [Extra configuration for CI server](#extra-configuration-for-ci-server)
|
89
90
|
- [Info about ENV variables](#info-about-env-variables)
|
@@ -618,6 +619,16 @@ KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
|
|
618
619
|
|
619
620
|
Thanks to that your CI build speed can be faster. We recommend using this feature with [Queue Mode](https://youtu.be/hUEB1XDKEFY) to ensure parallel CI nodes finish work at a similar time which gives you the shortest CI build time.
|
620
621
|
|
622
|
+
#### Why I see error: Don't know how to build task 'knapsack_pro:rspec_test_example_detector'?
|
623
|
+
|
624
|
+
If you will see error like:
|
625
|
+
|
626
|
+
```
|
627
|
+
Don't know how to build task 'knapsack_pro:rspec_test_example_detector' (See the list of available tasks with `rake --tasks`)
|
628
|
+
```
|
629
|
+
|
630
|
+
It probably means bundler can't find the rake task. You can try remove default prefix `bundle exec` used by knapsack_pro gem by setting `KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX=""`.
|
631
|
+
|
621
632
|
### How to manually define a list of slow test files to be split by test cases
|
622
633
|
|
623
634
|
If you don't want to rely on a list of test files from Knapsack Pro API to determine slow test files that should be split by test cases then you can define your own list of slow test files.
|
@@ -711,7 +722,7 @@ Read below required configuration step if you use Queue Mode and you set [`KNAPS
|
|
711
722
|
|
712
723
|
If you use other CI server you need to manually configure your CI server to set `KNAPSACK_PRO_CI_NODE_RETRY_COUNT=1` only during retry CI node attempt. If `KNAPSACK_PRO_CI_NODE_RETRY_COUNT > 0` then knapsack_pro won't allow starting running tests in Fallback Mode and instead will raise error so a user can manually retry CI node later when a connection to Knapsack Pro API can be established.
|
713
724
|
|
714
|
-
If you cannot set `KNAPSACK_PRO_CI_NODE_RETRY_COUNT` only for retried CI node or it is not possible for your CI server then you can disable Fallback Mode completely `KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false`.
|
725
|
+
If you cannot set `KNAPSACK_PRO_CI_NODE_RETRY_COUNT` only for retried CI node or it is not possible for your CI server then you can disable Fallback Mode completely `KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false`. When Fallback Mode is disabled then knapsack_pro gem will try to connect to Knapsack Pro API 6 times instead of only 3 times to ensure there is a low chance of failing your CI node due to lost connection with the API.
|
715
726
|
|
716
727
|
### Passing arguments to rake task
|
717
728
|
|
@@ -991,19 +1002,28 @@ You can parallelize your builds across virtual machines with [travis matrix feat
|
|
991
1002
|
|
992
1003
|
```yaml
|
993
1004
|
script:
|
994
|
-
# Step for RSpec
|
1005
|
+
# Step for RSpec in Regular Mode
|
995
1006
|
- "bundle exec rake knapsack_pro:rspec"
|
996
1007
|
|
997
|
-
# Step for
|
1008
|
+
# Step for RSpec in Queue Mode
|
1009
|
+
- "bundle exec rake knapsack_pro:queue:rspec"
|
1010
|
+
|
1011
|
+
# Step for Cucumber in Regular Mode
|
998
1012
|
- "bundle exec rake knapsack_pro:cucumber"
|
999
1013
|
|
1000
|
-
# Step for
|
1014
|
+
# Step for Cucumber in Queue Mode
|
1015
|
+
- "bundle exec rake knapsack_pro:queue:cucumber"
|
1016
|
+
|
1017
|
+
# Step for Minitest in Regular Mode
|
1001
1018
|
- "bundle exec rake knapsack_pro:minitest"
|
1002
1019
|
|
1003
|
-
# Step for
|
1020
|
+
# Step for Minitest in Queue Mode
|
1021
|
+
- "bundle exec rake knapsack_pro:queue:minitest"
|
1022
|
+
|
1023
|
+
# Step for test-unit in Regular Mode
|
1004
1024
|
- "bundle exec rake knapsack_pro:test_unit"
|
1005
1025
|
|
1006
|
-
# Step for Spinach
|
1026
|
+
# Step for Spinach in Regular Mode
|
1007
1027
|
- "bundle exec rake knapsack_pro:spinach"
|
1008
1028
|
|
1009
1029
|
env:
|
@@ -1015,6 +1035,10 @@ env:
|
|
1015
1035
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token
|
1016
1036
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
|
1017
1037
|
|
1038
|
+
# if you use Knapsack Pro Queue Mode you must set below env variable
|
1039
|
+
# to be able to retry single failed parallel job from Travis UI
|
1040
|
+
- KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true
|
1041
|
+
|
1018
1042
|
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
1019
1043
|
jobs:
|
1020
1044
|
- KNAPSACK_PRO_CI_NODE_INDEX=0
|
@@ -1626,6 +1650,9 @@ jobs:
|
|
1626
1650
|
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
|
1627
1651
|
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
|
1628
1652
|
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
|
1653
|
+
# if you use Knapsack Pro Queue Mode you must set below env variable
|
1654
|
+
# to be able to retry CI build and run previously recorded tests
|
1655
|
+
KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true
|
1629
1656
|
run: |
|
1630
1657
|
# run tests in Knapsack Pro Regular Mode
|
1631
1658
|
bundle exec rake knapsack_pro:rspec
|
@@ -43,7 +43,12 @@ module KnapsackPro
|
|
43
43
|
KnapsackPro.logger.info("Generating RSpec test examples JSON report for slow test files to prepare it to be split by test examples (by individual 'it's. Thanks to that a single slow test file can be split across parallel CI nodes). Analyzing #{slow_test_files.size} slow test files.")
|
44
44
|
|
45
45
|
# generate RSpec JSON report in separate process to not pollute RSpec state
|
46
|
-
cmd =
|
46
|
+
cmd = [
|
47
|
+
'RACK_ENV=test',
|
48
|
+
'RAILS_ENV=test',
|
49
|
+
KnapsackPro::Config::Env.rspec_test_example_detector_prefix,
|
50
|
+
'rake knapsack_pro:rspec_test_example_detector',
|
51
|
+
].join(' ')
|
47
52
|
unless Kernel.system(cmd)
|
48
53
|
raise "Could not generate JSON report for RSpec. Rake task failed when running #{cmd}"
|
49
54
|
end
|
@@ -121,7 +121,11 @@ module KnapsackPro
|
|
121
121
|
if retries < MAX_RETRY.call
|
122
122
|
wait = retries * REQUEST_RETRY_TIMEBOX
|
123
123
|
logger.warn("Wait #{wait}s and retry request to Knapsack Pro API.")
|
124
|
-
|
124
|
+
print_every = 2 # seconds
|
125
|
+
(wait / print_every).ceil.times do |i|
|
126
|
+
logger.warn("Next request in #{wait - i * print_every}s...")
|
127
|
+
Kernel.sleep(print_every)
|
128
|
+
end
|
125
129
|
retry
|
126
130
|
else
|
127
131
|
response_body
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# https://help.github.com/en/
|
1
|
+
# https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
2
2
|
module KnapsackPro
|
3
3
|
module Config
|
4
4
|
module CI
|
@@ -12,7 +12,8 @@ module KnapsackPro
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def node_build_id
|
15
|
-
# not
|
15
|
+
# A unique number for each run within a repository. This number does not change if you re-run the workflow run.
|
16
|
+
ENV['GITHUB_RUN_ID']
|
16
17
|
end
|
17
18
|
|
18
19
|
def commit_hash
|
@@ -179,6 +179,10 @@ module KnapsackPro
|
|
179
179
|
rspec_split_by_test_examples.to_s == 'true'
|
180
180
|
end
|
181
181
|
|
182
|
+
def rspec_test_example_detector_prefix
|
183
|
+
ENV.fetch('KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX', 'bundle exec')
|
184
|
+
end
|
185
|
+
|
182
186
|
def test_suite_token
|
183
187
|
env_name = 'KNAPSACK_PRO_TEST_SUITE_TOKEN'
|
184
188
|
ENV[env_name] || raise("Missing environment variable #{env_name}. You should set environment variable like #{env_name}_RSPEC (note there is suffix _RSPEC at the end). knapsack_pro gem will set #{env_name} based on #{env_name}_RSPEC value. If you use other test runner than RSpec then use proper suffix.")
|
@@ -16,7 +16,7 @@ module KnapsackPro
|
|
16
16
|
cli_args = (args || '').split
|
17
17
|
# if user didn't provide the format then use explicitly default progress formatter
|
18
18
|
# in order to avoid KnapsackPro::Formatters::RSpecQueueSummaryFormatter being the only default formatter
|
19
|
-
if !cli_args.
|
19
|
+
if !cli_args.any? { |arg| arg.start_with?('-f') || arg.start_with?('--format')}
|
20
20
|
cli_args += ['--format', 'progress']
|
21
21
|
end
|
22
22
|
cli_args += [
|
@@ -2,7 +2,6 @@ module KnapsackPro
|
|
2
2
|
class SlowTestFileDeterminer
|
3
3
|
TIME_THRESHOLD_PER_CI_NODE = 0.7 # 70%
|
4
4
|
REPORT_DIR = 'tmp/knapsack_pro/slow_test_file_determiner'
|
5
|
-
REPORT_PATH = "#{REPORT_DIR}/slow_test_files.json"
|
6
5
|
|
7
6
|
# test_files: { 'path' => 'a_spec.rb', 'time_execution' => 0.0 }
|
8
7
|
# time_execution: of build distribution (total time of CI build run)
|
@@ -16,13 +15,19 @@ module KnapsackPro
|
|
16
15
|
|
17
16
|
def self.save_to_json_report(test_files)
|
18
17
|
FileUtils.mkdir_p(REPORT_DIR)
|
19
|
-
File.write(
|
18
|
+
File.write(report_path, test_files.to_json)
|
20
19
|
end
|
21
20
|
|
22
21
|
def self.read_from_json_report
|
23
|
-
raise 'Report with slow test files was not generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up tmp/knapsack_pro directory. Please do not remove this directory during tests runtime!' unless File.exists?(
|
24
|
-
slow_test_files_json_report = File.read(
|
22
|
+
raise 'Report with slow test files was not generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up tmp/knapsack_pro directory. Please do not remove this directory during tests runtime!' unless File.exists?(report_path)
|
23
|
+
slow_test_files_json_report = File.read(report_path)
|
25
24
|
JSON.parse(slow_test_files_json_report)
|
26
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.report_path
|
30
|
+
"#{REPORT_DIR}/slow_test_files_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
@@ -2,7 +2,6 @@ module KnapsackPro
|
|
2
2
|
module TestCaseDetectors
|
3
3
|
class RSpecTestExampleDetector
|
4
4
|
REPORT_DIR = 'tmp/knapsack_pro/test_case_detectors/rspec'
|
5
|
-
REPORT_PATH = "#{REPORT_DIR}/rspec_dry_run_json_report.json"
|
6
5
|
|
7
6
|
def generate_json_report
|
8
7
|
require 'rspec/core'
|
@@ -22,13 +21,13 @@ module KnapsackPro
|
|
22
21
|
|
23
22
|
if test_file_entities.empty?
|
24
23
|
no_examples_json = { examples: [] }.to_json
|
25
|
-
File.write(
|
24
|
+
File.write(report_path, no_examples_json)
|
26
25
|
return
|
27
26
|
end
|
28
27
|
|
29
28
|
cli_args = cli_format + [
|
30
29
|
'--dry-run',
|
31
|
-
'--out',
|
30
|
+
'--out', report_path,
|
32
31
|
'--default-path', test_dir,
|
33
32
|
] + KnapsackPro::TestFilePresenter.paths(test_file_entities)
|
34
33
|
options = RSpec::Core::ConfigurationOptions.new(cli_args)
|
@@ -39,9 +38,9 @@ module KnapsackPro
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def test_file_example_paths
|
42
|
-
raise "No report found at #{
|
41
|
+
raise "No report found at #{report_path}" unless File.exists?(report_path)
|
43
42
|
|
44
|
-
json_report = File.read(
|
43
|
+
json_report = File.read(report_path)
|
45
44
|
hash_report = JSON.parse(json_report)
|
46
45
|
hash_report
|
47
46
|
.fetch('examples')
|
@@ -61,6 +60,10 @@ module KnapsackPro
|
|
61
60
|
|
62
61
|
private
|
63
62
|
|
63
|
+
def report_path
|
64
|
+
"#{REPORT_DIR}/rspec_dry_run_json_report_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
|
65
|
+
end
|
66
|
+
|
64
67
|
def adapter_class
|
65
68
|
KnapsackPro::Adapters::RSpecAdapter
|
66
69
|
end
|
@@ -78,7 +81,7 @@ module KnapsackPro
|
|
78
81
|
end
|
79
82
|
|
80
83
|
def remove_old_json_report
|
81
|
-
File.delete(
|
84
|
+
File.delete(report_path) if File.exists?(report_path)
|
82
85
|
end
|
83
86
|
|
84
87
|
def test_file_hash_for(test_file_path)
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -87,9 +87,20 @@ shared_examples 'when retry request' do
|
|
87
87
|
expect(logger).to receive(:warn).exactly(3).with(server_error.inspect)
|
88
88
|
|
89
89
|
expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
|
90
|
+
expect(logger).to receive(:warn).with("Next request in 8s...")
|
91
|
+
expect(logger).to receive(:warn).with("Next request in 6s...")
|
92
|
+
expect(logger).to receive(:warn).with("Next request in 4s...")
|
93
|
+
expect(logger).to receive(:warn).with("Next request in 2s...")
|
90
94
|
expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
|
91
|
-
expect(
|
92
|
-
expect(
|
95
|
+
expect(logger).to receive(:warn).with("Next request in 16s...")
|
96
|
+
expect(logger).to receive(:warn).with("Next request in 14s...")
|
97
|
+
expect(logger).to receive(:warn).with("Next request in 12s...")
|
98
|
+
expect(logger).to receive(:warn).with("Next request in 10s...")
|
99
|
+
expect(logger).to receive(:warn).with("Next request in 8s...")
|
100
|
+
expect(logger).to receive(:warn).with("Next request in 6s...")
|
101
|
+
expect(logger).to receive(:warn).with("Next request in 4s...")
|
102
|
+
expect(logger).to receive(:warn).with("Next request in 2s...")
|
103
|
+
expect(Kernel).to receive(:sleep).exactly(12).with(2)
|
93
104
|
|
94
105
|
expect(subject).to eq(parsed_response)
|
95
106
|
|
@@ -115,15 +126,37 @@ shared_examples 'when retry request' do
|
|
115
126
|
expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
|
116
127
|
|
117
128
|
expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
|
129
|
+
expect(logger).to receive(:warn).with("Next request in 8s...")
|
130
|
+
expect(logger).to receive(:warn).with("Next request in 6s...")
|
131
|
+
expect(logger).to receive(:warn).with("Next request in 4s...")
|
132
|
+
expect(logger).to receive(:warn).with("Next request in 2s...")
|
133
|
+
|
118
134
|
expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
|
135
|
+
expect(logger).to receive(:warn).with("Next request in 16s...")
|
136
|
+
expect(logger).to receive(:warn).with("Next request in 14s...")
|
137
|
+
expect(logger).to receive(:warn).with("Next request in 12s...")
|
138
|
+
expect(logger).to receive(:warn).with("Next request in 10s...")
|
139
|
+
expect(logger).to receive(:warn).with("Next request in 8s...")
|
140
|
+
expect(logger).to receive(:warn).with("Next request in 6s...")
|
141
|
+
expect(logger).to receive(:warn).with("Next request in 4s...")
|
142
|
+
expect(logger).to receive(:warn).with("Next request in 2s...")
|
143
|
+
|
119
144
|
expect(logger).to receive(:warn).with("Wait 24s and retry request to Knapsack Pro API.")
|
145
|
+
12.times do |i|
|
146
|
+
expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
|
147
|
+
end
|
148
|
+
|
120
149
|
expect(logger).to receive(:warn).with("Wait 32s and retry request to Knapsack Pro API.")
|
150
|
+
16.times do |i|
|
151
|
+
expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
|
152
|
+
end
|
153
|
+
|
121
154
|
expect(logger).to receive(:warn).with("Wait 40s and retry request to Knapsack Pro API.")
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
expect(Kernel).to receive(:sleep).with(
|
155
|
+
20.times do |i|
|
156
|
+
expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
|
157
|
+
end
|
158
|
+
|
159
|
+
expect(Kernel).to receive(:sleep).exactly(60).with(2)
|
127
160
|
|
128
161
|
expect(subject).to eq(parsed_response)
|
129
162
|
|
@@ -22,7 +22,14 @@ describe KnapsackPro::Config::CI::GithubActions do
|
|
22
22
|
describe '#node_build_id' do
|
23
23
|
subject { described_class.new.node_build_id }
|
24
24
|
|
25
|
-
|
25
|
+
context 'when environment exists' do
|
26
|
+
let(:env) { { 'GITHUB_RUN_ID' => 2706 } }
|
27
|
+
it { should eql 2706 }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when environment doesn't exist" do
|
31
|
+
it { should be nil }
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
describe '#commit_hash' do
|
@@ -658,6 +658,20 @@ describe KnapsackPro::Config::Env do
|
|
658
658
|
end
|
659
659
|
end
|
660
660
|
|
661
|
+
describe '.rspec_test_example_detector_prefix' do
|
662
|
+
subject { described_class.rspec_test_example_detector_prefix }
|
663
|
+
|
664
|
+
context 'when ENV exists' do
|
665
|
+
before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX' => '' }) }
|
666
|
+
it { should eq '' }
|
667
|
+
end
|
668
|
+
|
669
|
+
context "when ENV doesn't exist" do
|
670
|
+
before { stub_const("ENV", {}) }
|
671
|
+
it { should eq 'bundle exec' }
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
661
675
|
describe '.test_suite_token' do
|
662
676
|
subject { described_class.test_suite_token }
|
663
677
|
|
@@ -104,6 +104,31 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
|
|
104
104
|
subject
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
context 'when format param is provided without a delimiter' do
|
109
|
+
let(:args) { '-fMyCustomFormatter' }
|
110
|
+
|
111
|
+
it 'uses provided format param instead of default formatter progress' do
|
112
|
+
expected_exitstatus = 0
|
113
|
+
expected_accumulator = {
|
114
|
+
status: :completed,
|
115
|
+
exitstatus: expected_exitstatus
|
116
|
+
}
|
117
|
+
accumulator = {
|
118
|
+
status: :next,
|
119
|
+
runner: runner,
|
120
|
+
can_initialize_queue: true,
|
121
|
+
args: ['-fMyCustomFormatter', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
122
|
+
exitstatus: 0,
|
123
|
+
all_test_file_paths: [],
|
124
|
+
}
|
125
|
+
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
126
|
+
|
127
|
+
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
128
|
+
|
129
|
+
subject
|
130
|
+
end
|
131
|
+
end
|
107
132
|
end
|
108
133
|
|
109
134
|
context 'when args not provided' do
|
@@ -27,7 +27,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '.save_to_json_report', :clear_tmp do
|
30
|
-
let(:json_report_path) { 'tmp/knapsack_pro/slow_test_file_determiner/
|
30
|
+
let(:json_report_path) { 'tmp/knapsack_pro/slow_test_file_determiner/slow_test_files_node_0.json' }
|
31
31
|
let(:test_files) do
|
32
32
|
[
|
33
33
|
{ 'path' => 'a_spec.rb', 'time_execution' => 1.0 },
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
2
2
|
let(:report_dir) { 'tmp/knapsack_pro/test_case_detectors/rspec' }
|
3
|
-
let(:report_path) { 'tmp/knapsack_pro/test_case_detectors/rspec/
|
3
|
+
let(:report_path) { 'tmp/knapsack_pro/test_case_detectors/rspec/rspec_dry_run_json_report_node_0.json' }
|
4
4
|
let(:rspec_test_example_detector) { described_class.new }
|
5
5
|
|
6
6
|
describe '#generate_json_report' do
|
@@ -116,7 +116,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
116
116
|
it do
|
117
117
|
expect(File).to receive(:exists?).with(report_path).and_return(false)
|
118
118
|
|
119
|
-
expect { subject }.to raise_error(RuntimeError, 'No report found at tmp/knapsack_pro/test_case_detectors/rspec/
|
119
|
+
expect { subject }.to raise_error(RuntimeError, 'No report found at tmp/knapsack_pro/test_case_detectors/rspec/rspec_dry_run_json_report_node_0.json')
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
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: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|