summaryrefslogtreecommitdiff
path: root/integrationtests
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-30 10:08:52 +0300
committerPaul Buetow <paul@buetow.org>2025-06-30 10:08:52 +0300
commit88886206c2c758bf619362aaa484dd3e254b8ed1 (patch)
treea8295ffe10061909984211e01a6ca9aee005ef4d /integrationtests
parent38ed252e1a85c6d9a17cb7e244737c6f1d93d4d8 (diff)
fix: improve test server cleanup to prevent intermittent TestDMap2 failures
Added explicit cleanup with a 100ms delay when test servers are started to ensure the server process terminates and releases its port before the next test runs. This prevents intermittent failures in TestDMap2 when it runs after other tests that use servers. The issue was that test servers could linger briefly after context cancellation, causing port conflicts when tests run in sequence. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'integrationtests')
-rw-r--r--integrationtests/testhelpers.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/integrationtests/testhelpers.go b/integrationtests/testhelpers.go
index b750de6..a6a5f50 100644
--- a/integrationtests/testhelpers.go
+++ b/integrationtests/testhelpers.go
@@ -216,6 +216,12 @@ func NewTestServer(t *testing.T) *TestServer {
// Start starts the test server with the given log level
func (ts *TestServer) Start(logLevel string) error {
+ // Add cleanup to ensure server is stopped when test ends
+ ts.t.Cleanup(func() {
+ ts.Stop()
+ // Give the server a moment to release the port
+ time.Sleep(100 * time.Millisecond)
+ })
return startTestServer(ts.t, ts.ctx, &ServerConfig{
Port: ts.port,
BindAddress: ts.bindAddress,
@@ -225,6 +231,12 @@ func (ts *TestServer) Start(logLevel string) error {
// StartWithConfig starts the test server with custom configuration
func (ts *TestServer) StartWithConfig(cfg *ServerConfig) error {
+ // Add cleanup to ensure server is stopped when test ends
+ ts.t.Cleanup(func() {
+ ts.Stop()
+ // Give the server a moment to release the port
+ time.Sleep(100 * time.Millisecond)
+ })
if cfg == nil {
cfg = &ServerConfig{}
}