knapsack_pro 1.10.0 → 1.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/report.rb +14 -9
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +1 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +1 -1
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/report_spec.rb +30 -17
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +1 -1
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +2 -2
- 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: fb705b44a624bdd6caa055a2caee16cb3ebcf4f9a15a1cc718b5f6a2f03f89ce
|
4
|
+
data.tar.gz: 6155ff3b7f0bf3d96f12dbad0009499eb02953d0415e48c1bcaf2c3ffbf94027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e02c5b22c2a3a4261dd5cf75dce2a8bdeb086254df40166f38758766fcbfcb4c9c68aa3fb76ef748eab4db668a782ea7af2d4313bbf2e71491ada6af87cf320
|
7
|
+
data.tar.gz: 1d57f7e37be0f0d43c4b13e3cdcbcda612dce17ed9cb4854dca5e1d75d0e310ebc49cb2939476cca1eca275e565db597c3e82f7b3e1c8705c0f41afce887b570
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 1.10.1
|
4
|
+
|
5
|
+
* Fix log info when measured time of tests was lost
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/85
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.10.0...v1.10.1
|
10
|
+
|
3
11
|
### 1.10.0
|
4
12
|
|
5
13
|
* Logs error on lost info about recorded timing for test files due to missing json files in Queue Mode
|
data/lib/knapsack_pro/report.rb
CHANGED
@@ -27,7 +27,7 @@ module KnapsackPro
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.save_node_queue_to_api
|
30
|
+
def self.save_node_queue_to_api
|
31
31
|
test_files = []
|
32
32
|
Dir.glob("#{queue_path}/*.json").each do |file|
|
33
33
|
report = JSON.parse(File.read(file))
|
@@ -35,15 +35,20 @@ module KnapsackPro
|
|
35
35
|
end
|
36
36
|
|
37
37
|
if test_files.empty?
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
KnapsackPro.logger.warn("No test files were executed on this CI node.")
|
39
|
+
KnapsackPro.logger.debug("When you use knapsack_pro queue mode then probably reason might be that CI node was started after the test files from the queue were already executed by other CI nodes. That is why this CI node has no test files to execute.")
|
40
|
+
KnapsackPro.logger.debug("Another reason might be when your CI node failed in a way that prevented knapsack_pro to save time execution data to Knapsack Pro API and you have just tried to retry failed CI node but instead you got no test files to execute. In that case knapsack_pro don't know what testes should be executed here.")
|
41
|
+
end
|
42
|
+
|
43
|
+
measured_test_files = test_files
|
44
|
+
.map { |t| t['time_execution'] }
|
45
|
+
.select { |time_execution| time_execution != KnapsackPro::Tracker::DEFAULT_TEST_FILE_TIME }
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
if test_files.size > 0 && measured_test_files.size == 0
|
48
|
+
KnapsackPro.logger.warn("#{test_files.size} test files were executed on this CI node but the recorded time was lost due to:")
|
49
|
+
KnapsackPro.logger.warn("1. Probably you have a code (i.e. RSpec hooks) that clears tmp directory in your project. Please ensure you do not remove the content of tmp/knapsack_pro/queue/ directory between tests run.")
|
50
|
+
KnapsackPro.logger.warn("2. Another reason might be that you forgot to add Knapsack::Adapters::RspecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/")
|
51
|
+
KnapsackPro.logger.warn("3. All your tests are empty test files, are pending tests or have syntax error and could not be executed hence no measured time execution by knapsack_pro.")
|
47
52
|
end
|
48
53
|
|
49
54
|
create_build_subset(test_files)
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -43,16 +43,14 @@ describe KnapsackPro::Report do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '.save_node_queue_to_api' do
|
46
|
-
context 'when json files with recorded time exist
|
46
|
+
context 'when json files with recorded time does exist and test files have measured and default time execution' do
|
47
47
|
let(:json_test_file_a_path) { double }
|
48
|
-
let(:json_test_file_a) { [{ 'path' => 'a_spec.rb' }] }
|
48
|
+
let(:json_test_file_a) { [{ 'path' => 'a_spec.rb', 'time_execution' => 0.1234 }] }
|
49
49
|
|
50
50
|
let(:json_test_file_b_path) { double }
|
51
|
-
let(:json_test_file_b) { [{ 'path' => 'b_spec.rb' }] }
|
51
|
+
let(:json_test_file_b) { [{ 'path' => 'b_spec.rb', 'time_execution' => KnapsackPro::Tracker::DEFAULT_TEST_FILE_TIME }] }
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
subject { described_class.save_node_queue_to_api(executed_test_files_count) }
|
53
|
+
subject { described_class.save_node_queue_to_api }
|
56
54
|
|
57
55
|
before do
|
58
56
|
queue_id = 'fake-queue-id'
|
@@ -68,6 +66,8 @@ describe KnapsackPro::Report do
|
|
68
66
|
end
|
69
67
|
|
70
68
|
it 'creates build subset for 2 recorded test files timing' do
|
69
|
+
expect(KnapsackPro).not_to receive(:logger)
|
70
|
+
|
71
71
|
expect(described_class).to receive(:create_build_subset).with(
|
72
72
|
json_test_file_a + json_test_file_b
|
73
73
|
)
|
@@ -76,33 +76,46 @@ describe KnapsackPro::Report do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context 'when json files with recorded time does
|
80
|
-
let(:
|
79
|
+
context 'when json files with recorded time does exist and all test files have default time execution' do
|
80
|
+
let(:json_test_file_a_path) { double }
|
81
|
+
let(:json_test_file_a) { [{ 'path' => 'a_spec.rb', 'time_execution' => KnapsackPro::Tracker::DEFAULT_TEST_FILE_TIME }] }
|
82
|
+
|
83
|
+
let(:json_test_file_b_path) { double }
|
84
|
+
let(:json_test_file_b) { [{ 'path' => 'b_spec.rb', 'time_execution' => KnapsackPro::Tracker::DEFAULT_TEST_FILE_TIME }] }
|
81
85
|
|
82
|
-
subject { described_class.save_node_queue_to_api
|
86
|
+
subject { described_class.save_node_queue_to_api }
|
83
87
|
|
84
88
|
before do
|
85
89
|
queue_id = 'fake-queue-id'
|
86
90
|
expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
|
87
91
|
|
88
|
-
expect(Dir).to receive(:glob).with('tmp/knapsack_pro/queue/fake-queue-id/*.json').and_return([
|
92
|
+
expect(Dir).to receive(:glob).with('tmp/knapsack_pro/queue/fake-queue-id/*.json').and_return([
|
93
|
+
json_test_file_a_path,
|
94
|
+
json_test_file_b_path
|
95
|
+
])
|
96
|
+
|
97
|
+
expect(File).to receive(:read).with(json_test_file_a_path).and_return(json_test_file_a.to_json)
|
98
|
+
expect(File).to receive(:read).with(json_test_file_b_path).and_return(json_test_file_b.to_json)
|
89
99
|
end
|
90
100
|
|
91
101
|
it 'logs error on lost info about recorded timing for test files due missing json files AND creates empty build subset' do
|
92
102
|
logger = instance_double(Logger)
|
93
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
94
|
-
expect(logger).to receive(:
|
103
|
+
expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
|
104
|
+
expect(logger).to receive(:warn).with('2 test files were executed on this CI node but the recorded time was lost due to:')
|
105
|
+
expect(logger).to receive(:warn).with('1. Probably you have a code (i.e. RSpec hooks) that clears tmp directory in your project. Please ensure you do not remove the content of tmp/knapsack_pro/queue/ directory between tests run.')
|
106
|
+
expect(logger).to receive(:warn).with('2. Another reason might be that you forgot to add Knapsack::Adapters::RspecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/')
|
107
|
+
expect(logger).to receive(:warn).with('3. All your tests are empty test files, are pending tests or have syntax error and could not be executed hence no measured time execution by knapsack_pro.')
|
95
108
|
|
96
|
-
expect(described_class).to receive(:create_build_subset).with(
|
109
|
+
expect(described_class).to receive(:create_build_subset).with(
|
110
|
+
json_test_file_a + json_test_file_b
|
111
|
+
)
|
97
112
|
|
98
113
|
subject
|
99
114
|
end
|
100
115
|
end
|
101
116
|
|
102
|
-
context 'when json files with recorded time does not exist
|
103
|
-
|
104
|
-
|
105
|
-
subject { described_class.save_node_queue_to_api(executed_test_files_count) }
|
117
|
+
context 'when json files with recorded time does not exist' do
|
118
|
+
subject { described_class.save_node_queue_to_api }
|
106
119
|
|
107
120
|
before do
|
108
121
|
queue_id = 'fake-queue-id'
|
@@ -161,7 +161,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
|
|
161
161
|
|
162
162
|
it 'returns exit code 0' do
|
163
163
|
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|
164
|
-
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
164
|
+
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
165
165
|
|
166
166
|
expect(subject).to eq({
|
167
167
|
status: :completed,
|
@@ -203,7 +203,7 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
|
|
203
203
|
expect(KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension).to receive(:print_summary)
|
204
204
|
|
205
205
|
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|
206
|
-
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
206
|
+
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
207
207
|
|
208
208
|
expect(subject).to eq({
|
209
209
|
status: :completed,
|
@@ -217,7 +217,7 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
|
|
217
217
|
|
218
218
|
it do
|
219
219
|
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|
220
|
-
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
220
|
+
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
221
221
|
|
222
222
|
expect(subject).to eq({
|
223
223
|
status: :completed,
|