Skip to content

x-pack/filebeat/input/gcppubsub: fix integration tests#45150

Merged
chemamartinez merged 6 commits intoelastic:mainfrom
chemamartinez:gcppubsub-fix-integ-tests
Jul 4, 2025
Merged

x-pack/filebeat/input/gcppubsub: fix integration tests#45150
chemamartinez merged 6 commits intoelastic:mainfrom
chemamartinez:gcppubsub-fix-integ-tests

Conversation

@chemamartinez
Copy link
Copy Markdown
Contributor

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

@chemamartinez chemamartinez self-assigned this Jul 2, 2025
@chemamartinez chemamartinez added Filebeat Filebeat flaky-test Unstable or unreliable test cases. Team:Security-Service Integrations Security Service Integrations Team backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-8.19 Automated backport to the 8.19 branch labels Jul 2, 2025
@botelastic botelastic Bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 2, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 2, 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 marked this pull request as ready for review July 2, 2025 12:43
@chemamartinez chemamartinez requested review from a team as code owners July 2, 2025 12:44
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

@belimawr belimawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests are timing out, could you check if the're related to your change?

Comment thread CHANGELOG.next.asciidoc Outdated
@chemamartinez
Copy link
Copy Markdown
Contributor Author

Some tests are timing out, could you check if the're related to your change?

Thanks for bringing this up, the same tests were failing for agentbeat, I didn't realize agentbeat was also running filebeat integration tests. They should now pass.

I've checked the other failing tests and they are unrelated.

@chemamartinez chemamartinez requested a review from belimawr July 3, 2025 10:02
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 4, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@chemamartinez chemamartinez merged commit 5373f23 into elastic:main Jul 4, 2025
203 of 204 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 4, 2025

@Mergifyio backport 9.0 9.1

@chemamartinez chemamartinez deleted the gcppubsub-fix-integ-tests branch July 4, 2025 10:14
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jul 4, 2025

backport 9.0 9.1

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Jul 4, 2025
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 Bot pushed a commit that referenced this pull request Jul 4, 2025
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 Bot pushed a commit that referenced this pull request Jul 4, 2025
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)
chemamartinez added a commit that referenced this pull request Jul 4, 2025
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)

Co-authored-by: Chema Martínez <chema.martinez@elastic.co>
chemamartinez added a commit that referenced this pull request Jul 4, 2025
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)

Co-authored-by: Chema Martínez <chema.martinez@elastic.co>
chemamartinez added a commit that referenced this pull request Jul 7, 2025
…on tests (#45189)

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)

---------

Co-authored-by: Chema Martínez <chema.martinez@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches 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.

6 participants