letsencrypt / letsencrypt/boulder

Unittests modify DB concurrently

Open
#1,499 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/tests layer/storage
Dominant language
Go
Stars
5.8k
Forks
649
Avg merge
3d 23h
Merged PRs (30d)
24

Description

Many of our unittests test interact with the database. We use a real DB rather than a mock one, because the specific DB calls are important. When a test is done, we clean up its DB modifications by truncating each table.

However, this means we can't run unittests in parallel, since there will be spurious failures. There are a few approaches to this. For instance, Rails runs each test case inside a transaction that gets reverted when the test case is done. This, unless the test case itself tries to open a transaction. Transactions inside the test cases are a problem because MySQL does not support nested transactions. However, this may be sufficient for most of our test cases.

If we want to pursue the transaction-per-test-case approach, we probably need to modify Gorp to make DbMap's and Transactions interchangeable (or create an interface that both satisfy).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the unit-test database cleanup flow and Gorp’s DbMap and Transactions APIs. Assess whether transaction-per-test-case isolation can support tests that open transactions themselves; done means unit tests can run in parallel without spurious database failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.