Repository navigation
[amazon-cloudwatch-agent-test] Add scraper routing integration tests - #724
wenegiemepraise wants to merge 1 commit into
Conversation
| // carries no scraperRole (default role: claims only unannotated monitors). The two roles are | ||
| // complementary, giving exactly-one ownership. | ||
| func TestScraperRoleWiring(t *testing.T) { | ||
| assert.Equal(t, clusterScraperRoleValue, scraperRoleOf(t, clusterScraperAgentName), |
There was a problem hiding this comment.
TestScraperRoleWiring only reads the rendered scraperRole and the health test only checks the Target Allocator is up, so neither actually proves routing. Could we annotate one monitor and assert via each /jobs that the annotated job lands only on cluster-scraper and the bare one only on per-node?
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| defer cancel() | ||
| dep, err := clientset.AppsV1().Deployments(agentNamespace).Get(ctx, clusterScraperTADeploymentName, metav1.GetOptions{}) |
There was a problem hiding this comment.
The harness only provisions cloudwatch-agent, so the cluster-scraper CR and its Target Allocator never render and these tests fail NotFound, and patch_cr only patches the custom image onto cloudwatch-agent. Could we render both agents and patch that image onto the cluster-scraper CR too?
| // monitor is owned by exactly one agent (no double-scrape, no gap). | ||
| // | ||
| // These assertions are deterministic and checkable out-of-cluster (CR spec + TA Deployment health); | ||
| // the per-monitor claim is exercised by the operator unit test TestAnnotationRoleMatches. |
There was a problem hiding this comment.
This deferral comment points at TestAnnotationRoleMatches, which is just a predicate unit test, rather than TestLoadConfigScraperRouting where an annotated monitor actually gets filtered into the scrape jobs. Could we repoint it so readers chasing routing land on the real test?
| return role | ||
| } | ||
|
|
||
| func unstructuredNestedString(obj map[string]interface{}, fields ...string) (string, bool, error) { |
There was a problem hiding this comment.
unstructuredNestedString reimplements unstructured.NestedString from a package that's already in the graph and can never actually return an error, so the error it returns and the require.NoError at :64 are both dead. Could we just use unstructured.NestedString?
| // scraperRoleOf reads spec.targetAllocator.prometheusCR.scraperRole from an AmazonCloudWatchAgent CR. | ||
| func scraperRoleOf(t *testing.T, agentName string) string { | ||
| t.Helper() | ||
| restConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath()) |
There was a problem hiding this comment.
scraperRoleOf rebuilds its own restConfig and dynamic client on every call, the health test duplicates deploymentAvailable from ta_resilience_test.go, and one 30s context covers both calls. Could we centralize the client and health helpers in k8s_helpers_test.go and give each call its own context?
|
Checklist posted for the PR author to move into the PR description under a PR Checklist
|
96dc0dd to
46ee70b
Compare
…E suites
Adds the EKS end-to-end coverage for the Target Allocator work: per-node
allocation, zero-step CRD bundling, TA resilience when the
ServiceMonitor/PodMonitor CRDs are absent, and annotation-based routing of
monitors between the per-node and cluster-scraper agents.
test/otel/pernode/ per_node, crd_bundling, ta_resilience,
scraper_routing, metrics + k8s helpers
terraform/eks/daemon/otel-pernode/ EKS harness for the suite
test/otel_collect/{otlp,prometheus,host_metrics} agent configs and OTLP
checks used by the suite
Supersedes the earlier per-node-only suite: this branch contains all of it
plus the routing coverage.
The suites are tagged `integration` and are not yet registered in the
generated test matrix, so they do not run in CI until a matrix entry is
added.
46ee70b to
278afe8
Compare
Summary
Add annotation-based scraper-routing integration tests to the
test/otel/pernodesuite (integrationbuild tag).What
TestScraperRoleWiring: the cluster-scraperAmazonCloudWatchAgentCR carriesspec.targetAllocator.prometheusCR.scraperRole=cluster-scraperand 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' -vDependencies
Exercises the SR operator (aws/amazon-cloudwatch-agent-operator#399) + helm PRs. Stacks on the E2E suite (#720,
pernode-e2e).