Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions docusaurus/docs/ruby/circleci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ Remove [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT`](reference.md#knapsack_pro_fixed_queue_
command: |
mkdir -p /tmp/test-results

export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true

# highlight-start
export KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE=/tmp/tests_to_run.txt
# Retrieve the tests to run (all or just the failed ones), and let Knapsack Pro split them optimally.
Expand All @@ -149,7 +147,6 @@ Remove [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT`](reference.md#knapsack_pro_fixed_queue_
The snippet above:

- [Collects metadata with the JUnit XML formatter](#collect-metadata-in-queue-mode)
- uses [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](split-by-test-examples.mdx) to split slow spec files by test examples
- uses [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`](reference.md#knapsack_pro_test_file_list_source_file) to specify what tests to run

<details>
Expand All @@ -162,8 +159,6 @@ The snippet above:
export CIRCLE_TEST_REPORTS=/tmp/test-results
mkdir -p $CIRCLE_TEST_REPORTS

export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true

# highlight-start
export KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE=/tmp/tests_to_run.txt
# Retrieve the tests to run (all or just the failed ones), and let Knapsack Pro split them optimally.
Expand Down
10 changes: 5 additions & 5 deletions docusaurus/docs/ruby/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ Parallelize test examples (instead of files) across CI nodes.

:::caution

- Requires RSpec >= 3.3.0
- Does not support `run_all_when_everything_filtered`
- Does not support `--tag`

:::

```bash
KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
```
Default: `true`

Available:
- `true`: distribute test examples for slow test files across CI nodes (more balanced builds)
- `false`: distribute whole test files across CI nodes

Make sure to read the details in [Split by test examples](split-by-test-examples.mdx).

Expand Down
2 changes: 0 additions & 2 deletions docusaurus/docs/ruby/rspec.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ RSpec.configure do |c|
end
```

If you are using RSpec in Queue Mode and [Split by test example](split-by-test-examples.mdx), `--tag` is not supported.

### Some tests are failing in Queue Mode

Since Knapsack Pro [ignores `.rspec`](rspec.mdx#rspec-is-ignored-in-queue-mode) and many projects use it to require `spec_helper.rb` or `rails_helper.rb`, some tests may be falling. Make sure you either require the correct helper at the top of each test file or pass it as an argument:
Expand Down
17 changes: 4 additions & 13 deletions docusaurus/docs/ruby/split-by-test-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import { IconExternalLink } from '@site/src/components/IconExternalLink'

:::caution

Only RSpec >= 3.3.0 is supported. [Let us know](https://knapsackpro.com/contact) if you use a different test runner. As an alternative, consider:
Only RSpec is supported, [let us know](https://knapsackpro.com/contact) if you use a different test runner.

- spreading test examples into multiple files
- tagging test examples (e.g., RSpec's [`--tag`](rspec.mdx#run-a-subset-of-tests))
As an alternative, consider spreading test examples into multiple files.

:::

You can set [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](reference.md#knapsack_pro_rspec_split_by_test_examples-rspec) to parallelize tests across CI nodes by example (`it`/`specify`). This is useful when you have slow test files but don't want to manually split test examples into smaller test files.
By default, Knapsack Pro parallelizes tests across CI nodes by example (`it`/`specify`). This is useful when you have slow test files but don't want to manually split test examples into smaller test files. You can disable this feature with [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=false`](reference.md#knapsack_pro_rspec_split_by_test_examples-rspec).

As an example, imagine you have two test files in your suite:

Expand Down Expand Up @@ -56,7 +55,7 @@ As an example, imagine you have two test files in your suite:

On your [Knapsack Pro dashboard](../overview/index.mdx#dashboard), you can see the yellow highlight because of the bottleneck: if you run those tests on 2 parallel CI nodes, the total execution time would be 6.5 minutes instead of the optimal 4.5 minutes (2.5 minutes + 6.5 minutes divided by 2 CI nodes).

By enabling `KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`, the bottleneck disappears because Knapsack Pro can distribute tests so that each CI node is balanced (e.g., 4.5 minutes + 4.5 minutes):
When splitting by test examples, the bottleneck disappears because Knapsack Pro distributes individual tests so that each CI node is balanced (e.g., 4.5 minutes + 4.5 minutes):

<div style={{ overflowX: 'auto' }}>
<table style={{ width: '100%', display: 'table' }}>
Expand Down Expand Up @@ -112,14 +111,6 @@ We recommend running at least 2 CI builds after you enable this feature or chang

:::caution

Does not support `--tag`

:::

Due to the [RSpec internals](https://github.com/rspec/rspec-core/issues/2522), `--tag` might be ignored when used together with `KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`. But you can use the `KNAPSACK_PRO_TEST_FILE_*` [environment variables](reference.md) to filter the test files to run.

:::caution

Does not support [`run_all_when_everything_filtered`](rspec.mdx#some-of-my-test-files-are-not-executed)

:::
Expand Down