Skip to content

run e2e legacy tests under bazel#23074

Merged
angular-robot[bot] merged 4 commits intoangular:mainfrom
jbedard:legacy-test
Nov 28, 2022
Merged

run e2e legacy tests under bazel#23074
angular-robot[bot] merged 4 commits intoangular:mainfrom
jbedard:legacy-test

Conversation

@jbedard
Copy link
Copy Markdown
Contributor

@jbedard jbedard commented May 3, 2022

This runs the legacy-cli/e2e tests via bazel using the bazel built npm packages from packages/**.

After all the pre-factors it's mainly just build config and a few code changes to use the bazel environment vars if present. This can be simplified if the non-bazel versions are dropped in the future. Currently all the CI jobs are prefixed with bazel-.

Build targets / API:

There are 9 bazel targets invoking the e2e tests with different configurations:

  • //tests/legacy-cli:e2e.{npm,yarn,esbuild,saucelabs}: configured like CI today
  • //tests/legacy-cli:e2e.snapshot.{npm,yarn,esbuild,saucelabs}: ^ using snapshots
  • //tests/legacy-cli:e2e: nothing pre-configured, does not run by default or on CI, is designed to be run and configured manually with bazel cli args.

With any of these you can:

  • bazel test to run as a bazel test
  • bazel run to do the equivalent of --debug and remain running on failure
  • --test_filters="..." which essentially does the e2e_runner --glob="..."
  • --test_arg="..." to specify additional e2e_runner args, --glob would work here too

Sharding
Today e2e tests have --shard and --nb-shards cli params which circleci sets based on the parallelism config.
Now those cli args are defaulted based on the bazel environment variables set by nodejs_test(shard_count) and/or the E2E_SHARD_TOTAL + E2E_SHARD environment variables I added. This way both bazel and circleci sharding can be combined into one (bazel shards via processes on one circleci environment, circleci sharding in isolated environments).

Prefactors:

@jbedard jbedard force-pushed the legacy-test branch 30 times, most recently from 1cfd471 to 52f1c3b Compare May 9, 2022 20:58
@alan-agius4
Copy link
Copy Markdown
Collaborator

alan-agius4 commented Sep 14, 2022

Couple of questions

  • How is it possible to run a single test or using --glob option?
  • How to debug a single test IE the --debug option?

Both of these are paramount for day to day tasks.

Comment thread .circleci/dynamic_config.yml Outdated
# Same as https://circleci.com/orbs/registry/orb/circleci/windows, but named.
working_directory: ~/ng
resource_class: windows.medium
resource_class: windows.2xlarge
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 Sep 26, 2022

Choose a reason for hiding this comment

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

This will increase the credit usage drastically 500 credits/min compared to the current 40 credits/min

https://circleci.com/product/features/resource-classes/#dev-windows

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll try decreasing it again. This was partially to understand why things were flaky or failing which I think was from running 8+ tests concurrently on a single machine. Now it's running 6 in bazel spread over 4 CI shards (the parallelism param).

Comment thread .circleci/dynamic_config.yml Outdated
docker:
- image: cimg/node:<< parameters.nodeversion >>
working_directory: ~/ng
resource_class: 2xlarge
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 Sep 26, 2022

Choose a reason for hiding this comment

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

Do we really need to use 2xlarge? None the less likely the default should be large at most.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll try reducing it. All the resource changes was from me playing around with resources/bazel sharding/CI parallelism

Comment thread .circleci/dynamic_config.yml
Comment thread .circleci/dynamic_config.yml
Comment thread .circleci/dynamic_config.yml Outdated
default: 'npm'
steps:
- custom_attach_workspace
- browser-tools/install-chrome
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is chrome needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without it I'm getting https://app.circleci.com/pipelines/github/angular/angular-cli/26617/workflows/8a85cca7-f1fb-4d5a-8698-83e522f485d4/jobs/352420/steps?invite=true#step-106-1703

... which might just required propper config of chrome within bazel. I can look into it more. It would be great to drop this step which requires 20-30s of CI time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is also used in the unit tests (bazel) and non-bazel e2e tests, so maybe it should stay?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I understand this it should not be necessary because we provide the browsers via bazel

Comment thread .circleci/win-ram-disk.ps1
Comment thread docs/DEVELOPER.md Outdated

- Run: `node tests/legacy-cli/run_e2e.js`
- Run a subset of the tests: `node tests/legacy-cli/run_e2e.js tests/legacy-cli/e2e/tests/i18n/ivy-localize-*`
- Run on a custom set of npm packages (tar files): `node tests/legacy-cli/run_e2e.js --package _angular_cli.tgz _angular_create.tgz dist/*.tgz ...`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be helpful to write the equivalent of node tests/legacy-cli/run_e2e.js tests/legacy-cli/e2e/tests/i18n/ivy-localize-*.

Comment thread .circleci/dynamic_config.yml Outdated
Comment on lines +52 to +53
var_7_subsets: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
var_7_build_types: &all_e2e_build_types ['e2e', 'snapshot']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
var_7_subsets: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
var_7_build_types: &all_e2e_build_types ['e2e', 'snapshot']
var_7: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
var_8: &all_e2e_build_types ['e2e', 'snapshot']

Since the key in this pair isn't actually used by yaml, we typical just count rather than providing any "context" in the naming scheme.

Comment thread .circleci/dynamic_config.yml Outdated
default: 'npm'
steps:
- custom_attach_workspace
- browser-tools/install-chrome
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I understand this it should not be necessary because we provide the browsers via bazel

Comment thread .circleci/win-ram-disk.ps1
Comment thread BUILD.bazel Outdated

# Files required by e2e tests
copy_to_bin(
name = "dot-files",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not a dot file right? Were others included at one point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assume it was at one point and has evolved over time. I'll change it 👍

Copy link
Copy Markdown
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM though still other comments that appear to be unaddressed.

@jbedard
Copy link
Copy Markdown
Contributor Author

jbedard commented Nov 14, 2022

I think those were all addressed offline and not in the comments here, just no one had pressed resolve.

Comment thread tests/legacy-cli/e2e/utils/project.ts Outdated
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

One comment otherwise LGTM. Can you also squash please?

Using execPath ensures the child processes are the same node binary without depending on PATH.
fixup: add ChromeHeadlessNoSandbox browser to to karma builder
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants