## Summary Mitigate Windows nightly timeout bursts caused by slow test database creation. Multiple tests were hitting `context deadline exceeded` because their 10-second deadlines started before database setup completed. Refs https://linear.app/codercom/issue/CORE-615 ## Changes - Use `STRATEGY FILE_COPY` for test database creation on PostgreSQL 15+, avoiding the more expensive default `WAL_LOG` strategy. PostgreSQL 13/14 remain unchanged. - Cache the PostgreSQL version lookup, preserving existing behavior if detection fails. - Log database copies exceeding 2 seconds, including duration and strategy. - Move context creation after database/server setup in affected WebPush, OIDC, notification, and prebuild tests, without changing timeout values. - Add unit tests for PostgreSQL version-based strategy selection. Test-only changes across 6 files; no production code changes. ## Validation - Local PostgreSQL 17.10 tests pass, including WebPush, prebuild reconciliation, OIDC, and notifications. - `go vet` and `golangci-lint` report no issues. - Local OIDC comparison: - Default strategy: 3–5 failures/run. - `FILE_COPY` with partial context fixes: 1–2 failures/run. - **Final implementation: 0 failures across 5 runs**, with maximum database creation time reduced from 13.3s to 8.9s. ## Remaining Work - Run `nightly-gauntlet` repeatedly to verify improvements on Windows and macOS. - Compare WAL volume, checkpoint overhead, and test durations. `FILE_COPY` increases checkpoints, though local database creation was faster. - Confirm PostgreSQL 13 and 17 Linux jobs pass. **Status:** Draft pending nightly validation.
29 lines
727 B
Go
29 lines
727 B
Go
package dbtestutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCopyStrategyClauseForVersion(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
versionNum int
|
|
want string
|
|
}{
|
|
{name: "PostgreSQL13HasNoStrategyOption", versionNum: 130022, want: ""},
|
|
{name: "PostgreSQL14HasNoStrategyOption", versionNum: 140019, want: ""},
|
|
{name: "PostgreSQL15UsesFileCopy", versionNum: 150000, want: " STRATEGY FILE_COPY"},
|
|
{name: "PostgreSQL17UsesFileCopy", versionNum: 170006, want: " STRATEGY FILE_COPY"},
|
|
}
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
require.Equal(t, tc.want, copyStrategyClauseForVersion(tc.versionNum))
|
|
})
|
|
}
|
|
}
|