Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit 1fcb939

Browse files
feat(validate): disable parallel testing using a flag (#1255)
A new option for validate and validateAgainst Org to disable parallel testing across all the packages. This could be useful for large projects which are yet to be refactored to support running tests in parallel or during daily validation runs across unlocked packages on a sandbox. Use --disableparalleltesting as the option
1 parent c34be39 commit 1fcb939

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

packages/sfpowerscripts-cli/messages/validate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"disableArtifactUpdateFlagDescription": "Do not update information about deployed artifacts to the org",
2020
"fastfeedbackFlagDescription": "Enable validation in fast feedback mode, In fast feedback mode, validation will only do selective deployment of and selective tests",
2121
"orgInfoFlagDescription": "Display info about the org that is used for validation",
22-
"disableSourcePackageOverride": "Disables overriding unlocked package installation as source package installation during validate"
22+
"disableSourcePackageOverride": "Disables overriding unlocked package installation as source package installation during validate",
23+
"disableParallelTestingFlagDescription": "Disable test execution in parallel, this will execute apex tests in serial"
2324

2425
}

packages/sfpowerscripts-cli/messages/validateAgainstOrg.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"fastfeedbackFlagDescription": "Enable validation in fast feedback mode, In fast feedback mode, validation will only do selective deployment of changed components and selective tests",
1010
"configFileFlagDescription":"(Required if the release modes are ff-relese-config or thorough-release-config), Path to the config file which determines how the release defintion should be generated",
1111
"devhubAliasFlagDescription": "Provide the alias of the devhub previously authenticated, used for installing or updating dependency in individual/thorough modes",
12-
"disableSourcePackageOverride": "Disables overriding unlocked package installation as source package installation during validate"
12+
"disableSourcePackageOverride": "Disables overriding unlocked package installation as source package installation during validate",
13+
"disableParallelTestingFlagDescription": "Disable test execution in parallel, this will execute apex tests in serial"
1314
}

packages/sfpowerscripts-cli/src/commands/sfpowerscripts/orchestrator/validate.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ export default class Validate extends SfpowerscriptsCommand {
7474
tag: flags.string({
7575
description: messages.getMessage('tagFlagDescription'),
7676
}),
77+
disableparalleltesting: flags.boolean({
78+
description: messages.getMessage('disableParallelTestingFlagDescription'),
79+
default: false,
80+
}),
7781
disablediffcheck: flags.boolean({
7882
description: messages.getMessage('disableDiffCheckFlagDescription'),
7983
default: false,
@@ -168,7 +172,8 @@ export default class Validate extends SfpowerscriptsCommand {
168172
diffcheck: !this.flags.disablediffcheck,
169173
disableArtifactCommit: this.flags.disableartifactupdate,
170174
orgInfo: this.flags.orginfo,
171-
disableSourcePackageOverride : this.flags.disablesourcepkgoverride
175+
disableSourcePackageOverride : this.flags.disablesourcepkgoverride,
176+
disableParallelTestExecution: this.flags.disableparalleltesting
172177
};
173178

174179
setReleaseConfigForReleaseBasedModes(this.flags.releaseconfig,validateProps);

packages/sfpowerscripts-cli/src/commands/sfpowerscripts/orchestrator/validateAgainstOrg.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export default class Validate extends SfpowerscriptsCommand {
5757
description: messages.getMessage('disableSourcePackageOverride'),
5858
dependsOn:['devhubalias']
5959
}),
60+
disableparalleltesting: flags.boolean({
61+
description: messages.getMessage('disableParallelTestingFlagDescription'),
62+
default: false,
63+
}),
6064
loglevel: flags.enum({
6165
description: 'logging level for this command invocation',
6266
default: 'info',
@@ -121,7 +125,8 @@ export default class Validate extends SfpowerscriptsCommand {
121125
diffcheck: this.flags.diffcheck,
122126
baseBranch: this.flags.basebranch,
123127
disableArtifactCommit: this.flags.disableartifactupdate,
124-
disableSourcePackageOverride: this.flags.disablesourcepkgoverride
128+
disableSourcePackageOverride: this.flags.disablesourcepkgoverride,
129+
disableParallelTestExecution: this.flags.disableparalleltesting
125130
};
126131

127132

packages/sfpowerscripts-cli/src/impl/validate/ValidateImpl.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface ValidateProps {
8383
disableArtifactCommit?: boolean;
8484
orgInfo?: boolean;
8585
disableSourcePackageOverride?: boolean;
86+
disableParallelTestExecution?: boolean;
8687
}
8788

8889
export default class ValidateImpl implements PostDeployHook, PreDeployHook {
@@ -414,7 +415,7 @@ export default class ValidateImpl implements PostDeployHook, PreDeployHook {
414415
isBuildAllAsSourcePackages: !this.props.disableSourcePackageOverride,
415416
currentStage: Stage.VALIDATE,
416417
baseBranch: this.props.baseBranch,
417-
devhubAlias: this.props.hubOrg.getUsername(),
418+
devhubAlias: this.props.hubOrg?.getUsername(),
418419
};
419420

420421
//Build DiffOptions
@@ -727,6 +728,10 @@ export default class ValidateImpl implements PostDeployHook, PreDeployHook {
727728
return { id: null, result: true, message: 'No Tests To Run' };
728729
}
729730

731+
//override any behaviour if the override is from the deploy props
732+
if(this.props.disableParallelTestExecution)
733+
testOptions.synchronous = true;
734+
730735
displayTestHeader(sfpPackage);
731736

732737
const triggerApexTests: TriggerApexTests = new TriggerApexTests(

0 commit comments

Comments
 (0)