README.md in knapsack_pro-0.50.1 vs README.md in knapsack_pro-0.51.0
- old
+ new
@@ -3,17 +3,20 @@
[![Circle CI](https://circleci.com/gh/KnapsackPro/knapsack_pro-ruby.svg)](https://circleci.com/gh/KnapsackPro/knapsack_pro-ruby)
[![Gem Version](https://badge.fury.io/rb/knapsack_pro.svg)](https://rubygems.org/gems/knapsack_pro)
[![Code Climate](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby/badges/gpa.svg)](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby)
[![Test Coverage](https://codeclimate.com/github/KnapsackPro/knapsack-pro-ruby/badges/coverage.svg)](https://codeclimate.com/github/KnapsackPro/knapsack-pro-ruby/coverage)
+Follow us on [Twitter @KnapsackPro](https://twitter.com/KnapsackPro) and give Like on [Facebook KnapsackPro](https://www.facebook.com/KnapsackPro)
+
Knapsack Pro gem splits tests across CI nodes and makes sure that tests will run comparable time on each node. It uses [KnapsackPro.com API](http://docs.knapsackpro.com). You can learn more at [https://knapsackpro.com](https://knapsackpro.com?utm_source=github&utm_medium=readme&utm_campaign=knapsack_pro-ruby_gem&utm_content=learn_more)
The knapsack_pro gem supports:
* [RSpec](http://rspec.info)
* [Cucumber](https://cucumber.io)
* [Minitest](http://docs.seattlerb.org/minitest/)
+* [test-unit](https://github.com/test-unit/test-unit)
* [Spinach](https://github.com/codegram/spinach)
* [Turnip](https://github.com/jnicklas/turnip)
__Would you like to try knapsack_pro gem?__ You can [get an API token here](http://knapsackpro.com?utm_source=github&utm_medium=readme&utm_campaign=knapsack_pro-ruby_gem&utm_content=get_api_token).
@@ -58,10 +61,11 @@
- [How to set up](#how-to-set-up)
- [Usage (How to set up 1 of 3)](#usage-how-to-set-up-1-of-3)
- [Step for RSpec](#step-for-rspec)
- [Step for Cucumber](#step-for-cucumber)
- [Step for Minitest](#step-for-minitest)
+ - [Step for test-unit](#step-for-test-unit)
- [Step for Spinach](#step-for-spinach)
- [Custom configuration](#custom-configuration)
- [Setup your CI server (How to set up 2 of 3)](#setup-your-ci-server-how-to-set-up-2-of-3)
- [Set API key token](#set-api-key-token)
- [Set knapsack_pro command to execute tests](#set-knapsack_pro-command-to-execute-tests)
@@ -82,19 +86,21 @@
- [Environment variables for debugging gem](#environment-variables-for-debugging-gem)
- [Passing arguments to rake task](#passing-arguments-to-rake-task)
- [Passing arguments to rspec](#passing-arguments-to-rspec)
- [Passing arguments to cucumber](#passing-arguments-to-cucumber)
- [Passing arguments to minitest](#passing-arguments-to-minitest)
+ - [Passing arguments to test-unit](#passing-arguments-to-test-unit)
- [Passing arguments to spinach](#passing-arguments-to-spinach)
- [Knapsack Pro binary](#knapsack-pro-binary)
- [Test file names encryption](#test-file-names-encryption)
- [How to enable test file names encryption?](#how-to-enable-test-file-names-encryption)
- [How to debug test file names?](#how-to-debug-test-file-names)
- [How to enable branch names encryption?](#how-to-enable-branch-names-encryption)
- [How to debug branch names?](#how-to-debug-branch-names)
- [Supported CI providers](#supported-ci-providers)
- [Info for CircleCI users](#info-for-circleci-users)
+ - [CircleCI and knapsack_pro Queue Mode](#circleci-and-knapsack_pro-queue-mode)
- [Info for Travis users](#info-for-travis-users)
- [Info for semaphoreapp.com users](#info-for-semaphoreappcom-users)
- [Info for buildkite.com users](#info-for-buildkitecom-users)
- [Info for Gitlab CI users](#info-for-gitlab-ci-users)
- [Info for codeship.com users](#info-for-codeshipcom-users)
@@ -103,10 +109,11 @@
- [FAQ](#faq)
- [Common problems](#common-problems)
- [Why I see API error commit_hash parameter is required?](#why-i-see-api-error-commit_hash-parameter-is-required)
- [Why I see `LoadError: cannot load such file -- spec_helper`?](#why-i-see-loaderror-cannot-load-such-file----spec_helper)
- [Queue Mode problems](#queue-mode-problems)
+ - [Why when I use Queue Mode for RSpec then my tests fail?](#why-when-i-use-queue-mode-for-rspec-then-my-tests-fail)
- [Why I don't see collected time execution data for my build in user dashboard?](#why-i-dont-see-collected-time-execution-data-for-my-build-in-user-dashboard)
- [Why when I use Queue Mode for RSpec and test fails then I see multiple times info about failed test in RSpec result?](#why-when-i-use-queue-mode-for-rspec-and-test-fails-then-i-see-multiple-times-info-about-failed-test-in-rspec-result)
- [Why when I use Queue Mode for RSpec then I see multiple times the same pending tests?](#why-when-i-use-queue-mode-for-rspec-then-i-see-multiple-times-the-same-pending-tests)
- [Does in Queue Mode the RSpec is initialized many times that causes Rails load over and over again?](#does-in-queue-mode-the-rspec-is-initialized-many-times-that-causes-rails-load-over-and-over-again)
- [Why my tests are executed twice in queue mode? Why CI node runs whole test suite again?](#why-my-tests-are-executed-twice-in-queue-mode-why-ci-node-runs-whole-test-suite-again)
@@ -254,10 +261,23 @@
knapsack_pro_adapter = KnapsackPro::Adapters::MinitestAdapter.bind
knapsack_pro_adapter.set_test_helper_path(__FILE__)
```
+#### Step for test-unit
+
+Add at the beginning of your `test_helper.rb`:
+
+```ruby
+require 'knapsack_pro'
+
+# CUSTOM_CONFIG_GOES_HERE
+
+knapsack_pro_adapter = KnapsackPro::Adapters::TestUnitAdapter.bind
+knapsack_pro_adapter.set_test_helper_path(__FILE__)
+```
+
#### Step for Spinach
Create file `features/support/knapsack_pro.rb` and add there:
```ruby
@@ -268,11 +288,11 @@
KnapsackPro::Adapters::SpinachAdapter.bind
```
#### Custom configuration
-You can change the default Knapsack Pro configuration for RSpec, Cucumber, Minitest or Spinach tests. Here are examples what you can do. Put the configuration below in place of `CUSTOM_CONFIG_GOES_HERE` (in the configuration samples above).
+You can change the default Knapsack Pro configuration for RSpec, Cucumber, Minitest, test-unit or Spinach tests. Here are examples what you can do. Put the configuration below in place of `CUSTOM_CONFIG_GOES_HERE` (in the configuration samples above).
```ruby
# you can use your own logger
require 'logger'
KnapsackPro.logger = Logger.new(STDOUT)
@@ -288,11 +308,12 @@
Set one or more tokens depending on how many test suites you run on CI server.
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` - as value set token for rspec test suite. Token can be generated when you sign in to [knapsackpro.com](http://www.knapsackpro.com).
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` - token for cucumber test suite.
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST` - token for minitest test suite.
-* `KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH` - token for minitest test suite.
+* `KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT` - token for test-unit test suite.
+* `KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH` - token for spinach test suite.
__Tip:__ In case you have for instance multiple rspec test suites then prepend each of knapsack_pro command which executes tests with `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` variable.
#### Set knapsack_pro command to execute tests
@@ -305,10 +326,13 @@
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
# Step for Minitest
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
+ # Step for test-unit
+ $ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:test_unit
+
# Step for Spinach
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
You can add `KNAPSACK_PRO_TEST_FILE_PATTERN` if your tests are not in default directory. For instance:
@@ -319,10 +343,13 @@
$ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_features/**{,/*/**}/*.feature" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
# Step for Minitest
$ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_tests/**{,/*/**}/*_test.rb" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
+ # Step for test-unit
+ $ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_tests/**{,/*/**}/*_test.rb" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:test_unit
+
# Step for Spinach
$ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_features/**{,/*/**}/*.feature" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
__Tip:__ If you use one of the supported CI providers then instead of the above steps you should [take a look at this](#supported-ci-providers).
@@ -527,10 +554,20 @@
For instance to run verbose tests:
$ bundle exec rake "knapsack_pro:minitest[--verbose]"
+#### Passing arguments to test-unit
+
+Add arguments to knapsack_pro test-unit task like this:
+
+ $ bundle exec rake "knapsack_pro:test_unit[--arg_name value]"
+
+For instance to run verbose tests:
+
+ $ bundle exec rake "knapsack_pro:test_unit[--verbose]"
+
#### Passing arguments to spinach
Add arguments to knapsack_pro spinach task like this:
$ bundle exec rake "knapsack_pro:spinach[--arg_name value]"
@@ -541,10 +578,11 @@
$ knapsack_pro rspec "--tag custom_tag_name --profile"
$ knapsack_pro queue:rspec "--tag custom_tag_name --profile"
$ knapsack_pro cucumber "--name feature"
$ knapsack_pro minitest "--verbose --pride"
+ $ knapsack_pro test_unit "--verbose"
$ knapsack_pro spinach "--arg_name value"
This is optional way of using knapsack_pro when you don't want to add it to `Gemfile`.
### Test file names encryption
@@ -574,11 +612,11 @@
If you need to check what is the encryption hash for particular test file you can check that with the rake task:
$ KNAPSACK_PRO_SALT=xxx bundle exec rake knapsack_pro:encrypted_test_file_names[rspec]
-You can pass the name of test runner like `rspec`, `minitest`, `cucumber`, `spinach` as argument to rake task.
+You can pass the name of test runner like `rspec`, `minitest`, `test_unit`, `cucumber`, `spinach` as argument to rake task.
#### How to enable branch names encryption?
You need to add environment variable `KNAPSACK_PRO_BRANCH_ENCRYPTED=true` to your CI server.
@@ -615,10 +653,11 @@
environment:
# Tokens should be set in CircleCI settings to avoid expose tokens in build logs
# KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: rspec-token
# KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER: cucumber-token
# KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST: minitest-token
+ # KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT: test-unit-token
# KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH: spinach-token
test:
override:
# Step for RSpec
- bundle exec rake knapsack_pro:rspec:
@@ -630,10 +669,14 @@
# Step for Minitest
- bundle exec rake knapsack_pro:minitest:
parallel: true # Caution: there are 8 spaces indentation!
+ # Step for test-unit
+ - bundle exec rake knapsack_pro:test_unit:
+ parallel: true # Caution: there are 8 spaces indentation!
+
# Step for Spinach
- bundle exec rake knapsack_pro:spinach:
parallel: true # Caution: there are 8 spaces indentation!
```
@@ -656,10 +699,40 @@
bundle exec rake "knapsack_pro:queue:rspec[--format documentation]"
```
Please remember to add additional containers for your project in CircleCI settings.
+##### CircleCI and knapsack_pro Queue Mode
+
+If you use knapack_pro Queue Mode with CircleCI you may want to [collect metadata](https://circleci.com/docs/1.0/test-metadata/#metadata-collection-in-custom-test-steps) like junit xml report about your RSpec test suite.
+
+Here you can read how to configure [junit formatter](#how-to-use-junit-formatter-with-knapsack_pro-queue-mode). Step for CircleCI is to copy the xml report to `$CIRCLE_TEST_REPORTS` directory. Below is full config for your `spec_helper.rb`:
+
+```ruby
+# spec_helper.rb or rails_helper.rb
+
+# TODO This must be the same path as value for rspec --out argument
+TMP_RSPEC_XML_REPORT = 'tmp/rspec.xml'
+# move results to FINAL_RSPEC_XML_REPORT so the results won't accumulate with duplicated xml tags in TMP_RSPEC_XML_REPORT
+FINAL_RSPEC_XML_REPORT = 'tmp/rspec_final_results.xml'
+
+KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
+ if File.exist?(TMP_RSPEC_XML_REPORT)
+ FileUtils.mv(TMP_RSPEC_XML_REPORT, FINAL_RSPEC_XML_REPORT)
+ end
+end
+
+# Here is additional configuration to ensure the xml report will be visible by CircleCI
+KnapsackPro::Hooks::Queue.after_queue do |queue_id|
+ # Metadata collection
+ # https://circleci.com/docs/1.0/test-metadata/#metadata-collection-in-custom-test-steps
+ if File.exist?(FINAL_RSPEC_XML_REPORT) && ENV['CIRCLE_TEST_REPORTS']
+ FileUtils.cp(FINAL_RSPEC_XML_REPORT, "#{ENV['CIRCLE_TEST_REPORTS']}/rspec.xml")
+ end
+end
+```
+
#### Info for Travis users
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`
```yaml
@@ -671,55 +744,63 @@
- "bundle exec rake knapsack_pro:cucumber"
# Step for Minitest
- "bundle exec rake knapsack_pro:minitest"
+ # Step for test-unit
+ - "bundle exec rake knapsack_pro:test_unit"
+
# Step for Spinach
- "bundle exec rake knapsack_pro:spinach"
env:
global:
# tokens should be set in travis settings in web interface to avoid expose tokens in build logs
- KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token
- KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token
- KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
+ - KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token
- KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
- KNAPSACK_PRO_CI_NODE_TOTAL=2
matrix:
- KNAPSACK_PRO_CI_NODE_INDEX=0
- KNAPSACK_PRO_CI_NODE_INDEX=1
```
Such configuration will generate matrix with 2 following ENV rows:
- KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
- KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
+ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
+ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
More info about global and matrix ENV configuration in [travis docs](https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix).
#### Info for semaphoreapp.com users
-Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_CURRENT_THREAD`. The only thing you need to do is set up knapsack_pro rspec/cucumber/minitest command for as many threads as you need. Here is an example:
+Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_CURRENT_THREAD`. The only thing you need to do is set up knapsack_pro rspec/cucumber/minitest/test_unit command for as many threads as you need. Here is an example:
# Thread 1
## Step for RSpec
bundle exec rake knapsack_pro:rspec
## Step for Cucumber
bundle exec rake knapsack_pro:cucumber
## Step for Minitest
bundle exec rake knapsack_pro:minitest
+ ## Step for test-unit
+ bundle exec rake knapsack_pro:test_unit
## Step for Spinach
bundle exec rake knapsack_pro:spinach
# Thread 2
## Step for RSpec
bundle exec rake knapsack_pro:rspec
## Step for Cucumber
bundle exec rake knapsack_pro:cucumber
## Step for Minitest
bundle exec rake knapsack_pro:minitest
+ ## Step for test-unit
+ bundle exec rake knapsack_pro:test_unit
## Step for Spinach
bundle exec rake knapsack_pro:spinach
Tests will be split across threads.
@@ -736,10 +817,13 @@
bundle exec rake knapsack_pro:cucumber
# Step for Minitest
bundle exec rake knapsack_pro:minitest
+ # Step for test-unit
+ bundle exec rake knapsack_pro:test_unit
+
# Step for Spinach
bundle exec rake knapsack_pro:spinach
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
@@ -827,10 +911,13 @@
bundle exec rake knapsack_pro:cucumber
# Step for Minitest
bundle exec rake knapsack_pro:minitest
+ # Step for test-unit
+ bundle exec rake knapsack_pro:test_unit
+
# Step for Spinach
bundle exec rake knapsack_pro:spinach
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
@@ -919,10 +1006,20 @@
then problem might be related to the fact you specified complex `KNAPSACK_PRO_TEST_FILE_PATTERN` and knapsack_pro gem cannot detect correct main test directory with spec_helper. You should set `KNAPSACK_PRO_TEST_DIR=spec`. Please [read also example](#how-can-i-run-tests-from-multiple-directories).
#### Queue Mode problems
+##### Why when I use Queue Mode for RSpec then my tests fail?
+
+knapsack_pro Queue Mode uses `RSpec::Core::Runner` feature that allows [running specs multiple times with different runner options in the same process](https://relishapp.com/rspec/rspec-core/docs/running-specs-multiple-times-with-different-runner-options-in-the-same-process).
+Thanks to that we can run subset of test suite pulled from Knapsack Pro API work queue. This allows dynamic allocation of your tests across CI nodes without reloading whole Ruby/Rails application for each run of test suite subset .
+
+If you have custom things that are not common in how typical RSpec spec looks like then the RSpec feature won't be able to handle it between test suite subset runs.
+In that case you need to resolve failed tests in a way that allows RSpec to run the tests. Feel free to [ask me for help](https://knapsackpro.com/contact).
+
+You can learn more about [recent RSpec team changes](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/42) that was backported into knapsack_pro.
+
##### Why I don't see collected time execution data for my build in user dashboard?
If you go to [user dashboard](https://knapsackpro.com/dashboard) and open `Build metrics` for your API token and you open build for your last git commit you should see there info about collected time execution data from all CI nodes. If you don't see collected time execution data for CI nodes then please ensure:
* you have `Knapsack::Adapters::RspecAdapter.bind` in your `rails_helper.rb` or `spec_helper.rb`
@@ -984,11 +1081,11 @@
KNAPSACK_PRO_PROJECT_DIR=~/projects/rails-app \
KNAPSACK_PRO_CI_NODE_TOTAL=2 \
KNAPSACK_PRO_CI_NODE_INDEX=0 \
bundle exec rake "knapsack_pro:rspec[--seed 123]"
-Above example is for RSpec. You can use respectively rake task name and token environment variable when you want to run tests for minitest, cucumber or spinach.
+Above example is for RSpec. You can use respectively rake task name and token environment variable when you want to run tests for minitest, test_unit, cucumber or spinach.
It should work when all CI nodes finished work and sent time execution data to Knapsack Pro API.
You can visit [user dashboard](https://knapsackpro.com/dashboard) to preview particular CI build and ensure time execution data were collected from all CI nodes.
If at least one CI node has not sent time execution data to the Knapsack Pro API then you should check below solution.
Check test runner output on particular CI node you would like to retry in development. You should see at the beginning of rspec command an output that can
@@ -1079,11 +1176,11 @@
##### B. Use tags to mark set of tests in particular test file
Another way is to use tags to mark subset of tests in particular test file and then split tests based on tags.
-This example is for knapack_pro Regular Mode. I don't recommend to user this approach with Queue Mode.
+This example is for knapack_pro Regular Mode. You can also use knapack_pro Queue Mode with tags.
Here is example of test file with specified tags for describe groups:
```ruby
# spec/features/something_spec.rb
@@ -1101,11 +1198,11 @@
it {}
end
end
```
-You need to create multiple API tokens for different tags. In this example we need 3 different API tokens.
+You need to create API token per each tag. In this example we need 3 different API tokens.
You need to run below commands for each CI node.
# run only tests with tagA
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=api_key_for_tagA bundle exec rake "knapsack_pro:rspec[--tag tagA]"
@@ -1166,15 +1263,19 @@
bundle exec rake "knapsack_pro:queue:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
The xml report will contain all tests executed across intermediate test subset runs based on work queue. You need to add after subset queue hook to rename `rspec.xml` to `rspec_final_results.xml` thanks to that the final results file will contain only single xml tag with all tests executed on the CI node. This is related to the way how queue mode works. Detailed explanation is in the [issue](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/40).
# spec_helper.rb or rails_helper.rb
+
+ # TODO This must be the same path as value for rspec --out argument
+ TMP_RSPEC_XML_REPORT = 'tmp/rspec.xml'
+ # move results to FINAL_RSPEC_XML_REPORT so the results won't accumulate with duplicated xml tags in TMP_RSPEC_XML_REPORT
+ FINAL_RSPEC_XML_REPORT = 'tmp/rspec_final_results.xml'
+
KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
- # TODO This must be the same path as value for rspec --out argument
- old_xml_file = 'tmp/rspec.xml'
- # move results to new_xml_file so the results won't accumulate with duplicated xml tags in old_xml_file
- new_xml_file = 'tmp/rspec_final_results.xml'
- FileUtils.mv(old_xml_file, new_xml_file) if File.exist?(old_xml_file)
+ if File.exist?(TMP_RSPEC_XML_REPORT)
+ FileUtils.mv(TMP_RSPEC_XML_REPORT, FINAL_RSPEC_XML_REPORT)
+ end
end
#### How many API keys I need?
Basically you need as many API keys as you have steps in your build.