knapsack_pro 9.0.0 → 9.1.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/lib/knapsack_pro/adapters/minitest_adapter.rb +8 -13
- data/lib/knapsack_pro/client/connection.rb +1 -1
- data/lib/knapsack_pro/config/env.rb +1 -24
- data/lib/knapsack_pro/version.rb +1 -1
- metadata +2 -196
- data/.circleci/config.yml +0 -468
- data/.github/assets/install-button.png +0 -0
- data/.github/assets/knapsack-diamonds.png +0 -0
- data/.github/dependabot.yml +0 -11
- data/.github/pull_request_template.md +0 -11
- data/.gitignore +0 -39
- data/.rspec +0 -5
- data/CHANGELOG.md +0 -1995
- data/Gemfile +0 -13
- data/LICENSE +0 -22
- data/README.md +0 -90
- data/Rakefile +0 -2
- data/knapsack_pro.gemspec +0 -43
- data/spec/fixtures/test_file_list_source_file.txt +0 -6
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml +0 -59
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml +0 -61
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml +0 -50
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml +0 -50
- data/spec/integration/api/build_distributions_subset_spec.rb +0 -77
- data/spec/integration/api/build_subsets_create_spec.rb +0 -77
- data/spec/integration/runners/fallback_spec.rb +0 -131
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/rspec_runner.rb +0 -80
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +0 -137
- data/spec/integration/runners/queue/rspec_runner_spec.rb +0 -2672
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +0 -221
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +0 -216
- data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +0 -189
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +0 -427
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +0 -61
- data/spec/knapsack_pro/adapters/test_unit_adapter_spec.rb +0 -86
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +0 -102
- data/spec/knapsack_pro/build_distribution_fetcher_spec.rb +0 -89
- data/spec/knapsack_pro/client/api/action_spec.rb +0 -17
- data/spec/knapsack_pro/client/api/v1/base_spec.rb +0 -2
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +0 -95
- data/spec/knapsack_pro/client/api/v1/build_subsets_spec.rb +0 -35
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +0 -83
- data/spec/knapsack_pro/client/connection_spec.rb +0 -581
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/base_spec.rb +0 -10
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +0 -135
- data/spec/knapsack_pro/config/ci/circle_spec.rb +0 -122
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +0 -81
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +0 -80
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +0 -140
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +0 -137
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +0 -133
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/travis_spec.rb +0 -73
- data/spec/knapsack_pro/config/env_generator_spec.rb +0 -52
- data/spec/knapsack_pro/config/env_spec.rb +0 -1291
- data/spec/knapsack_pro/config/temp_files_spec.rb +0 -25
- data/spec/knapsack_pro/crypto/branch_encryptor_spec.rb +0 -53
- data/spec/knapsack_pro/crypto/decryptor_spec.rb +0 -83
- data/spec/knapsack_pro/crypto/digestor_spec.rb +0 -13
- data/spec/knapsack_pro/crypto/encryptor_spec.rb +0 -58
- data/spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb +0 -27
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +0 -448
- data/spec/knapsack_pro/hooks/queue_spec.rb +0 -199
- data/spec/knapsack_pro/presenter_spec.rb +0 -57
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +0 -248
- data/spec/knapsack_pro/queue_spec.rb +0 -35
- data/spec/knapsack_pro/report_spec.rb +0 -232
- data/spec/knapsack_pro/repository_adapter_initiator_spec.rb +0 -21
- data/spec/knapsack_pro/repository_adapters/base_adapter_spec.rb +0 -13
- data/spec/knapsack_pro/repository_adapters/env_adapter_spec.rb +0 -27
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +0 -106
- data/spec/knapsack_pro/runners/base_runner_spec.rb +0 -87
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +0 -92
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +0 -57
- data/spec/knapsack_pro/runners/queue/base_runner_spec.rb +0 -73
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +0 -209
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +0 -203
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +0 -111
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +0 -56
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +0 -62
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +0 -119
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +0 -42
- data/spec/knapsack_pro/task_loader_spec.rb +0 -14
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +0 -217
- data/spec/knapsack_pro/test_case_mergers/base_merger_spec.rb +0 -27
- data/spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb +0 -81
- data/spec/knapsack_pro/test_file_cleaner_spec.rb +0 -11
- data/spec/knapsack_pro/test_file_finder_spec.rb +0 -176
- data/spec/knapsack_pro/test_file_pattern_spec.rb +0 -49
- data/spec/knapsack_pro/test_file_presenter_spec.rb +0 -22
- data/spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb +0 -41
- data/spec/knapsack_pro/test_flat_distributor_spec.rb +0 -60
- data/spec/knapsack_pro/tracker_spec.rb +0 -184
- data/spec/knapsack_pro/utils_spec.rb +0 -55
- data/spec/knapsack_pro_spec.rb +0 -116
- data/spec/spec_helper.rb +0 -47
- data/spec/support/.gitkeep +0 -0
- data/spec/support/fakes/cucumber.rb +0 -25
- data/spec/support/fakes/minitest.rb +0 -18
- data/spec/support/shared_examples/adapter.rb +0 -17
- data/spec_fake/controllers/users_controller_spec.rb +0 -0
- data/spec_fake/models/admin_spec.rb +0 -0
- data/spec_fake/models/user_spec.rb +0 -0
- data/spec_fake/spec_helper.rb +0 -0
- data/spec_time_tracker/spec_helper.rb +0 -29
- data/test_fake/a_test.rb +0 -0
- data/test_fake/b_test.rb +0 -0
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
shared_examples 'when request got response from API' do
|
|
2
|
-
context 'when body response is JSON and API response code is 400' do
|
|
3
|
-
let(:body) { '{"errors": "value"}' }
|
|
4
|
-
let(:code) { '400' } # it must be string code
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
|
|
8
|
-
expect(logger).to receive(:debug).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
9
|
-
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
|
10
|
-
expect(logger).to receive(:debug).with('API response:')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it do
|
|
14
|
-
parsed_response = { 'errors' => 'value' }
|
|
15
|
-
|
|
16
|
-
expect(logger).to receive(:error).with(parsed_response)
|
|
17
|
-
|
|
18
|
-
expect(subject).to eq(parsed_response)
|
|
19
|
-
expect(connection.success?).to be true
|
|
20
|
-
expect(connection.errors?).to be true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'when body response is JSON with build_distribution_id' do
|
|
25
|
-
let(:body) { '{"build_distribution_id": "seed-uuid"}' }
|
|
26
|
-
let(:code) { '200' } # it must be string code
|
|
27
|
-
|
|
28
|
-
before do
|
|
29
|
-
expect(KnapsackPro).to receive(:logger).exactly(5).and_return(logger)
|
|
30
|
-
expect(logger).to receive(:debug).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
31
|
-
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
|
32
|
-
expect(logger).to receive(:debug).with("Test suite split seed: seed-uuid")
|
|
33
|
-
expect(logger).to receive(:debug).with('API response:')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it do
|
|
37
|
-
parsed_response = { 'build_distribution_id' => 'seed-uuid' }
|
|
38
|
-
|
|
39
|
-
expect(logger).to receive(:debug).with(parsed_response)
|
|
40
|
-
|
|
41
|
-
expect(subject).to eq(parsed_response)
|
|
42
|
-
expect(connection.success?).to be true
|
|
43
|
-
expect(connection.errors?).to be false
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context 'when body response is empty' do
|
|
48
|
-
let(:body) { '' }
|
|
49
|
-
let(:code) { '200' } # it must be string code
|
|
50
|
-
|
|
51
|
-
before do
|
|
52
|
-
expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
|
|
53
|
-
expect(logger).to receive(:debug).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
54
|
-
expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
|
|
55
|
-
expect(logger).to receive(:debug).with('API response:')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it do
|
|
59
|
-
expect(logger).to receive(:debug).with('')
|
|
60
|
-
|
|
61
|
-
expect(subject).to eq('')
|
|
62
|
-
expect(connection.success?).to be true
|
|
63
|
-
expect(connection.errors?).to be false
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
shared_examples 'when retry request' do
|
|
69
|
-
context 'when body response is JSON and API response code is 500' do
|
|
70
|
-
let(:body) { '{"error": "Internal Server Error"}' }
|
|
71
|
-
let(:code) { '500' } # it must be string code
|
|
72
|
-
|
|
73
|
-
before do
|
|
74
|
-
expect(KnapsackPro).to receive(:logger).at_least(1).and_return(logger)
|
|
75
|
-
allow(http).to receive(:set_debug_output)
|
|
76
|
-
allow(http).to receive(:ipaddr).and_return(nil)
|
|
77
|
-
allow(logger).to receive(:warn).at_least(:once)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it do
|
|
81
|
-
expect(logger).to receive(:debug).exactly(3).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
82
|
-
expect(logger).to receive(:debug).exactly(3).with('API request UUID: fake-uuid')
|
|
83
|
-
expect(logger).to receive(:debug).exactly(3).with('API response:')
|
|
84
|
-
|
|
85
|
-
parsed_response = { 'error' => 'Internal Server Error' }
|
|
86
|
-
|
|
87
|
-
expect(logger).to receive(:error).exactly(3).with(parsed_response)
|
|
88
|
-
|
|
89
|
-
server_error = described_class::ServerError.new(parsed_response)
|
|
90
|
-
expect(logger).to receive(:warn).exactly(3).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
91
|
-
expect(logger).to receive(:warn).exactly(3).with('Request failed due to:')
|
|
92
|
-
expect(logger).to receive(:warn).exactly(3).with(server_error.inspect)
|
|
93
|
-
|
|
94
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
95
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
96
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
97
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
98
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
99
|
-
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
100
|
-
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
101
|
-
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
102
|
-
expect(logger).to receive(:warn).with("8s left before retry...")
|
|
103
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
104
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
105
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
106
|
-
expect(Kernel).to receive(:sleep).exactly(12).with(2)
|
|
107
|
-
|
|
108
|
-
expect(subject).to eq(parsed_response)
|
|
109
|
-
|
|
110
|
-
expect(connection.success?).to be false
|
|
111
|
-
expect(connection.errors?).to be true
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context 'when max request retries defined' do
|
|
115
|
-
before do
|
|
116
|
-
expect(KnapsackPro::Config::Env).to receive(:max_request_retries).at_least(1).and_return(4)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it do
|
|
120
|
-
expect(logger).to receive(:debug).exactly(4).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
121
|
-
expect(logger).to receive(:debug).exactly(4).with('API request UUID: fake-uuid')
|
|
122
|
-
expect(logger).to receive(:debug).exactly(4).with('API response:')
|
|
123
|
-
|
|
124
|
-
parsed_response = { 'error' => 'Internal Server Error' }
|
|
125
|
-
|
|
126
|
-
expect(logger).to receive(:error).exactly(4).with(parsed_response)
|
|
127
|
-
|
|
128
|
-
server_error = described_class::ServerError.new(parsed_response)
|
|
129
|
-
expect(logger).to receive(:warn).exactly(4).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
130
|
-
expect(logger).to receive(:warn).exactly(4).with('Request failed due to:')
|
|
131
|
-
expect(logger).to receive(:warn).exactly(4).with(server_error.inspect)
|
|
132
|
-
|
|
133
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
134
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
135
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
136
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
137
|
-
|
|
138
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
139
|
-
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
140
|
-
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
141
|
-
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
142
|
-
expect(logger).to receive(:warn).with("8s left before retry...")
|
|
143
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
144
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
145
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
146
|
-
|
|
147
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
148
|
-
11.times do |i|
|
|
149
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
expect(Kernel).to receive(:sleep).exactly(4+8+12).with(2)
|
|
153
|
-
|
|
154
|
-
expect(subject).to eq(parsed_response)
|
|
155
|
-
|
|
156
|
-
expect(connection.success?).to be false
|
|
157
|
-
expect(connection.errors?).to be true
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
context 'when Fallback Mode is disabled' do
|
|
162
|
-
before do
|
|
163
|
-
expect(KnapsackPro::Config::Env).to receive(:fallback_mode_enabled?).at_least(1).and_return(false)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it do
|
|
167
|
-
expect(logger).to receive(:debug).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
168
|
-
expect(logger).to receive(:debug).exactly(6).with('API request UUID: fake-uuid')
|
|
169
|
-
expect(logger).to receive(:debug).exactly(6).with('API response:')
|
|
170
|
-
|
|
171
|
-
parsed_response = { 'error' => 'Internal Server Error' }
|
|
172
|
-
|
|
173
|
-
expect(logger).to receive(:error).exactly(6).with(parsed_response)
|
|
174
|
-
|
|
175
|
-
server_error = described_class::ServerError.new(parsed_response)
|
|
176
|
-
expect(logger).to receive(:warn).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
177
|
-
expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
|
|
178
|
-
expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
|
|
179
|
-
|
|
180
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
181
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
182
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
183
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
184
|
-
|
|
185
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
186
|
-
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
187
|
-
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
188
|
-
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
189
|
-
expect(logger).to receive(:warn).with("8s left before retry...")
|
|
190
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
191
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
192
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
193
|
-
|
|
194
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
195
|
-
11.times do |i|
|
|
196
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to the Knapsack Pro API.")
|
|
200
|
-
15.times do |i|
|
|
201
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to the Knapsack Pro API.")
|
|
205
|
-
19.times do |i|
|
|
206
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
expect(Kernel).to receive(:sleep).exactly(60).with(2)
|
|
210
|
-
|
|
211
|
-
expect(subject).to eq(parsed_response)
|
|
212
|
-
|
|
213
|
-
expect(connection.success?).to be false
|
|
214
|
-
expect(connection.errors?).to be true
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
context 'when Regular Mode' do
|
|
219
|
-
before do
|
|
220
|
-
expect(KnapsackPro::Config::Env).to receive(:regular_mode?).at_least(1).and_return(true)
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it do
|
|
224
|
-
expect(logger).to receive(:debug).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
225
|
-
expect(logger).to receive(:debug).exactly(6).with('API request UUID: fake-uuid')
|
|
226
|
-
expect(logger).to receive(:debug).exactly(6).with('API response:')
|
|
227
|
-
|
|
228
|
-
parsed_response = { 'error' => 'Internal Server Error' }
|
|
229
|
-
|
|
230
|
-
expect(logger).to receive(:error).exactly(6).with(parsed_response)
|
|
231
|
-
|
|
232
|
-
server_error = described_class::ServerError.new(parsed_response)
|
|
233
|
-
expect(logger).to receive(:warn).exactly(6).with("#{expected_http_method} http://api.knapsackpro.test:3000/v1/fake_endpoint")
|
|
234
|
-
expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
|
|
235
|
-
expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
|
|
236
|
-
|
|
237
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
238
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
239
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
240
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
241
|
-
|
|
242
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
243
|
-
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
244
|
-
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
245
|
-
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
246
|
-
expect(logger).to receive(:warn).with("8s left before retry...")
|
|
247
|
-
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
248
|
-
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
249
|
-
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
250
|
-
|
|
251
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
252
|
-
11.times do |i|
|
|
253
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to the Knapsack Pro API.")
|
|
257
|
-
15.times do |i|
|
|
258
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to the Knapsack Pro API.")
|
|
262
|
-
19.times do |i|
|
|
263
|
-
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
expect(Kernel).to receive(:sleep).exactly(60).with(2)
|
|
267
|
-
|
|
268
|
-
expect(subject).to eq(parsed_response)
|
|
269
|
-
|
|
270
|
-
expect(connection.success?).to be false
|
|
271
|
-
expect(connection.errors?).to be true
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
describe KnapsackPro::Client::Connection do
|
|
278
|
-
let(:endpoint_path) { '/v1/fake_endpoint' }
|
|
279
|
-
let(:request_hash) { { fake: 'hash' } }
|
|
280
|
-
let(:http_method) { :post }
|
|
281
|
-
let(:action) do
|
|
282
|
-
instance_double(KnapsackPro::Client::API::Action,
|
|
283
|
-
endpoint_path: endpoint_path,
|
|
284
|
-
http_method: http_method,
|
|
285
|
-
request_hash: request_hash)
|
|
286
|
-
end
|
|
287
|
-
let(:test_suite_token) { '3fa64859337f6e56409d49f865d13fd7' }
|
|
288
|
-
let(:connection) { described_class.new(action) }
|
|
289
|
-
let(:headers) do
|
|
290
|
-
{
|
|
291
|
-
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
|
292
|
-
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
|
293
|
-
'GITHUB_ACTIONS' => 'true',
|
|
294
|
-
}
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
before do
|
|
298
|
-
stub_const('ENV', headers)
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
describe '#call' do
|
|
302
|
-
let(:logger) { instance_double(Logger) }
|
|
303
|
-
let(:http) { instance_double(Net::HTTP) }
|
|
304
|
-
let(:http_response) do
|
|
305
|
-
header = { 'X-Request-Id' => 'fake-uuid' }
|
|
306
|
-
instance_double(Net::HTTPOK, body: body, header: header, code: code)
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
subject { connection.call }
|
|
310
|
-
|
|
311
|
-
before do
|
|
312
|
-
expect(Net::HTTP).to receive(:new).with('api.knapsackpro.test', 3000).and_return(http)
|
|
313
|
-
|
|
314
|
-
expect(http).to receive(:use_ssl=).with(false)
|
|
315
|
-
expect(http).to receive(:open_timeout=).with(15)
|
|
316
|
-
expect(http).to receive(:read_timeout=).with(15)
|
|
317
|
-
allow(http).to receive(:ipaddr=).at_least(:once)
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
context 'when http method is POST on GitHub Actions' do
|
|
321
|
-
let(:http_method) { :post }
|
|
322
|
-
|
|
323
|
-
before do
|
|
324
|
-
expect(http).to receive(:post).with(
|
|
325
|
-
endpoint_path,
|
|
326
|
-
request_hash.to_json,
|
|
327
|
-
{
|
|
328
|
-
'Content-Type' => 'application/json',
|
|
329
|
-
'Accept' => 'application/json',
|
|
330
|
-
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
|
331
|
-
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
|
332
|
-
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
|
333
|
-
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
|
334
|
-
}
|
|
335
|
-
).and_return(http_response)
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
it_behaves_like 'when request got response from API' do
|
|
339
|
-
let(:expected_http_method) { 'POST' }
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
context 'when http method is POST and CI is undetected' do
|
|
344
|
-
let(:http_method) { :post }
|
|
345
|
-
|
|
346
|
-
let(:headers) do
|
|
347
|
-
{
|
|
348
|
-
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
|
349
|
-
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
|
350
|
-
}
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
before do
|
|
354
|
-
expect(http).to receive(:post).with(
|
|
355
|
-
anything,
|
|
356
|
-
anything,
|
|
357
|
-
hash_not_including('KNAPSACK-PRO-CI-PROVIDER')
|
|
358
|
-
).and_return(http_response)
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
it_behaves_like 'when request got response from API' do
|
|
362
|
-
let(:expected_http_method) { 'POST' }
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
context 'when http method is GET on GitHub Actions' do
|
|
367
|
-
let(:http_method) { :get }
|
|
368
|
-
|
|
369
|
-
before do
|
|
370
|
-
uri = URI.parse("http://api.knapsackpro.test:3000#{endpoint_path}")
|
|
371
|
-
uri.query = URI.encode_www_form(request_hash)
|
|
372
|
-
expect(http).to receive(:get).with(
|
|
373
|
-
uri,
|
|
374
|
-
{
|
|
375
|
-
'Content-Type' => 'application/json',
|
|
376
|
-
'Accept' => 'application/json',
|
|
377
|
-
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
|
378
|
-
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
|
379
|
-
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
|
380
|
-
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
|
381
|
-
}
|
|
382
|
-
).and_return(http_response)
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
it_behaves_like 'when request got response from API' do
|
|
386
|
-
let(:expected_http_method) { 'GET' }
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
context 'when http method is GET and CI is undetected' do
|
|
391
|
-
let(:http_method) { :get }
|
|
392
|
-
|
|
393
|
-
let(:headers) do
|
|
394
|
-
{
|
|
395
|
-
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
|
396
|
-
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
|
397
|
-
}
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
before do
|
|
401
|
-
expect(http).to receive(:get).with(
|
|
402
|
-
anything,
|
|
403
|
-
hash_not_including('KNAPSACK-PRO-CI-PROVIDER')
|
|
404
|
-
).and_return(http_response)
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
it_behaves_like 'when request got response from API' do
|
|
408
|
-
let(:expected_http_method) { 'GET' }
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
context 'when retry request for http method POST' do
|
|
413
|
-
let(:http_method) { :post }
|
|
414
|
-
|
|
415
|
-
before do
|
|
416
|
-
expect(http).to receive(:post).at_least(3).with(
|
|
417
|
-
endpoint_path,
|
|
418
|
-
request_hash.to_json,
|
|
419
|
-
{
|
|
420
|
-
'Content-Type' => 'application/json',
|
|
421
|
-
'Accept' => 'application/json',
|
|
422
|
-
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
|
423
|
-
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
|
424
|
-
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
|
425
|
-
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
|
426
|
-
}
|
|
427
|
-
).and_return(http_response)
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
it_behaves_like 'when retry request' do
|
|
431
|
-
let(:expected_http_method) { 'POST' }
|
|
432
|
-
end
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
context 'when retry request for http method GET' do
|
|
436
|
-
let(:http_method) { :get }
|
|
437
|
-
|
|
438
|
-
before do
|
|
439
|
-
uri = URI.parse("http://api.knapsackpro.test:3000#{endpoint_path}")
|
|
440
|
-
uri.query = URI.encode_www_form(request_hash)
|
|
441
|
-
expect(http).to receive(:get).at_least(3).with(
|
|
442
|
-
uri,
|
|
443
|
-
{
|
|
444
|
-
'Content-Type' => 'application/json',
|
|
445
|
-
'Accept' => 'application/json',
|
|
446
|
-
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
|
447
|
-
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
|
448
|
-
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
|
449
|
-
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
|
450
|
-
}
|
|
451
|
-
).and_return(http_response)
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
it_behaves_like 'when retry request' do
|
|
455
|
-
let(:expected_http_method) { 'GET' }
|
|
456
|
-
end
|
|
457
|
-
end
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
describe '#success?' do
|
|
461
|
-
subject { connection.success? }
|
|
462
|
-
|
|
463
|
-
before do
|
|
464
|
-
allow(connection).to receive(:response_body).and_return(response_body)
|
|
465
|
-
end
|
|
466
|
-
|
|
467
|
-
context 'when response has no value' do
|
|
468
|
-
let(:response_body) { nil }
|
|
469
|
-
|
|
470
|
-
it { should be false }
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
context 'when response has value' do
|
|
474
|
-
let(:response_body) do
|
|
475
|
-
{ 'fake' => 'response' }
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
before do
|
|
479
|
-
http_response = double(code: code)
|
|
480
|
-
allow(connection).to receive(:http_response).and_return(http_response)
|
|
481
|
-
end
|
|
482
|
-
|
|
483
|
-
context 'when response code is 200' do
|
|
484
|
-
let(:code) { '200' } # it must be string code
|
|
485
|
-
|
|
486
|
-
it { should be true }
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
context 'when response code is 300' do
|
|
490
|
-
let(:code) { '300' } # it must be string code
|
|
491
|
-
|
|
492
|
-
it { should be true }
|
|
493
|
-
end
|
|
494
|
-
|
|
495
|
-
context 'when response code is 400' do
|
|
496
|
-
let(:code) { '400' } # it must be string code
|
|
497
|
-
|
|
498
|
-
it { should be true }
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
context 'when response code is 500' do
|
|
502
|
-
let(:code) { '500' } # it must be string code
|
|
503
|
-
|
|
504
|
-
it { should be false }
|
|
505
|
-
end
|
|
506
|
-
end
|
|
507
|
-
end
|
|
508
|
-
|
|
509
|
-
describe '#errors?' do
|
|
510
|
-
subject { connection.errors? }
|
|
511
|
-
|
|
512
|
-
before do
|
|
513
|
-
allow(connection).to receive(:response_body).and_return(response_body)
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
context 'when response has no value' do
|
|
517
|
-
let(:response_body) { nil }
|
|
518
|
-
|
|
519
|
-
it { should be false }
|
|
520
|
-
end
|
|
521
|
-
|
|
522
|
-
context 'when response has value' do
|
|
523
|
-
context 'when response has no errors' do
|
|
524
|
-
let(:response_body) do
|
|
525
|
-
{ 'fake' => 'response' }
|
|
526
|
-
end
|
|
527
|
-
|
|
528
|
-
it { should be false }
|
|
529
|
-
end
|
|
530
|
-
|
|
531
|
-
context 'when response has errors' do
|
|
532
|
-
let(:response_body) do
|
|
533
|
-
{ 'errors' => [{ 'field' => 'is wrong' }] }
|
|
534
|
-
end
|
|
535
|
-
|
|
536
|
-
it { should be true }
|
|
537
|
-
end
|
|
538
|
-
|
|
539
|
-
context 'when response has error (i.e. internal server error)' do
|
|
540
|
-
let(:response_body) do
|
|
541
|
-
{ 'error' => 'Internal Server Error' }
|
|
542
|
-
end
|
|
543
|
-
|
|
544
|
-
it { should be true }
|
|
545
|
-
end
|
|
546
|
-
end
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
describe '#server_error?' do
|
|
550
|
-
subject { connection.server_error? }
|
|
551
|
-
|
|
552
|
-
before do
|
|
553
|
-
http_response = double(code: code)
|
|
554
|
-
allow(connection).to receive(:http_response).and_return(http_response)
|
|
555
|
-
end
|
|
556
|
-
|
|
557
|
-
context 'when response code is 200' do
|
|
558
|
-
let(:code) { '200' } # it must be string code
|
|
559
|
-
|
|
560
|
-
it { should be false }
|
|
561
|
-
end
|
|
562
|
-
|
|
563
|
-
context 'when response code is 300' do
|
|
564
|
-
let(:code) { '300' } # it must be string code
|
|
565
|
-
|
|
566
|
-
it { should be false }
|
|
567
|
-
end
|
|
568
|
-
|
|
569
|
-
context 'when response code is 400' do
|
|
570
|
-
let(:code) { '400' } # it must be string code
|
|
571
|
-
|
|
572
|
-
it { should be false }
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
context 'when response code is 500' do
|
|
576
|
-
let(:code) { '500' } # it must be string code
|
|
577
|
-
|
|
578
|
-
it { should be true }
|
|
579
|
-
end
|
|
580
|
-
end
|
|
581
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::AppVeyor do
|
|
2
|
-
let(:env) { {} }
|
|
3
|
-
|
|
4
|
-
before do
|
|
5
|
-
stub_const('ENV', env)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it { should be_kind_of KnapsackPro::Config::CI::Base }
|
|
9
|
-
|
|
10
|
-
describe '#node_total' do
|
|
11
|
-
subject { described_class.new.node_total }
|
|
12
|
-
|
|
13
|
-
it { should be nil }
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '#node_index' do
|
|
17
|
-
subject { described_class.new.node_index }
|
|
18
|
-
|
|
19
|
-
it { should be nil }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe '#node_build_id' do
|
|
23
|
-
subject { described_class.new.node_build_id }
|
|
24
|
-
|
|
25
|
-
context 'when the environment exists' do
|
|
26
|
-
let(:env) { { 'APPVEYOR_BUILD_ID' => 123 } }
|
|
27
|
-
it { should eql 123 }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when the environment doesn't exist" do
|
|
31
|
-
it { should be nil }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe '#commit_hash' do
|
|
36
|
-
subject { described_class.new.commit_hash }
|
|
37
|
-
|
|
38
|
-
context 'when the environment exists' do
|
|
39
|
-
let(:env) { { 'APPVEYOR_REPO_COMMIT' => '2e13512fc230d6f9ebf4923352718e4d' } }
|
|
40
|
-
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when the environment doesn't exist" do
|
|
44
|
-
it { should be nil }
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe '#branch' do
|
|
49
|
-
subject { described_class.new.branch }
|
|
50
|
-
|
|
51
|
-
context 'when the environment exists' do
|
|
52
|
-
let(:env) { { 'APPVEYOR_REPO_BRANCH' => 'main' } }
|
|
53
|
-
it { should eql 'main' }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when the environment doesn't exist" do
|
|
57
|
-
it { should be nil }
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe '#project_dir' do
|
|
62
|
-
subject { described_class.new.project_dir }
|
|
63
|
-
|
|
64
|
-
context 'when the environment exists' do
|
|
65
|
-
let(:env) { { 'APPVEYOR_BUILD_FOLDER' => '/path/to/clone/repo' } }
|
|
66
|
-
it { should eql '/path/to/clone/repo' }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "when the environment doesn't exist" do
|
|
70
|
-
it { should be nil }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe '#user_seat' do
|
|
75
|
-
subject { described_class.new.user_seat }
|
|
76
|
-
|
|
77
|
-
context 'when the APPVEYOR_REPO_COMMIT_AUTHOR environment variable exists' do
|
|
78
|
-
let(:env) { { 'APPVEYOR_REPO_COMMIT_AUTHOR' => 'jane_doe' } }
|
|
79
|
-
|
|
80
|
-
it { should eql 'jane_doe' }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context "when the APPVEYOR_REPO_COMMIT_AUTHOR environment variable doesn't exist" do
|
|
84
|
-
it { should be nil }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::Base do
|
|
2
|
-
its(:node_total) { should be nil }
|
|
3
|
-
its(:node_index) { should be nil }
|
|
4
|
-
its(:node_build_id) { should be nil }
|
|
5
|
-
its(:node_retry_count) { should be nil }
|
|
6
|
-
its(:commit_hash) { should be nil }
|
|
7
|
-
its(:branch) { should be nil }
|
|
8
|
-
its(:project_dir) { should be nil }
|
|
9
|
-
its(:user_seat) { should be nil }
|
|
10
|
-
end
|