Skip to content
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

smoke tests: parallelization #4784

Open
wants to merge 141 commits into
base: main
Choose a base branch
from
Open

smoke tests: parallelization #4784

wants to merge 141 commits into from

Conversation

midleman
Copy link
Contributor

@midleman midleman commented Sep 23, 2024

Intent

The goal is to optimize our E2E smoke tests, which currently run serially, by parallelizing them to reduce overall execution time.

Approach

Initially, all tests were run from a single file (main.ts), which handled shared dependencies but prevented parallel execution. To address this, I split the tests into multiple "main" files, which improved execution times but made it challenging to balance workloads effectively. Ultimately, the best solution was to refactor each test to run independently, allowing for true parallelization.

Because mocha-junit-reporter doesn’t support parallel runs, I switched to mocha-xunit-reporter, which natively handles parallel execution. After the tests complete, I convert the results to the junit format to ensure compatibility with TestRail.

Impact on Workflow

  1. ❌ Previously, when adding new test specs, we needed to manually import and include them in the main.ts file. We no longer need to do this! 🎉

  2. ❌ We also no longer need to wrap all tests in setup().

  3. ✅ The only thing we need to do is add setupEnvAndHooks(); (previously installAllHandlers) in the parent describe block of the test

How to Run in Parallel

Use the --parallel flag and specify --jobs:

yarn smoketest-no-compile --tracing --parallel --jobs 2

GHA Workflow Updates

I performed an analysis on run time for the full and pr test suites with varying concurrent jobs. Summary of my findings:

Full Test Suite (avg time)

  • 1 machine: ~25 minutes
  • 2 machines: ~11 minutes
  • 3 machines: ~9.5 minutes

PR Test Suite (avg time)

  • 1 machine: ~6 minutes
  • 2 machines: ~3 minutes
  • 3 machines: ~2.5 minutes

To promote stability and prevent constrained resources, I set GHA workflows to use 2 jobs. This is still a major speed improvement.

QA Validation

  • Confirmed that --tracing works as expected and all expected logs exist.
  • Verified that results (pass, fail, skip) are correctly imported into TestRail. See example.
  • Skipping data-explorer-100x100.test.ts - I think it's just a performance issue and we can do a quick follow to look into the test.

@@ -38,7 +32,7 @@ export function setup(logger: Logger) {
});
it('Create a new Conda environment [C628628]', async function () {
// This test relies on Conda already being installed on the machine
const projSuffix = '_condaInstalled';
const projSuffix = '_condaInstalled_' + Math.floor(Math.random() * 1000000).toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test has been flakey. and on retry it can't create a new project bc project name already exists - so i appended a random # at end to avoid that conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant