knapsack_pro 2.3.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a36ff1388dd1ad1c95c0fd5041fc771d27f28b36c0d02773fa8205ae4812818b
4
- data.tar.gz: c07a145c9d4f62d9901cb1bb2122662ca57c69a75d8dd500771799af215204a0
3
+ metadata.gz: d9d29bfab6d9abd18cc90777bf6fe0f12e0a9c5622ccdd7ba75ecaa503b5afe5
4
+ data.tar.gz: 827c14d1cf91da82dea672ec71c53b7f966342ba1d85c1b1f0610ab2776d22b7
5
5
  SHA512:
6
- metadata.gz: 8aeb03d459916e73d5281fc28293300acc6e375747954afd070ef34cc062e08d603dee4bea5e614850ca723f15f3e926a69e7f0efee1399c02320baee0d18100
7
- data.tar.gz: 1ac8483c14d798c0b4f8f163846e2f3e922223dad285516674568998ada15a917633a34b243b571b5f2e11f3d2a8d1086390ac1c39abd3205cb3c17aedf26c4f
6
+ metadata.gz: 785be65ef6709bbce2e2e302f55c7c9be5782c1dd5ede66d43c67119dd6342dd9e1d4d7851f426732ea61b986505d7a0ac08165782a11c0338c209bc4f4fc167
7
+ data.tar.gz: c30bf1b7dc4ac778c34763a18aee465c3266ee366589999be11ae71ab73c8263cf0470e1ce8646260de6a41b0f749dd9cdaf1b7d5d326c20a758da0e2c7f4f8e
@@ -1,10 +1,50 @@
1
1
  # Change Log
2
2
 
3
+ ### 2.8.0
4
+
5
+ * More actionable error message when RSpec split by examples is not working due to RSpec dry-run failure
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/130
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.7.0...v2.8.0
10
+
11
+ ### 2.7.0
12
+
13
+ * Add support for env var `KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE` to allow accepting file containing test files to run
14
+
15
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/129
16
+
17
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.6.0...v2.7.0
18
+
19
+ ### 2.6.0
20
+
21
+ * Improve logger to show failed requests URL and when retry will happen
22
+
23
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/127
24
+
25
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.5.0...v2.6.0
26
+
27
+ ### 2.5.0
28
+
29
+ * Add production branch to non encryptable branches names
30
+
31
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/126
32
+
33
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.4.0...v2.5.0
34
+
35
+ ### 2.4.0
36
+
37
+ * Update list of non encryptable branches
38
+
39
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/125
40
+
41
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.3.0...v2.4.0
42
+
3
43
  ### 2.3.0
4
44
 
5
45
  * When you use Regular Mode then try 6 attempts to connect to the API instead of 3 attempts
6
46
 
