knapsack_pro 3.7.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +2 -1
  3. data/.github/assets/install-button.png +0 -0
  4. data/.github/assets/knapsack-diamonds.png +0 -0
  5. data/CHANGELOG.md +16 -0
  6. data/README.md +75 -1680
  7. data/lib/knapsack_pro/adapters/base_adapter.rb +2 -2
  8. data/lib/knapsack_pro/adapters/rspec_adapter.rb +3 -3
  9. data/lib/knapsack_pro/adapters/test_unit_adapter.rb +1 -1
  10. data/lib/knapsack_pro/allocator.rb +4 -4
  11. data/lib/knapsack_pro/base_allocator_builder.rb +1 -1
  12. data/lib/knapsack_pro/build_distribution_fetcher.rb +1 -1
  13. data/lib/knapsack_pro/queue_allocator.rb +4 -4
  14. data/lib/knapsack_pro/report.rb +1 -1
  15. data/lib/knapsack_pro/runners/rspec_runner.rb +1 -0
  16. data/lib/knapsack_pro/slow_test_file_determiner.rb +1 -1
  17. data/lib/knapsack_pro/slow_test_file_finder.rb +1 -1
  18. data/lib/knapsack_pro/tracker.rb +1 -1
  19. data/lib/knapsack_pro/urls.rb +37 -0
  20. data/lib/knapsack_pro/version.rb +1 -1
  21. data/lib/knapsack_pro.rb +1 -0
  22. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +1 -0
  23. data/spec/knapsack_pro/allocator_spec.rb +3 -3
  24. data/spec/knapsack_pro/base_allocator_builder_spec.rb +1 -1
  25. data/spec/knapsack_pro/queue_allocator_spec.rb +3 -3
  26. data/spec/knapsack_pro/report_spec.rb +1 -1
  27. data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +1 -0
  28. data/spec/knapsack_pro/runners/rspec_runner_spec.rb +39 -19
  29. data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +1 -1
  30. data/spec/knapsack_pro/slow_test_file_finder_spec.rb +1 -1
  31. data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
  32. data/spec/knapsack_pro/tracker_spec.rb +1 -0
  33. metadata +9 -6
@@ -38,8 +38,8 @@ module KnapsackPro
38
38
  else
39
39
  puts "\n\n"
40
40
  KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50)
41
- KnapsackPro.logger.error("You forgot to call #{self}.bind method in your test runner configuration file. It is needed to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/")
42
- KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have deleted the .knapsack_pro directory from the disk accidentally. Please ensure you do not remove the .knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard")
41
+ KnapsackPro.logger.error("You forgot to call #{self}.bind method in your test runner configuration file. It is needed to record test files time execution. Please follow the installation guide to configure your project properly #{KnapsackPro::Urls::INSTALLATION_GUIDE}")
42
+ KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have deleted the .knapsack_pro directory from the disk accidentally. Please ensure you do not remove the .knapsack_pro directory: #{KnapsackPro::Urls::DASHBOARD__ZEROISH_TEST_EXECUTION_TIMES}")
43
43
  Kernel.exit(1)
44
44
  end
45
45
  end
@@ -5,7 +5,7 @@ module KnapsackPro
5
5
 
6
6
  def self.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
7
7
  if KnapsackPro::Config::Env.rspec_split_by_test_examples? && has_tag_option?(cli_args)
8
- error_message = 'It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it#warning-dont-use-rspec-tag-option'
8
+ error_message = "It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: #{KnapsackPro::Urls::RSPEC__SPLIT_BY_TEST_EXAMPLES__TAG}"
9
9
  KnapsackPro.logger.error(error_message)
10
10
  raise error_message
11
11
  end
@@ -66,7 +66,7 @@ module KnapsackPro
66
66
  end
67
67
 
68
68
  if example.metadata[:focus] && KnapsackPro::Adapters::RSpecAdapter.rspec_configuration.filter.rules[:focus]
69
- raise "We detected a test file path #{current_test_path} with a test using the metadata `:focus` tag. RSpec might not run some tests in the Queue Mode (causing random tests skipping problem). Please remove the `:focus` tag from your codebase. See more: https://knapsackpro.com/faq/question/rspec-is-not-running-some-tests"
69
+ raise "We detected a test file path #{current_test_path} with a test using the metadata `:focus` tag. RSpec might not run some tests in the Queue Mode (causing random tests skipping problem). Please remove the `:focus` tag from your codebase. See more: #{KnapsackPro::Urls::RSPEC__SKIPS_TESTS}"
70
70
  end
71
71
 
72
72
  example.run
@@ -123,7 +123,7 @@ module KnapsackPro
123
123
  # and didn't notice the class name changed
124
124
  class RspecAdapter < RSpecAdapter
125
125
  def self.bind
126
- error_message = 'You have attempted to call KnapsackPro::Adapters::RspecAdapter.bind. Please switch to using the new class name: KnapsackPro::Adapters::RSpecAdapter. See https://docs.knapsackpro.com/knapsack_pro-ruby/guide for up-to-date configuration instructions.'
126
+ error_message = "You have attempted to call KnapsackPro::Adapters::RspecAdapter.bind. Please switch to using the new class name: KnapsackPro::Adapters::RSpecAdapter. See #{KnapsackPro::Urls::INSTALLATION_GUIDE} for up-to-date configuration instructions."
127
127
  KnapsackPro.logger.error(error_message)
128
128
  raise error_message
129
129
  end
@@ -24,7 +24,7 @@ module KnapsackPro
24
24
  end
25
25
 
26
26
  unless found_valid_test_file_path
27
- KnapsackPro.logger.warn('cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at https://github.com/KnapsackPro/knapsack_pro-ruby/pull/123')
27
+ KnapsackPro.logger.warn("cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at #{KnapsackPro::Urls::TEST_UNIT__TEST_FILE_PATH_DETECTION}")
28
28
  KnapsackPro.logger.warn("See test file for #{obj.inspect}")
29
29
  end
30
30
 
@@ -25,18 +25,18 @@ module KnapsackPro
25
25
  raise ArgumentError.new(response) if connection.errors?
26
26
  prepare_test_files(response)
27
27
  elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
28
- message = 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
28
+ message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
29
29
  KnapsackPro.logger.error(message)
30
30
  raise message
31
31
  elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
32
- message = 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
32
+ message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
33
33
  unless KnapsackPro::Config::Env.fixed_test_suite_split?
34
- message += ' Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed'
34
+ message += " Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_TEST_SUITE_SPLIT}"
35
35
  end
36
36
  KnapsackPro.logger.error(message)
37
37
  raise message
38
38
  else
39
- KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. Read more about fallback mode at https://knapsackpro.com/faq/question/what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily")
39
+ KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
40
40
  fallback_test_files
41
41
  end
42
42
  end
@@ -36,7 +36,7 @@ module KnapsackPro
36
36
  if adapter_class == KnapsackPro::Adapters::RSpecAdapter && KnapsackPro::Config::Env.rspec_split_by_test_examples?
37
37
  require 'rspec/core/version'
38
38
  unless Gem::Version.new(::RSpec::Core::Version::STRING) >= Gem::Version.new('3.3.0')
39
- raise 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
39
+ raise "RSpec >= 3.3.0 is required to split test files by test examples. Learn more: #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}"
40
40
  end
41
41
 
42
42
  slow_test_files = get_slow_test_files
@@ -31,7 +31,7 @@ module KnapsackPro
31
31
  raise ArgumentError.new(response) if connection.errors?
32
32
  BuildDistributionEntity.new(response)
33
33
  else
34
- KnapsackPro.logger.warn("Slow test files fallback behaviour started. We could not connect with Knapsack Pro API to fetch last CI build test files that are needed to determine slow test files. No test files will be split by test cases. It means all test files will be split by the whole test files as if split by test cases would be disabled https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases")
34
+ KnapsackPro.logger.warn("Slow test files fallback behaviour started. We could not connect with Knapsack Pro API to fetch last CI build test files that are needed to determine slow test files. No test files will be split by test cases. It means all test files will be split by the whole test files as if split by test cases would be disabled #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}")
35
35
  BuildDistributionEntity.new({
36
36
  'time_execution' => 0.0,
37
37
  'test_files' => [],
@@ -27,19 +27,19 @@ module KnapsackPro
27
27
  raise ArgumentError.new(response) if connection.errors?
28
28
  prepare_test_files(response)
29
29
  elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
30
- message = 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
30
+ message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
31
31
  KnapsackPro.logger.error(message)
32
32
  raise message
33
33
  elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
34
- message = 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
34
+ message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
35
35
  unless KnapsackPro::Config::Env.fixed_queue_split?
36
- message += ' Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node'
36
+ message += " Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_QUEUE_SPLIT}"
37
37
  end
38
38
  KnapsackPro.logger.error(message)
39
39
  raise message
40
40
  else
41
41
  @fallback_activated = true
42
- KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at https://knapsackpro.com/faq/question/what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily")
42
+ KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
43
43
  fallback_test_files(executed_test_files)
44
44
  end
45
45
  end
@@ -47,7 +47,7 @@ module KnapsackPro
47
47
  if test_files.size > 0 && measured_test_files.size == 0
48
48
  KnapsackPro.logger.warn("#{test_files.size} test files were executed on this CI node but the recorded time was lost due to:")
49
49
  KnapsackPro.logger.warn("1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.")
50
- KnapsackPro.logger.warn("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/")
50
+ KnapsackPro.logger.warn("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: #{KnapsackPro::Urls::INSTALLATION_GUIDE}")
51
51
  KnapsackPro.logger.warn("3. Another potential reason for this warning is that all your tests are empty test files, pending tests, or they have syntax errors, and the time execution was not recorded for them.")
52
52
  end
53
53
 
@@ -32,6 +32,7 @@ module KnapsackPro
32
32
  # instead we pass test files and test example paths to t.rspec_opts
33
33
  t.pattern = []
34
34
  t.rspec_opts = "#{args} --default-path #{runner.test_dir} #{runner.stringify_test_file_paths}"
35
+ t.verbose = KnapsackPro::Config::Env.log_level < ::Logger::WARN
35
36
  end
36
37
  Rake::Task[task_name].invoke
37
38
  end
@@ -20,7 +20,7 @@ module KnapsackPro
20
20
  end
21
21
 
22
22
  def self.read_from_json_report
23
- raise 'The report with slow test files has not been generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!' unless File.exist?(report_path)
23
+ raise "The report with slow test files has not been generated yet. If you have enabled split by test cases #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES} and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!" unless File.exist?(report_path)
24
24
  slow_test_files_json_report = File.read(report_path)
25
25
  JSON.parse(slow_test_files_json_report)
26
26
  end
@@ -6,7 +6,7 @@ module KnapsackPro
6
6
  # Returns slow test files.
7
7
  def self.call(adapter_class)
8
8
  if KnapsackPro::Config::Env.test_files_encrypted?
9
- raise 'Split by test cases is not possible when you have enabled test file names encryption ( https://github.com/KnapsackPro/knapsack_pro-ruby#test-file-names-encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
9
+ raise "Split by test cases is not possible when you have enabled test file names encryption ( #{KnapsackPro::Urls::ENCRYPTION} ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}"
10
10
  end
11
11
 
12
12
  # get list of recorded test files for last CI Build
@@ -112,7 +112,7 @@ module KnapsackPro
112
112
  end
113
113
 
114
114
  def read_prerun_tests_report
115
- raise "Report #{prerun_tests_report_path} doest not exist on the disk. Most likely, it was removed accidentally. Please report the bug to the Knapsack Pro support team at https://knapsackpro.com/contact" unless File.exist?(prerun_tests_report_path)
115
+ raise "Report #{prerun_tests_report_path} doest not exist on the disk. Most likely, it was removed accidentally. Please report the bug to the Knapsack Pro support team at #{KnapsackPro::Urls::SUPPORT}" unless File.exist?(prerun_tests_report_path)
116
116
  JSON.parse(File.read(prerun_tests_report_path))
117
117
  end
118
118
 
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KnapsackPro
4
+ module Urls
5
+ HOST = 'https://knapsackpro.com'
6
+
7
+ SUPPORT = "#{HOST}/perma/ruby/support"
8
+
9
+ DASHBOARD__ZEROISH_TEST_EXECUTION_TIMES = "#{HOST}/perma/ruby/dashboard-zeroish-test-execution-times"
10
+
11
+ ENCRYPTION = "#{HOST}/perma/ruby/encryption"
12
+
13
+ FALLBACK_MODE = "#{HOST}/perma/ruby/fallback-mode"
14
+
15
+ FIXED_QUEUE_SPLIT = "#{HOST}/perma/ruby/fixed-queue-split"
16
+
17
+ FIXED_TEST_SUITE_SPLIT = "#{HOST}/perma/ruby/fixed-test-suite-split"
18
+
19
+ INSTALLATION_GUIDE = "#{HOST}/perma/ruby/installation-guide"
20
+
21
+ QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false"
22
+
23
+ QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
24
+
25
+ REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false"
26
+
27
+ REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
28
+
29
+ RSPEC__SKIPS_TESTS = "#{HOST}/perma/ruby/rspec-skips-tests"
30
+
31
+ RSPEC__SPLIT_BY_TEST_EXAMPLES__TAG = "#{HOST}/perma/ruby/rspec-split-by-test-examples-tag"
32
+
33
+ SPLIT_BY_TEST_EXAMPLES = "#{HOST}/perma/ruby/split-by-test-examples"
34
+
35
+ TEST_UNIT__TEST_FILE_PATH_DETECTION = "#{HOST}/perma/ruby/test-unit-test-file-path-detection"
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '3.7.0'
2
+ VERSION = '3.9.0'
3
3
  end
data/lib/knapsack_pro.rb CHANGED
@@ -6,6 +6,7 @@ require 'uri'
6
6
  require 'rake/testtask'
7
7
  require 'digest'
8
8
  require 'securerandom'
9
+ require_relative 'knapsack_pro/urls'
9
10
  require_relative 'knapsack_pro/version'
10
11
  require_relative 'knapsack_pro/extensions/time'
11
12
  require_relative 'knapsack_pro/hooks/queue'
@@ -98,6 +98,7 @@ describe KnapsackPro::Adapters::BaseAdapter do
98
98
 
99
99
  before do
100
100
  expect(::Kernel).to receive(:at_exit).and_yield
101
+ allow(File).to receive(:exist?)
101
102
  expect(File).to receive(:exist?).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt').and_return(adapter_bind_method_called_file_exists)
102
103
  end
103
104
 
@@ -28,7 +28,7 @@ describe KnapsackPro::Allocator do
28
28
  end
29
29
 
30
30
  it do
31
- expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
31
+ expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false')
32
32
  end
33
33
  end
34
34
 
@@ -43,7 +43,7 @@ describe KnapsackPro::Allocator do
43
43
  end
44
44
 
45
45
  it do
46
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
46
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
47
47
  end
48
48
  end
49
49
 
@@ -53,7 +53,7 @@ describe KnapsackPro::Allocator do
53
53
  end
54
54
 
55
55
  it do
56
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed')
56
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-test-suite-split')
57
57
  end
58
58
  end
59
59
  end
@@ -149,7 +149,7 @@ describe KnapsackPro::BaseAllocatorBuilder do
149
149
  end
150
150
 
151
151
  it do
152
- expect { subject }.to raise_error RuntimeError, 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
152
+ expect { subject }.to raise_error RuntimeError, 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://knapsackpro.com/perma/ruby/split-by-test-examples'
153
153
  end
154
154
  end
155
155
 
@@ -31,7 +31,7 @@ describe KnapsackPro::QueueAllocator do
31
31
  end
32
32
 
33
33
  it do
34
- expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
34
+ expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
35
35
  end
36
36
  end
37
37
 
@@ -46,7 +46,7 @@ describe KnapsackPro::QueueAllocator do
46
46
  end
47
47
 
48
48
  it do
49
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
49
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
50
50
  end
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ describe KnapsackPro::QueueAllocator do
56
56
  end
57
57
 
58
58
  it do
59
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node')
59
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-queue-split')
60
60
  end
61
61
  end
62
62
  end
@@ -105,7 +105,7 @@ describe KnapsackPro::Report do
105
105
  expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
106
106
  expect(logger).to receive(:warn).with('2 test files were executed on this CI node but the recorded time was lost due to:')
107
107
  expect(logger).to receive(:warn).with('1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.')
108
- expect(logger).to receive(:warn).with("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/")
108
+ expect(logger).to receive(:warn).with("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://knapsackpro.com/perma/ruby/installation-guide")
109
109
  expect(logger).to receive(:warn).with('3. Another potential reason for this warning is that all your tests are empty test files, pending tests, or they have syntax errors, and the time execution was not recorded for them.')
110
110
 
111
111
  expect(described_class).to receive(:create_build_subset).with(
@@ -114,6 +114,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
114
114
  expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
115
115
 
116
116
  # .minitest_run
117
+ allow(File).to receive(:exist?)
117
118
  expect(File).to receive(:exist?).with('./a_test.rb').and_return(true)
118
119
  expect(File).to receive(:exist?).with('./b_test.rb').and_return(true)
119
120
  expect(File).to receive(:exist?).with('./fake_path_test.rb').and_return(false)
@@ -36,6 +36,7 @@ describe KnapsackPro::Runners::RSpecRunner do
36
36
  test_files_to_execute_exist?: true)
37
37
  end
38
38
  let(:task) { double }
39
+ let(:task_config) { double }
39
40
 
40
41
  before do
41
42
  expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called).ordered
@@ -47,36 +48,55 @@ describe KnapsackPro::Runners::RSpecRunner do
47
48
 
48
49
  expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task)
49
50
 
50
- t = double
51
- expect(RSpec::Core::RakeTask).to receive(:new).with('knapsack_pro:rspec_run').and_yield(t)
52
- expect(t).to receive(:rspec_opts=).with('--profile --color --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
53
- expect(t).to receive(:pattern=).with([])
51
+ expect(RSpec::Core::RakeTask).to receive(:new).with('knapsack_pro:rspec_run').and_yield(task_config)
52
+ expect(task_config).to receive(:rspec_opts=).with('--profile --color --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
53
+ expect(task_config).to receive(:pattern=).with([])
54
54
  end
55
55
 
56
- context 'when rake task already exists' do
57
- before do
58
- expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(true)
59
- expect(task).to receive(:clear)
56
+ shared_examples 'invokes RSpec rake task' do
57
+ context 'when rake task already exists' do
58
+ before do
59
+ expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(true)
60
+ expect(task).to receive(:clear)
61
+ end
62
+
63
+ it do
64
+ result = double(:result)
65
+ expect(task).to receive(:invoke).and_return(result)
66
+ expect(subject).to eq result
67
+ end
60
68
  end
61
69
 
62
- it do
63
- result = double(:result)
64
- expect(task).to receive(:invoke).and_return(result)
65
- expect(subject).to eq result
70
+ context "when rake task doesn't exist" do
71
+ before do
72
+ expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(false)
73
+ expect(task).not_to receive(:clear)
74
+ end
75
+
76
+ it do
77
+ result = double(:result)
78
+ expect(task).to receive(:invoke).and_return(result)
79
+ expect(subject).to eq result
80
+ end
66
81
  end
67
82
  end
68
83
 
69
- context "when rake task doesn't exist" do
84
+ context 'when the default log level' do
70
85
  before do
71
- expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(false)
72
- expect(task).not_to receive(:clear)
86
+ expect(task_config).to receive(:verbose=).with(true)
73
87
  end
74
88
 
75
- it do
76
- result = double(:result)
77
- expect(task).to receive(:invoke).and_return(result)
78
- expect(subject).to eq result
89
+ it_behaves_like 'invokes RSpec rake task'
90
+ end
91
+
92
+ context 'when the warning log level' do
93
+ before do
94
+ expect(KnapsackPro::Config::Env).to receive(:log_level).and_return(::Logger::WARN)
95
+
96
+ expect(task_config).to receive(:verbose=).with(false)
79
97
  end
98
+
99
+ it_behaves_like 'invokes RSpec rake task'
80
100
  end
81
101
  end
82
102
 
@@ -84,7 +84,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
84
84
 
85
85
  context 'when json report does not exist' do
86
86
  it do
87
- expect { subject }.to raise_error(RuntimeError, 'The report with slow test files has not been generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!')
87
+ expect { subject }.to raise_error(RuntimeError, 'The report with slow test files has not been generated yet. If you have enabled split by test cases https://knapsackpro.com/perma/ruby/split-by-test-examples and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!')
88
88
  end
89
89
  end
90
90
  end
@@ -36,7 +36,7 @@ describe KnapsackPro::SlowTestFileFinder do
36
36
  let(:test_files_encrypted?) { true }
37
37
 
38
38
  it do
39
- expect { subject }.to raise_error RuntimeError, 'Split by test cases is not possible when you have enabled test file names encryption ( https://github.com/KnapsackPro/knapsack_pro-ruby#test-file-names-encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
39
+ expect { subject }.to raise_error RuntimeError, 'Split by test cases is not possible when you have enabled test file names encryption ( https://knapsackpro.com/perma/ruby/encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://knapsackpro.com/perma/ruby/split-by-test-examples'
40
40
  end
41
41
  end
42
42
  end
@@ -11,6 +11,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
11
11
 
12
12
  expect(FileUtils).to receive(:mkdir_p).with(report_dir)
13
13
 
14
+ allow(File).to receive(:exist?)
14
15
  expect(File).to receive(:exist?).at_least(:once).with(report_path).and_return(true)
15
16
  expect(File).to receive(:delete).with(report_path)
16
17
 
@@ -102,6 +102,7 @@ describe KnapsackPro::Tracker do
102
102
  before do
103
103
  test_paths.each_with_index do |test_path, index|
104
104
  tracker.current_test_path = test_path
105
+ sleep 0.001
105
106
  tracker.stop_timer
106
107
  end
107
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-29 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -190,6 +190,8 @@ extensions: []
190
190
  extra_rdoc_files: []
191
191
  files:
192
192
  - ".circleci/config.yml"
193
+ - ".github/assets/install-button.png"
194
+ - ".github/assets/knapsack-diamonds.png"
193
195
  - ".gitignore"
194
196
  - ".rspec"
195
197
  - CHANGELOG.md
@@ -276,6 +278,7 @@ files:
276
278
  - lib/knapsack_pro/test_files_with_test_cases_composer.rb
277
279
  - lib/knapsack_pro/test_flat_distributor.rb
278
280
  - lib/knapsack_pro/tracker.rb
281
+ - lib/knapsack_pro/urls.rb
279
282
  - lib/knapsack_pro/utils.rb
280
283
  - lib/knapsack_pro/version.rb
281
284
  - lib/tasks/cucumber.rake
@@ -390,7 +393,7 @@ metadata:
390
393
  documentation_uri: https://docs.knapsackpro.com/integration/
391
394
  homepage_uri: https://knapsackpro.com
392
395
  source_code_uri: https://github.com/KnapsackPro/knapsack_pro-ruby
393
- post_install_message:
396
+ post_install_message:
394
397
  rdoc_options: []
395
398
  require_paths:
396
399
  - lib
@@ -405,8 +408,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
408
  - !ruby/object:Gem::Version
406
409
  version: '0'
407
410
  requirements: []
408
- rubygems_version: 3.1.6
409
- signing_key:
411
+ rubygems_version: 3.4.6
412
+ signing_key:
410
413
  specification_version: 4
411
414
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
412
415
  job finish work at a similar time.