Skip to content

Commit 5373f23

Browse files
x-pack/filebeat/input/gcppubsub: fix integration tests (#45150)
Solved two issues in the GCP Pub/Sub input tests: - GCP Pub/Sub Emulator Container Missing: this has been fixed by ensuring the Pub/Sub emulator Docker container is properly launched for the test environment. - Fix for Segfault in NewInput.func2: a segmentation fault occurred when test code accessed in.metrics before it was initialized. Metrics are now explicitly initialized in the test setup to avoid nil pointer dereferencing.
1 parent 38b3f73 commit 5373f23

File tree

8 files changed

+25
-11
lines changed

8 files changed

+25
-11
lines changed

CHANGELOG-developer.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
115115
- Fix IIS module logging errors in case application pool PDH counter is not found. {pull}42274[42274]
116116
- Removed direct dependency on Azure/go-autorest/autorest/adal, which is deprecated. {issue}41463[41463] {pull}42959[42959]
117117
- Fixed flaky zookeeper integration tests. {pull}43638[43638]
118+
- Fixed Fileebat GCP Pub/Sub input integration tests. {pull}45150[45150]
118119

119120
==== Added
120121

dev-tools/mage/integtest_docker.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ func WithGoIntegTestHostEnv(env map[string]string) map[string]string {
191191
// images for the next release after a feature freeze, which causes temporary test failures.
192192
env["TESTING_FILEBEAT_ALLOW_OLDER"] = "1"
193193

194+
env["PUBSUB_EMULATOR_HOST"] = "localhost:8432"
195+
194196
return env
195197
}
196198

x-pack/agentbeat/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ services:
2020
ports:
2121
- 9200:9200
2222

23+
googlepubsub:
24+
image: docker.elastic.co/integrations-ci/beats-googlepubsub:emulator-${SDK_VERSION:-398.0.0-0}-1
25+
build:
26+
context: ${ES_BEATS}/testing/environments/docker/googlepubsub
27+
args:
28+
SDK_VERSION: ${SDK_VERSION:-398.0.0-0}
29+
hostname: googlepubsub
30+
ports:
31+
- 8432:8432
32+
2333
cometd:
2434
build: ${ES_BEATS}/testing/environments/docker/cometd
2535
hostname: cometd

x-pack/filebeat/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ services:
2020
ports:
2121
- 9200:9200
2222

23+
googlepubsub:
24+
image: docker.elastic.co/integrations-ci/beats-googlepubsub:emulator-${SDK_VERSION:-398.0.0-0}-1
25+
build:
26+
context: ${ES_BEATS}/testing/environments/docker/googlepubsub
27+
args:
28+
SDK_VERSION: ${SDK_VERSION:-398.0.0-0}
29+
hostname: googlepubsub
30+
ports:
31+
- 8432:8432
32+
2333
cometd:
2434
build: ${ES_BEATS}/testing/environments/docker/cometd
2535
hostname: cometd

x-pack/filebeat/input/gcppubsub/docker-compose.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

x-pack/filebeat/input/gcppubsub/pubsub_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ func runTestWithACKer(t *testing.T, cfg *conf.C, onEvent eventHandler, run func(
251251
}
252252
//nolint:errcheck // ignore
253253
pubsubInput := in.(*pubsubInput)
254+
// Initialize metrics explicitly for tests
255+
pubsubInput.metrics = newInputMetrics("", nil)
254256
defer pubsubInput.Stop()
255257

256258
run(client, pubsubInput, eventOutlet, t)

0 commit comments

Comments
 (0)