Skip to content

[amazon-cloudwatch-agent-test] Add scraper routing integration tests#724

Open
wenegiemepraise wants to merge 5 commits into
aws:mainfrom
wenegiemepraise:scraper-routing-e2e
Open

[amazon-cloudwatch-agent-test] Add scraper routing integration tests#724
wenegiemepraise wants to merge 5 commits into
aws:mainfrom
wenegiemepraise:scraper-routing-e2e

Conversation

@wenegiemepraise

Copy link
Copy Markdown

Summary

Add annotation-based scraper-routing integration tests to the test/otel/pernode suite (integration build tag).

What

  • TestScraperRoleWiring: the cluster-scraper AmazonCloudWatchAgent CR carries spec.targetAllocator.prometheusCR.scraperRole=cluster-scraper and the per-node agent carries none (default role) — the annotation-routing partition wiring.
  • TestClusterScraperTargetAllocatorHealthy: the operator built the cluster-scraper Target Allocator Deployment and it is Available and not crashlooping.

Testing

go vet -tags integration ./test/otel/pernode/ clean. Run against a cluster with the SR operator + helm PRs deployed:
KUBECONFIG=... CLUSTER_NAME=<c> AWS_REGION=<r> go test -tags integration ./test/otel/pernode/ -run 'TestScraperRoleWiring|TestClusterScraperTargetAllocatorHealthy' -v

Dependencies

Exercises the SR operator (aws/amazon-cloudwatch-agent-operator#399) + helm PRs. Stacks on the E2E suite (#720, pernode-e2e).

Add an integration suite (test/otel/pernode) and Terraform harness
(terraform/eks/daemon/otel-pernode) that validate the Target Allocator
per-node allocation strategy end to end, plus the zero-step
ServiceMonitor/PodMonitor CRD bundling (G1) and TA resilience to missing
CRDs (G2).

Suite:
- per_node_test.go asserts every scraped series is collected by the agent on
  the scraped pod's own node (target_node == @resource.k8s.node.name) and that
  the workload spans >= 2 nodes.
- crd_bundling_test.go asserts the SM/PM CRDs are served via discovery after a
  plain chart install (no prometheus-operator prerequisite).
- ta_resilience_test.go asserts the TA Deployment is Available with zero
  container restarts and that it discovers the monitors once the CRDs exist.
- resources/workload.yaml: sm-app/pm-app behind a ServiceMonitor and PodMonitor
  with a target_node relabel, plus a load generator.

Harness installs a helm-charts checkout that bundles the CRDs (no separate CRD
install step, by design), deploys custom operator and Target Allocator images
carrying the per-node + CRD-watch code, forces the per-node strategy on the CR,
applies the workload, and runs the suite.
Validated the pernode suite against a live per-node cluster:
- Select Target Allocator pods by app.kubernetes.io/name=cloudwatch-agent-
  target-allocator (the operator labels component as
  amazon-cloudwatch-agent-target-allocator, so the previous selector matched
  nothing).
- Assert the TA is currently Ready/Running and not in CrashLoopBackOff instead
  of requiring a lifetime restart count of 0. The readiness/crashloop check
  still catches a TA that died on a missing CRD, but is portable across reruns
  on long-lived clusters; the lifetime restart count is now logged
  informationally (expected 0 only on a freshly provisioned harness cluster).
- Add local_chart_path var to install the chart from a local checkout
  (skipping the git clone) so unpushed working-tree changes can be exercised.
- Raise the helm_release timeout to 900s for the multi-deployment fresh
  install (operator, agent DaemonSet, Target Allocator, webhook).
Add scraper_routing_test.go to the pernode E2E suite (integration build tag):
- TestScraperRoleWiring: the cluster-scraper AmazonCloudWatchAgent CR carries
  spec.targetAllocator.prometheusCR.scraperRole=cluster-scraper and the per-node
  agent carries none (default role) -- the annotation-routing partition wiring.
- TestClusterScraperTargetAllocatorHealthy: the operator built the cluster-scraper
  Target Allocator Deployment and it is Available and not crashlooping.
@wenegiemepraise
wenegiemepraise requested a review from a team as a code owner July 15, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant