knapsack_pro 10.0.1 → 11.0.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/base_adapter.rb +6 -6
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +3 -3
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +3 -3
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +0 -29
- data/lib/knapsack_pro/client/api/v2/queues.rb +1 -3
- data/lib/knapsack_pro/client/connection.rb +25 -12
- data/lib/knapsack_pro/commands.rb +8 -8
- data/lib/knapsack_pro/config/ci/app_veyor.rb +0 -8
- data/lib/knapsack_pro/config/ci/base.rb +0 -7
- data/lib/knapsack_pro/config/ci/buildkite.rb +1 -9
- data/lib/knapsack_pro/config/ci/circle.rb +0 -8
- data/lib/knapsack_pro/config/ci/cirrus_ci.rb +0 -8
- data/lib/knapsack_pro/config/ci/codefresh.rb +0 -8
- data/lib/knapsack_pro/config/ci/codeship.rb +0 -8
- data/lib/knapsack_pro/config/ci/github_actions.rb +2 -10
- data/lib/knapsack_pro/config/ci/gitlab_ci.rb +0 -9
- data/lib/knapsack_pro/config/ci/heroku.rb +1 -9
- data/lib/knapsack_pro/config/ci/semaphore.rb +0 -8
- data/lib/knapsack_pro/config/ci/semaphore2.rb +0 -8
- data/lib/knapsack_pro/config/ci/travis.rb +0 -8
- data/lib/knapsack_pro/config/env.rb +12 -42
- data/lib/knapsack_pro/crypto/branch_encryptor.rb +4 -5
- data/lib/knapsack_pro/extensions/rspec_extension.rb +1 -1
- data/lib/knapsack_pro/queue_allocator.rb +33 -88
- data/lib/knapsack_pro/regular_allocator.rb +41 -20
- data/lib/knapsack_pro/report.rb +37 -8
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +10 -2
- data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -1
- data/lib/knapsack_pro/runners/minitest_runner.rb +2 -1
- data/lib/knapsack_pro/runners/queue/base_runner.rb +17 -8
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +1 -1
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +1 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +3 -3
- data/lib/knapsack_pro/runners/rspec_runner.rb +2 -1
- data/lib/knapsack_pro/runners/spinach_runner.rb +2 -1
- data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -1
- data/lib/knapsack_pro/tracker.rb +2 -4
- data/lib/knapsack_pro/urls.rb +4 -10
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/tasks/queue/rspec.rake +5 -1
- metadata +2 -3
- data/lib/knapsack_pro/client/api/v1/queues.rb +0 -44
|
@@ -5,6 +5,7 @@ module KnapsackPro
|
|
|
5
5
|
class SpinachRunner < BaseRunner
|
|
6
6
|
def self.run(args)
|
|
7
7
|
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_spinach
|
|
8
|
+
ENV['KNAPSACK_PRO_NODE_UUID'] = SecureRandom.uuid
|
|
8
9
|
|
|
9
10
|
adapter_class = KnapsackPro::Adapters::SpinachAdapter
|
|
10
11
|
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
|
@@ -15,7 +16,7 @@ module KnapsackPro
|
|
|
15
16
|
|
|
16
17
|
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
|
17
18
|
|
|
18
|
-
cmd = %Q[
|
|
19
|
+
cmd = %Q[KNAPSACK_PRO_SINGLE_BATCH_MODE_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=#{ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN']} bundle exec spinach #{args} --features_path #{runner.test_dir} -- #{runner.stringify_test_file_paths}]
|
|
19
20
|
|
|
20
21
|
Kernel.exec(cmd)
|
|
21
22
|
end
|
|
@@ -5,7 +5,8 @@ module KnapsackPro
|
|
|
5
5
|
class TestUnitRunner < BaseRunner
|
|
6
6
|
def self.run(args)
|
|
7
7
|
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_test_unit
|
|
8
|
-
ENV['
|
|
8
|
+
ENV['KNAPSACK_PRO_SINGLE_BATCH_MODE_ENABLED'] = 'true'
|
|
9
|
+
ENV['KNAPSACK_PRO_NODE_UUID'] = SecureRandom.uuid
|
|
9
10
|
|
|
10
11
|
adapter_class = KnapsackPro::Adapters::TestUnitAdapter
|
|
11
12
|
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
data/lib/knapsack_pro/tracker.rb
CHANGED
|
@@ -4,8 +4,6 @@ module KnapsackPro
|
|
|
4
4
|
class Tracker
|
|
5
5
|
include Singleton
|
|
6
6
|
|
|
7
|
-
# when test file is pending, empty with no tests or has syntax error then assume time execution
|
|
8
|
-
# to better allocate it in Queue Mode for future CI build runs
|
|
9
7
|
DEFAULT_TEST_FILE_TIME = 0.0 # seconds
|
|
10
8
|
|
|
11
9
|
attr_reader :global_time, :test_files_with_time, :prerun_tests_loaded
|
|
@@ -22,7 +20,7 @@ module KnapsackPro
|
|
|
22
20
|
|
|
23
21
|
# Remove report only when the reset! method is called explicitly.
|
|
24
22
|
# The report should be persisted on the disk so that multiple tracker instances can share the report state.
|
|
25
|
-
# Tracker instance can be created by knapsack_pro process and a separate tracker is created by rake task (e.g., RSpec) in
|
|
23
|
+
# Tracker instance can be created by knapsack_pro process and a separate tracker is created by rake task (e.g., RSpec) in Single-Batch Mode.
|
|
26
24
|
File.delete(prerun_tests_report_path) if File.exist?(prerun_tests_report_path)
|
|
27
25
|
end
|
|
28
26
|
|
|
@@ -71,7 +69,7 @@ module KnapsackPro
|
|
|
71
69
|
|
|
72
70
|
def to_a
|
|
73
71
|
# When the test files are not loaded in the memory then load them from the disk.
|
|
74
|
-
# Useful for the
|
|
72
|
+
# Useful for the Single-Batch Mode when the memory is not shared between tracker instances.
|
|
75
73
|
# Tracker instance can be created by knapsack_pro process and a separate tracker is created by rake task (e.g., RSpec)
|
|
76
74
|
load_prerun_tests unless prerun_tests_loaded
|
|
77
75
|
|
data/lib/knapsack_pro/urls.rb
CHANGED
|
@@ -12,21 +12,15 @@ module KnapsackPro
|
|
|
12
12
|
|
|
13
13
|
FALLBACK_MODE = "#{HOST}/perma/ruby/fallback-mode"
|
|
14
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
15
|
INSTALLATION_GUIDE = "#{HOST}/perma/ruby/installation-guide"
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false"
|
|
17
|
+
NORMAL_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false"
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
NORMAL_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"
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
SINGLE_BATCH_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false"
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
SINGLE_BATCH_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"
|
|
30
24
|
|
|
31
25
|
RSPEC__DEPRECATED_RUN_ALL_WHEN_EVERYTHING_FILTERED = "#{HOST}/perma/ruby/rspec-deprecated-run-all-when-everything-filtered"
|
|
32
26
|
|
data/lib/knapsack_pro/version.rb
CHANGED
data/lib/tasks/queue/rspec.rake
CHANGED
|
@@ -5,7 +5,11 @@ require 'knapsack_pro'
|
|
|
5
5
|
namespace :knapsack_pro do
|
|
6
6
|
namespace :queue do
|
|
7
7
|
task :rspec, [:rspec_args] do |_, args|
|
|
8
|
-
|
|
8
|
+
if ENV.fetch('KNAPSACK_PRO_SINGLE_BATCH', 'false') == 'true'
|
|
9
|
+
KnapsackPro::Runners::RSpecRunner.run(args[:rspec_args])
|
|
10
|
+
else
|
|
11
|
+
Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:rspec_go[#{args[:rspec_args]}]'")
|
|
12
|
+
end
|
|
9
13
|
end
|
|
10
14
|
|
|
11
15
|
task :rspec_go, [:rspec_args] do |_, args|
|
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:
|
|
4
|
+
version: 11.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ArturT
|
|
@@ -217,7 +217,6 @@ files:
|
|
|
217
217
|
- lib/knapsack_pro/client/api/v1/base.rb
|
|
218
218
|
- lib/knapsack_pro/client/api/v1/build_distributions.rb
|
|
219
219
|
- lib/knapsack_pro/client/api/v1/build_subsets.rb
|
|
220
|
-
- lib/knapsack_pro/client/api/v1/queues.rb
|
|
221
220
|
- lib/knapsack_pro/client/api/v2/queues.rb
|
|
222
221
|
- lib/knapsack_pro/client/connection.rb
|
|
223
222
|
- lib/knapsack_pro/commands.rb
|
|
@@ -321,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
321
320
|
- !ruby/object:Gem::Version
|
|
322
321
|
version: '0'
|
|
323
322
|
requirements: []
|
|
324
|
-
rubygems_version: 4.0.
|
|
323
|
+
rubygems_version: 4.0.20
|
|
325
324
|
specification_version: 4
|
|
326
325
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|
|
327
326
|
job finish work at a similar time.
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module KnapsackPro
|
|
4
|
-
module Client
|
|
5
|
-
module API
|
|
6
|
-
module V1
|
|
7
|
-
class Queues < Base
|
|
8
|
-
CODE_ATTEMPT_CONNECT_TO_QUEUE_FAILED = 'ATTEMPT_CONNECT_TO_QUEUE_FAILED'
|
|
9
|
-
|
|
10
|
-
class << self
|
|
11
|
-
def queue(args)
|
|
12
|
-
request_hash = {
|
|
13
|
-
:fixed_queue_split => KnapsackPro::Config::Env.fixed_queue_split,
|
|
14
|
-
:can_initialize_queue => args.fetch(:can_initialize_queue),
|
|
15
|
-
:attempt_connect_to_queue => args.fetch(:attempt_connect_to_queue),
|
|
16
|
-
:commit_hash => args.fetch(:commit_hash),
|
|
17
|
-
:branch => args.fetch(:branch),
|
|
18
|
-
:node_total => args.fetch(:node_total),
|
|
19
|
-
:node_index => args.fetch(:node_index),
|
|
20
|
-
:node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
|
|
21
|
-
:user_seat => KnapsackPro::Config::Env.masked_user_seat,
|
|
22
|
-
batch_uuid: args.fetch(:batch_uuid)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
|
|
26
|
-
request_hash.merge!({
|
|
27
|
-
:test_files => args.fetch(:test_files),
|
|
28
|
-
:build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
|
|
29
|
-
:commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
|
|
30
|
-
})
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
action_class.new(
|
|
34
|
-
endpoint_path: '/v1/queues/queue',
|
|
35
|
-
http_method: :post,
|
|
36
|
-
request_hash: request_hash
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|