Skip to content

Refactor: run all E2E tests with isolated servers#133

Merged
josecelano merged 4 commits intotorrust:developfrom
josecelano:run-all-e2e-test-wih-independend-servers
May 3, 2023
Merged

Refactor: run all E2E tests with isolated servers#133
josecelano merged 4 commits intotorrust:developfrom
josecelano:run-all-e2e-test-wih-independend-servers

Conversation

@josecelano
Copy link
Copy Markdown
Member

@josecelano josecelano commented May 2, 2023

We are running all E2E with the same application instance. The process is as follows:

1.- Start docker containers with E2E env.
2.- Run E2E tests.
3.- Stop containers.

After merging this PR, we can run an isolated app instance for each test.

This PR allows E2E tests to be executed with isolated app instances:

  • Without using docker.
  • And in a way, we can mock services, setting the initial test state easier, etcetera.

For now, we can run most of the E2E tests twice: with the shared docker instance or with the isolated app instances. YOu can change the behaviour with an env var.

With the shared app (docker):

TORRUST_IDX_BACK_E2E_SHARED=true cargo test

With isolated app instance (only rust):

cargo test

Some tests cannot be executed in an isolated env because they require a running tracker. We could change them to use a mock.

In general, I would try to keep only a few E2E tests using the real tracker and most of them using the mock. In the future, we could differentiate them using a different folder. Right now, the ones that require the running tracker have this:

if !env.provides_a_tracker() {
   return
}

to skip the test when the test env does not provide a running tracker.

josecelano added 4 commits May 2, 2023 13:14
It shows a more user-friendly message when you run E2E tests and the
server is not responding on the default location http://localhost:3000
E2E tests can be executed with an external shared running app (that must be
started before running all the tests) or with an isolated env per test
(that can be customized and it lasts only until the end of the test).
E2E tests can be executed with a shared app instance with:

```
TORRUST_IDX_BACK_E2E_SHARED=true cargo test
```

or with an isolated instance per test:

```
cargo test
```

In the first case, you have to start the env manbually before running the tests, and manually stop it when tests are finished.
In the second test, the test will launch a new app on a different socket using a different database.

Shared env:

- Requires docker
- It's slower
- It comes with a real traker

Isolated env:

- Doesn't require docker
- It's faster
- You have to mock the TrackerService (not implemented yet)
@josecelano josecelano marked this pull request as ready for review May 3, 2023 18:07
@josecelano
Copy link
Copy Markdown
Member Author

ACK 14d0acb

@josecelano josecelano merged commit a46217d into torrust:develop May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant