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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15d64502a63c7087b4d8793ad780d0f7454d2414c93c0da46967e20620578fe0
4
- data.tar.gz: 88addd61d85b84f2fc043ff17e554564d95b40be262fe55a51714efa5ae4f719
3
+ metadata.gz: fb705b44a624bdd6caa055a2caee16cb3ebcf4f9a15a1cc718b5f6a2f03f89ce
4
+ data.tar.gz: 6155ff3b7f0bf3d96f12dbad0009499eb02953d0415e48c1bcaf2c3ffbf94027
5
5
  SHA512:
6
- metadata.gz: 67664f1170199a4f5f6cb2fbabdfd15fbebd2c73d04a0646bacdc20411411722f5b7b0946d8a76417150fcbe60211b13b97f27a09ca10840a44caaea8beccb0a
7
- data.tar.gz: d835f28e6af4885f42e6daa218caace7401f1ab9e406d1f8a4c06af6f20ad671e37b8501e35aceaea41183d94d56feec462badb86747053843b7a1957ec64867
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
@@ -27,7 +27,7 @@ module KnapsackPro
27
27
  end
28
28
  end
29
29
 
30
- def self.save_node_queue_to_api(executed_test_files_count)
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
- if executed_test_files_count == 0
39
- KnapsackPro.logger.warn("No test files were executed on this CI node.")
40
- 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.")
41
- 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.")
42
- end
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
- if executed_test_files_count > 0
45
- KnapsackPro.logger.error("#{executed_test_files_count} test files were executed on this CI node but the recorded time of it was lost. 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. 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/")
46
- end
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)
@@ -48,7 +48,7 @@ module KnapsackPro
48
48
  if test_file_paths.empty?
49
49
  KnapsackPro::Hooks::Queue.call_after_queue
50
50
 
51
- KnapsackPro::Report.save_node_queue_to_api(all_test_file_paths.count)
51
+ KnapsackPro::Report.save_node_queue_to_api
52
52
 
53
53
  return {
54
54
  status: :completed,
@@ -59,7 +59,7 @@ module KnapsackPro
59
59
 
60
60
  KnapsackPro::Hooks::Queue.call_after_queue
61
61
 
62
- KnapsackPro::Report.save_node_queue_to_api(all_test_file_paths.count)
62
+ KnapsackPro::Report.save_node_queue_to_api
63
63
 
64
64
  return {
65
65
  status: :completed,
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.10.0'
2
+ VERSION = '1.10.1'
3
3
  end
@@ -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 for executed test files' do
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
- let(:executed_test_files_count) { 2 }
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 not exist for executed test files' do
80
- let(:executed_test_files_count) { 2 }
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(executed_test_files_count) }
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(:error).with('2 test files were executed on this CI node but the recorded time of it was lost. 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. 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/')
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 AND no executed test files' do
103
- let(:executed_test_files_count) { 0 }
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).with(0)
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).with(1)
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).with(0)
220
+ expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
221
221
 
222
222
  expect(subject).to eq({
223
223
  status: :completed,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT