Skip to content

Commit 96fc183

Browse files
committed
refactor: extract magic number to constant and improve workflow docs
- Extract 2-second sleep to postgresStabilizationPeriod constant for better maintainability - Update architecture description to include all accepted values (x86/amd64, arm/arm64)
1 parent 775e5ec commit 96fc183

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.github/workflows/test_images.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
type: string
1717
required: true
1818
architectures:
19-
description: "Comma-separated list of architectures to test (x86,arm)"
19+
description: "Comma-separated list of architectures to test (x86/amd64, arm/arm64)"
2020
type: string
2121
default: "x86,arm"
2222
required: false

tests/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import (
1515
"github.com/docker/docker/pkg/stdcopy"
1616
)
1717

18+
const (
19+
// postgresStabilizationPeriod is the duration to wait after PostgreSQL
20+
// passes readiness checks to allow background workers, extensions, and
21+
// internal caches to fully initialize before running tests.
22+
postgresStabilizationPeriod = 2 * time.Second
23+
)
24+
1825
// Test represents a single test case
1926
type Test struct {
2027
Name string
@@ -419,10 +426,10 @@ func (r *TestRunner) waitForPostgres(timeout time.Duration) error {
419426
if err == nil && exitCode == 0 {
420427
// Give PostgreSQL a short grace period even after a successful readiness check.
421428
// Although pg_isready and a trivial SELECT can succeed, background workers,
422-
// extensions, and internal caches may still be initializing. Waiting a fixed
423-
// 2 seconds helps ensure a stable database state and reduces test flakiness
424-
// in subsequent operations that depend on a fully-initialized instance.
425-
time.Sleep(2 * time.Second)
429+
// extensions, and internal caches may still be initializing. This delay helps
430+
// ensure a stable database state and reduces test flakiness in subsequent
431+
// operations that depend on a fully-initialized instance.
432+
time.Sleep(postgresStabilizationPeriod)
426433
return nil
427434
}
428435
}

0 commit comments

Comments
 (0)