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

chore(doc): added new instructions for e2e test with different lxd versions [WD-9034] #666

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion ARCHITECTURE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,28 @@ A webhook triggers a [demo](https://github.com/canonical/demos.haus) build for a

The [update_demo.yml](.github/workflows/update_demo.yml) workflow updates a branch called `demo` automatically on any merge to main. This keeps at least one demo instance running and always up to date.

A secret is needed to enable HaProxy to forward requests to the LXD API backend. Ask one of the collaborators for the secret.
A secret is needed to enable HaProxy to forward requests to the LXD API backend. Ask one of the collaborators for the secret.

## E2E test setup for multiple lxd versions

The e2e test suite is run whenever a pull request is created and updated. This is done in the `browser-e2e-test` job from the `PR checks` github [workflow](https://github.com/canonical/lxd-ui/blob/6b574493501264dbac5722b1c2858f4d0020af75/.github/workflows/pr.yaml#L1). The job is run using the github actions matrix strategy so that the same tests can be carried out against different lxd versions and browser types in isolated github runner environments simultaneously. Currently e2e tests are run against the following parameter combinations:

| lxd version | browser |
| ----------- | -------- |
| 5.0/stable | chromium |
| 5.0/stable | firefox |
| latest/edge | chromium |
| latest/edge | firefox |

For each parameter combination, a playwright project defined in [playwright.config.ts](https://github.com/canonical/lxd-ui/blob/6b574493501264dbac5722b1c2858f4d0020af75/playwright.config.ts#L1) is selected by name with reference syntax `browser:lxd-version` and executed. The execution flow is depicted in the diagram below:

```mermaid
flowchart TD
A(pull request created) -->|other workflow jobs| B(browser-e2e-test)
B --> C{Github Matrix Runner}
C -->|5.0/stable chromium| D[Run chromium:lxd-5.0-stable]
C --> E[...]
C -->|latest/edge firefox| F[Run firefox:lxd-latest-edge]
```

To add additional lxd versions for e2e testing, add two new projects to [playwright.config.ts](https://github.com/canonical/lxd-ui/blob/6b574493501264dbac5722b1c2858f4d0020af75/playwright.config.ts#L1) for chromium and firefox. Set the `lxdVersion` parameter accordingly. In [pr.yaml](https://github.com/canonical/lxd-ui/blob/6b574493501264dbac5722b1c2858f4d0020af75/.github/workflows/pr.yaml#L1) include the new lxd versions for the `browser-e2e-test` job. Now you can write tests for the new lxd versions specifically.
14 changes: 12 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,19 @@ Install playwright and its browsers

npx playwright install

The tests expect the environment on localhost to be accessible. Execute `dotrun` and start tests with
The e2e tests can be run against LXD 5.0, or the edge version of LXD. If you want to run the tests against the edge version, first make sure your lxd is up to date with

npx playwright test
snap refresh lxd --channel latest/edge

The tests expect the environment on localhost to be accessible. Execute `dotrun` first then run the tests against the latest LXD version with

yarn test-e2e-edge

or against the LTS LXD version with

yarn test-e2e-stable

### Nice utilities from Playwright

Generate new tests with helper [Doc](https://playwright.dev/docs/codegen)

Expand Down
Loading