knapsack_pro 1.15.0 → 1.16.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: 6de10d3f404a03841c25d3a554c9b44a9b0c9ca97386d46ebe38a3b9eb0eed5f
4
- data.tar.gz: 625ad48ee1f6d3a1961f60bf7ce23fe209b26f4f03ec565876050969630eca3e
3
+ metadata.gz: 19a2cee7a78789810cdeca8df09ab0ebce2141cc4682c8a58fb8db4c5c7fafe2
4
+ data.tar.gz: 2fd92dbf8190a930ef46b84d96b94e680f0d36dbd6353a85535bcb88488cdce3
5
5
  SHA512:
6
- metadata.gz: 5c05eec67c0d656f85049b73f625678b15c813997d84d3ecbdefaa063532a445ecb888b8a08c928dbcf46314dafbf155b1bfb8a2319c923be3e7f958fc04f879
7
- data.tar.gz: 0ffbca55a18ab1e35e741edcc90020e3ff7ef1fe58296aa860e9397b48557f85d0d0ae327d3be84794ac062528220e4ed9165aa7223e65d37534be71403bd2e3
6
+ metadata.gz: bbe18332a829d8af9a1dccc3717a7868fc5dad3c64c66320019ade8278689d1080380ece596788917ae31b5afb516a6109b2f5db7ef5e202bfbb909bb485367c
7
+ data.tar.gz: d5d5a6877d2f29f067eadfb711bd1504bff3fcba172d13840f60c8b7dbf7ba9c17b9d33f82b265626a59f8211da2cbc3c820755c9acb464e471ae98490e8751e
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.16.0
4
+
5
+ * Add test runner name to `KNAPSACK-PRO-CLIENT-NAME` header send to Knapsack Pro API
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/95
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.15.0...v1.16.0
10
+
3
11
  ### 1.15.0
4
12
 
5
13
  * Add support for Codefresh.io CI provider
data/README.md CHANGED
@@ -42,7 +42,11 @@ The knapsack_pro has also [queue mode](#queue-mode) to get an optimal test suite
42
42
 
43
43
  ## FAQ
44
44
 
45
- You can see list of questions for common problems and tips in below [Table of Contents](#table-of-contents). Scroll 1 page down and you will see the FAQ in the table of contents.
45
+ __NEW:__ Up to date [FAQ for knapsack_pro gem can be found here](https://knapsackpro.com/faq/knapsack_pro_client/knapsack_pro_ruby).
46
+
47
+ __OLD:__ This README also contains FAQ questions but we keep adding new info only to our new FAQ page mentioned above.
48
+
49
+ We keep this old FAQ in README to not break old links spread across the web. You can see old FAQ list of questions for common problems and tips in below [Table of Contents](#table-of-contents). Scroll 1 page down and you will see the FAQ in the table of contents.
46
50
 
47
51
  # Requirements
48
52
 
@@ -175,6 +179,7 @@ You can see list of questions for common problems and tips in below [Table of Co
175
179
  - [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)
176
180
  - [What hooks are supported in Queue Mode?](#what-hooks-are-supported-in-queue-mode)
177
181
  - [How to run knapsack_pro with parallel_tests gem?](#how-to-run-knapsack_pro-with-parallel_tests-gem)
182
+ - [Should I use parallel_tests gem (what are pitfalls)?](#should-i-use-parallel_tests-gem-what-are-pitfalls)
178
183
  - [parallel_tests with knapsack_pro on parallel CI nodes](#parallel_tests-with-knapsack_pro-on-parallel-ci-nodes)
179
184
  - [parallel_tests with knapsack_pro on single CI machine](#parallel_tests-with-knapsack_pro-on-single-ci-machine)
180
185
  - [How to retry failed tests (flaky tests)?](#how-to-retry-failed-tests-flaky-tests)
@@ -869,13 +874,31 @@ end
869
874
  # Here is additional configuration to ensure the xml report will be visible by CircleCI
870
875
  KnapsackPro::Hooks::Queue.after_queue do |queue_id|
871
876
  # Metadata collection
872
- # https://circleci.com/docs/1.0/test-metadata/#metadata-collection-in-custom-test-steps
877
+ # https://circleci.com/docs/2.0/collect-test-data/#metadata-collection-in-custom-test-steps
873
878
  if File.exist?(FINAL_RSPEC_XML_REPORT) && ENV['CIRCLE_TEST_REPORTS']
874
879
  FileUtils.cp(FINAL_RSPEC_XML_REPORT, "#{ENV['CIRCLE_TEST_REPORTS']}/rspec.xml")
875
880
  end
876
881
  end
877
882
  ```
878
883
 
884
+ Ensure you have in CircleCI config yml
885
+
886
+ ```yaml
887
+ - run:
888
+ name: RSpec via knapsack_pro Queue Mode
889
+ command: |
890
+ export CIRCLE_TEST_REPORTS=/tmp/test-results
891
+ mkdir $CIRCLE_TEST_REPORTS
892
+ bundle exec rake "knapsack_pro:queue:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
893
+
894
+ # collect reports
895
+ - store_test_results:
896
+ path: /tmp/test-results
897
+ - store_artifacts:
898
+ path: /tmp/test-results
899
+ destination: test-results
900
+ ```
901
+
879
902
  #### Info for Travis users
880
903
 
881
904
  You can parallelize your builds across virtual machines with [travis matrix feature](http://docs.travis-ci.com/user/speeding-up-the-build/#parallelizing-your-builds-across-virtual-machines). Edit `.travis.yml`
@@ -1212,7 +1235,7 @@ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knaps
1212
1235
 
1213
1236
  Remember to add API tokens like `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` and `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` to `Environment` page of your project settings in Codeship.
1214
1237
 
1215
- If you want to use Codeship retry single CI node feature to retry just failed tests on particular CI node then you should set [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node).
1238
+ CodeShip uses the same build number if you restart a build. Because of that you need to set [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node) in order to be able to restart CI build in Queue Mode.
1216
1239
 
1217
1240
  #### Info for Heroku CI users
1218
1241
 
@@ -2648,6 +2671,23 @@ end
2648
2671
 
2649
2672
  #### How to run knapsack_pro with parallel_tests gem?
2650
2673
 
2674
+ ##### Should I use parallel_tests gem (what are pitfalls)?
2675
+
2676
+ If you plan to use parallel_tests please be careful how many parallel processes with running tests you will start on a single CI node.
2677
+ Often it happens that running 2 or more processes with tests using parallel_tests gem on the CI node that has low performance leads to slower execution of test suite. You can accidentally make your whole test suite running slower by using parallel_tests if you have not enough powerful CI server (slow CPU, not enough RAM, slow disk).
2678
+
2679
+ If you use parallel_tests and knapsack_pro you can see recorded tests timing in Knapsack Pro [user dashboard](https://knapsackpro.com/dashboard). See the "Build metrics" link next to your API token and check the last recorded CI build time. You will be able to see there how long each test files took to execute. If you notice that after adding parallel_tests gem your test files started to take more time than before it means you overloaded your CI server.
2680
+
2681
+ You should:
2682
+
2683
+ * reduce the number of parallel processes in parallel_tests gem
2684
+ * or buy a more powerful CI node to allow running more parallel processes (vertical scaling)
2685
+ * or don't use parallel_tests gem at all (recommended)
2686
+
2687
+ In case of tests execution time increase (slower tests) I recommend using more parallel nodes offered by your CI provider to scale your tests horizontally. Basically, adding parallel CI nodes instead of vertically adding more CPU/RAM to CI node is a better option. Parallel_tests gem has mixed output results from the parallel processes so it's easier to just browse tests output from parallel CI nodes when you scale horizontally by using knapsack_pro without parallel_tests.
2688
+
2689
+ If you want to use parallel_tests you can use it with Knapsack Pro Queue Mode to auto-balance tests split across parallel processes started by parallel_tests gem. See below tips on how to do it on [many parallel CI nodes where each node starts many parallel_tests processes](#parallel_tests-with-knapsack_pro-on-parallel-ci-nodes) or [on a single powerful CI server](#parallel_tests-with-knapsack_pro-on-single-ci-machine).
2690
+
2651
2691
  ##### parallel_tests with knapsack_pro on parallel CI nodes
2652
2692
 
2653
2693
  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.
@@ -2804,7 +2844,7 @@ bundle exec rspec --only-failures
2804
2844
 
2805
2845
  #### How can I run tests from multiple directories?
2806
2846
 
2807
- The test file pattern config option supports any glob pattern handled by [`Dir.glob`](http://ruby-doc.org/core-2.4.1/Dir.html#method-c-glob) and can be configured to pull test files from multiple directories. An example of this when using RSpec would be `""{spec,engines/*/spec}/**/*_spec.rb" "`. For complex cases like this, the test directory can't be extracted and must be specified manually using the `KNAPSACK_PRO_TEST_DIR` environment variable:
2847
+ The test file pattern config option supports any glob pattern handled by [`Dir.glob`](http://ruby-doc.org/core-2.4.1/Dir.html#method-c-glob) and can be configured to pull test files from multiple directories. An example of this when using RSpec would be `"{spec,engines/*/spec}/**/*_spec.rb"`. For complex cases like this, the test directory can't be extracted and must be specified manually using the `KNAPSACK_PRO_TEST_DIR` environment variable:
2808
2848
 
2809
2849
  ```
2810
2850
  # This is example where you have in engines directory multiple projects
@@ -47,17 +47,17 @@ require_relative 'knapsack_pro/test_file_pattern'
47
47
  require_relative 'knapsack_pro/test_flat_distributor'
48
48
  require_relative 'knapsack_pro/task_loader'
49
49
  require_relative 'knapsack_pro/tracker'
50
- require_relative 'knapsack_pro/allocator'
51
- require_relative 'knapsack_pro/queue_allocator'
52
- require_relative 'knapsack_pro/base_allocator_builder'
53
- require_relative 'knapsack_pro/allocator_builder'
54
- require_relative 'knapsack_pro/queue_allocator_builder'
55
50
  require_relative 'knapsack_pro/adapters/base_adapter'
56
51
  require_relative 'knapsack_pro/adapters/rspec_adapter'
57
52
  require_relative 'knapsack_pro/adapters/cucumber_adapter'
58
53
  require_relative 'knapsack_pro/adapters/minitest_adapter'
59
54
  require_relative 'knapsack_pro/adapters/test_unit_adapter'
60
55
  require_relative 'knapsack_pro/adapters/spinach_adapter'
56
+ require_relative 'knapsack_pro/allocator'
57
+ require_relative 'knapsack_pro/queue_allocator'
58
+ require_relative 'knapsack_pro/base_allocator_builder'
59
+ require_relative 'knapsack_pro/allocator_builder'
60
+ require_relative 'knapsack_pro/queue_allocator_builder'
61
61
  require_relative 'knapsack_pro/runners/base_runner'
62
62
  require_relative 'knapsack_pro/runners/rspec_runner'
63
63
  require_relative 'knapsack_pro/runners/cucumber_runner'
@@ -1,7 +1,16 @@
1
1
  module KnapsackPro
2
2
  class BaseAllocatorBuilder
3
+ TEST_RUNNER_MAP = {
4
+ KnapsackPro::Adapters::RSpecAdapter => 'rspec',
5
+ KnapsackPro::Adapters::CucumberAdapter => 'cucumber',
6
+ KnapsackPro::Adapters::MinitestAdapter => 'minitest',
7
+ KnapsackPro::Adapters::SpinachAdapter => 'spinach',
8
+ KnapsackPro::Adapters::TestUnitAdapter => 'test-unit',
9
+ }
10
+
3
11
  def initialize(adapter_class)
4
12
  @adapter_class = adapter_class
13
+ ENV['KNAPSACK_PRO_TEST_RUNNER'] = TEST_RUNNER_MAP[adapter_class]
5
14
  end
6
15
 
7
16
  def allocator
@@ -67,11 +67,18 @@ module KnapsackPro
67
67
  {
68
68
  'Content-Type' => 'application/json',
69
69
  'Accept' => 'application/json',
70
- 'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
70
+ 'KNAPSACK-PRO-CLIENT-NAME' => client_name,
71
71
  'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
72
72
  }
73
73
  end
74
74
 
75
+ def client_name
76
+ [
77
+ 'knapsack_pro-ruby',
78
+ ENV['KNAPSACK_PRO_TEST_RUNNER'],
79
+ ].compact.join('/')
80
+ end
81
+
75
82
  def parse_response_body(body)
76
83
  return '' if body == '' || body.nil?
77
84
  JSON.parse(body)
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.15.0'
2
+ VERSION = '1.16.0'
3
3
  end
@@ -2,6 +2,62 @@ describe KnapsackPro::BaseAllocatorBuilder do
2
2
  let(:adapter_class) { KnapsackPro::Adapters::BaseAdapter }
3
3
  let(:allocator_builder) { described_class.new(adapter_class) }
4
4
 
5
+ describe 'initialize method' do
6
+ context 'when unknown adapter (base adapter)' do
7
+ let(:adapter_class) { KnapsackPro::Adapters::BaseAdapter }
8
+
9
+ it do
10
+ allocator_builder
11
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to be_nil
12
+ end
13
+ end
14
+
15
+ context 'when RSpec adapter' do
16
+ let(:adapter_class) { KnapsackPro::Adapters::RSpecAdapter }
17
+
18
+ it do
19
+ allocator_builder
20
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to eq 'rspec'
21
+ end
22
+ end
23
+
24
+ context 'when Cucumber adapter' do
25
+ let(:adapter_class) { KnapsackPro::Adapters::CucumberAdapter }
26
+
27
+ it do
28
+ allocator_builder
29
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to eq 'cucumber'
30
+ end
31
+ end
32
+
33
+ context 'when Minitest adapter' do
34
+ let(:adapter_class) { KnapsackPro::Adapters::MinitestAdapter }
35
+
36
+ it do
37
+ allocator_builder
38
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to eq 'minitest'
39
+ end
40
+ end
41
+
42
+ context 'when Spinach adapter' do
43
+ let(:adapter_class) { KnapsackPro::Adapters::SpinachAdapter }
44
+
45
+ it do
46
+ allocator_builder
47
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to eq 'spinach'
48
+ end
49
+ end
50
+
51
+ context 'when Test::Unit adapter' do
52
+ let(:adapter_class) { KnapsackPro::Adapters::TestUnitAdapter }
53
+
54
+ it do
55
+ allocator_builder
56
+ expect(ENV['KNAPSACK_PRO_TEST_RUNNER']).to eq 'test-unit'
57
+ end
58
+ end
59
+ end
60
+
5
61
  describe '#allocator' do
6
62
  subject { allocator_builder.allocator }
7
63
 
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.15.0
4
+ version: 1.16.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-10-11 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake