Skip to content

Add Gardener Receiver E2E Test - #67

Open
chrkl wants to merge 14 commits into
gardener:mainfrom
chrkl:gardener-integration
Open

Add Gardener Receiver E2E Test#67
chrkl wants to merge 14 commits into
gardener:mainfrom
chrkl:gardener-integration

Conversation

@chrkl

@chrkl chrkl commented Jul 29, 2026

Copy link
Copy Markdown
Member

How to categorize this PR?

/kind test

What this PR does / why we need it:

Add e2e test for the Gardener metrics receiver

Which issue(s) this PR fixes:
gardener/observability#57

Special notes for your reviewer:

Release note:

Add Gardener Receiver e2e test

@chrkl
chrkl requested a review from a team as a code owner July 29, 2026 10:29
@gardener-prow gardener-prow Bot added the kind/test Test label Jul 29, 2026
@gardener-prow

gardener-prow Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign rickardsjp 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

@gardener-prow gardener-prow Bot added cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 29, 2026
@hyperspace-pr-bot

Copy link
Copy Markdown

Summary

The following content is AI-generated and provides a summary of the pull request:


/kind test

What this PR does / why we need it:

Adds an end-to-end integration test for the Gardener metrics receiver. The test spins up a KinD cluster with a full Gardener deployment, then verifies that the OpenTelemetry Collector correctly scrapes and exports Gardener resource metrics (shoots, seeds, projects, managed seeds, gardenlets) via both the Prometheus exporter and the OTLP HTTP exporter.

Key additions:

  • .github/workflows/gardener-integration.yaml — New GitHub Actions workflow that triggers on PRs (opened/edited/reopened), on a nightly schedule (0 4 * * *), or manually via workflow_dispatch (with an optional gardener_ref input). It checks out both this repo and gardener/gardener, sets up Go, and runs the integration test script.

  • hack/gardener-integration-test.sh — Shell script that:

    1. Brings up a KinD cluster using Gardener's make kind-up
    2. Deploys Gardener via make gardener-up
    3. Resolves the latest snapshot collector image from the container registry
    4. Deploys two OpenTelemetryCollector instances — one with a Prometheus exporter, one with an OTLP HTTP exporter
    5. Deploys a Prometheus Operator instance with a ServiceMonitor and OTLP write receiver enabled
    6. Creates a sample Shoot resource
    7. Polls Prometheus to verify both garden_shoot_info (scraped path) and garden.shoot.info (OTLP push path) metrics are present within a 5-minute timeout
    8. Tears down the KinD cluster on exit (skippable via SKIP_TEARDOWN)

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

Add Gardener integration test for the Gardener metrics receiver, covering both Prometheus scrape and OTLP push export paths.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.6

  • Event Trigger: pull_request.opened
  • Summary Prompt: Default Prompt
  • Correlation ID: 706e9200-8b38-11f1-833e-5f9a5d86dcbe
  • LLM: anthropic--claude-4.6-sonnet
  • Output Template: Repository PR Template
  • File Content Strategy: Full file content

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR introduces a Gardener integration test workflow and script with several substantive issues: the most critical is that resolve_collector_image will always fail because the Google Artifact Registry tag-list API does not include the Docker Hub-specific .manifest field, meaning the test can never successfully run. Additionally, the missing synchronize trigger means new commits pushed to a PR won't trigger the test, two endgroup calls are missing on early-return error paths producing malformed CI log output, and actions/setup-go@v6 diverges from the @v7 version used everywhere else in the repository.

PR Bot Information

Version: 1.29.6

  • Event Trigger: pull_request.opened
  • Correlation ID: 706e9200-8b38-11f1-833e-5f9a5d86dcbe
  • LLM: anthropic--claude-4.6-sonnet
  • Experiment Variant: control
  • File Content Strategy: Full file content

Comment thread .github/workflows/gardener-integration.yaml Outdated
Comment thread .github/workflows/gardener-integration.yaml Outdated
Comment thread receiver/gardenerreceiver/hack/gardener-receiver-e2e-test.sh
Comment thread receiver/gardenerreceiver/hack/gardener-receiver-e2e-test.sh Outdated
Comment thread receiver/gardenerreceiver/hack/gardener-receiver-e2e-test.sh Outdated
@chrkl

chrkl commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

/hold

@gardener-prow gardener-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2026
@chrkl
chrkl force-pushed the gardener-integration branch 6 times, most recently from 09c8e23 to 0d4f655 Compare July 29, 2026 12:44
@chrkl

chrkl commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

/unhold

@gardener-prow gardener-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2026
@chrkl
chrkl force-pushed the gardener-integration branch from 0d4f655 to 2657451 Compare July 29, 2026 13:30
@chrkl chrkl changed the title Add Gardener integration test Add Gardener Receiver E2E test Aug 7, 2026
@chrkl chrkl changed the title Add Gardener Receiver E2E test Add Gardener Receiver E2E Test Aug 7, 2026
@chrkl
chrkl force-pushed the gardener-integration branch 2 times, most recently from f5e8420 to 7cb9047 Compare August 7, 2026 11:28
@chrkl

chrkl commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

/hold

@gardener-prow gardener-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 7, 2026
@chrkl
chrkl force-pushed the gardener-integration branch from f57026a to a227420 Compare August 7, 2026 12:53
@gardener-prow gardener-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 7, 2026
@chrkl
chrkl force-pushed the gardener-integration branch 2 times, most recently from 30fdc33 to 98d4db6 Compare August 11, 2026 12:52
return &monitoringv1.ServiceMonitor{
TypeMeta: metav1.TypeMeta{APIVersion: monitoringv1.SchemeGroupVersion.String(), Kind: monitoringv1.ServiceMonitorsKind},
ObjectMeta: metav1.ObjectMeta{
Name: "gardener-prometheus-collector",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could use the constant defined above.


// serviceMonitorLabel is the label the Prometheus instance selects
// ServiceMonitors by, and that the ServiceMonitor carries.
var serviceMonitorLabel = map[string]string{"app": "gardener-prometheus-collector"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could use the constant defined above.

},
Spec: monitoringv1.ServiceMonitorSpec{
Selector: metav1.LabelSelector{MatchLabels: map[string]string{
"app.kubernetes.io/name": "gardener-prometheus-collector",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could use the constant defined above.

func prometheusCollector(namespace, image string) *otelv1beta1.OpenTelemetryCollector {
return &otelv1beta1.OpenTelemetryCollector{
TypeMeta: metav1.TypeMeta{APIVersion: otelv1beta1.GroupVersion.String(), Kind: otelCollectorKind},
ObjectMeta: metav1.ObjectMeta{Name: "gardener-prometheus", Namespace: namespace},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought maybe we could extract "gardener-prometheus" into its own constant next to prometheusCollectorDeployment to show one is the collector and the other the deployment that the OTel operator deploys.

)

// deployComponents replicates the bulk of the former shell
// run_collector_e2e_test: it creates the test namespace, the Gardener API

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

deployComponents replicates the bulk of the former shell run_collector_e2e_test

Does this sentence apply? Was there such a script before, or only in your PR?

return 0, fmt.Errorf("parse sample value %q: %w", raw, err)
}
return value, nil
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe it would be a smaller improvement if we used a Prometheus client instead, and worked with the objects it returns.

}
]
| max_by(.uploaded).tag // empty
')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there an alternative way to find the collector image from the repository directly? Like, do we have some pinned dependency somewhere that we could use to reference to find the image?

chrkl added 14 commits August 14, 2026 10:03
The test script attempts to modify system files and run service
commands without sudo, assuming it runs as root. Use `sudo -E` to
preserve the environment and pass PATH explicitly to maintain access
to the Go/KinD/kubectl toolchain.
Gardener's CI setup requires dnsmasq but ubuntu-latest
runners don't include it. Disable the systemd unit to
prevent it from binding port 53 before Gardener's script
configures it.
This disables some Prow specific features in Gardener like pushing
metrics to Prometheus remote write.
This was added for testing purposes only.
Replace direct script invocation with `make test-e2e` in CI
workflow and add corresponding make target.
Move metric validation from shell script polling into a build-tagged Go
test
suite using Ginkgo/Gomega. This allows the validation to run
independently
against an already-provisioned cluster via `make test-e2e-validate`.

The test establishes a port-forward to Prometheus and asserts on both
the
scraped garden_shoot_info metric and the OTLP-pushed garden.shoot.info
metric.
The e2e suite now deploys the full stack (collectors, Prometheus, Shoot)
in addition to validating metrics. Previously deployment was handled
entirely by the shell script; this migration to Go gives us better
testing semantics and easier debugging.

Add dependencies on the otel-operator and prometheus-operator API
packages to support programmatic resource creation. Refactor the shell
script to focus on KinD/Gardener provisioning while the Go suite handles
component deployment.
Install ginkgo/v2 and its dependencies, then migrate the e2e
test command from `go test` to the ginkgo CLI for better test
output formatting and GitHub Actions integration.
Replace the port-forward mechanism with a LoadBalancer service
that exposes Prometheus directly. This simplifies the test setup
by relying on Gardener's provider-local cloud-controller to assign
an external IP from the configured range.
@chrkl
chrkl force-pushed the gardener-integration branch from 86bdc8a to 63e4ca1 Compare August 14, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/test Test size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants