-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Summary
We are using the latest Salesforce CLI to run our test suites in our CI on our sandboxes and production environment. We are running each test suite one by one. For each run we use the CLI command sf apex run test --json --target-org **** --suite-names Test_Suite1 --wait 10 --output-dir test-results/apex --result-format json. Apparently the whole run is taking really long, but if we run all tests by just running sf apex run test --wait 10 it is really quick.
It seems like the tests are ready really fast and the json result is shown, but it has kind of a delay till the command ends and the script gets the exit status of the command.
All ~2000 tests through 24 test suites one by one take around 50 minutes (summarised test execution time around 8 minutes), all ~2000 tests at once take around 7 minutes (test execution time around 8 minutes).
Steps To Reproduce
Our repositories of our packages are private, so we can not share it. To reproduce the behaviour it should be enough to:
- create a lot of tests within 24 test suites
- run the test suites one by one and write down the time it took (use the script which I add at the bottom of this issue for )
- run the tests at once and write down the time it took (using
sf apex run test --wait 10)
--> compare the times
Alternative (easier):
- run
sf apex test runand observe how long the command takes to finish and the terminal to be ready again
Expected result
The two compared times should be quite similar and not differ that much.
Actual result
The two compared times differ really much.
System Information
I am using a mac with zsh, but the issue is the same on windows and in our CI, which is using linux.
Salesforce CLI version:
{
"cliVersion": "@salesforce/cli/2.8.11",
"architecture": "darwin-arm64",
"nodeVersion": "node-v20.5.1",
"osVersion": "Darwin 22.6.0",
"shell": "zsh",
"rootPath": "/opt/homebrew/lib/node_modules/@salesforce/cli",
"pluginVersions": [
"@oclif/plugin-autocomplete 2.3.8 (core)",
"@oclif/plugin-commands 2.2.25 (core)",
"@oclif/plugin-help 5.2.19 (core)",
"@oclif/plugin-not-found 2.4.1 (core)",
"@oclif/plugin-plugins 3.4.2 (core)",
"@oclif/plugin-search 0.0.22 (core)",
"@oclif/plugin-update 3.2.3 (core)",
"@oclif/plugin-version 1.3.10 (core)",
"@oclif/plugin-warn-if-update-available 2.1.0 (core)",
"@oclif/plugin-which 2.2.32 (core)",
"@salesforce/cli 2.8.11 (core)",
"apex 2.3.14 (core)",
"auth 2.8.16 (core)",
"data 2.5.8 (core)",
"deploy-retrieve 1.17.8 (core)",
"dev 0.7.1 (user)",
"info 2.6.40 (core)",
"limits 2.3.33 (core)",
"login 1.2.29 (core)",
"marketplace 0.1.3 (core)",
"org 2.10.6 (core)",
"packaging 1.17.0 (user)",
"schema 2.3.25 (core)",
"settings 1.4.28 (core)",
"sobject 0.2.6 (core)",
"source 2.10.33 (core)",
"telemetry 2.3.1 (core)",
"templates 55.5.11 (core)",
"trust 2.6.9 (core)",
"user 2.3.32 (core)",
"@tmh-bis-salesforce/tmh-bis-salesforce-cli-plugin 0.5.3 (user)"
]
}Additional information
script for running all tests at once:
#! /bin/bash
username=org_username # set the org username or alias
echo "Start $(date)"
echo ""
mkdir test-results-once-json
echo "sf apex run test --json --target-org $username --wait 15 --output-dir test-results/apex --result-format json"
sf apex run test --json --target-org $username --wait 15 --output-dir test-results/apex --result-format json > test-results-once-json/test-result.json
echo ""
echo "End $(date)"
result of running the script:
Start Tue Sep 19 12:55:57 CEST 2023
mkdir: test-results-once-json: File exists
sf apex run test --json --target-org *** --wait 15 --output-dir test-results/apex --result-format json
End Tue Sep 19 13:02:03 CEST 2023script for running the test suites one by one:
#! /bin/bash
username=org_username # set the org username or alias
testsuites=( TestSuite1 TestSuite2 TestSuite3 TestSuite4 TestSuite5 ... ) # fill in the test suite names
echo "Start $(date)"
echo ""
echo "The following test suites will be executed:"
for value in "${testsuites[@]}"
do
echo "$value"
done
mkdir test-results-json
for value in "${testsuites[@]}"
do
echo ""
echo "sf apex run test --json --target-org $username --suite-names $value --wait 15 --output-dir test-results/apex --result-format json"
sf apex run test --json --target-org $username --suite-names $value --wait 15 --output-dir test-results/apex --result-format json > test-results-json/$value.json
done
echo ""
echo "End $(date)"
result of running the script
Start Tue Sep 19 11:11:54 CEST 2023
The following test suites will be executed:
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
***
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
sf apex run test --json --target-org *** --suite-names *** --wait 15 --output-dir test-results/apex --result-format json
End Tue Sep 19 12:02:40 CEST 2023