Skip to content

Fix random test failure due to port collision #156

@josecelano

Description

@josecelano

For the API testing, we are using an independent API server for each test because:

  • We want tests to be isolated.
  • Sometimes, we need a specific tracker configuration for the test.

We assign a random port for each API server and test with a function like this:

fn random_port() -> u16 {
    // todo: this may produce random test failures because two tests can try to bind the same port.
    // We could create a pool of available ports (with read/write lock)
    let mut rng = thread_rng();
    rng.gen_range(49152..65535)
}

We have reached a high number of parallel running tests that produces this conflict too often.

We could create a centralised free-of-race-conditions service which assigns the free port numbers.

We could also reuse API server for tests that use the same configuration and do not conflict, but I would like to avoid that because it can generate hidden coupling between tests.

Metadata

Metadata

Assignees

Labels

BugIncorrect Behavior

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions