knapsack_pro 1.8.0 → 1.9.0

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: 4e439d9522688ef5f7ed0774c471fb6bffed329affd7e01c43cabce63709a348
4
- data.tar.gz: b6838efdb36311c9f5d1c96f1fe18479bc33625703f3e6663a0fa754a25da97c
3
+ metadata.gz: 5d7bf901385b7f5c6010f0ec20241cf9d74e4c954cf69ae75ca7f5ac1d4c549b
4
+ data.tar.gz: 0a24d55e70d9055e70ae052ef152e0cf1a85716d4d93025e800a5b1769853f0d
5
5
  SHA512:
6
- metadata.gz: 45cd07d1faa6ba56d558d853c9068701e9bef059d6f36f0aefe40b7267aa287f6f976f5d276d0791da26fdf38347bfda4209aa9c9548de66a426fa4654cdcc54
7
- data.tar.gz: 9fa2019aa18ef91a7a10b658501b89ae752395973f1d01d5e9ecbaedca08d095153d03f659132e8e4a8775c21b1327e57b2191b4f45b3a042c3c2702bcd3a26c
6
+ metadata.gz: '0482cd76a5a08df97ce43abf6d89763f1f8fb83cd3aca349c09de993513a87c623bfe0abb31a05d9dd5701101ebf19789e0a41145b3f2e435567a244a462a992'
7
+ data.tar.gz: 0b958c6d1bf0d8f9cdfcb4a97b5f48a0ad3b046acdc6c6b7198e0a7865f37928fe8f2d4d62acb0306489d5779bd07b613cb5774aca426dd774b81fd6cf431435
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.9.0
4
+
5
+ * Reduce data transfer and speed up usage of Knapsack Pro API for Queue Mode
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/81
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.8.0...v1.9.0
10
+
3
11
  ### 1.8.0
4
12
 
5
13
  * Run Fallback Mode when `OpenSSL::SSL::SSLError` certificate verify failed for API
