Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
perf(tests): close idle connections before shutting the server down (#21336)
Danny Xueb6da19f9341
diff --git a/backend/tests/tests.go b/backend/tests/tests.goindex 0247c251e6..9e0b74ec91 100644--- a/backend/tests/tests.go+++ b/backend/tests/tests.go@@ -347,6 +347,11 @@ func (ctl *controller) waitForHealthz(ctx context.Context) error {// Close closes long running resources.func (ctl *controller) Close(ctx context.Context) error {var e error+ // Drop the client's idle HTTP/2 connection before shutting the server down.+ // Otherwise httpServer.Shutdown waits out the idle connection, ~1s per test.+ if ctl.client != nil {+ ctl.client.CloseIdleConnections()+ }if ctl.server != nil {if err := ctl.server.Shutdown(ctx); err != nil {e = multierr.Append(e, err)diff --git a/docs/design/backend-test-execution-time.md b/docs/design/backend-test-execution-time.mdindex 4a24c31634..a7bc02d056 100644--- a/docs/design/backend-test-execution-time.md+++ b/docs/design/backend-test-execution-time.md@@ -1,5 +1,7 @@# Backend test execution time+Status: in progress+## ScopeCut the execution time of `go test ./backend/...`. It takes 14–19.5 minutes in@@ -90,7 +92,7 @@ cost inside a package that runs 3.7× parallel, and effort 1's saving sits insideffort 4's, so they do not simply add. Together they should take it from 635 sof wall clock to roughly 330 s.-### 1. Close idle connections before shutting the server down+### [✓] 1. Close idle connections before shutting the server down**Three lines.** `httpServer.Shutdown` burns 1036 ms on every one of the 207boots. It is waiting out an idle HTTP/2 connection that nobody will reuse: the@@ -113,6 +115,13 @@ That 217 s is part of effort 4's total, not on top of it. This goes first onlybecause it is three lines and needs no restructuring, and it stops matteringonce effort 4 collapses the boot count.+**What it bought.** Over 5 cycles the shutdown went from 1058 ms to **1 ms**+and the boot-and-shutdown cycle from 1720 ms to **691 ms**, as projected. A+package-isolated `go test ./backend/tests/` — not the full-suite figure above —+went from **679 s to 611 s** across its 233 boots: 227 s off the summed test+time, compressed 3.3× by the package's own parallelism. Measure the efforts+below against 611 s.+### 2. One shared container per package, then turn parallelism on**1371 s of wall clock across four packages, about 1070 s of it container