Skip to content

Commit

Permalink
Run selenium tests without docker (#1995)
Browse files Browse the repository at this point in the history
* Run selenium tests without docker

This PR removes the docker compose based setup of running
selenium test and replaces it with infrastructure based on
 native chromium and chromedriver.

The new setup uses chromium with options to override DNS resolution
so that all request are hitting the vite dev server. This dev server
is reconfigured to terminate TLS and forward request to the replica
(or, if hot reloading is enabled, serve assets directly).

Two new config env variables are introduced for the `npm run dev`
command:
* TLS_DEV_SERVER: when set to 1, the dev server will handle https instead
  of http.
* NO_HOT_RELOAD: when set to 1, all requests are forwarded to the replica.
  Assets are not hot reloaded.

There are some changes to the test:
* the copy / paste of the seed phrase has been replaced by
  reading the phrase from the DOM directly, because chromium
  now runs in headless mode (as non-headless is not supported
  on github action runners natively), which makes chromium behave
  differently with regards to the clipboard.
* The check that the raw URL is inaccessible now returns a slightly
  different error message, so the assert on the message was changed.

Still to do (in a separate PR):
* Documentation

* Disable /dev/shm usage

* Fix chrome version

* Fix chrome options

* Apply suggestions from code review

Co-authored-by: Nicolas Mattia <[email protected]>

* Add comment about host resolver rules

* Simplify browser logs indexing

Co-authored-by: Nicolas Mattia <[email protected]>

* Simplify getting recovery phrase from DOM

* TS ignore code executed in browser

* Fix formatting

* Fix seed phrase simplification

* Simplify replica forwarding plugin

* Remove obsolete env variable

* Name parameters of replica forward plugin

* Remove file output for chromedriver logs

* Revert migration to lockfile version v3

* Don't apply forwarding rule on nullish host

* Replace @ts-ignore with cast

* Deny access to all hosts that include a .raw subdomain

* Remove cast

* Remove outdated comment

Co-authored-by: Nicolas Mattia <[email protected]>

* Run formatter

* Update comments regarding accessing raw URLs

---------

Co-authored-by: Nicolas Mattia <[email protected]>
  • Loading branch information
Frederik Rothenberger and nmattia authored Nov 7, 2023
1 parent 072544c commit 9e24648
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 486 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/canister-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ jobs:
dfx --version
echo node --version
node --version
echo docker --version
docker --version
- name: 'Run dfx'
run: dfx start --background
Expand Down Expand Up @@ -449,30 +447,23 @@ jobs:
dfx canister create --all
dfx canister install test_app --wasm test_app.wasm
- name: Start docker compose
run: scripts/start-selenium-env --no-hot-reload

- run: npm ci
- run: npm test
- name: Run dev server
id: dev-server-start
run: |
TLS_DEV_SERVER=1 NO_HOT_RELOAD=1 npm run dev&
dev_server_pid=$!
echo "dev_server_pid=$dev_server_pid" >> "$GITHUB_OUTPUT"
- run: "II_URL=${{ matrix.domain }} SCREEN=${{ matrix.device }} npm run test:e2e -- --shard=$(tr <<<'${{ matrix.shard }}' -s _ /)" # replace 1_N with 1/N
- name: Collect docker logs
working-directory: docker-test-env
if: ${{ always() }}
run: docker compose logs > ../docker-compose.log

- name: Stop dfx
if: ${{ always() }}
run: dfx stop

- name: Shut down docker services
working-directory: docker-test-env
run: docker compose down

- name: Archive test logs
- name: Stop dev server
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: e2e-test-log-${{ matrix.device }}-${{ matrix.shard }}
path: ./*.log
run: kill ${{ steps.dev-server-start.outputs.dev_server_pid }}

- name: Archive test failures
if: ${{ always() }}
Expand Down
27 changes: 0 additions & 27 deletions docker-test-env/README.md

This file was deleted.

44 changes: 0 additions & 44 deletions docker-test-env/docker-compose.yml

This file was deleted.

11 changes: 0 additions & 11 deletions docker-test-env/reverse_proxy/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions docker-test-env/reverse_proxy/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions docker-test-env/reverse_proxy/certs/dummy.crt

This file was deleted.

51 changes: 0 additions & 51 deletions docker-test-env/reverse_proxy/certs/dummy.key

This file was deleted.

126 changes: 0 additions & 126 deletions docker-test-env/reverse_proxy/nginx.conf

This file was deleted.

Loading

0 comments on commit 9e24648

Please sign in to comment.