data/README.md CHANGED
@@ -165,6 +165,8 @@ You can see list of questions for common problems and tips in below [Table of Co
165
165
  - [How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?](#how-to-set-beforesuite-and-aftersuite-rspec-hooks-in-queue-mode-percyio-example)
166
166
  - [How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?](#how-to-call-beforesuite-and-aftersuite-rspec-hooks-only-once-in-queue-mode)
167
167
  - [How to run knapsack_pro with parallel_tests gem?](#how-to-run-knapsack_pro-with-parallel_tests-gem)
168
+ - [parallel_tests with knapsack_pro on parallel CI nodes](#parallel_tests-with-knapsack_pro-on-parallel-ci-nodes)
169
+ - [parallel_tests with knapsack_pro on single CI machine](#parallel_tests-with-knapsack_pro-on-single-ci-machine)
168
170
  - [How to retry failed tests (flaky tests)?](#how-to-retry-failed-tests-flaky-tests)
169
171
  - [How can I run tests from multiple directories?](#how-can-i-run-tests-from-multiple-directories)
170
172
  - [Why I don't see all test files being recorded in user dashboard](#why-i-dont-see-all-test-files-being-recorded-in-user-dashboard)
@@ -2116,6 +2118,8 @@ end
2116
2118
 
2117
2119
  #### How to run knapsack_pro with parallel_tests gem?
2118
2120
 
2121
+ ##### parallel_tests with knapsack_pro on parallel CI nodes
2122
+
2119
2123
  You can run knapsack_pro with [parallel_tests](https://github.com/grosser/parallel_tests) gem to run multiple concurrent knapsack_pro commands per CI node.
2120
2124
 
2121
2125
  Let's consider this example. We have 2 CI node. On each CI node we want to run 2 concurrent knapsack_pro commands by parallel_tests gem (`PARALLEL_TESTS_CONCURRENCY=2`).
@@ -2199,6 +2203,49 @@ To ensure everything works you can check output for each CI node.
2199
2203
  (tests output here)
2200
2204
  ```
2201
2205
 
2206
+ ##### parallel_tests with knapsack_pro on single CI machine
2207
+
2208
+ This tip is only relevant to you if you cannot use multiple parallel CI nodes on your CI provider. In such case, you can run your tests on a single CI machine with knapsack_pro Queue Mode in order to auto balance execution of tests and thanks to this better utilize CI machine resources.
2209
+
2210
+ You can run knapsack_pro with [parallel_tests](https://github.com/grosser/parallel_tests) gem to run multiple concurrent knapsack_pro commands on single CI node.
2211
+
2212
+ Create in your project directory an executable file `bin/parallel_tests_knapsack_pro_single_machine`:
2213
+
2214
+ ```bash
2215
+ #!/bin/bash
2216
+ # bin/parallel_tests_knapsack_pro_single_machine
2217
+
2218
+ export KNAPSACK_PRO_CI_NODE_TOTAL=$PARALLEL_TESTS_CONCURRENCY
2219
+
2220
+ if [ "$TEST_ENV_NUMBER" == "" ]; then
2221
+ export KNAPSACK_PRO_CI_NODE_INDEX=0
2222
+ else
2223
+ export KNAPSACK_PRO_CI_NODE_INDEX=$(( $TEST_ENV_NUMBER - 1 ))
2224
+ fi
2225
+
2226
+ echo KNAPSACK_PRO_CI_NODE_TOTAL=$KNAPSACK_PRO_CI_NODE_TOTAL KNAPSACK_PRO_CI_NODE_INDEX=$KNAPSACK_PRO_CI_NODE_INDEX PARALLEL_TESTS_CONCURRENCY=$PARALLEL_TESTS_CONCURRENCY
2227
+
2228
+ bundle exec rake knapsack_pro:queue:rspec
2229
+ ```
2230
+
2231
+ Then you need another script `bin/parallel_tests_knapsack_pro_single_machine_run` to run above script with `parallel_tests`:
2232
+
2233
+ ```bash
2234
+ #!/bin/bash
2235
+ # bin/parallel_tests_knapsack_pro_single_machine_run
2236
+
2237
+ export PARALLEL_TESTS_CONCURRENCY=2;
2238
+
2239
+ RAILS_ENV=test \
2240
+ KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=xxx \
2241
+ KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
2242
+ KNAPSACK_PRO_PROJECT_DIR=/home/user/rails-app-repo \
2243
+ PARALLEL_TESTS_CONCURRENCY=$PARALLEL_TESTS_CONCURRENCY \
2244
+ bundle exec parallel_test -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests_knapsack_pro_single_machine'
2245
+ ```
2246
+
2247
+ Now you can run `bin/parallel_tests_knapsack_pro_single_machine_run` and it will execute 2 parallel processes with `parallel_tests`. Each process will run knapsack_pro Queue Mode to autobalance test files distribution across the processes.
2248
+
2202
2249
  #### How to retry failed tests (flaky tests)?
2203
2250
 
2204
2251
  Flaky (nondeterministic) tests, are tests that exhibit both a passing and a failing result with the same code.
@@ -5,19 +5,26 @@ module KnapsackPro
5
5
  class Queues < Base
6
6
  class << self
7
7
  def queue(args)
8
+ request_hash = {
9
+ :fixed_queue_split => KnapsackPro::Config::Env.fixed_queue_split,
10
+ :can_initialize_queue => args.fetch(:can_initialize_queue),
11
+ :commit_hash => args.fetch(:commit_hash),
12
+ :branch => args.fetch(:branch),
13
+ :node_total => args.fetch(:node_total),
14
+ :node_index => args.fetch(:node_index),
15
+ :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
16
+ }
17
+
18
+ if request_hash[:can_initialize_queue]
19
+ request_hash.merge!({
20
+ :test_files => args.fetch(:test_files)
21
+ })
22
+ end
23
+
8
24
  action_class.new(
9
25
  endpoint_path: '/v1/queues/queue',
10
26
  http_method: :post,
11
- request_hash: {
12
- :fixed_queue_split => KnapsackPro::Config::Env.fixed_queue_split,
13
- :can_initialize_queue => args.fetch(:can_initialize_queue),
14
- :commit_hash => args.fetch(:commit_hash),
15
- :branch => args.fetch(:branch),
16
- :node_total => args.fetch(:node_total),
17
- :node_index => args.fetch(:node_index),
18
- :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
19
- :test_files => args.fetch(:test_files)
20
- }
27
+ request_hash: request_hash
21
28
  )
22
29
  end
23
30
  end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.8.0'
2
+ VERSION = '1.9.0'
3
3
  end
@@ -1,12 +1,12 @@
1
1
  describe KnapsackPro::Client::API::V1::Queues do
2
2
  describe '.queue' do
3
3
  let(:fixed_queue_split) { double }
4
- let(:can_initialize_queue) { double }
5
4
  let(:commit_hash) { double }
6
5
  let(:branch) { double }
7
6
  let(:node_total) { double }
8
7
  let(:node_index) { double }
9
8
  let(:test_files) { double }
9
+ let(:node_build_id) { double }
10
10
 
11
11
  subject do
12
12
  described_class.queue(
@@ -21,28 +21,52 @@ describe KnapsackPro::Client::API::V1::Queues do
21
21
 
22
22
  before do
23
23
  expect(KnapsackPro::Config::Env).to receive(:fixed_queue_split).and_return(fixed_queue_split)
24
+ expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(node_build_id)
24
25
  end
25
26
 
26
- it do
27
- node_build_id = double
28
- expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(node_build_id)
27
+ context 'when can_initialize_queue=true' do
28
+ let(:can_initialize_queue) { true }
29
+
30
+ it 'sends test_files among other params' do
31
+ action = double
32
+ expect(KnapsackPro::Client::API::Action).to receive(:new).with({
33
+ endpoint_path: '/v1/queues/queue',
34
+ http_method: :post,
35
+ request_hash: {
36
+ fixed_queue_split: fixed_queue_split,
37
+ can_initialize_queue: can_initialize_queue,
38
+ commit_hash: commit_hash,
39
+ branch: branch,
40
+ node_total: node_total,
41
+ node_index: node_index,
42
+ node_build_id: node_build_id,
43
+ test_files: test_files
44
+ }
45
+ }).and_return(action)
46
+ expect(subject).to eq action
47
+ end
48
+ end
49
+
50
+ context 'when can_initialize_queue=false' do
51
+ let(:can_initialize_queue) { false }
29
52
 
30
- action = double
31
- expect(KnapsackPro::Client::API::Action).to receive(:new).with({
32
- endpoint_path: '/v1/queues/queue',
33
- http_method: :post,
34
- request_hash: {
35
- fixed_queue_split: fixed_queue_split,
36
- can_initialize_queue: can_initialize_queue,
37
- commit_hash: commit_hash,
38
- branch: branch,
39
- node_total: node_total,
40
- node_index: node_index,
41
- node_build_id: node_build_id,
42
- test_files: test_files
43
- }
44
- }).and_return(action)
45
- expect(subject).to eq action
53
+ it 'does not send test_files among other params' do
54
+ action = double
55
+ expect(KnapsackPro::Client::API::Action).to receive(:new).with({
56
+ endpoint_path: '/v1/queues/queue',
57
+ http_method: :post,
58
+ request_hash: {
59
+ fixed_queue_split: fixed_queue_split,
60
+ can_initialize_queue: can_initialize_queue,
61
+ commit_hash: commit_hash,
62
+ branch: branch,
63
+ node_total: node_total,
64
+ node_index: node_index,
65
+ node_build_id: node_build_id,
66
+ }
67
+ }).and_return(action)
68
+ expect(subject).to eq action
69
+ end
46
70
  end
47
71
  end
48
72
  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: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
398
398
  - !ruby/object:Gem::Version
399
399
  version: '0'
400
400
  requirements: []
401
- rubygems_version: 3.0.1
401
+ rubygems_version: 3.0.3
402
402
  signing_key:
403
403
  specification_version: 4
404
404
  summary: Knapsack Pro splits tests across CI nodes and makes sure that tests will