knapsack_pro 7.12.1 → 7.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/knapsack_pro/allocator.rb +4 -2
- data/lib/knapsack_pro/config/env.rb +4 -0
- data/lib/knapsack_pro/queue_allocator.rb +4 -2
- data/lib/knapsack_pro/runners/queue/base_runner.rb +4 -1
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +3 -0
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +3 -0
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +7 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/integration/runners/fallback_spec.rb +131 -0
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +129 -0
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +129 -0
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +137 -0
- data/spec/integration/runners/queue/rspec_runner_spec.rb +2 -4
- data/spec/knapsack_pro/allocator_spec.rb +35 -15
- data/spec/knapsack_pro/config/env_spec.rb +1 -2
- data/spec/knapsack_pro/queue_allocator_spec.rb +3 -3
- data/spec/knapsack_pro/utils_spec.rb +2 -2
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199f5a710b27c9e76985316a9ac5dfeb95b6f7970a9246f26cdfaee8fb06adcd
|
4
|
+
data.tar.gz: 2b3421149a4284e32abf8f3351e6efafac9fc2bcd26a0225228b6f1a1ba5753d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983ffb0e290dba0d7a3e93bcf025fa0fd380e9457bc9c93c477783386c79dfeb1195a726f1513aea2970c882c46621d929e5ad204e343afa81eaa9ca73906790
|
7
|
+
data.tar.gz: 3f5031d341b563fbf231e38506c70521fc3cbd3b7ff55a529c725491b330cbd7bed105fbd6540c97fe76842d6c84b63dbaf8369937a4cbddb10ebde754ec6a1a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 7.13.1
|
4
|
+
|
5
|
+
* Fix handling signals for non-RSpec test runners
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/286
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.13.0...v7.13.1
|
10
|
+
|
11
|
+
### 7.13.0
|
12
|
+
|
13
|
+
* Add `KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE` to specify a custom exit code whenever Knapsack Pro fails because Fallback Mode cannot be used
|
14
|
+
|
15
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/284
|
16
|
+
|
17
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.12.1...v7.13.0
|
18
|
+
|
3
19
|
### 7.12.1
|
4
20
|
|
5
21
|
* fix(RSpec split by examples): properly disable split by test examples on a single node to speed up tests
|
@@ -29,14 +29,16 @@ module KnapsackPro
|
|
29
29
|
elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
|
30
30
|
message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
|
31
31
|
KnapsackPro.logger.error(message)
|
32
|
-
|
32
|
+
exit_code = KnapsackPro::Config::Env.fallback_mode_error_exit_code
|
33
|
+
Kernel.exit(exit_code)
|
33
34
|
elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
|
34
35
|
message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
|
35
36
|
unless KnapsackPro::Config::Env.fixed_test_suite_split?
|
36
37
|
message += " Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_TEST_SUITE_SPLIT}"
|
37
38
|
end
|
38
39
|
KnapsackPro.logger.error(message)
|
39
|
-
|
40
|
+
exit_code = KnapsackPro::Config::Env.fallback_mode_error_exit_code
|
41
|
+
Kernel.exit(exit_code)
|
40
42
|
else
|
41
43
|
KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
|
42
44
|
fallback_test_files
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module KnapsackPro
|
4
4
|
class QueueAllocator
|
5
|
+
FallbackModeError = Class.new(StandardError)
|
6
|
+
|
5
7
|
def initialize(args)
|
6
8
|
@fast_and_slow_test_files_to_run = args.fetch(:fast_and_slow_test_files_to_run)
|
7
9
|
@fallback_mode_test_files = args.fetch(:fallback_mode_test_files)
|
@@ -31,14 +33,14 @@ module KnapsackPro
|
|
31
33
|
elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
|
32
34
|
message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
|
33
35
|
KnapsackPro.logger.error(message)
|
34
|
-
raise message
|
36
|
+
raise FallbackModeError.new(message)
|
35
37
|
elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
|
36
38
|
message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
|
37
39
|
unless KnapsackPro::Config::Env.fixed_queue_split?
|
38
40
|
message += " Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_QUEUE_SPLIT}"
|
39
41
|
end
|
40
42
|
KnapsackPro.logger.error(message)
|
41
|
-
raise message
|
43
|
+
raise FallbackModeError.new(message)
|
42
44
|
else
|
43
45
|
@fallback_activated = true
|
44
46
|
KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
|
@@ -59,12 +59,15 @@ module KnapsackPro
|
|
59
59
|
Signal.trap(signal) {
|
60
60
|
puts "#{signal} signal has been received. Terminating Knapsack Pro..."
|
61
61
|
@@terminate_process = true
|
62
|
-
|
62
|
+
post_trap_signals
|
63
63
|
log_threads
|
64
64
|
}
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def post_trap_signals
|
69
|
+
end
|
70
|
+
|
68
71
|
def log_threads
|
69
72
|
threads = Thread.list
|
70
73
|
|
@@ -29,6 +29,9 @@ module KnapsackPro
|
|
29
29
|
end
|
30
30
|
|
31
31
|
Kernel.exit(accumulator[:exitstatus])
|
32
|
+
rescue KnapsackPro::QueueAllocator::FallbackModeError
|
33
|
+
exit_code = KnapsackPro::Config::Env.fallback_mode_error_exit_code
|
34
|
+
Kernel.exit(exit_code)
|
32
35
|
end
|
33
36
|
|
34
37
|
def self.run_tests(accumulator)
|
@@ -40,6 +40,9 @@ module KnapsackPro
|
|
40
40
|
end
|
41
41
|
|
42
42
|
Kernel.exit(accumulator[:exitstatus])
|
43
|
+
rescue KnapsackPro::QueueAllocator::FallbackModeError
|
44
|
+
exit_code = KnapsackPro::Config::Env.fallback_mode_error_exit_code
|
45
|
+
Kernel.exit(exit_code)
|
43
46
|
end
|
44
47
|
|
45
48
|
def self.run_tests(accumulator)
|
@@ -55,6 +55,9 @@ module KnapsackPro
|
|
55
55
|
rescue KnapsackPro::Runners::Queue::BaseRunner::TerminationError
|
56
56
|
exit_code = @rspec_pure.error_exit_code(@rspec_runner.knapsack__error_exit_code)
|
57
57
|
Kernel.exit(exit_code)
|
58
|
+
rescue KnapsackPro::QueueAllocator::FallbackModeError
|
59
|
+
exit_code = KnapsackPro::Config::Env.fallback_mode_error_exit_code
|
60
|
+
Kernel.exit(exit_code)
|
58
61
|
rescue Exception => exception
|
59
62
|
KnapsackPro.logger.error("An unexpected exception happened. RSpec cannot handle it. The exception: #{exception.inspect}")
|
60
63
|
KnapsackPro.logger.error("Exception message: #{exception.message}")
|
@@ -114,6 +117,10 @@ module KnapsackPro
|
|
114
117
|
|
115
118
|
private
|
116
119
|
|
120
|
+
def post_trap_signals
|
121
|
+
RSpec.world.wants_to_quit = true
|
122
|
+
end
|
123
|
+
|
117
124
|
def pre_run_setup
|
118
125
|
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
|
119
126
|
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
['RSpec', 'Minitest', 'Cucumber'].each do |runner|
|
6
|
+
describe "#{Object.const_get("KnapsackPro::Runners::#{runner}Runner")} Fallback - Integration tests" do
|
7
|
+
def log(stdout, stderr, status)
|
8
|
+
puts '='*50
|
9
|
+
puts 'STDOUT:'
|
10
|
+
puts stdout
|
11
|
+
puts
|
12
|
+
|
13
|
+
puts '='*50
|
14
|
+
puts 'STDERR:'
|
15
|
+
puts stderr
|
16
|
+
puts
|
17
|
+
|
18
|
+
puts '='*50
|
19
|
+
puts 'Exit status code:'
|
20
|
+
puts status
|
21
|
+
puts
|
22
|
+
end
|
23
|
+
|
24
|
+
subject do
|
25
|
+
stdout, stderr, status = Open3.capture3("ruby #{@task.path}")
|
26
|
+
log(stdout, stderr, status) if ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
|
27
|
+
OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
|
28
|
+
end
|
29
|
+
|
30
|
+
before(:each) do
|
31
|
+
ENV['KNAPSACK_PRO_ENDPOINT'] = 'https://fail.knapsackpro.com' # ensure the API is not reachable
|
32
|
+
ENV['KNAPSACK_PRO_MAX_REQUEST_RETRIES'] = '1' # only try once to reach the API
|
33
|
+
end
|
34
|
+
|
35
|
+
around(:each) do |example|
|
36
|
+
Tempfile.create do |file|
|
37
|
+
file.write(<<~CONTENT)
|
38
|
+
require 'knapsack_pro'
|
39
|
+
|
40
|
+
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_#{runner.upcase}'] = SecureRandom.hex
|
41
|
+
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
|
42
|
+
|
43
|
+
#{Object.const_get("KnapsackPro::Runners::#{runner}Runner")}.run('')
|
44
|
+
CONTENT
|
45
|
+
file.rewind
|
46
|
+
|
47
|
+
@task = file
|
48
|
+
example.run
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
after(:each) do
|
53
|
+
ENV.delete('KNAPSACK_PRO_ENDPOINT')
|
54
|
+
ENV.delete('KNAPSACK_PRO_MAX_REQUEST_RETRIES')
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with fallback mode disabled' do
|
58
|
+
before(:each) do
|
59
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'false'
|
60
|
+
end
|
61
|
+
|
62
|
+
after(:each) do
|
63
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'exits with 1 and logs the error' do
|
67
|
+
actual = subject
|
68
|
+
|
69
|
+
expect(actual.exit_code).to eq 1
|
70
|
+
|
71
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false')
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'with a user defined exit code' do
|
75
|
+
before do
|
76
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
77
|
+
end
|
78
|
+
|
79
|
+
after do
|
80
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'exits with the passed exit code and logs the error' do
|
84
|
+
actual = subject
|
85
|
+
|
86
|
+
expect(actual.exit_code).to eq 123
|
87
|
+
|
88
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with fallback mode enabled and positive node retry count' do
|
94
|
+
before(:each) do
|
95
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'true'
|
96
|
+
ENV['KNAPSACK_PRO_CI_NODE_RETRY_COUNT'] = '1'
|
97
|
+
end
|
98
|
+
|
99
|
+
after(:each) do
|
100
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
101
|
+
ENV.delete('KNAPSACK_PRO_CI_NODE_RETRY_COUNT')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'exits with 1 and logs the error' do
|
105
|
+
actual = subject
|
106
|
+
|
107
|
+
expect(actual.exit_code).to eq 1
|
108
|
+
|
109
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'with a user defined exit code' do
|
113
|
+
before do
|
114
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
115
|
+
end
|
116
|
+
|
117
|
+
after do
|
118
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'exits with the passed exit code and logs the error' do
|
122
|
+
actual = subject
|
123
|
+
|
124
|
+
expect(actual.exit_code).to eq 123
|
125
|
+
|
126
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
describe "#{KnapsackPro::Runners::Queue::CucumberRunner} Fallback - Integration tests" do
|
6
|
+
def log(stdout, stderr, status)
|
7
|
+
puts '='*50
|
8
|
+
puts 'STDOUT:'
|
9
|
+
puts stdout
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts '='*50
|
13
|
+
puts 'STDERR:'
|
14
|
+
puts stderr
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts '='*50
|
18
|
+
puts 'Exit status code:'
|
19
|
+
puts status
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
subject do
|
24
|
+
stdout, stderr, status = Open3.capture3("ruby #{@task.path}")
|
25
|
+
log(stdout, stderr, status) if ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
|
26
|
+
OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
ENV['KNAPSACK_PRO_ENDPOINT'] = 'https://fail.knapsackpro.com' # ensure the API is not reachable
|
31
|
+
ENV['KNAPSACK_PRO_MAX_REQUEST_RETRIES'] = '1' # only try once to reach the API
|
32
|
+
end
|
33
|
+
|
34
|
+
around(:each) do |example|
|
35
|
+
Tempfile.create do |file|
|
36
|
+
file.write(<<~CONTENT)
|
37
|
+
require 'knapsack_pro'
|
38
|
+
|
39
|
+
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER'] = SecureRandom.hex
|
40
|
+
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
|
41
|
+
|
42
|
+
#{KnapsackPro::Runners::Queue::CucumberRunner}.run('')
|
43
|
+
CONTENT
|
44
|
+
file.rewind
|
45
|
+
|
46
|
+
@task = file
|
47
|
+
example.run
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
after(:each) do
|
52
|
+
ENV.delete('KNAPSACK_PRO_ENDPOINT')
|
53
|
+
ENV.delete('KNAPSACK_PRO_MAX_REQUEST_RETRIES')
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with fallback mode disabled' do
|
57
|
+
before(:each) do
|
58
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'false'
|
59
|
+
end
|
60
|
+
|
61
|
+
after(:each) do
|
62
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'exits with 1 and logs the error' do
|
66
|
+
actual = subject
|
67
|
+
|
68
|
+
expect(actual.exit_code).to eq 1
|
69
|
+
|
70
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with a user defined exit code' do
|
74
|
+
before do
|
75
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
76
|
+
end
|
77
|
+
|
78
|
+
after do
|
79
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'exits with the passed exit code and logs the error' do
|
83
|
+
actual = subject
|
84
|
+
|
85
|
+
expect(actual.exit_code).to eq 123
|
86
|
+
|
87
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with fallback mode enabled and positive node retry count' do
|
93
|
+
before(:each) do
|
94
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'true'
|
95
|
+
ENV['KNAPSACK_PRO_CI_NODE_RETRY_COUNT'] = '1'
|
96
|
+
end
|
97
|
+
|
98
|
+
after(:each) do
|
99
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
100
|
+
ENV.delete('KNAPSACK_PRO_CI_NODE_RETRY_COUNT')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'exits with 1 and logs the error' do
|
104
|
+
actual = subject
|
105
|
+
|
106
|
+
expect(actual.exit_code).to eq 1
|
107
|
+
|
108
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'with a user defined exit code' do
|
112
|
+
before do
|
113
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
114
|
+
end
|
115
|
+
|
116
|
+
after do
|
117
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'exits with the passed exit code and logs the error' do
|
121
|
+
actual = subject
|
122
|
+
|
123
|
+
expect(actual.exit_code).to eq 123
|
124
|
+
|
125
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
describe "#{KnapsackPro::Runners::Queue::MinitestRunner} Fallback - Integration tests" do
|
6
|
+
def log(stdout, stderr, status)
|
7
|
+
puts '='*50
|
8
|
+
puts 'STDOUT:'
|
9
|
+
puts stdout
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts '='*50
|
13
|
+
puts 'STDERR:'
|
14
|
+
puts stderr
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts '='*50
|
18
|
+
puts 'Exit status code:'
|
19
|
+
puts status
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
subject do
|
24
|
+
stdout, stderr, status = Open3.capture3("ruby #{@task.path}")
|
25
|
+
log(stdout, stderr, status) if ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
|
26
|
+
OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
ENV['KNAPSACK_PRO_ENDPOINT'] = 'https://fail.knapsackpro.com' # ensure the API is not reachable
|
31
|
+
ENV['KNAPSACK_PRO_MAX_REQUEST_RETRIES'] = '1' # only try once to reach the API
|
32
|
+
end
|
33
|
+
|
34
|
+
around(:each) do |example|
|
35
|
+
Tempfile.create do |file|
|
36
|
+
file.write(<<~CONTENT)
|
37
|
+
require 'knapsack_pro'
|
38
|
+
|
39
|
+
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST'] = SecureRandom.hex
|
40
|
+
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
|
41
|
+
|
42
|
+
#{KnapsackPro::Runners::Queue::MinitestRunner}.run('')
|
43
|
+
CONTENT
|
44
|
+
file.rewind
|
45
|
+
|
46
|
+
@task = file
|
47
|
+
example.run
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
after(:each) do
|
52
|
+
ENV.delete('KNAPSACK_PRO_ENDPOINT')
|
53
|
+
ENV.delete('KNAPSACK_PRO_MAX_REQUEST_RETRIES')
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with fallback mode disabled' do
|
57
|
+
before(:each) do
|
58
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'false'
|
59
|
+
end
|
60
|
+
|
61
|
+
after(:each) do
|
62
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'exits with 1 and logs the error' do
|
66
|
+
actual = subject
|
67
|
+
|
68
|
+
expect(actual.exit_code).to eq 1
|
69
|
+
|
70
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with a user defined exit code' do
|
74
|
+
before do
|
75
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
76
|
+
end
|
77
|
+
|
78
|
+
after do
|
79
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'exits with the passed exit code and logs the error' do
|
83
|
+
actual = subject
|
84
|
+
|
85
|
+
expect(actual.exit_code).to eq 123
|
86
|
+
|
87
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with fallback mode enabled and positive node retry count' do
|
93
|
+
before(:each) do
|
94
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'true'
|
95
|
+
ENV['KNAPSACK_PRO_CI_NODE_RETRY_COUNT'] = '1'
|
96
|
+
end
|
97
|
+
|
98
|
+
after(:each) do
|
99
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
100
|
+
ENV.delete('KNAPSACK_PRO_CI_NODE_RETRY_COUNT')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'exits with 1 and logs the error' do
|
104
|
+
actual = subject
|
105
|
+
|
106
|
+
expect(actual.exit_code).to eq 1
|
107
|
+
|
108
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'with a user defined exit code' do
|
112
|
+
before do
|
113
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
114
|
+
end
|
115
|
+
|
116
|
+
after do
|
117
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'exits with the passed exit code and logs the error' do
|
121
|
+
actual = subject
|
122
|
+
|
123
|
+
expect(actual.exit_code).to eq 123
|
124
|
+
|
125
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
describe "#{KnapsackPro::Runners::Queue::RSpecRunner} Fallback - Integration tests" do
|
6
|
+
def log(stdout, stderr, status)
|
7
|
+
puts '='*50
|
8
|
+
puts 'STDOUT:'
|
9
|
+
puts stdout
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts '='*50
|
13
|
+
puts 'STDERR:'
|
14
|
+
puts stderr
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts '='*50
|
18
|
+
puts 'Exit status code:'
|
19
|
+
puts status
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
subject do
|
24
|
+
stdout, stderr, status = Open3.capture3("ruby #{@task.path}")
|
25
|
+
log(stdout, stderr, status) if ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
|
26
|
+
OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
ENV['KNAPSACK_PRO_ENDPOINT'] = 'https://fail.knapsackpro.com' # ensure the API is not reachable
|
31
|
+
ENV['KNAPSACK_PRO_MAX_REQUEST_RETRIES'] = '1' # only try once to reach the API
|
32
|
+
end
|
33
|
+
|
34
|
+
around(:each) do |example|
|
35
|
+
Tempfile.create do |file|
|
36
|
+
file.write(<<~CONTENT)
|
37
|
+
require 'knapsack_pro'
|
38
|
+
|
39
|
+
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC'] = SecureRandom.hex
|
40
|
+
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
|
41
|
+
|
42
|
+
#{KnapsackPro::Runners::Queue::RSpecRunner}.run('')
|
43
|
+
CONTENT
|
44
|
+
file.rewind
|
45
|
+
|
46
|
+
@task = file
|
47
|
+
example.run
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
after(:each) do
|
52
|
+
ENV.delete('KNAPSACK_PRO_ENDPOINT')
|
53
|
+
ENV.delete('KNAPSACK_PRO_MAX_REQUEST_RETRIES')
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with fallback mode disabled' do
|
57
|
+
before(:each) do
|
58
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'false'
|
59
|
+
end
|
60
|
+
|
61
|
+
after(:each) do
|
62
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'exits with 1 and logs error and summary' do
|
66
|
+
actual = subject
|
67
|
+
|
68
|
+
expect(actual.exit_code).to eq 1
|
69
|
+
|
70
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
71
|
+
expect(actual.stdout).to include(/Finished in .* seconds \(files took .* seconds to load\)/)
|
72
|
+
expect(actual.stdout).to include('0 examples, 0 failures')
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with a user defined exit code' do
|
76
|
+
before do
|
77
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'exits with the passed exit code and logs error and summary' do
|
85
|
+
actual = subject
|
86
|
+
|
87
|
+
expect(actual.exit_code).to eq 123
|
88
|
+
|
89
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
90
|
+
expect(actual.stdout).to include(/Finished in .* seconds \(files took .* seconds to load\)/)
|
91
|
+
expect(actual.stdout).to include('0 examples, 0 failures')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'with fallback mode enabled and positive node retry count' do
|
97
|
+
before(:each) do
|
98
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ENABLED'] = 'true'
|
99
|
+
ENV['KNAPSACK_PRO_CI_NODE_RETRY_COUNT'] = '1'
|
100
|
+
end
|
101
|
+
|
102
|
+
after(:each) do
|
103
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ENABLED')
|
104
|
+
ENV.delete('KNAPSACK_PRO_CI_NODE_RETRY_COUNT')
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'exits with 1 and logs error and summary' do
|
108
|
+
actual = subject
|
109
|
+
|
110
|
+
expect(actual.exit_code).to eq 1
|
111
|
+
|
112
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
113
|
+
expect(actual.stdout).to include(/Finished in .* seconds \(files took .* seconds to load\)/)
|
114
|
+
expect(actual.stdout).to include('0 examples, 0 failures')
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'with a user defined exit code' do
|
118
|
+
before do
|
119
|
+
ENV['KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE'] = '123'
|
120
|
+
end
|
121
|
+
|
122
|
+
after do
|
123
|
+
ENV.delete('KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE')
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'exits with the passed exit code and logs error and summary' do
|
127
|
+
actual = subject
|
128
|
+
|
129
|
+
expect(actual.exit_code).to eq 123
|
130
|
+
|
131
|
+
expect(actual.stdout).to include('ERROR -- : [knapsack_pro] knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
132
|
+
expect(actual.stdout).to include(/Finished in .* seconds \(files took .* seconds to load\)/)
|
133
|
+
expect(actual.stdout).to include('0 examples, 0 failures')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -53,9 +53,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
53
53
|
ENV['TEST__TEST_FILE_CASES_FOR_SLOW_TEST_FILES'] = test_file_paths.to_json
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
return if ENV['TEST__SHOW_DEBUG_LOG'] != 'true'
|
58
|
-
|
56
|
+
def log(stdout, stderr, status)
|
59
57
|
puts '='*50
|
60
58
|
puts 'STDOUT:'
|
61
59
|
puts stdout
|
@@ -83,7 +81,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
83
81
|
|
84
82
|
subject do
|
85
83
|
stdout, stderr, status = Open3.capture3(command)
|
86
|
-
|
84
|
+
log(stdout, stderr, status) if ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
|
87
85
|
OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
|
88
86
|
end
|
89
87
|
|
@@ -23,43 +23,63 @@ describe KnapsackPro::Allocator do
|
|
23
23
|
|
24
24
|
shared_examples_for 'when connection to API failed (fallback mode)' do
|
25
25
|
context 'when fallback mode is disabled' do
|
26
|
-
before do
|
26
|
+
before(:each) do
|
27
27
|
expect(KnapsackPro::Config::Env).to receive(:fallback_mode_enabled?).and_return(false)
|
28
28
|
end
|
29
29
|
|
30
|
-
it do
|
31
|
-
|
30
|
+
it 'logs the error and exits' do
|
31
|
+
logger = instance_double(Logger)
|
32
|
+
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
33
|
+
expect(logger).to receive(:error).with(
|
34
|
+
'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false'
|
35
|
+
)
|
36
|
+
|
37
|
+
expect { subject }.to raise_error(SystemExit)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
41
|
context 'when CI node retry count > 0' do
|
36
|
-
before do
|
42
|
+
before(:each) do
|
37
43
|
expect(KnapsackPro::Config::Env).to receive(:ci_node_retry_count).and_return(1)
|
38
44
|
end
|
39
45
|
|
40
46
|
context 'when fixed_test_suite_split=true' do
|
41
|
-
before do
|
47
|
+
before(:each) do
|
42
48
|
expect(KnapsackPro::Config::Env).to receive(:fixed_test_suite_split).and_return(true)
|
43
49
|
end
|
44
50
|
|
45
|
-
it do
|
46
|
-
|
51
|
+
it 'logs the error and exits' do
|
52
|
+
logger = instance_double(Logger)
|
53
|
+
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
54
|
+
|
55
|
+
expect(logger).to receive(:error).with(
|
56
|
+
'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count'
|
57
|
+
)
|
58
|
+
|
59
|
+
expect { subject }.to raise_error(SystemExit)
|
47
60
|
end
|
48
61
|
end
|
49
62
|
|
50
63
|
context 'when fixed_test_suite_split=false' do
|
51
|
-
before do
|
64
|
+
before(:each) do
|
52
65
|
expect(KnapsackPro::Config::Env).to receive(:fixed_test_suite_split).and_return(false)
|
53
66
|
end
|
54
67
|
|
55
|
-
it do
|
56
|
-
|
68
|
+
it 'logs the error and exits' do
|
69
|
+
logger = instance_double(Logger)
|
70
|
+
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
71
|
+
|
72
|
+
expect(logger).to receive(:error).with(
|
73
|
+
'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-test-suite-split'
|
74
|
+
)
|
75
|
+
|
76
|
+
expect { subject }.to raise_error(SystemExit)
|
57
77
|
end
|
58
78
|
end
|
59
79
|
end
|
60
80
|
|
61
81
|
context 'when fallback mode started' do
|
62
|
-
before do
|
82
|
+
before(:each) do
|
63
83
|
test_flat_distributor = instance_double(KnapsackPro::TestFlatDistributor)
|
64
84
|
expect(KnapsackPro::TestFlatDistributor).to receive(:new).with(fallback_mode_test_files, ci_node_total).and_return(test_flat_distributor)
|
65
85
|
expect(test_flat_distributor).to receive(:test_files_for_node).with(ci_node_index).and_return([
|
@@ -72,7 +92,7 @@ describe KnapsackPro::Allocator do
|
|
72
92
|
end
|
73
93
|
end
|
74
94
|
|
75
|
-
before do
|
95
|
+
before(:each) do
|
76
96
|
encrypted_branch = double
|
77
97
|
expect(KnapsackPro::Crypto::BranchEncryptor).to receive(:call).with(repository_adapter.branch).and_return(encrypted_branch)
|
78
98
|
|
@@ -118,7 +138,7 @@ describe KnapsackPro::Allocator do
|
|
118
138
|
}
|
119
139
|
end
|
120
140
|
|
121
|
-
before do
|
141
|
+
before(:each) do
|
122
142
|
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(fast_and_slow_test_files_to_run, response['test_files']).and_call_original
|
123
143
|
end
|
124
144
|
|
@@ -131,7 +151,7 @@ describe KnapsackPro::Allocator do
|
|
131
151
|
end
|
132
152
|
let(:api_code) { 'TEST_SUITE_SPLIT_CACHE_MISS' }
|
133
153
|
|
134
|
-
before do
|
154
|
+
before(:each) do
|
135
155
|
encrypted_branch = double
|
136
156
|
expect(KnapsackPro::Crypto::BranchEncryptor).to receive(:call).with(repository_adapter.branch).and_return(encrypted_branch)
|
137
157
|
|
@@ -183,7 +203,7 @@ describe KnapsackPro::Allocator do
|
|
183
203
|
}
|
184
204
|
end
|
185
205
|
|
186
|
-
before do
|
206
|
+
before(:each) do
|
187
207
|
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(fast_and_slow_test_files_to_run, response2['test_files']).and_call_original
|
188
208
|
end
|
189
209
|
|
@@ -1016,9 +1016,8 @@ describe KnapsackPro::Config::Env do
|
|
1016
1016
|
describe '.rspec_split_by_test_examples?' do
|
1017
1017
|
subject { described_class.rspec_split_by_test_examples? }
|
1018
1018
|
|
1019
|
-
|
1019
|
+
after(:each) do
|
1020
1020
|
described_class.remove_instance_variable(:@rspec_split_by_test_examples)
|
1021
|
-
rescue NameError
|
1022
1021
|
end
|
1023
1022
|
|
1024
1023
|
context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true AND KNAPSACK_PRO_CI_NODE_TOTAL >= 2' do
|
@@ -31,7 +31,7 @@ describe KnapsackPro::QueueAllocator do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it do
|
34
|
-
expect { subject }.to raise_error(
|
34
|
+
expect { subject }.to raise_error(KnapsackPro::QueueAllocator::FallbackModeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -46,7 +46,7 @@ describe KnapsackPro::QueueAllocator do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it do
|
49
|
-
expect { subject }.to raise_error(
|
49
|
+
expect { subject }.to raise_error(KnapsackPro::QueueAllocator::FallbackModeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -56,7 +56,7 @@ describe KnapsackPro::QueueAllocator do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it do
|
59
|
-
expect { subject }.to raise_error(
|
59
|
+
expect { subject }.to raise_error(KnapsackPro::QueueAllocator::FallbackModeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-queue-split')
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -23,7 +23,7 @@ describe KnapsackPro::Utils do
|
|
23
23
|
context 'when Timecop does not mock the time' do
|
24
24
|
it do
|
25
25
|
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
26
|
-
expect(subject).to be_within(0.
|
26
|
+
expect(subject).to be_within(0.01).of(now)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -47,7 +47,7 @@ describe KnapsackPro::Utils do
|
|
47
47
|
|
48
48
|
time = Time.local(2020, 1, 31)
|
49
49
|
Timecop.travel(time) do
|
50
|
-
expect(subject).to be_within(0.
|
50
|
+
expect(subject).to be_within(0.01).of(now)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
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: 7.
|
4
|
+
version: 7.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -318,7 +318,11 @@ files:
|
|
318
318
|
- spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml
|
319
319
|
- spec/integration/api/build_distributions_subset_spec.rb
|
320
320
|
- spec/integration/api/build_subsets_create_spec.rb
|
321
|
+
- spec/integration/runners/fallback_spec.rb
|
322
|
+
- spec/integration/runners/queue/cucumber_runner_fallback_spec.rb
|
323
|
+
- spec/integration/runners/queue/minitest_runner_fallback_spec.rb
|
321
324
|
- spec/integration/runners/queue/rspec_runner.rb
|
325
|
+
- spec/integration/runners/queue/rspec_runner_fallback_spec.rb
|
322
326
|
- spec/integration/runners/queue/rspec_runner_spec.rb
|
323
327
|
- spec/knapsack_pro/adapters/base_adapter_spec.rb
|
324
328
|
- spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
|
@@ -442,7 +446,11 @@ test_files:
|
|
442
446
|
- spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml
|
443
447
|
- spec/integration/api/build_distributions_subset_spec.rb
|
444
448
|
- spec/integration/api/build_subsets_create_spec.rb
|
449
|
+
- spec/integration/runners/fallback_spec.rb
|
450
|
+
- spec/integration/runners/queue/cucumber_runner_fallback_spec.rb
|
451
|
+
- spec/integration/runners/queue/minitest_runner_fallback_spec.rb
|
445
452
|
- spec/integration/runners/queue/rspec_runner.rb
|
453
|
+
- spec/integration/runners/queue/rspec_runner_fallback_spec.rb
|
446
454
|
- spec/integration/runners/queue/rspec_runner_spec.rb
|
447
455
|
- spec/knapsack_pro/adapters/base_adapter_spec.rb
|
448
456
|
- spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
|