Skip to content

Commit 76279b0

Browse files
test: Remove queries containing DDL from unit tests (#8479)
DDL (Data Definition Language) operations such as `ALTER` and `TRUNCATE` are extremely expensive in Vitess. Each time Vitess detects a DDL statement, it triggers a full schema reload, rebuilding the in-memory schema models that are used for query planning and routing. Our Storage Authority, Registration Authority, bad-key-revoker (cmd), and cert-checker (cmd) unit tests repeatedly execute `ALTER` (and some `TRUNCATE`) statements during routine cleanup of every table in the Boulder database at the end of each test case. This has the effect of dramatically worse performance when running on Vitess. The good news is that we can omit these executions entirely by fixing our unit tests so they no longer make implicit assumptions about the Registration ID of the account under test. - Remove `ALTER TABLE ... AUTO_INCREMENT = 1` from cleanup to avoid unnecessary DDL - Replace per-table `SET FOREIGN_KEY_CHECKS` toggles with toggles at the beginning and end of the transaction. Replacing tables (20) x 2 statements with just 2. - Replace `TRUNCATE TABLE` with `DELETE FROM ... WHERE 1 = 1` to avoid unnecessary DDL - Remove implicit dependencies on `RegID = 1 (or 2 or 3 or 4)` in `ra`, `sa`, and `cmd/bad-key-revoker` unit tests The results on both MariaDB and Vitess are extremely good. Local unit test times with ProxySQL + MariaDB: SA: 7.1s to 2.5s RA: 4.5s to 1.1s Local unit test times with Vitess + MySQL 8.0: SA: 43s to 2.7s RA: 28s to 1.5s Part of #7736
1 parent f676b96 commit 76279b0

File tree

5 files changed

+333
-313
lines changed

5 files changed

+333
-313
lines changed

cmd/bad-key-revoker/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func TestFindUnrevoked(t *testing.T) {
247247
test.AssertNotError(t, err, "findUnrevoked failed")
248248
test.AssertEquals(t, len(rows), 1)
249249
test.AssertEquals(t, rows[0].Serial, "ff")
250-
test.AssertEquals(t, rows[0].RegistrationID, int64(1))
250+
test.AssertEquals(t, rows[0].RegistrationID, regID)
251251
test.AssertByteEquals(t, rows[0].DER, []byte{1, 2, 3})
252252

253253
bkr.maxRevocations = 0

0 commit comments

Comments
 (0)