knapsack_pro 8.3.3 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -1
- data/.gitignore +0 -1
- data/CHANGELOG.md +9 -1
- data/README.md +1 -1
- data/lib/knapsack_pro/client/api/v1/queues.rb +1 -0
- data/lib/knapsack_pro/queue_allocator.rb +13 -12
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +3 -1
- data/spec/knapsack_pro/config/env_spec.rb +330 -352
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +448 -0
- data/spec_time_tracker/spec_helper.rb +29 -0
- metadata +4 -4
- data/bin/test +0 -15
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +0 -545
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17dceae7090394f68959e5b8bdef4c0640ce4027b28efe41fb8f3d612b5f0348
|
4
|
+
data.tar.gz: 5828288a2160348d9acce467e17d16da00e8f794aa39e70d0d0b5fecc0b9188c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abf9abe76b5e0841d95c09230cd88289e6c197a26dad27cd2a9c7f2fe97310c9d1fbe1ddb77134676c604daa7a28bd8d6c405598262f9623a9110c5b7ce15751
|
7
|
+
data.tar.gz: 7c9a0f978b8f01b2e5ad888535ddfbaf006b20da5a5853edc454dd82044f1608b2ce9d21acd25a00c77146bbad7e0954d76f5fc2ae541970cdfd9feaee0bc45e
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,17 @@
|
|
2
2
|
|
3
3
|
### UNRELEASED (patch)
|
4
4
|
|
5
|
+
### 8.4.0
|
6
|
+
|
7
|
+
* Add a batch UUID to the V1 Queue API request payload to improve handling of retried requests
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/307
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.3...v8.4.0
|
12
|
+
|
5
13
|
### 8.3.3
|
6
14
|
|
7
|
-
*
|
15
|
+
* Replace `Hash#sum` with `Hash#reduce` to fix a rare bug in the RSpec time tracker for a specific project
|
8
16
|
|
9
17
|
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/305
|
10
18
|
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ bundle update knapsack_pro
|
|
67
67
|
RSpec:
|
68
68
|
|
69
69
|
```bash
|
70
|
-
|
70
|
+
bundle exec rspec
|
71
71
|
```
|
72
72
|
|
73
73
|
Scripted tests can be found in the [Rails App With Knapsack Pro repository](https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/master/bin/knapsack_pro_all.rb).
|
@@ -19,6 +19,7 @@ module KnapsackPro
|
|
19
19
|
:node_index => args.fetch(:node_index),
|
20
20
|
:node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
|
21
21
|
:user_seat => KnapsackPro::Config::Env.masked_user_seat,
|
22
|
+
batch_uuid: args.fetch(:batch_uuid)
|
22
23
|
}
|
23
24
|
|
24
25
|
if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
|
@@ -41,26 +41,26 @@ module KnapsackPro
|
|
41
41
|
@fallback_mode = false
|
42
42
|
end
|
43
43
|
|
44
|
-
def test_file_paths(can_initialize_queue, executed_test_files)
|
44
|
+
def test_file_paths(can_initialize_queue, executed_test_files, batch_uuid: SecureRandom.uuid)
|
45
45
|
return [] if @fallback_mode
|
46
46
|
|
47
|
-
batch = pull_tests_from_queue(can_initialize_queue)
|
47
|
+
batch = pull_tests_from_queue(can_initialize_queue, batch_uuid)
|
48
48
|
|
49
49
|
return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed?
|
50
50
|
return normalize_test_files(batch.test_files) if batch.queue_exists?
|
51
51
|
|
52
52
|
test_files_result = test_suite.calculate_test_files
|
53
53
|
|
54
|
-
return try_initializing_queue(test_files_result.test_files) if test_files_result.quick?
|
54
|
+
return try_initializing_queue(test_files_result.test_files, batch_uuid) if test_files_result.quick?
|
55
55
|
|
56
56
|
# The tests to run were found slowly. By that time, the queue could have already been initialized by another CI node.
|
57
57
|
# Attempt to pull tests from the queue to avoid the attempt to initialize the queue unnecessarily (queue initialization is an expensive request with a big test files payload).
|
58
|
-
batch = pull_tests_from_queue(can_initialize_queue)
|
58
|
+
batch = pull_tests_from_queue(can_initialize_queue, batch_uuid)
|
59
59
|
|
60
60
|
return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed?
|
61
61
|
return normalize_test_files(batch.test_files) if batch.queue_exists?
|
62
62
|
|
63
|
-
try_initializing_queue(test_files_result.test_files)
|
63
|
+
try_initializing_queue(test_files_result.test_files, batch_uuid)
|
64
64
|
end
|
65
65
|
|
66
66
|
private
|
@@ -80,7 +80,7 @@ module KnapsackPro
|
|
80
80
|
KnapsackPro::TestFilePresenter.paths(decrypted_test_files)
|
81
81
|
end
|
82
82
|
|
83
|
-
def build_action(can_initialize_queue:, attempt_connect_to_queue:, test_files: nil)
|
83
|
+
def build_action(can_initialize_queue:, attempt_connect_to_queue:, batch_uuid:, test_files: nil)
|
84
84
|
if can_initialize_queue && !attempt_connect_to_queue
|
85
85
|
raise 'Test files are required when initializing a new queue.' if test_files.nil?
|
86
86
|
test_files = KnapsackPro::Crypto::Encryptor.call(test_files)
|
@@ -95,25 +95,26 @@ module KnapsackPro
|
|
95
95
|
node_index: ci_node_index,
|
96
96
|
node_build_id: ci_node_build_id,
|
97
97
|
test_files: test_files,
|
98
|
+
batch_uuid: batch_uuid
|
98
99
|
)
|
99
100
|
end
|
100
101
|
|
101
|
-
def pull_tests_from_queue(can_initialize_queue)
|
102
|
-
action = build_action(can_initialize_queue: can_initialize_queue, attempt_connect_to_queue: can_initialize_queue)
|
102
|
+
def pull_tests_from_queue(can_initialize_queue, batch_uuid)
|
103
|
+
action = build_action(can_initialize_queue: can_initialize_queue, attempt_connect_to_queue: can_initialize_queue, batch_uuid: batch_uuid)
|
103
104
|
connection = KnapsackPro::Client::Connection.new(action)
|
104
105
|
response = connection.call
|
105
106
|
Batch.new(connection, response)
|
106
107
|
end
|
107
108
|
|
108
|
-
def initialize_queue(tests_to_run)
|
109
|
-
action = build_action(can_initialize_queue: true, attempt_connect_to_queue: false, test_files: tests_to_run)
|
109
|
+
def initialize_queue(tests_to_run, batch_uuid)
|
110
|
+
action = build_action(can_initialize_queue: true, attempt_connect_to_queue: false, batch_uuid: batch_uuid, test_files: tests_to_run)
|
110
111
|
connection = KnapsackPro::Client::Connection.new(action)
|
111
112
|
response = connection.call
|
112
113
|
Batch.new(connection, response)
|
113
114
|
end
|
114
115
|
|
115
|
-
def try_initializing_queue(tests)
|
116
|
-
result = initialize_queue(tests)
|
116
|
+
def try_initializing_queue(tests, batch_uuid)
|
117
|
+
result = initialize_queue(tests, batch_uuid)
|
117
118
|
|
118
119
|
return switch_to_fallback_mode(executed_test_files: []) if result.connection_failed?
|
119
120
|
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -10,6 +10,7 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
10
10
|
let(:masked_user_seat) { double }
|
11
11
|
let(:can_initialize_queue) { [false, true].sample }
|
12
12
|
let(:attempt_connect_to_queue) { [false, true].sample }
|
13
|
+
let(:batch_uuid) { SecureRandom.uuid }
|
13
14
|
|
14
15
|
subject do
|
15
16
|
described_class.queue(
|
@@ -19,7 +20,8 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
19
20
|
branch: branch,
|
20
21
|
node_total: node_total,
|
21
22
|
node_index: node_index,
|
22
|
-
test_files: test_files
|
23
|
+
test_files: test_files,
|
24
|
+
batch_uuid: batch_uuid
|
23
25
|
)
|
24
26
|
end
|
25
27
|
|