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

Integration tests scaffolding #129

Merged
merged 3 commits into from
Apr 29, 2023
Merged

Integration tests scaffolding #129

merged 3 commits into from
Apr 29, 2023

Conversation

josecelano
Copy link
Member

Changes needed to run tests with independent app instances running on different ports.

This allow the user to set the por to 0 and the OS will assign a free
port to the server. This will be used by iuntegration tests to run each
test with a different app instance running on a different port.
To be able to run it from tests.
It allows integration test to run a custom env (with a custom
configuration) and totally isolated from other tests.

The test env used a socket address assigned from the OS (free port).

You can do that by setting the port number to 0 in the config.toml file:

```
[net]
port = 0
```
@josecelano josecelano marked this pull request as ready for review April 29, 2023 15:42
@josecelano
Copy link
Member Author

ACK 6d5e002

@josecelano josecelano merged commit d0015d5 into torrust:develop Apr 29, 2023
josecelano added a commit that referenced this pull request May 3, 2023
14d0acb refactor: run e2e tests with independent isolated servers too. (Jose Celano)
1df870b refactor: extract logic for setting up test envs (Jose Celano)
36f17f1 tests: panic when E2E server env is not running (Jose Celano)
bce946f refactor: removed unneeded intermediary var (Jose Celano)

Pull request description:

  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](#129), 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):

  ```text
  TORRUST_IDX_BACK_E2E_SHARED=true cargo test
  ```

  With isolated app instance (only rust):

  ```text
  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:

  ```rust
  if !env.provides_a_tracker() {
     return
  }
  ```

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

ACKs for top commit:
  josecelano:
    ACK 14d0acb

Tree-SHA512: 3ab562785938548caf238fd91d6894d0a1dc8e02eece10e157286fc9cb2950f9fdf5393c97b696ee5bde24577191c268fd95764eee5604f51b2ab314154f3125
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