Skip to content

Commit d66921a

Browse files
committed
[aiconformance]: dump resources we apply
1 parent fb21b5e commit d66921a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tests/e2e/scenarios/ai-conformance/validators/harness.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ type ValidatorHarness struct {
4242

4343
// testNamespace is a per-test namespace to use for creating resources. It is lazily initialized when TestNamespace() is called.
4444
testNamespace string
45+
46+
// objectIDs tracks the Kubernetes objects that have been created or observed during the test. This can be used for cleanup or reporting.
47+
objectIDs []*KubeObjectID
4548
}
4649

4750
// NewValidatorHarness creates a new ValidatorHarness.

tests/e2e/scenarios/ai-conformance/validators/kube.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ func (h *ValidatorHarness) ApplyManifest(defaultNamespace string, manifestPath s
216216
h.Fatalf("failed to parse manifest %s: %v", manifestPath, err)
217217
}
218218

219+
h.objectIDs = append(h.objectIDs, objects...)
220+
219221
h.ShellExec(fmt.Sprintf("kubectl apply -n %s -f %s", defaultNamespace, manifestPath))
220222

221223
return objects
@@ -235,17 +237,20 @@ func (h *ValidatorHarness) dumpNamespaceResources(ctx context.Context, ns string
235237
return
236238
}
237239

238-
resourceTypes := []string{
239-
"pods",
240-
"jobs",
241-
"deployments",
242-
"statefulsets",
243-
"services",
244-
"events",
240+
resourceTypes := make(map[string]bool)
241+
for _, objectID := range h.objectIDs {
242+
gvk := objectID.GVK()
243+
id := fmt.Sprintf("%s.%s", gvk.Kind, gvk.Group)
244+
resourceTypes[id] = true
245245
}
246246

247-
for _, resourceType := range resourceTypes {
248-
if err := h.dumpResource(ctx, ns, resourceType, filepath.Join(clusterInfoDir, resourceType+".yaml")); err != nil {
247+
// Always include Events, Pods: they are usually not in the manifest, but are often critical for understanding failures.
248+
resourceTypes["Events"] = true
249+
resourceTypes["Pods"] = true
250+
251+
for resourceType := range resourceTypes {
252+
filename := strings.ToLower(resourceType) + ".yaml"
253+
if err := h.dumpResource(ctx, ns, resourceType, filepath.Join(clusterInfoDir, filename)); err != nil {
249254
h.Logf("failed to dump resource %s: %v", resourceType, err)
250255
}
251256
}

0 commit comments

Comments
 (0)