knapsack_pro 1.21.0 → 1.22.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: 59df1c0c620e9c92fb18e3963029fd02df6f04754ffe1b5c590cd7ca45159f55
4
- data.tar.gz: 5cf6b36b8f908d8dbb9788918f7586c3b0334ec91a3a79afd768fbde3a8088b2
3
+ metadata.gz: 6c1620234d6399fb4f66840cc101d290f70e9b8c6bbb6c7f2df7b2f2fa16062a
4
+ data.tar.gz: f0d3b9c93244b37baa1817bb2b910d1e4e1f3a84e13482f90755a528a04c8a5a
5
5
  SHA512:
6
- metadata.gz: ae228667bbd897ad31512140d6c6382aefe2fce977748f909b3da7cca7a39495731cde4e079cd8a0247bd2d332fe8809aecf69fe773c34f864e74febc0a4dbbc
7
- data.tar.gz: fc8255bc114f010a6a85a14aa98dab171767769e8476c3c422fd92e17198588e767f08bdb1072ca36c5038aef23af4396a8b44fa271b720845f26bd16fbae32b
6
+ metadata.gz: 5bfe8f48e23514d4dc3c9dd957fbaa5d14d39fae4b9c6eb5c9426eeaae9a57007fb379d6a00860ea30b4cb9766444678e55bf306bba742cf80d470387e22c9a7
7
+ data.tar.gz: 171de7e1e9c7dbf18b291ffd0f183459e0b9a41b0c60ff2c15de4867db6c07caefcae8e3d57718a001e04c49320878cc022656cfc82709b948e48770dafb2b5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.22.0
4
+
5
+ * 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
6
+ * When Fallback Mode is disabled with env `KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false` then retry the request to Knapsack Pro API for 6 times instead of only 3 times.
7
+
8
+ Here is related [info why some users want to disable Fallback Mode](https://github.com/KnapsackPro/knapsack_pro-ruby#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).
9
+
10
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/112
11
+
12
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.21.0...v1.22.0
13
+
3
14
  ### 1.21.0
4
15
 
5
16
  * Automatically detect slow test files for RSpec and split them by test examples when `KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true`
@@ -4,8 +4,8 @@ module KnapsackPro
4
4
  class ServerError < StandardError; end
5
5
 
6
6
  TIMEOUT = 15
7
- MAX_RETRY = 3
8
- REQUEST_RETRY_TIMEBOX = 4
7
+ MAX_RETRY = -> { KnapsackPro::Config::Env.fallback_mode_enabled? ? 3 : 6 }
8
+ REQUEST_RETRY_TIMEBOX = 8
9
9
 
10
10
  def initialize(action)
11
11
  @action = action
@@ -118,7 +118,7 @@ module KnapsackPro
118
118
  rescue ServerError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::EPIPE, EOFError, SocketError, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError => e
119
119
  logger.warn(e.inspect)
120
120
  retries += 1
121
- if retries < MAX_RETRY
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
  Kernel.sleep(wait)
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.21.0'
2
+ VERSION = '1.22.0'
3
3
  end
@@ -72,12 +72,13 @@ shared_examples 'when retry request' do
72
72
 
73
73
  before do
74
74
  expect(KnapsackPro).to receive(:logger).at_least(1).and_return(logger)
75
+ end
76
+
77
+ it do
75
78
  expect(logger).to receive(:debug).exactly(3).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
76
79
  expect(logger).to receive(:debug).exactly(3).with('API request UUID: fake-uuid')
77
80
  expect(logger).to receive(:debug).exactly(3).with('API response:')
78
- end
79
81
 
80
- it do
81
82
  parsed_response = { 'error' => 'Internal Server Error' }
82
83
 
83
84
  expect(logger).to receive(:error).exactly(3).with(parsed_response)
@@ -85,16 +86,51 @@ shared_examples 'when retry request' do
85
86
  server_error = described_class::ServerError.new(parsed_response)
86
87
  expect(logger).to receive(:warn).exactly(3).with(server_error.inspect)
87
88
 
88
- expect(logger).to receive(:warn).with("Wait 4s and retry request to Knapsack Pro API.")
89
89
  expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
90
- expect(Kernel).to receive(:sleep).with(4)
90
+ expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
91
91
  expect(Kernel).to receive(:sleep).with(8)
92
+ expect(Kernel).to receive(:sleep).with(16)
92
93
 
93
94
  expect(subject).to eq(parsed_response)
94
95
 
95
96
  expect(connection.success?).to be false
96
97
  expect(connection.errors?).to be true
97
98
  end
99
+
100
+ context 'when Fallback Mode is disabled' do
101
+ before do
102
+ expect(KnapsackPro::Config::Env).to receive(:fallback_mode_enabled?).at_least(1).and_return(false)
103
+ end
104
+
105
+ it do
106
+ expect(logger).to receive(:debug).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
107
+ expect(logger).to receive(:debug).exactly(6).with('API request UUID: fake-uuid')
108
+ expect(logger).to receive(:debug).exactly(6).with('API response:')
109
+
110
+ parsed_response = { 'error' => 'Internal Server Error' }
111
+
112
+ expect(logger).to receive(:error).exactly(6).with(parsed_response)
113
+
114
+ server_error = described_class::ServerError.new(parsed_response)
115
+ expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
116
+
117
+ expect(logger).to receive(:warn).with("Wait 8s and retry request to Knapsack Pro API.")
118
+ expect(logger).to receive(:warn).with("Wait 16s and retry request to Knapsack Pro API.")
119
+ expect(logger).to receive(:warn).with("Wait 24s and retry request to Knapsack Pro API.")
120
+ expect(logger).to receive(:warn).with("Wait 32s and retry request to Knapsack Pro API.")
121
+ expect(logger).to receive(:warn).with("Wait 40s and retry request to Knapsack Pro API.")
122
+ expect(Kernel).to receive(:sleep).with(8)
123
+ expect(Kernel).to receive(:sleep).with(16)
124
+ expect(Kernel).to receive(:sleep).with(24)
125
+ expect(Kernel).to receive(:sleep).with(32)
126
+ expect(Kernel).to receive(:sleep).with(40)
127
+
128
+ expect(subject).to eq(parsed_response)
129
+
130
+ expect(connection.success?).to be false
131
+ expect(connection.errors?).to be true
132
+ end
133
+ end
98
134
  end
99
135
  end
100
136
 
@@ -186,7 +222,7 @@ describe KnapsackPro::Client::Connection do
186
222
  let(:http_method) { :post }
187
223
 
188
224
  before do
189
- expect(http).to receive(:post).exactly(3).with(
225
+ expect(http).to receive(:post).at_least(3).with(
190
226
  endpoint_path,
191
227
  request_hash.to_json,
192
228
  {
@@ -210,7 +246,7 @@ describe KnapsackPro::Client::Connection do
210
246
  before do
211
247
  uri = URI.parse("http://api.knapsackpro.test:3000#{endpoint_path}")
212
248
  uri.query = URI.encode_www_form(request_hash)
213
- expect(http).to receive(:get).exactly(3).with(
249
+ expect(http).to receive(:get).at_least(3).with(
214
250
  uri,
215
251
  {
216
252
  'Content-Type' => 'application/json',
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.21.0
4
+ version: 1.22.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-05-06 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake