-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
runtime: Enable customization of parallel workers #1588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 29 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
6774382
[#1044] allow assignment of work using api hook
eman2673 a4de83b
[#1044] Using array instead of iterable
eman2673 9223aba
[#1044] Adding type for parallelCanAssign
eman2673 587187d
[#1044] Using variable for workers instead of repeating _.values.
eman2673 eab037e
[#1044] Mansplaining the custom worker assignment process
eman2673 179b12d
[#1044] Making casing consistent
eman2673 f501380
Instead of killing the job, make sure at least 1 worker is assigned
eman2673 13ada90
Detailing example a bit more.
eman2673 37b23e1
Put close worker back. No longer reused
eman2673 6654b6e
Utilizing ParallelAssignmentValidator type for ISupportCodeLibrary.pa…
eman2673 ffac8c5
Moving idle state to worker ready message
eman2673 981574c
[#1044] Emitting warning for all workers idle
eman2673 381d5aa
Resolving some minor README issues
eman2673 628e90a
[#1044] Refactoring out nextPickleIndex + README example as test
eman2673 ef33a9a
Omitting complex 3 cause cannot guaranty the worker as both will be r…
eman2673 b085009
Dropping use of _.values to iterate for waking workers
eman2673 189a1d5
copy the pickleIds to leave the passed argument intact
eman2673 e512a2b
Parsing test cases to verify order and parallelism
eman2673 7cfb9b3
Using spawn tag to get errorOutput for warning validation
eman2673 d173e64
Merge pull request #1 from cucumber/master
eman2673 5634903
Merge pull request #2 from cucumber/master
eman2673 40290f3
Merging from cucumber-main
eman2673 865894f
Merge branch 'cucumber-main'
eman2673 cddc5a5
Simplify tests (#4)
eman2673 753a5e6
Resolve conflicts (#5)
eman2673 50a9f62
merge main
davidjgoss 248d45a
Merge branch 'main' into master
eman2673 975cf41
Merge branch 'main' into master
aurelien-reeves 15c0fe5
update feature helper
charlierudolph ba96d2a
change table structure
charlierudolph 5ae125c
reduce timeout, attempt to make more reliable on windows
charlierudolph 6e4f781
fix timing issue, larger time window to reduce flakes
charlierudolph bc66b40
Merge branch 'main' into master
davidjgoss 5426a09
Update CHANGELOG.md
davidjgoss 23339e9
update docs
charlierudolph 10a88f2
Merge branch 'master' of github.com:eman2673/cucumber-js into eman267…
charlierudolph 4187469
increase time to decrease chance of flakes
charlierudolph d70c4df
Merge branch 'main' into master
davidjgoss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Feature: Running scenarios in parallel with custom assignment | ||
|
||
@spawn | ||
Scenario: Bad parallel assignment helper uses 1 worker | ||
Given a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
const {Given, setParallelCanAssign} = require('@cucumber/cucumber') | ||
|
||
setParallelCanAssign(() => false) | ||
|
||
Given('slow step', (done) => setTimeout(done, 100)) | ||
""" | ||
And a file named "features/a.feature" with: | ||
""" | ||
Feature: only one worker works | ||
Scenario: someone must do work | ||
Given slow step | ||
|
||
Scenario: even if it's all the work | ||
Given slow step | ||
""" | ||
When I run cucumber-js with `--parallel 2` | ||
Then the error output contains the text: | ||
""" | ||
WARNING: All workers went idle 2 time(s). Consider revising handler passed to setParallelCanAssign. | ||
""" | ||
And no pickles run at the same time | ||
|
||
Scenario: assignment is appropriately applied | ||
Given a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
const {Given, setParallelCanAssign} = require('@cucumber/cucumber') | ||
const {atMostOnePicklePerTag} = require('@cucumber/cucumber/lib/support_code_library_builder/parallel_can_assign_helpers') | ||
|
||
setParallelCanAssign(atMostOnePicklePerTag(["@complex", "@simple"])) | ||
|
||
Given('complex step', (done) => setTimeout(done, 325)) | ||
Given('simple step', (done) => setTimeout(done, 200)) | ||
""" | ||
And a file named "features/a.feature" with: | ||
""" | ||
Feature: adheres to setParallelCanAssign handler | ||
@complex | ||
Scenario: complex1 | ||
Given complex step | ||
|
||
@complex | ||
Scenario: complex2 | ||
Given complex step | ||
|
||
@complex | ||
Scenario: complex3 | ||
Given complex step | ||
|
||
@simple | ||
Scenario: simple1 | ||
Given simple step | ||
|
||
@simple | ||
Scenario: simple2 | ||
Given simple step | ||
|
||
@simple | ||
Scenario: simple3 | ||
Given simple step | ||
""" | ||
When I run cucumber-js with `--parallel 2` | ||
Then it passes | ||
And the following pairs of pickles execute at the same time: | ||
| complex1 | simple1 | | ||
| complex1 | simple2 | | ||
| simple2 | complex2 | | ||
| complex2 | simple3 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { DataTable, Then } from '../../' | ||
import { World } from '../support/world' | ||
import messages from '@cucumber/messages' | ||
import { expect } from 'chai' | ||
|
||
function getPairsOfPicklesRunningAtTheSameTime( | ||
envelopes: messages.Envelope[] | ||
): string[][] { | ||
const pickleIdToName: Record<string, string> = {} | ||
const testCaseIdToPickleId: Record<string, string> = {} | ||
const testCaseStarteIdToPickleId: Record<string, string> = {} | ||
let currentRunningPickleIds: string[] = [] | ||
const result: string[][] = [] | ||
envelopes.forEach((envelope) => { | ||
if (envelope.pickle != null) { | ||
pickleIdToName[envelope.pickle.id] = envelope.pickle.name | ||
} else if (envelope.testCase != null) { | ||
testCaseIdToPickleId[envelope.testCase.id] = envelope.testCase.pickleId | ||
} else if (envelope.testCaseStarted != null) { | ||
const pickleId = testCaseIdToPickleId[envelope.testCaseStarted.testCaseId] | ||
testCaseStarteIdToPickleId[envelope.testCaseStarted.id] = pickleId | ||
currentRunningPickleIds.forEach((x) => { | ||
result.push([pickleIdToName[x], pickleIdToName[pickleId]]) | ||
}) | ||
currentRunningPickleIds.push(pickleId) | ||
} else if (envelope.testCaseFinished != null) { | ||
const pickleId = | ||
testCaseStarteIdToPickleId[envelope.testCaseFinished.testCaseStartedId] | ||
currentRunningPickleIds = currentRunningPickleIds.filter( | ||
(x) => x != pickleId | ||
) | ||
} | ||
}) | ||
return result | ||
} | ||
|
||
Then('no pickles run at the same time', function (this: World) { | ||
const actualPairs = getPairsOfPicklesRunningAtTheSameTime( | ||
this.lastRun.envelopes | ||
) | ||
expect(actualPairs).to.eql([]) | ||
}) | ||
|
||
Then( | ||
'the following pairs of pickles execute at the same time:', | ||
function (this: World, dataTable: DataTable) { | ||
const expectedPairs = dataTable.raw() | ||
const actualPairs = getPairsOfPicklesRunningAtTheSameTime( | ||
this.lastRun.envelopes | ||
) | ||
expect(actualPairs).to.eql(expectedPairs) | ||
} | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.