Skip to content

Commit fb3b833

Browse files
committed
initv2
1 parent 2933210 commit fb3b833

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

lib/knapsack_pro/client/api/v2/queues.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,34 @@ def queue(args)
4646
)
4747
end
4848

49+
def connect
50+
git_adapter = KnapsackPro::RepositoryAdapters::GitAdapter.new
51+
repository_adapter = KnapsackPro::RepositoryAdapterInitiator.call
52+
53+
request_hash = {
54+
attempt_connect_to_queue: true,
55+
batch_uuid: SecureRandom.uuid,
56+
branch: KnapsackPro::Crypto::BranchEncryptor.call(repository_adapter.branch),
57+
build_author: git_adapter.build_author,
58+
can_initialize_queue: true,
59+
commit_authors: git_adapter.commit_authors,
60+
commit_hash: repository_adapter.commit_hash,
61+
fixed_queue_split: KnapsackPro::Config::Env.fixed_queue_split_?,
62+
node_index: KnapsackPro::Config::Env.ci_node_index,
63+
node_total: KnapsackPro::Config::Env.ci_node_total,
64+
node_uuid: SecureRandom.uuid,
65+
skip_pull: true,
66+
test_queue_id: KnapsackPro::Config::Env.test_queue_id,
67+
user_seat: KnapsackPro::Config::Env.masked_user_seat,
68+
}
69+
70+
action_class.new(
71+
endpoint_path: '/v2/queues/queue',
72+
http_method: :post,
73+
request_hash: request_hash
74+
)
75+
end
76+
4977
def initialize(paths)
5078
git_adapter = KnapsackPro::RepositoryAdapters::GitAdapter.new
5179
repository_adapter = KnapsackPro::RepositoryAdapterInitiator.call

lib/knapsack_pro/rspec/test_queue_initializer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def call(args)
2323
private
2424

2525
def test_queue_exists?
26-
action = KnapsackPro::Client::API::V1::Queues.connect
26+
action = KnapsackPro::Client::API::V2::Queues.connect
2727
connection = KnapsackPro::Client::Connection.new(action)
2828
response = connection.call
2929

@@ -53,7 +53,7 @@ def initialize_test_queue(slow_id_paths)
5353
exit 1
5454
end
5555

56-
action = KnapsackPro::Client::API::V1::Queues.initialize(paths)
56+
action = KnapsackPro::Client::API::V2::Queues.initialize(paths)
5757
connection = KnapsackPro::Client::Connection.new(action)
5858
response = connection.call
5959

spec/integration/rspec/test_queue_initializer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require 'json'
44

55
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = SecureRandom.hex
6-
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
6+
ENV['KNAPSACK_PRO_TEST_QUEUE_ID'] = SecureRandom.uuid
7+
ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = ENV['KNAPSACK_PRO_TEST_QUEUE_ID']
78
ENV['KNAPSACK_PRO_TEST_DIR'] = 'spec_integration'
89
ENV['KNAPSACK_PRO_TEST_FILE_PATTERN'] = "spec_integration/**{,/*/**}/*_spec.rb"
910

spec/integration/rspec/test_queue_initializer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def log(stdout, stderr, status)
111111

112112
expect(actual.stdout).to include('DEBUG -- knapsack_pro: GET https://api.knapsackpro.com/v1/build_distributions/last').once
113113
expect(actual.stdout).to include('INFO -- knapsack_pro: Calculating Split by Test Examples. Analyzing 1 slow test files').once
114-
expect(actual.stdout).to include('DEBUG -- knapsack_pro: POST https://api.knapsackpro.com/v1/queues/queue').twice
114+
expect(actual.stdout).to include('DEBUG -- knapsack_pro: POST https://api.knapsackpro.com/v2/queues/queue').twice
115115
expect(actual.stdout).to include('"test_files":[{"path":"spec_integration/fast_spec.rb[1:1]"},{"path":"spec_integration/fast_spec.rb[1:2]"},{"path":"spec_integration/slow_spec.rb[1:1]"},{"path":"spec_integration/slow_spec.rb[1:2]"}]').once
116116
expect(actual.stdout).to include('INFO -- knapsack_pro: Test Queue URL: http://example.com').once
117117

0 commit comments

Comments
 (0)