knapsack_pro 2.10.0 → 2.10.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 +8 -0
- data/lib/knapsack_pro/base_allocator_builder.rb +0 -8
- data/lib/knapsack_pro/queue_allocator.rb +8 -19
- data/lib/knapsack_pro/queue_allocator_builder.rb +2 -2
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/queue_allocator_builder_spec.rb +6 -6
- data/spec/knapsack_pro/queue_allocator_spec.rb +33 -71
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b0ef524a80bd3e88c8c12c631880e644734fc8be8253bd4aa8d9c58fcc2dc48
|
4
|
+
data.tar.gz: 7fa53878c1cbf1fb421f2637c98db03133654df1abf07d058179b2516a01da49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6faf1e8b52b3d93c424945e560dba8caeda53a208b002c370b2e050f31aafbffd66856e06e7475043891923ef5315f40a3f6ee9e58fad243eb91fc12bde47ad7
|
7
|
+
data.tar.gz: c4767bf21996e966db844779e177b10086626b6a8bfd7ffd67333842aa2376814234b54a00a945b70a676d481c70bea07ae74480c3f2359e5ab7588490194eca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 2.10.1
|
4
|
+
|
5
|
+
* Fix RSpec split by test examples feature broken by lazy generating of JSON report with test example ids
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/135
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.10.0...v2.10.1
|
10
|
+
|
3
11
|
### 2.10.0
|
4
12
|
|
5
13
|
* Add support for an attempt to connect to existing Queue on API side to reduce slow requests number
|
@@ -28,10 +28,6 @@ module KnapsackPro
|
|
28
28
|
all_test_files_to_run
|
29
29
|
end
|
30
30
|
|
31
|
-
def lazy_fallback_mode_test_files
|
32
|
-
lambda { fallback_mode_test_files }
|
33
|
-
end
|
34
|
-
|
35
31
|
# detect test files present on the disk that should be run
|
36
32
|
# this may include some fast test files + slow test files split by test cases
|
37
33
|
def fast_and_slow_test_files_to_run
|
@@ -67,10 +63,6 @@ module KnapsackPro
|
|
67
63
|
end
|
68
64
|
end
|
69
65
|
|
70
|
-
def lazy_fast_and_slow_test_files_to_run
|
71
|
-
lambda { fast_and_slow_test_files_to_run }
|
72
|
-
end
|
73
|
-
|
74
66
|
private
|
75
67
|
|
76
68
|
attr_reader :adapter_class
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module KnapsackPro
|
2
2
|
class QueueAllocator
|
3
3
|
def initialize(args)
|
4
|
-
@
|
5
|
-
@
|
4
|
+
@fast_and_slow_test_files_to_run = args.fetch(:fast_and_slow_test_files_to_run)
|
5
|
+
@fallback_mode_test_files = args.fetch(:fallback_mode_test_files)
|
6
6
|
@ci_node_total = args.fetch(:ci_node_total)
|
7
7
|
@ci_node_index = args.fetch(:ci_node_index)
|
8
8
|
@ci_node_build_id = args.fetch(:ci_node_build_id)
|
@@ -46,21 +46,15 @@ module KnapsackPro
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
attr_reader :
|
50
|
-
:
|
49
|
+
attr_reader :fast_and_slow_test_files_to_run,
|
50
|
+
:fallback_mode_test_files,
|
51
51
|
:ci_node_total,
|
52
52
|
:ci_node_index,
|
53
53
|
:ci_node_build_id,
|
54
54
|
:repository_adapter
|
55
55
|
|
56
|
-
# This method might be slow because it reads test files from disk.
|
57
|
-
# This method can be very slow (a few seconds or more) when you use RSpec split by test examples feature because RSpec needs to generate JSON report with test examples ids
|
58
|
-
def lazy_loaded_fast_and_slow_test_files_to_run
|
59
|
-
@lazy_loaded_fast_and_slow_test_files_to_run ||= lazy_fast_and_slow_test_files_to_run.call
|
60
|
-
end
|
61
|
-
|
62
56
|
def encrypted_test_files
|
63
|
-
KnapsackPro::Crypto::Encryptor.call(
|
57
|
+
KnapsackPro::Crypto::Encryptor.call(fast_and_slow_test_files_to_run)
|
64
58
|
end
|
65
59
|
|
66
60
|
def encrypted_branch
|
@@ -87,17 +81,12 @@ module KnapsackPro
|
|
87
81
|
end
|
88
82
|
|
89
83
|
def prepare_test_files(response)
|
90
|
-
|
91
|
-
|
92
|
-
decrypted_test_files = KnapsackPro::Crypto::Decryptor.call(lazy_loaded_fast_and_slow_test_files_to_run, response['test_files'])
|
93
|
-
KnapsackPro::TestFilePresenter.paths(decrypted_test_files)
|
94
|
-
else
|
95
|
-
KnapsackPro::TestFilePresenter.paths(response['test_files'])
|
96
|
-
end
|
84
|
+
decrypted_test_files = KnapsackPro::Crypto::Decryptor.call(fast_and_slow_test_files_to_run, response['test_files'])
|
85
|
+
KnapsackPro::TestFilePresenter.paths(decrypted_test_files)
|
97
86
|
end
|
98
87
|
|
99
88
|
def fallback_test_files(executed_test_files)
|
100
|
-
test_flat_distributor = KnapsackPro::TestFlatDistributor.new(
|
89
|
+
test_flat_distributor = KnapsackPro::TestFlatDistributor.new(fallback_mode_test_files, ci_node_total)
|
101
90
|
test_files_for_node_index = test_flat_distributor.test_files_for_node(ci_node_index)
|
102
91
|
KnapsackPro::TestFilePresenter.paths(test_files_for_node_index) - executed_test_files
|
103
92
|
end
|
@@ -2,8 +2,8 @@ module KnapsackPro
|
|
2
2
|
class QueueAllocatorBuilder < BaseAllocatorBuilder
|
3
3
|
def allocator
|
4
4
|
KnapsackPro::QueueAllocator.new(
|
5
|
-
|
6
|
-
|
5
|
+
fast_and_slow_test_files_to_run: fast_and_slow_test_files_to_run,
|
6
|
+
fallback_mode_test_files: fallback_mode_test_files,
|
7
7
|
ci_node_total: env.ci_node_total,
|
8
8
|
ci_node_index: env.ci_node_index,
|
9
9
|
ci_node_build_id: env.ci_node_build_id,
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -8,11 +8,11 @@ describe KnapsackPro::QueueAllocatorBuilder do
|
|
8
8
|
subject { allocator_builder.allocator }
|
9
9
|
|
10
10
|
before do
|
11
|
-
|
12
|
-
expect(allocator_builder).to receive(:
|
11
|
+
fast_and_slow_test_files_to_run = double
|
12
|
+
expect(allocator_builder).to receive(:fast_and_slow_test_files_to_run).and_return(fast_and_slow_test_files_to_run)
|
13
13
|
|
14
|
-
|
15
|
-
expect(allocator_builder).to receive(:
|
14
|
+
fallback_mode_test_files = double
|
15
|
+
expect(allocator_builder).to receive(:fallback_mode_test_files).and_return(fallback_mode_test_files)
|
16
16
|
|
17
17
|
repository_adapter = double
|
18
18
|
expect(KnapsackPro::RepositoryAdapterInitiator).to receive(:call).and_return(repository_adapter)
|
@@ -25,8 +25,8 @@ describe KnapsackPro::QueueAllocatorBuilder do
|
|
25
25
|
expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(ci_node_build_id)
|
26
26
|
|
27
27
|
expect(KnapsackPro::QueueAllocator).to receive(:new).with(
|
28
|
-
|
29
|
-
|
28
|
+
fast_and_slow_test_files_to_run: fast_and_slow_test_files_to_run,
|
29
|
+
fallback_mode_test_files: fallback_mode_test_files,
|
30
30
|
ci_node_total: ci_node_total,
|
31
31
|
ci_node_index: ci_node_index,
|
32
32
|
ci_node_build_id: ci_node_build_id,
|
@@ -1,8 +1,6 @@
|
|
1
1
|
describe KnapsackPro::QueueAllocator do
|
2
|
-
let(:
|
3
|
-
let(:
|
4
|
-
let(:lazy_loaded_fallback_mode_test_files) { double }
|
5
|
-
let(:lazy_fallback_mode_test_files) { double(call: lazy_loaded_fallback_mode_test_files) }
|
2
|
+
let(:fast_and_slow_test_files_to_run) { double }
|
3
|
+
let(:fallback_mode_test_files) { double }
|
6
4
|
let(:ci_node_total) { double }
|
7
5
|
let(:ci_node_index) { double }
|
8
6
|
let(:ci_node_build_id) { double }
|
@@ -10,8 +8,8 @@ describe KnapsackPro::QueueAllocator do
|
|
10
8
|
|
11
9
|
let(:queue_allocator) do
|
12
10
|
described_class.new(
|
13
|
-
|
14
|
-
|
11
|
+
fast_and_slow_test_files_to_run: fast_and_slow_test_files_to_run,
|
12
|
+
fallback_mode_test_files: fallback_mode_test_files,
|
15
13
|
ci_node_total: ci_node_total,
|
16
14
|
ci_node_index: ci_node_index,
|
17
15
|
ci_node_build_id: ci_node_build_id,
|
@@ -66,7 +64,7 @@ describe KnapsackPro::QueueAllocator do
|
|
66
64
|
context 'when fallback mode started' do
|
67
65
|
before do
|
68
66
|
test_flat_distributor = instance_double(KnapsackPro::TestFlatDistributor)
|
69
|
-
expect(KnapsackPro::TestFlatDistributor).to receive(:new).with(
|
67
|
+
expect(KnapsackPro::TestFlatDistributor).to receive(:new).with(fallback_mode_test_files, ci_node_total).and_return(test_flat_distributor)
|
70
68
|
expect(test_flat_distributor).to receive(:test_files_for_node).with(ci_node_index).and_return([
|
71
69
|
{ 'path' => 'c_spec.rb' },
|
72
70
|
{ 'path' => 'd_spec.rb' },
|
@@ -133,32 +131,20 @@ describe KnapsackPro::QueueAllocator do
|
|
133
131
|
let(:errors?) { false }
|
134
132
|
|
135
133
|
context 'when response returns test files (successful attempt to connect to queue already existing on the API side)' do
|
136
|
-
let(:test_files) do
|
137
|
-
[
|
138
|
-
{ 'path' => 'a_spec.rb' },
|
139
|
-
{ 'path' => 'b_spec.rb' },
|
140
|
-
]
|
141
|
-
end
|
142
134
|
let(:response) do
|
143
|
-
{
|
135
|
+
{
|
136
|
+
'test_files' => [
|
137
|
+
{ 'path' => 'a_spec.rb' },
|
138
|
+
{ 'path' => 'b_spec.rb' },
|
139
|
+
]
|
140
|
+
}
|
144
141
|
end
|
145
142
|
|
146
|
-
|
147
|
-
|
148
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(true)
|
149
|
-
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(lazy_loaded_fast_and_slow_test_files_to_run, response['test_files']).and_return(test_files)
|
150
|
-
end
|
151
|
-
|
152
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
143
|
+
before do
|
144
|
+
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(fast_and_slow_test_files_to_run, response['test_files']).and_call_original
|
153
145
|
end
|
154
146
|
|
155
|
-
|
156
|
-
before do
|
157
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(false)
|
158
|
-
end
|
159
|
-
|
160
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
161
|
-
end
|
147
|
+
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
162
148
|
end
|
163
149
|
|
164
150
|
context 'when response has code=ATTEMPT_CONNECT_TO_QUEUE_FAILED' do
|
@@ -172,7 +158,7 @@ describe KnapsackPro::QueueAllocator do
|
|
172
158
|
expect(KnapsackPro::Crypto::BranchEncryptor).to receive(:call).with(repository_adapter.branch).and_return(encrypted_branch)
|
173
159
|
|
174
160
|
encrypted_test_files = double
|
175
|
-
expect(KnapsackPro::Crypto::Encryptor).to receive(:call).with(
|
161
|
+
expect(KnapsackPro::Crypto::Encryptor).to receive(:call).with(fast_and_slow_test_files_to_run).and_return(encrypted_test_files)
|
176
162
|
|
177
163
|
# 2nd request is no more an attempt to connect to queue.
|
178
164
|
# We want to try to initalize a new queue so we will also send list of test files from disk.
|
@@ -212,32 +198,20 @@ describe KnapsackPro::QueueAllocator do
|
|
212
198
|
let(:response2_errors?) { false }
|
213
199
|
|
214
200
|
context 'when 2nd response returns test files (successful attempt to connect to queue already existing on the API side)' do
|
215
|
-
let(:test_files) do
|
216
|
-
[
|
217
|
-
{ 'path' => 'a_spec.rb' },
|
218
|
-
{ 'path' => 'b_spec.rb' },
|
219
|
-
]
|
220
|
-
end
|
221
201
|
let(:response2) do
|
222
|
-
{
|
202
|
+
{
|
203
|
+
'test_files' => [
|
204
|
+
{ 'path' => 'a_spec.rb' },
|
205
|
+
{ 'path' => 'b_spec.rb' },
|
206
|
+
]
|
207
|
+
}
|
223
208
|
end
|
224
209
|
|
225
|
-
|
226
|
-
|
227
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(true)
|
228
|
-
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(lazy_loaded_fast_and_slow_test_files_to_run, response2['test_files']).and_return(test_files)
|
229
|
-
end
|
230
|
-
|
231
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
210
|
+
before do
|
211
|
+
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(fast_and_slow_test_files_to_run, response2['test_files']).and_call_original
|
232
212
|
end
|
233
213
|
|
234
|
-
|
235
|
-
before do
|
236
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(false)
|
237
|
-
end
|
238
|
-
|
239
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
240
|
-
end
|
214
|
+
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
241
215
|
end
|
242
216
|
end
|
243
217
|
end
|
@@ -304,32 +278,20 @@ describe KnapsackPro::QueueAllocator do
|
|
304
278
|
let(:errors?) { false }
|
305
279
|
|
306
280
|
context 'when response returns test files (successful attempt to connect to queue already existing on the API side)' do
|
307
|
-
let(:test_files) do
|
308
|
-
[
|
309
|
-
{ 'path' => 'a_spec.rb' },
|
310
|
-
{ 'path' => 'b_spec.rb' },
|
311
|
-
]
|
312
|
-
end
|
313
281
|
let(:response) do
|
314
|
-
{
|
282
|
+
{
|
283
|
+
'test_files' => [
|
284
|
+
{ 'path' => 'a_spec.rb' },
|
285
|
+
{ 'path' => 'b_spec.rb' },
|
286
|
+
]
|
287
|
+
}
|
315
288
|
end
|
316
289
|
|
317
|
-
|
318
|
-
|
319
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(true)
|
320
|
-
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(lazy_loaded_fast_and_slow_test_files_to_run, response['test_files']).and_return(test_files)
|
321
|
-
end
|
322
|
-
|
323
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
290
|
+
before do
|
291
|
+
expect(KnapsackPro::Crypto::Decryptor).to receive(:call).with(fast_and_slow_test_files_to_run, response['test_files']).and_call_original
|
324
292
|
end
|
325
293
|
|
326
|
-
|
327
|
-
before do
|
328
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(false)
|
329
|
-
end
|
330
|
-
|
331
|
-
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
332
|
-
end
|
294
|
+
it { should eq ['a_spec.rb', 'b_spec.rb'] }
|
333
295
|
end
|
334
296
|
end
|
335
297
|
end
|