7
- Add `KNAPSACK_PRO_MAX_REQUEST_RETRIES` environment variable to let user define their own number of request retries to the API. It is useful to set it to `0` for [forked repos](https://knapsackpro.com/faq/question/how-to-make-knapsack_pro-works-for-forked-repositories-of-my-project) when you want to relay on Fallback Mode.
47
+ Add `KNAPSACK_PRO_MAX_REQUEST_RETRIES` environment variable to let user define their own number of request retries to the API. It is useful to set it to `0` for [forked repos](https://knapsackpro.com/faq/question/how-to-make-knapsack_pro-works-for-forked-repositories-of-my-project) when you want to rely on Fallback Mode.
8
48
 
9
49
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/124
10
50
 
data/README.md CHANGED
@@ -2320,7 +2320,7 @@ There are a few ways to reproduce tests executed on CI node in your development
2320
2320
 
2321
2321
  ##### for knapsack_pro regular mode
2322
2322
 
2323
- knapsack_pro gem will retry requests to Knapsack Pro API multiple times every few seconds till it switchs to fallback behavior (Fallback Mode) and it will split test files across CI nodes based on popular test directory names. When knapsack_pro starts Fallback Mode then you will see a warning in the output.
2323
+ knapsack_pro gem will retry requests to Knapsack Pro API multiple times every few seconds till it switches to fallback behavior (Fallback Mode) and it will split test files across CI nodes based on popular test directory names. When knapsack_pro starts Fallback Mode then you will see a warning in the output.
2324
2324
 
2325
2325
  Note there is an unlikely scenario when some of the CI nodes may start in Fallback Mode but others don't and then it could happen that some of test files might be skipped. You should [read this to learn more](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/124) and decide if you like to use Fallback Mode when running tests with knapsack_pro Regular Mode.
2326
2326
 
@@ -2330,7 +2330,7 @@ If your CI provider allows to retry only one of parallel CI nodes then please [r
2330
2330
 
2331
2331
  knapsack_pro gem will retry requests to Knapsack Pro API multiple times every few seconds till it switches to fallback behavior (Fallback Mode) and it will split test files across CI nodes based on popular test directory names.
2332
2332
 
2333
- Note that if one of the CI nodes will lose connection to Knapsack Pro API but other not then you may see that some of the test files will be executed on multiple CI nodes. **Fallback Mode guarantees each of the test files is run at least once across CI nodes when you use knapsack_pro in Queue Mode.** Thanks to that we know if the whole test suite is green or not. When knapsack_pro starts Fallback Mode then you will see a warning in the output.
2333
+ Note that if one of the CI nodes loses connection to Knapsack Pro API but others don't, then some of the test files may be executed on multiple CI nodes. **Fallback Mode guarantees each of the test files is run at least once across CI nodes when you use knapsack_pro in Queue Mode.** Thanks to that we know if the whole test suite is green or not. When knapsack_pro starts Fallback Mode then you will see a warning in the output.
2334
2334
 
2335
2335
  If your CI provider allows to retry only one of parallel CI nodes then please [read about this edge case as well](#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode).
2336
2336
 
@@ -2472,12 +2472,13 @@ Below example is for rspec. You can change `$KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC
2472
2472
  if [ "$KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC" = "" ]; then
2473
2473
  KNAPSACK_PRO_ENDPOINT=https://api-disabled-for-fork.knapsackpro.com \
2474
2474
  KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=disabled-for-fork \
2475
+ KNAPSACK_PRO_MAX_REQUEST_RETRIES=0 \
2475
2476
  bundle exec rake knapsack_pro:rspec # use Regular Mode here always
2476
2477
  else
2477
2478
  # Regular Mode
2478
2479
  bundle exec rake knapsack_pro:rspec
2479
2480
 
2480
- # You can use Queue Mode instead of Regular Mode if you like
2481
+ # or you can use Queue Mode instead of Regular Mode if you like
2481
2482
  # bundle exec rake knapsack_pro:queue:rspec
2482
2483
  fi
2483
2484
  ```
@@ -3081,7 +3082,9 @@ The test file pattern and exclude pattern support any glob pattern handled by [`
3081
3082
 
3082
3083
  #### How to run a specific list of test files or only some tests from test file?
3083
3084
 
3084
- :information_source: If you don't want to use the pattern [`KNAPSACK_PRO_TEST_FILE_PATTERN`](#how-can-i-run-tests-from-multiple-directories) to define a list of tests to run then read below.
3085
+ :information_source: If you don't want to use the pattern [`KNAPSACK_PRO_TEST_FILE_PATTERN`](#how-can-i-run-tests-from-multiple-directories) to define a list of tests to run then read below two options.
3086
+
3087
+ **Option 1:**
3085
3088
 
3086
3089
  If you want to run a specific list of test files that are explicitly defined by you or auto-generated by some kind of script you created then please use:
3087
3090
 
@@ -3089,7 +3092,24 @@ If you want to run a specific list of test files that are explicitly defined by
3089
3092
 
3090
3093
  Note `KNAPSACK_PRO_TEST_FILE_LIST` must be a list of test files comma separated. You can provide line number for tests inside of spec file in case of RSpec (this way you can run only one test or a group of tests from RSpec spec file). You can provide the same file a few times with different test line number.
3091
3094
 
3092
- Note when you set `KNAPSACK_PRO_TEST_FILE_LIST` then below environment variables are ignored:
3095
+ **Option 2:**
3096
+
3097
+ Similarly, you can also provide a source file containing the test files that you would like to run. For example:
3098
+ `KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE=spec/fixtures/test_file_list_source_file.txt`
3099
+ And the content of the source file can be any of the format below:
3100
+
3101
+ ```
3102
+ ./spec/test1_spec.rb
3103
+ spec/test2_spec.rb[1]
3104
+ ./spec/test3_spec.rb[1:2:3:4]
3105
+ ./spec/test4_spec.rb:4
3106
+ ./spec/test4_spec.rb:5
3107
+ ```
3108
+
3109
+ > Note that each of the line must be ending with `\n` the new line.
3110
+
3111
+ Note when you set `KNAPSACK_PRO_TEST_FILE_LIST` or `KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE` then below environment variables are ignored:
3112
+
3093
3113
  * `KNAPSACK_PRO_TEST_FILE_PATTERN`
3094
3114
  * `KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN`
3095
3115
 
@@ -3257,6 +3277,8 @@ $ gem build knapsack_pro.gemspec
3257
3277
  $ gem push knapsack_pro-X.X.X.gem
3258
3278
  ```
3259
3279
 
3280
+ Update the latest available gem version in `TestSuiteClientVersionChecker` for the Knapsack Pro API repository.
3281
+
3260
3282
  ## Mentions
3261
3283
 
3262
3284
  List of articles where people mentioned Knapsack Pro:
@@ -115,14 +115,19 @@ module KnapsackPro
115
115
 
116
116
  response_body
117
117
  rescue ServerError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, EOFError, SocketError, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError => e
118
+ logger.warn("#{action.http_method.to_s.upcase} #{endpoint_url}")
119
+ logger.warn('Request failed due to:')
118
120
  logger.warn(e.inspect)
119
121
  retries += 1
120
122
  if retries < max_request_retries
121
123
  wait = retries * REQUEST_RETRY_TIMEBOX
122
- logger.warn("Wait #{wait}s and retry request to Knapsack Pro API.")
123
124
  print_every = 2 # seconds
124
125
  (wait / print_every).ceil.times do |i|
125
- logger.warn("Next request in #{wait - i * print_every}s...")
126
+ if i == 0
127
+ logger.warn("Wait for #{wait}s before retrying the request to Knapsack Pro API.")
128
+ else
129
+ logger.warn("#{wait - i * print_every}s left before retry...")
130
+ end
126
131
  Kernel.sleep(print_every)
127
132
  end
128
133
  retry
@@ -74,6 +74,10 @@ module KnapsackPro
74
74
  ENV['KNAPSACK_PRO_TEST_FILE_LIST']
75
75
  end
76
76
 
77
+ def test_file_list_source_file
78
+ ENV['KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE']
79
+ end
80
+
77
81
  def test_dir
78
82
  ENV['KNAPSACK_PRO_TEST_DIR']
79
83
  end
@@ -1,7 +1,23 @@
1
1
  module KnapsackPro
2
2
  module Crypto
3
3
  class BranchEncryptor
4
- NON_ENCRYPTABLE_BRANCHES = %w(develop development dev master staging)
4
+ NON_ENCRYPTABLE_BRANCHES = [
5
+ 'master',
6
+ 'main',
7
+ 'develop',
8
+ 'development',
9
+ 'dev',
10
+ 'staging',
11
+ 'production',
12
+ # GitHub Actions has branch names starting with refs/heads/
13
+ 'refs/heads/master',
14
+ 'refs/heads/main',
15
+ 'refs/heads/develop',
16
+ 'refs/heads/development',
17
+ 'refs/heads/dev',
18
+ 'refs/heads/staging',
19
+ 'refs/heads/production',
20
+ ]
5
21
 
6
22
  def self.call(branch)
7
23
  if KnapsackPro::Config::Env.branch_encrypted?
@@ -33,7 +33,16 @@ module KnapsackPro
33
33
  options = ::RSpec::Core::ConfigurationOptions.new(cli_args)
34
34
  exit_code = ::RSpec::Core::Runner.new(options).run($stderr, $stdout)
35
35
  if exit_code != 0
36
- raise 'There was problem to generate test examples for test suite'
36
+ debug_cmd = ([
37
+ 'bundle exec rspec',
38
+ ] + cli_args).join(' ')
39
+
40
+ KnapsackPro.logger.error('-'*10 + ' START of actionable error message ' + '-'*50)
41
+ KnapsackPro.logger.error('There was a problem while generating test examples for the slow test files using the RSpec dry-run flag. To reproduce the error triggered by the RSpec, please try to run below command (this way, you can find out what is causing the error):')
42
+ KnapsackPro.logger.error(debug_cmd)
43
+ KnapsackPro.logger.error('-'*10 + ' END of actionable error message ' + '-'*50)
44
+
45
+ raise 'There was a problem while generating test examples for the slow test files. Please read actionable error message above.'
37
46
  end
38
47
  end
39
48
 
@@ -63,6 +63,10 @@ module KnapsackPro
63
63
  return KnapsackPro::Config::Env.test_file_list.split(',').map(&:strip)
64
64
  end
65
65
 
66
+ if test_file_list_enabled && KnapsackPro::Config::Env.test_file_list_source_file
67
+ return File.read(KnapsackPro::Config::Env.test_file_list_source_file).split(/\n/)
68
+ end
69
+
66
70
  test_file_paths = Dir.glob(test_file_pattern).uniq
67
71
 
68
72
  excluded_test_file_paths =
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '2.3.0'
2
+ VERSION = '2.8.0'
3
3
  end
@@ -0,0 +1,6 @@
1
+ ./spec/test1_spec.rb
2
+ spec/test2_spec.rb[1]
3
+ ./spec/test3_spec.rb[1:2:3:4]
4
+ ./spec/test4_spec.rb:4
5
+ ./spec/test4_spec.rb:5
6
+
@@ -84,22 +84,22 @@ shared_examples 'when retry request' do
84
84
  expect(logger).to receive(:error).exactly(3).with(parsed_response)
85
85
 
86
86
  server_error = described_class::ServerError.new(parsed_response)
87
+ expect(logger).to receive(:warn).exactly(3).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
88
+ expect(logger).to receive(:warn).exactly(3).with('Request failed due to:')
87
89
  expect(logger).to receive(:warn).exactly(3).with(server_error.inspect)
88
90
 
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...")
94
- expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
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...")
91
+ expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
92
+ expect(logger).to receive(:warn).with("6s left before retry...")
93
+ expect(logger).to receive(:warn).with("4s left before retry...")
94
+ expect(logger).to receive(:warn).with("2s left before retry...")
95
+ expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
96
+ expect(logger).to receive(:warn).with("14s left before retry...")
97
+ expect(logger).to receive(:warn).with("12s left before retry...")
98
+ expect(logger).to receive(:warn).with("10s left before retry...")
99
+ expect(logger).to receive(:warn).with("8s left before retry...")
100
+ expect(logger).to receive(:warn).with("6s left before retry...")
101
+ expect(logger).to receive(:warn).with("4s left before retry...")
102
+ expect(logger).to receive(:warn).with("2s left before retry...")
103
103
  expect(Kernel).to receive(:sleep).exactly(12).with(2)
104
104
 
105
105
  expect(subject).to eq(parsed_response)
@@ -123,27 +123,27 @@ shared_examples 'when retry request' do
123
123
  expect(logger).to receive(:error).exactly(4).with(parsed_response)
124
124
 
125
125
  server_error = described_class::ServerError.new(parsed_response)
126
+ expect(logger).to receive(:warn).exactly(4).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
127
+ expect(logger).to receive(:warn).exactly(4).with('Request failed due to:')
126
128
  expect(logger).to receive(:warn).exactly(4).with(server_error.inspect)
127
129
 
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
-
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
-
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...")
130
+ expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
131
+ expect(logger).to receive(:warn).with("6s left before retry...")
132
+ expect(logger).to receive(:warn).with("4s left before retry...")
133
+ expect(logger).to receive(:warn).with("2s left before retry...")
134
+
135
+ expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
136
+ expect(logger).to receive(:warn).with("14s left before retry...")
137
+ expect(logger).to receive(:warn).with("12s left before retry...")
138
+ expect(logger).to receive(:warn).with("10s left before retry...")
139
+ expect(logger).to receive(:warn).with("8s left before retry...")
140
+ expect(logger).to receive(:warn).with("6s left before retry...")
141
+ expect(logger).to receive(:warn).with("4s left before retry...")
142
+ expect(logger).to receive(:warn).with("2s left before retry...")
143
+
144
+ expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
145
+ 11.times do |i|
146
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
147
147
  end
148
148
 
149
149
  expect(Kernel).to receive(:sleep).exactly(4+8+12).with(2)
@@ -170,37 +170,37 @@ shared_examples 'when retry request' do
170
170
  expect(logger).to receive(:error).exactly(6).with(parsed_response)
171
171
 
172
172
  server_error = described_class::ServerError.new(parsed_response)
173
+ expect(logger).to receive(:warn).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
174
+ expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
173
175
  expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
174
176
 
175
- expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
176
- expect(logger).to receive(:warn).with("Next request in 8s...")
177
- expect(logger).to receive(:warn).with("Next request in 6s...")
178
- expect(logger).to receive(:warn).with("Next request in 4s...")
179
- expect(logger).to receive(:warn).with("Next request in 2s...")
180
-
181
- expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
182
- expect(logger).to receive(:warn).with("Next request in 16s...")
183
- expect(logger).to receive(:warn).with("Next request in 14s...")
184
- expect(logger).to receive(:warn).with("Next request in 12s...")
185
- expect(logger).to receive(:warn).with("Next request in 10s...")
186
- expect(logger).to receive(:warn).with("Next request in 8s...")
187
- expect(logger).to receive(:warn).with("Next request in 6s...")
188
- expect(logger).to receive(:warn).with("Next request in 4s...")
189
- expect(logger).to receive(:warn).with("Next request in 2s...")
190
-
191
- expect(logger).to receive(:warn).with("Wait 24s and retry request to Knapsack Pro API.")
192
- 12.times do |i|
193
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
177
+ expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
178
+ expect(logger).to receive(:warn).with("6s left before retry...")
179
+ expect(logger).to receive(:warn).with("4s left before retry...")
180
+ expect(logger).to receive(:warn).with("2s left before retry...")
181
+
182
+ expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
183
+ expect(logger).to receive(:warn).with("14s left before retry...")
184
+ expect(logger).to receive(:warn).with("12s left before retry...")
185
+ expect(logger).to receive(:warn).with("10s left before retry...")
186
+ expect(logger).to receive(:warn).with("8s left before retry...")
187
+ expect(logger).to receive(:warn).with("6s left before retry...")
188
+ expect(logger).to receive(:warn).with("4s left before retry...")
189
+ expect(logger).to receive(:warn).with("2s left before retry...")
190
+
191
+ expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
192
+ 11.times do |i|
193
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
194
194
  end
195
195
 
196
- expect(logger).to receive(:warn).with("Wait 32s and retry request to Knapsack Pro API.")
197
- 16.times do |i|
198
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
196
+ expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to Knapsack Pro API.")
197
+ 15.times do |i|
198
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
199
199
  end
200
200
 
201
- expect(logger).to receive(:warn).with("Wait 40s and retry request to Knapsack Pro API.")
202
- 20.times do |i|
203
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
201
+ expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to Knapsack Pro API.")
202
+ 19.times do |i|
203
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
204
204
  end
205
205
 
206
206
  expect(Kernel).to receive(:sleep).exactly(60).with(2)
@@ -227,37 +227,37 @@ shared_examples 'when retry request' do
227
227
  expect(logger).to receive(:error).exactly(6).with(parsed_response)
228
228
 
229
229
  server_error = described_class::ServerError.new(parsed_response)
230
+ expect(logger).to receive(:warn).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
231
+ expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
230
232
  expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
231
233
 
232
- expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
233
- expect(logger).to receive(:warn).with("Next request in 8s...")
234
- expect(logger).to receive(:warn).with("Next request in 6s...")
235
- expect(logger).to receive(:warn).with("Next request in 4s...")
236
- expect(logger).to receive(:warn).with("Next request in 2s...")
237
-
238
- expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
239
- expect(logger).to receive(:warn).with("Next request in 16s...")
240
- expect(logger).to receive(:warn).with("Next request in 14s...")
241
- expect(logger).to receive(:warn).with("Next request in 12s...")
242
- expect(logger).to receive(:warn).with("Next request in 10s...")
243
- expect(logger).to receive(:warn).with("Next request in 8s...")
244
- expect(logger).to receive(:warn).with("Next request in 6s...")
245
- expect(logger).to receive(:warn).with("Next request in 4s...")
246
- expect(logger).to receive(:warn).with("Next request in 2s...")
247
-
248
- expect(logger).to receive(:warn).with("Wait 24s and retry request to Knapsack Pro API.")
249
- 12.times do |i|
250
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
234
+ expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
235
+ expect(logger).to receive(:warn).with("6s left before retry...")
236
+ expect(logger).to receive(:warn).with("4s left before retry...")
237
+ expect(logger).to receive(:warn).with("2s left before retry...")
238
+
239
+ expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
240
+ expect(logger).to receive(:warn).with("14s left before retry...")
241
+ expect(logger).to receive(:warn).with("12s left before retry...")
242
+ expect(logger).to receive(:warn).with("10s left before retry...")
243
+ expect(logger).to receive(:warn).with("8s left before retry...")
244
+ expect(logger).to receive(:warn).with("6s left before retry...")
245
+ expect(logger).to receive(:warn).with("4s left before retry...")
246
+ expect(logger).to receive(:warn).with("2s left before retry...")
247
+
248
+ expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
249
+ 11.times do |i|
250
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
251
251
  end
252
252
 
253
- expect(logger).to receive(:warn).with("Wait 32s and retry request to Knapsack Pro API.")
254
- 16.times do |i|
255
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
253
+ expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to Knapsack Pro API.")
254
+ 15.times do |i|
255
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
256
256
  end
257
257
 
258
- expect(logger).to receive(:warn).with("Wait 40s and retry request to Knapsack Pro API.")
259
- 20.times do |i|
260
- expect(logger).to receive(:warn).with("Next request in #{(i+1)*2}s...")
258
+ expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to Knapsack Pro API.")
259
+ 19.times do |i|
260
+ expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
261
261
  end
262
262
 
263
263
  expect(Kernel).to receive(:sleep).exactly(60).with(2)
@@ -238,6 +238,20 @@ describe KnapsackPro::Config::Env do
238
238
  end
239
239
  end
240
240
 
241
+ describe '.test_file_list_source_file' do
242
+ subject { described_class.test_file_list_source_file }
243
+
244
+ context 'when ENV exists' do
245
+ let(:test_file_list_source_file) { 'spec/fixtures/test_file_list_source_file.txt' }
246
+ before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE' => test_file_list_source_file }) }
247
+ it { should eq test_file_list_source_file }
248
+ end
249
+
250
+ context "when ENV doesn't exist" do
251
+ it { should be_nil }
252
+ end
253
+ end
254
+
241
255
  describe '.test_dir' do
242
256
  subject { described_class.test_dir }
243
257
 
@@ -67,7 +67,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
67
67
  let(:exit_code) { 1 }
68
68
 
69
69
  it do
70
- expect { subject }.to raise_error(RuntimeError, 'There was problem to generate test examples for test suite')
70
+ expect { subject }.to raise_error(RuntimeError, 'There was a problem while generating test examples for the slow test files. Please read actionable error message above.')
71
71
  end
72
72
  end
73
73
  end
@@ -154,5 +154,23 @@ describe KnapsackPro::TestFileFinder do
154
154
  end
155
155
  end
156
156
  end
157
+
158
+ context 'when KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE is defined' do
159
+ let(:test_file_list_source_file) { 'spec/fixtures/test_file_list_source_file.txt' }
160
+
161
+ before do
162
+ stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE' => test_file_list_source_file })
163
+ end
164
+
165
+ it do
166
+ expect(subject).to eq([
167
+ { 'path' => 'spec/test1_spec.rb' },
168
+ { 'path' => 'spec/test2_spec.rb[1]' },
169
+ { 'path' => 'spec/test3_spec.rb[1:2:3:4]' },
170
+ { 'path' => 'spec/test4_spec.rb:4' },
171
+ { 'path' => 'spec/test4_spec.rb:5' },
172
+ ])
173
+ end
174
+ end
157
175
  end
158
176
  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: 2.3.0
4
+ version: 2.8.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-09-10 00:00:00.000000000 Z
11
+ date: 2020-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -308,6 +308,7 @@ files:
308
308
  - lib/tasks/salt.rake
309
309
  - lib/tasks/spinach.rake
310
310
  - lib/tasks/test_unit.rake
311
+ - spec/fixtures/test_file_list_source_file.txt
311
312
  - spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml
312
313
  - spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml
313
314
  - spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml
@@ -428,6 +429,7 @@ specification_version: 4
428
429
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
429
430
  job finish work at a similar time.
430
431
  test_files:
432
+ - spec/fixtures/test_file_list_source_file.txt
431
433
  - spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml
432
434
  - spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml
433
435
  - spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml