Skip to content

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

Merged
chemamartinez merged 1 commit into9.1from
mergify/bp/9.1/pr-45150
Jul 4, 2025
Merged

[9.1](backport #45150) x-pack/filebeat/input/gcppubsub: fix integration tests#45190
chemamartinez merged 1 commit into9.1from
mergify/bp/9.1/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 leehinman 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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 4, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@chemamartinez chemamartinez merged commit 12cd1d6 into 9.1 Jul 4, 2025
206 checks passed
@chemamartinez chemamartinez deleted the mergify/bp/9.1/pr-45150 branch July 4, 2025 14:16
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