Skip to content

[9.0](backport #45150) x-pack/filebeat/input/gcppubsub: fix integration tests#45189

Merged
chemamartinez merged 2 commits into9.0from
mergify/bp/9.0/pr-45150
Jul 7, 2025
Merged

[9.0](backport #45150) x-pack/filebeat/input/gcppubsub: fix integration tests#45189
chemamartinez merged 2 commits into9.0from
mergify/bp/9.0/pr-45150

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Jul 4, 2025

Proposed commit message

This PR addresses two issues in the GCP Pub/Sub input tests:

  1. GCP Pub/Sub Emulator Container Missing:

Tests like TestTopicDoesNotExist were being skipped due to the missing PUBSUB_EMULATOR_HOST environment variable:

<testcase classname="github.com/elastic/beats/v7/x-pack/filebeat/input/gcppubsub" name="TestTopicDoesNotExist" time="0.000000">
<skipped message="=== RUN TestTopicDoesNotExist pubsub_test.go:230: PUBSUB_EMULATOR_HOST is not set in environment. You can start the emulator with "docker-compose up" from the _meta directory. The default address is PUBSUB_EMULATOR_HOST=localhost:8432 --- SKIP: TestTopicDoesNotExist (0.00s) "/>
</testcase>

This has been fixed by ensuring the Pub/Sub emulator Docker container is properly launched for the test environment.

  1. Fix for Segfault in NewInput.func2:

A segmentation fault occurred when test code accessed in.metrics before it was initialized.

=== FAIL: x-pack/filebeat/input/gcppubsub TestSubscriptionExists (unknown)
    logger.go:146: 2025-06-26T17:56:37.058+0200	INFO	gcp.pubsub	logp/logger.go:169	Initialized GCP Pub/Sub input.	{"pubsub_project": "test-project-id", "pubsub_topic": "test-topic-foo", "pubsub_subscription": {"Name":"test-subscription-bar","NumGoroutines":1,"MaxOutstandingMessages":1600,"Create":true}}
    pubsub_test.go:142: Topic created: test-topic-foo
    pubsub_test.go:189: New subscription created: test-subscription-bar
    pubsub_test.go:166: Published 5 messages to topic test-topic-foo. ID range: [1, 5]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1056a2740]

Metrics are now explicitly initialized in the test setup to avoid nil pointer dereferencing.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Run the integration tests from x-pack/filebeat with:

# mage -v goIntegTest

This is an automatic backport of pull request #45150 done by [Mergify](https://mergify.com).

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.

(cherry picked from commit 5373f23)
@mergify mergify Bot added the backport label Jul 4, 2025
@mergify mergify Bot requested review from a team as code owners July 4, 2025 10:15
@mergify mergify Bot added the backport label Jul 4, 2025
@mergify mergify Bot requested review from faec and mauri870 and removed request for a team July 4, 2025 10:15
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 4, 2025
@github-actions github-actions Bot added Filebeat Filebeat flaky-test Unstable or unreliable test cases. Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Security-Service Integrations Security Service Integrations Team labels Jul 4, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 4, 2025
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented Jul 7, 2025

This pull request has not been merged yet. Could you please review and merge it @chemamartinez? 🙏

@chemamartinez chemamartinez merged commit a4d08f1 into 9.0 Jul 7, 2025
174 of 177 checks passed
@chemamartinez chemamartinez deleted the mergify/bp/9.0/pr-45150 branch July 7, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Filebeat Filebeat flaky-test Unstable or unreliable test cases. Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants