Skip to content

Commit bb598b3

Browse files
MattHandzeladamyeats
authored andcommitted
Fix flaky test TestHTTPConnectWithHeaders (#1397)
The test was failing intermittently due to a race condition where the datasource connection attempt occurred before the proxy server was ready to accept connections. This fix adds synchronization logic that polls the proxy server port until it's accepting connections (with a 5-second timeout) Fixes #1397
1 parent 57469c1 commit bb598b3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/plugin/driver_integration_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,20 @@ func TestHTTPConnectWithHeaders(t *testing.T) {
12021202
assert.Equal(t, nil, err)
12031203
}()
12041204

1205+
// Wait for proxy server to be ready
1206+
proxyAddr := fmt.Sprintf("%s:%s", proxyHost, proxyPort)
1207+
for i := 0; i < 50; i++ {
1208+
conn, err := net.DialTimeout("tcp", proxyAddr, 100*time.Millisecond)
1209+
if err == nil {
1210+
conn.Close()
1211+
break
1212+
}
1213+
if i == 49 {
1214+
t.Fatalf("Proxy server failed to start after 5 seconds")
1215+
}
1216+
time.Sleep(100 * time.Millisecond)
1217+
}
1218+
12051219
username := getEnv("CLICKHOUSE_USERNAME", "default")
12061220
password := getEnv("CLICKHOUSE_PASSWORD", "")
12071221
secure := map[string]string{}

0 commit comments

Comments
 (0)