Skip to content

Conversation

@Kunal1522
Copy link
Contributor

Fixes #3202

What's in the test

Main test function:

  • TestMetadata_Subscriptions - The actual test. Sets up a Broker, deploys two functions (subscriber and producer), fires an event, and checks the subscriber's logs to confirm it received the event through the Broker.
    Helper functions:
  • createBroker(t, namespace, name) - Creates a Knative Broker using kubectl apply. Waits for it to be ready before returning.
  • deleteBroker(t, namespace, name) - Cleanup helper that deletes the Broker when the test finishes.
  • waitForTrigger(t, namespace, functionName) - Waits for the Knative Trigger (created by func subscribe) to reach Ready state. Without this, events might get lost if we send them too early.
    Unused legacy helpers (kept for potential future use):
  • sendEventToBrokerWithRetry - Retry wrapper for sending events (not currently used, test uses direct HTTP instead)
  • sendEventToBrokerInternal - In-cluster event sending using Kubernetes port-forwarding (not currently used, test deploys a Producer function instead)

This test verifies the full Knative Eventing flow using func subscribe:
- Creates a producer function that sends CloudEvents to the broker
- Creates a subscriber function that receives events via a Trigger
- Validates the complete event delivery pipeline

Fixes knative#3202
@knative-prow
Copy link

knative-prow bot commented Jan 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kunal1522
Once this PR has been reviewed and has the lgtm label, please assign lkingland for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow
Copy link

knative-prow bot commented Jan 2, 2026

Hi @Kunal1522. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 2, 2026
@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.18%. Comparing base (039b926) to head (963ccb7).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3324      +/-   ##
==========================================
+ Coverage   55.09%   55.18%   +0.09%     
==========================================
  Files         170      170              
  Lines       19850    19850              
==========================================
+ Hits        10937    10955      +18     
+ Misses       7845     7825      -20     
- Partials     1068     1070       +2     
Flag Coverage Δ
e2e 40.03% <ø> (+0.44%) ⬆️
e2e go 35.62% <ø> (ø)
e2e node 31.13% <ø> (ø)
e2e python 35.27% <ø> (-0.09%) ⬇️
e2e quarkus 31.28% <ø> (ø)
e2e rust 30.74% <ø> (+0.01%) ⬆️
e2e springboot 30.71% <ø> (-0.06%) ⬇️
e2e typescript 31.25% <ø> (ø)
integration 17.46% <ø> (-0.03%) ⬇️
unit macos-14 44.96% <ø> (ø)
unit macos-latest 44.96% <ø> (ø)
unit ubuntu-24.04-arm 45.07% <ø> (ø)
unit ubuntu-latest 45.86% <ø> (ø)
unit windows-latest 44.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The subscribe command doesn't support the -v (verbose) flag that newCmd()
automatically adds when FUNC_E2E_VERBOSE=true. This causes test failures.

Changed to use exec.Command directly for the subscribe call to bypass
the automatic verbose flag addition while keeping it for other commands.
Check for broker-ingress service before running the test to gracefully
skip if Knative Eventing is not installed or not ready yet.
The test was failing in CI because it tried to send events before
the broker-ingress service was registered in DNS. This adds a retry
loop to wait for the service to be available before proceeding.

Fixes timing issues in fresh cluster environments.
@Kunal1522 Kunal1522 marked this pull request as draft January 2, 2026 21:14
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 2, 2026
@Kunal1522 Kunal1522 marked this pull request as ready for review January 3, 2026 10:21
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 3, 2026
- Remove unused sendEventToBroker* functions
- Use callback pattern for reliable event verification
- Clean up comments and reduce code size
@Kunal1522
Copy link
Contributor Author

Kunal1522 commented Jan 4, 2026

i spent quite a bit of time trying different approaches to get the producer, subscriber, and broker pods to talk back to the test, basically saying "hey, i got the event." turns out a lot of things like reading pod logs, writing files inside containers, or hitting the broker directly don't really work because of container isolation. so instead of the test trying to pull info from pods, i just flipped it. now the subscriber pushes a callback to the test. the test spins up a small http server on a dynamic port, passes the url via CALLBACK_URL env var, and when the subscriber gets an event it posts the event id back. a go channel catches this and the test knows everything worked. hopefully this solves the todo at line 558-563 e2e/e2e_metadata_test.go

@Kunal1522
Copy link
Contributor Author

/ok-to-test

@knative-prow
Copy link

knative-prow bot commented Jan 4, 2026

@Kunal1522: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@intojhanurag
Copy link
Member

intojhanurag commented Jan 5, 2026

i spent quite a bit of time trying different approaches to get the producer, subscriber, and broker pods to talk back to the test, basically saying "hey, i got the event." turns out a lot of things like reading pod logs, writing files inside containers, or hitting the broker directly don't really work because of container isolation. so instead of the test trying to pull info from pods, i just flipped it. now the subscriber pushes a callback to the test. the test spins up a small http server on a dynamic port, passes the url via CALLBACK_URL env var, and when the subscriber gets an event it posts the event id back. a go channel catches this and the test knows everything worked. hopefully this solves the todo at line 558-563 e2e/e2e_metadata_test.go

Yeah It seems good now , we should use defer for cleanup i think, not sure :)
/cc @gauron99

@intojhanurag
Copy link
Member

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 5, 2026
@knative-prow knative-prow bot requested a review from gauron99 January 5, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E Subscription Tests

2 participants