ProtonMail / gluon

An IMAP server library written in Go
MIT License
462 stars 27 forks source link

Flaky tests #404

Open upils opened 10 months ago

upils commented 10 months ago

gluon was recently packaged in Debian and also synced to the Ubuntu archive.

We noticed that tests were unreliable.

Here are 2 examples of the package building, resulting in 2 different sets of tests failing:

The third time the build was successful. This is not critical since we now have a package but will surely be problematic during following upgrades.

I tried to reproduce locally, especially with the -race flag. This flag is not present in our build but since I suspect a race condition between several tests I thought it could make it easier to trigger. But no luck so far. I noticed you run the tests in CI with this flag so maybe you have already encountered the problem?

In the first build attempt:

In the second build attempt:

MailBoxes are created using utils.NewRandomMailboxID() in the tests, so several independent tests should not impact each other.

I also checked the connection management (looking at runOneToOneTest() and withConnections()) and did not see any obvious bug like sharing a connection between tests, reusing a connection, forgetting to check connection closing errors, etc.

Maybe the IMAP server is not always reliably answering to requests in the same order?

Let me know if you need more details or have other ideas to try and reproduce to pinpoint the issue.

LBeernaertProton commented 10 months ago

Some tests are a bit flaky since they rely on non-deterministic behavior.

We are aware of the issue, but fixing this is not a high priority at the moment.