Add Gardener Receiver E2E Test - #67
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
SummaryThe 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:
Which issue(s) this PR fixes: Special notes for your reviewer: Release note:
PR Bot InformationVersion:
|
There was a problem hiding this comment.
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
|
/hold |
09c8e23 to
0d4f655
Compare
|
/unhold |
0d4f655 to
2657451
Compare
f5e8420 to
7cb9047
Compare
|
/hold |
f57026a to
a227420
Compare
30fdc33 to
98d4db6
Compare
| return &monitoringv1.ServiceMonitor{ | ||
| TypeMeta: metav1.TypeMeta{APIVersion: monitoringv1.SchemeGroupVersion.String(), Kind: monitoringv1.ServiceMonitorsKind}, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "gardener-prometheus-collector", |
There was a problem hiding this comment.
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"} |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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}, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
| } |
There was a problem hiding this comment.
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 | ||
| ') |
There was a problem hiding this comment.
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?
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.
86bdc8a to
63e4ca1
Compare
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: