Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit cb7b0cf

Browse files
authored
Fix one of the causes of IT flakiness: port conflicts between IPv4 and IPv6 (#1132)
The integration tests rare flakiness (~1/16 chance) seems to have multiple causes. This PR fixes one of them - flakiness caused by port conflicts between IPv4 and IPv6. In one of the flaky runs, `QueryAndIngestPipelineTestcase.testWildcardGoesToElastic` panicked while trying to parse results returned from Quesma (Quesma seemingly returned something really incorrect!): ```go resp, bodyBytes := a.RequestToQuesma(ctx, t, "POST", "/unmentioned_index/_search", []byte(`{"query": {"match_all": {}}}`)) var jsonResponse map[string]interface{} if err := json.Unmarshal(bodyBytes, &jsonResponse); err != nil { t.Fatalf("Failed to unmarshal response body: %s", err) } hits, _ := jsonResponse["hits"].(map[string]interface{}) // PANIC HERE ``` Thankfully I collected a tcpdump from this run, which showed something strange: <img width="1667" alt="Request to Quesma, but Kibana responds" src="https://github.com/user-attachments/assets/e7e32cd0-2aa2-4185-8829-ed99e8b334f7" /> Dumping all containers info from Docker: ``` Quesma container: "Ports": { "8080/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "32790" }, { "HostIp": "::", "HostPort": "32789" }], }, Kibana container: "Ports": { "5601/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "32791" }, { "HostIp": "::", "HostPort": "32790" }] }, ``` Quesma container is bound to `0.0.0.0:32790` (IPv4) and Kibana container is bound to `::0:32790` (IPv6). When we make requests to Quesma, we connect to `localhost:32790` - depending on the codepath sometimes it connects to the correct IPv4 Quesma endpoint, but sometimes it uses IPv6 and erroneously connects to Kibana instead. This is a bug in testcontainers-go: testcontainers/testcontainers-go#551 A suggested solution on the linked issue is to bind ports to host only by IPv4 - this PR applies such workaround. Note that there are some other sources of flakiness in Quesma's ITs still left to debug and fix - this only fixes one of them.
1 parent 38f12b0 commit cb7b0cf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ci/it/testcases/utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (c *Containers) Cleanup(ctx context.Context) {
5252
func setupElasticsearch(ctx context.Context) (testcontainers.Container, error) {
5353
req := testcontainers.ContainerRequest{
5454
Image: "docker.elastic.co/elasticsearch/elasticsearch:8.11.1",
55-
ExposedPorts: []string{"9200/tcp", "9300/tcp"},
55+
ExposedPorts: []string{"0.0.0.0::9200/tcp", "0.0.0.0::9300/tcp"},
5656
// Do i ned
5757
Env: map[string]string{
5858
"discovery.type": "single-node",
@@ -99,7 +99,7 @@ func setupQuesma(ctx context.Context, quesmaConfig string) (testcontainers.Conta
9999
}
100100
quesmaReq := testcontainers.ContainerRequest{
101101
Image: "quesma/quesma:nightly",
102-
ExposedPorts: []string{"9999/tcp", "8080/tcp"},
102+
ExposedPorts: []string{"0.0.0.0::9999/tcp", "0.0.0.0::8080/tcp"},
103103
Env: map[string]string{
104104
"QUESMA_CONFIG_FILE": "/configuration/conf.yaml",
105105
},
@@ -138,7 +138,7 @@ func setupKibana(ctx context.Context, quesmaContainer testcontainers.Container)
138138

139139
req := testcontainers.ContainerRequest{
140140
Image: "docker.elastic.co/kibana/kibana:8.11.1",
141-
ExposedPorts: []string{"5601/tcp"},
141+
ExposedPorts: []string{"0.0.0.0::5601/tcp"},
142142
Env: map[string]string{
143143
"ELASTICSEARCH_HOSTS": fmt.Sprintf("[\"%s\"]", fmt.Sprintf("http://%s:%s", GetInternalDockerHost(), port.Port())),
144144
"XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY": "QUESMAQUESMAQUESMAQUESMAQUESMAQUESMAQUESMAQUESMA",
@@ -165,7 +165,7 @@ func setupKibana(ctx context.Context, quesmaContainer testcontainers.Container)
165165
func setupClickHouse(ctx context.Context) (testcontainers.Container, error) {
166166
req := testcontainers.ContainerRequest{
167167
Image: "clickhouse/clickhouse-server:24.5.3.5-alpine",
168-
ExposedPorts: []string{"8123/tcp", "9000/tcp"},
168+
ExposedPorts: []string{"0.0.0.0::8123/tcp", "0.0.0.0::9000/tcp"},
169169
HostConfigModifier: func(hc *container.HostConfig) {
170170
hc.ExtraHosts = []string{"localhost-for-github-ci:host-gateway"}
171171
},

0 commit comments

Comments
 (0)