Skip to content

🧪 Add e2e tests for cluster-level export filtering: mta868,869,870#646

Open
RanWurmbrand wants to merge 5 commits into
migtools:mainfrom
RanWurmbrand:test/ca7-ca8-ca10
Open

🧪 Add e2e tests for cluster-level export filtering: mta868,869,870#646
RanWurmbrand wants to merge 5 commits into
migtools:mainfrom
RanWurmbrand:test/ca7-ca8-ca10

Conversation

@RanWurmbrand

@RanWurmbrand RanWurmbrand commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

closes: #645

Summary

Add e2e tests for cluster-level export filtering (CA-7, CA-8, CA-10) and a reusable resource assertion utility.

Changes

  • CA-7: Verify CRBs referencing ServiceAccounts from other namespaces are excluded from export
  • CA-8: Verify --label-selector scopes export to labeled workloads and their associated RBAC
  • CA-10a/b: Verify --crd-skip-group and --crd-include-group flags control CRD export behavior
  • utils.go: Add ResourceMatch struct with AssertResourcesExist() and AssertResourcesDontExist() for verifying exported resource files by kind, name, and scope
  • resources.go: Add Label field to ServiceAccount struct
  • testdata: Add gadget_crd.yaml and gadget_cr.yaml for CA-10b test

Test plan

  • Run ginkgo run -v -r --focus="CA-7" e2e-tests/tests
  • Run ginkgo run -v -r --focus="CA-8" e2e-tests/tests
  • Run ginkgo run -v -r --focus="CA-10" e2e-tests/tests
  • Run go test ./e2e-tests/utils -v

Summary by CodeRabbit

  • New Features

    • Added support for labeling Kubernetes service accounts during test scenarios.
    • Added test resources for defining and deploying custom resource types.
    • Added controls for including or excluding custom resource definitions by group during exports.
  • Bug Fixes

    • Improved cluster-level export filtering so unrelated roles and bindings are excluded while applicable resources remain available.
  • Tests

    • Expanded validation for resource presence, namespace handling, custom resources, and label-based export behavior.

…s on ressources.go

Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
@RanWurmbrand RanWurmbrand self-assigned this Jul 13, 2026
@RanWurmbrand RanWurmbrand added the test Testing related label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds resource filename assertion utilities, optional ServiceAccount labeling, and end-to-end coverage for label-scoped cluster exports, unrelated ClusterRoleBindings, and CRD include/skip group behavior.

Changes

Export filtering validation

Layer / File(s) Summary
Resource matching utilities
e2e-tests/utils/utils.go, e2e-tests/utils/utils_test.go
Adds resource filename matching and existence/non-existence assertions with table-driven coverage for scopes, groups, versions, namespaces, and missing files.
Cluster resource filtering tests
e2e-tests/framework/resources.go, e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go, e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go
Adds optional ServiceAccount labeling and tests that label selectors and namespace-scoped subjects include or exclude the expected cluster RBAC resources.
CRD group filtering tests
e2e-tests/testdata/gadget_cr.yaml, e2e-tests/testdata/gadget_crd.yaml, e2e-tests/tests/tier0/mta_869_crd_flags_test.go
Adds Gadget CRD fixtures and tests for skipping or including CRD groups, exporting custom resources, applying included resources, and validating the target Gadget instance.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SourceCluster
  participant CranePipeline
  participant ExportDirectory
  participant TargetCluster
  SourceCluster->>CranePipeline: Create Gadget CRD and custom resource
  CranePipeline->>ExportDirectory: Export CRD and custom resource
  CranePipeline->>TargetCluster: Apply exported resources
  TargetCluster-->>CranePipeline: Confirm CRD establishment and Gadget validation
Loading

Possibly related PRs

  • migtools/crane#205: Implements the CRD include/skip group behavior exercised by the new e2e coverage.
  • migtools/crane#576: Adds the ServiceAccount helpers extended here with optional labeling.

Suggested labels: test-automation

Suggested reviewers: nachandr

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: new e2e tests for cluster-level export filtering.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Test Coverage Report

Total: 49.6%

Per-package coverage

  • github.com/konveyor/crane — 0.0%
  • github.com/konveyor/crane/cmd/apply — 52.7%
  • github.com/konveyor/crane/cmd/convert — 0.0%
  • github.com/konveyor/crane/cmd/export — 92.9%
  • github.com/konveyor/crane/cmd/plugin-manager — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/add — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/list — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/remove — 0.0%
  • github.com/konveyor/crane/cmd/skopeo-sync-gen — 0.0%
  • github.com/konveyor/crane/cmd/transfer-pvc — 18.7%
  • github.com/konveyor/crane/cmd/transform — 59.7%
  • github.com/konveyor/crane/cmd/transform/listplugins — 23.0%
  • github.com/konveyor/crane/cmd/transform/optionals — 0.0%
  • github.com/konveyor/crane/cmd/tunnel-api — 0.0%
  • github.com/konveyor/crane/cmd/validate — 69.2%
  • github.com/konveyor/crane/cmd/version — 20.0%
  • github.com/konveyor/crane/internal/apply — 33.8%
  • github.com/konveyor/crane/internal/buildinfo — 100.0%
  • github.com/konveyor/crane/internal/file — 79.0%
  • github.com/konveyor/crane/internal/flags — 0.0%
  • github.com/konveyor/crane/internal/kustomize — 85.7%
  • github.com/konveyor/crane/internal/plugin — 32.9%
  • github.com/konveyor/crane/internal/transform — 80.8%
  • github.com/konveyor/crane/internal/validate — 58.6%
Full function-level details
github.com/konveyor/crane/cmd/apply/apply.go:44:			Complete								100.0%
github.com/konveyor/crane/cmd/apply/apply.go:50:			Validate								87.5%
github.com/konveyor/crane/cmd/apply/apply.go:64:			Run									0.0%
github.com/konveyor/crane/cmd/apply/apply.go:68:			NewApplyCommand								0.0%
github.com/konveyor/crane/cmd/apply/apply.go:110:			getStageNames								100.0%
github.com/konveyor/crane/cmd/apply/apply.go:118:			addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/apply/apply.go:134:			run									81.4%
github.com/konveyor/crane/cmd/convert/convert.go:30:			NewConvertOptions							0.0%
github.com/konveyor/crane/cmd/convert/convert.go:63:			addFlagsForConvertOptions						0.0%
github.com/konveyor/crane/cmd/convert/convert.go:74:			Complete								0.0%
github.com/konveyor/crane/cmd/convert/convert.go:83:			Run									0.0%
github.com/konveyor/crane/cmd/convert/convert.go:87:			run									0.0%
github.com/konveyor/crane/cmd/convert/convert.go:112:			getClientFromContext							0.0%
github.com/konveyor/crane/cmd/convert/convert.go:134:			getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/export/cluster.go:29:			NewClusterScopeHandler							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:35:			isClusterScopedResource							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:44:			filterRbacResources							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:102:			NewClusterScopedRbacHandler						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:113:			exportedSANamespaces							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:126:			groupMatchesExportedSANamespaces					100.0%
github.com/konveyor/crane/cmd/export/cluster.go:143:			parseServiceAccountUserSubject						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:154:			prepareForFiltering							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:187:			filteredResourcesOfKind							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:213:			accept									100.0%
github.com/konveyor/crane/cmd/export/cluster.go:223:			acceptClusterRoleBinding						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:260:			acceptClusterRole							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:284:			acceptSecurityContextConstraints					100.0%
github.com/konveyor/crane/cmd/export/cluster.go:336:			anyServiceAccountInNamespace						100.0%
github.com/konveyor/crane/cmd/export/crd.go:18:				normalizeGroupSet							85.7%
github.com/konveyor/crane/cmd/export/crd.go:30:				shouldSkipCRDGroup							100.0%
github.com/konveyor/crane/cmd/export/crd.go:51:				crdFailureAPIResourceName						100.0%
github.com/konveyor/crane/cmd/export/crd.go:57:				getOperatorManager							92.9%
github.com/konveyor/crane/cmd/export/crd.go:89:				collectRelatedCRDs							94.7%
github.com/konveyor/crane/cmd/export/discover.go:41:			hasClusterScopedManifests						100.0%
github.com/konveyor/crane/cmd/export/discover.go:59:			prepareClusterResourceDir						100.0%
github.com/konveyor/crane/cmd/export/discover.go:75:			prepareFailuresDir							100.0%
github.com/konveyor/crane/cmd/export/discover.go:87:			writeResources								85.7%
github.com/konveyor/crane/cmd/export/discover.go:135:			writeErrors								83.3%
github.com/konveyor/crane/cmd/export/discover.go:177:			getFilePath								95.2%
github.com/konveyor/crane/cmd/export/discover.go:215:			discoverPreferredResources						100.0%
github.com/konveyor/crane/cmd/export/discover.go:244:			resourceToExtract							100.0%
github.com/konveyor/crane/cmd/export/discover.go:318:			isAdmittedResource							100.0%
github.com/konveyor/crane/cmd/export/discover.go:327:			getObjects								96.3%
github.com/konveyor/crane/cmd/export/discover.go:378:			iterateItemsByGet							90.5%
github.com/konveyor/crane/cmd/export/discover.go:413:			iterateItemsInList							92.3%
github.com/konveyor/crane/cmd/export/export.go:54:			Complete								92.0%
github.com/konveyor/crane/cmd/export/export.go:101:			Validate								100.0%
github.com/konveyor/crane/cmd/export/export.go:142:			validateExportNamespace							87.5%
github.com/konveyor/crane/cmd/export/export.go:159:			allResourceListsForbidden						87.5%
github.com/konveyor/crane/cmd/export/export.go:177:			mergeImpersonationExtras						100.0%
github.com/konveyor/crane/cmd/export/export.go:192:			Run									0.0%
github.com/konveyor/crane/cmd/export/export.go:316:			NewExportCommand							48.1%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:43:		Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:48:		Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:91:		Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:95:		NewAddCommand								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:127:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:132:		run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:204:		downloadBinary								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:253:		binaryURIForPlatform							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:46:		Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:51:		Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:56:		Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:60:		NewListCommand								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:90:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:98:		run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:167:		printInstalledInformation						0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:177:		groupInformationForPlugins						0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:196:		printInformation							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:208:		printParamsInformation							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:222:		getOptionalFields							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:247:		printTable								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:47:	NewPluginManagerCommand							0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:78:	addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:86:	run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:47:	NewRemoveCommand							0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:77:	run									0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:61:	Complete								0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:65:	Validate								0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:69:	NewSkopeoSyncGenCommand							0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:103:	shouldAddImageStream							0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:114:	Run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:37:		NewRsyncLogStream							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:50:		Init									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:143:		writeProgressToFile							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:153:		Close									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:159:		Streams									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:195:		addDataSize								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:220:		String									100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:224:		MarshalJSON								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:228:		AsString								97.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:276:		NewProgress								100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:296:		Completed								100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:301:		Status									100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:326:		Merge									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:381:		newDataSize								72.7%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:404:		parseRsyncLogs								76.1%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:484:		waitForPodRunning							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:518:		getFinalPodStatus							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:93:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:121:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:137:		NewTransferPVCCommand							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:173:		addFlagsToTransferPVCCommand						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:193:		Complete								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:224:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:250:		Run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:254:		getClientFromContext							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:275:		getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:282:		run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:500:		getValidatedResourceName						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:510:		getNodeNameForPVC							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:530:		getIDsForNamespace							58.3%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:593:		getSecurityContextFromWorkload						74.5%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:693:		podSpecReferencesPVC							100.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:702:		extractPodSecurityContext						90.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:752:		inspectPVCFileOwnership							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:856:		getRsyncClientPodSecurityContext					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:860:		getRsyncServerPodSecurityContext					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:864:		garbageCollect								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:901:		deleteResourcesIteratively						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:927:		deleteResourcesForGVK							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:948:		followClientLogs							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:977:		waitForEndpoint								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:989:		createEndpoint								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1034:	getRouteHostName							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1051:	buildDestinationPVC							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1072:	ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1092:	ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1104:	ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1120:	String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1124:	Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1134:	Type									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1140:	parseSourceDestinationMapping						100.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1162:	String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1166:	Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1175:	Type									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1179:	String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1183:	Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:1193:	Type									0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:47:	NewListPluginsCommand							0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:80:	GetPluginNames								85.7%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:95:	getFilteredPlugins							75.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:104:	run									0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:31:	Complete								0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:36:	Validate								0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:41:	Run									0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:45:	NewOptionalsCommand							0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:78:	run									0.0%
github.com/konveyor/crane/cmd/transform/transform.go:56:		Complete								0.0%
github.com/konveyor/crane/cmd/transform/transform.go:62:		Validate								83.3%
github.com/konveyor/crane/cmd/transform/transform.go:81:		Run									0.0%
github.com/konveyor/crane/cmd/transform/transform.go:86:		getPluginCompletions							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:111:		NewTransformCommand							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:155:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:177:		run									11.8%
github.com/konveyor/crane/cmd/transform/transform.go:328:		optionalFlagsToLower							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:338:		runStageWithCleanup							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:354:		reconcileInstructionStages						81.0%
github.com/konveyor/crane/cmd/transform/transform.go:397:		ensurePreviousStagesRun							83.3%
github.com/konveyor/crane/cmd/transform/transform.go:414:		ensureStagesHaveOutput							92.9%
github.com/konveyor/crane/cmd/transform/transform.go:452:		createDefaultStagesForAllPlugins					94.7%
github.com/konveyor/crane/cmd/transform/transform.go:504:		validateStageNameToken							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:519:		findStageByDirName							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:531:		findStagesByName							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:543:		createStageDirectory							77.8%
github.com/konveyor/crane/cmd/transform/transform.go:564:		createCustomStageWithExplicitName					100.0%
github.com/konveyor/crane/cmd/transform/transform.go:580:		createCustomStageWithAutoPriority					71.4%
github.com/konveyor/crane/cmd/transform/transform.go:602:		createPluginStage							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:635:		resolveAndValidateStages						58.5%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:35:		NewTunnelAPIOptions							0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:65:		addFlagsForTunnelAPIOptions						0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:77:		Complete								0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:100:		Validate								0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:116:		Run									0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:120:		getClientFromContext							0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:129:		getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:136:		run									0.0%
github.com/konveyor/crane/cmd/validate/validate.go:37:			Complete								90.0%
github.com/konveyor/crane/cmd/validate/validate.go:56:			determineClusterContext							91.7%
github.com/konveyor/crane/cmd/validate/validate.go:84:			Validate								100.0%
github.com/konveyor/crane/cmd/validate/validate.go:129:			Run									16.7%
github.com/konveyor/crane/cmd/validate/validate.go:235:			NewValidateCommand							47.6%
github.com/konveyor/crane/cmd/version/version.go:20:			Complete								0.0%
github.com/konveyor/crane/cmd/version/version.go:25:			Validate								0.0%
github.com/konveyor/crane/cmd/version/version.go:30:			Run									0.0%
github.com/konveyor/crane/cmd/version/version.go:34:			NewVersionCommand							0.0%
github.com/konveyor/crane/cmd/version/version.go:60:			run									100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:21:			CreateTempDir								100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:28:			ListFilesRecursively							91.7%
github.com/konveyor/crane/e2e-tests/utils/utils.go:51:			ListFilesRecursivelyAsList						80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:75:			HasFilesRecursively							80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:86:			ReadTestdataFile							88.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:105:			TestdataFilePath							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:125:			GoldenManifestsDir							90.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:147:			GoldenManifestsDirForPlatform						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:170:			CompareDirectoryFileSets						78.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:205:			CompareDirectoryYAMLSemantics						82.4%
github.com/konveyor/crane/e2e-tests/utils/utils.go:239:			CompareDirectoryYAMLSemanticsExport					100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:247:			CompareDirectoryYAMLSemanticsExportAllowOptionalOCPOutputDefaults	100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:251:			compareDirectoryYAMLSemanticsExport					92.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:330:			isOptionalOCPOutputIdentity						100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:357:			buildNormalizedExportIndex						81.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:397:			canonicalizeDocs							87.5%
github.com/konveyor/crane/e2e-tests/utils/utils.go:411:			extractResourceIdentity							79.5%
github.com/konveyor/crane/e2e-tests/utils/utils.go:482:			parseYAMLDocuments							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:498:			canonicalOpenShiftDockercfgSecretName					80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:514:			compareYAMLFileBytes							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:541:			AssertNoKindsInOutput							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:597:			AssertKindsInOutput							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:649:			LooksLikeYAMLFile							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:663:			normalizeUnstableFields							77.8%
github.com/konveyor/crane/e2e-tests/utils/utils.go:741:			stripPodTemplateHash							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:749:			normalizePodServiceAccountVolumeNames					90.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:806:			normalizeServiceAccountDockercfgReferences				94.1%
github.com/konveyor/crane/e2e-tests/utils/utils.go:840:			normalizeWithPath							83.3%
github.com/konveyor/crane/e2e-tests/utils/utils.go:878:			shouldDropField								100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:934:			AssertWhiteoutResourceFilesExist					0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:974:			AssertWhiteoutResourceFileCount						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1006:		AssertWhiteoutCommentsInKustomization					0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1061:		AssertKindsNotInActiveKustomizeResources				0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1103:		CaptureAPISurfaceScriptPath						75.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1122:		ToInt64									0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1139:		ExtractCPUAverageUtilization						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1172:		AssertFilesExist							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1198:		RemapNamespaceInYAML							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1240:		getPrefixAndSuffix							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1259:		fileHasPrefixAndSuffix							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1267:		AssertResourcesExist							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1289:		AssertResourcesDontExist						90.9%
github.com/konveyor/crane/internal/apply/kustomize.go:31:		ApplySingleStage							0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:80:		ApplyMultiStage								0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:134:		runKustomizeBuild							0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:143:		filterClusterScopedResources						82.4%
github.com/konveyor/crane/internal/apply/kustomize.go:199:		splitMultiDocYAMLToFiles						86.7%
github.com/konveyor/crane/internal/buildinfo/buildinfo.go:25:		readKustomizeVersion							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:22:		ReadFiles								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:32:		readFiles								84.0%
github.com/konveyor/crane/internal/file/file_helper.go:91:		GetWhiteOutFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:95:		GetTransformPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:99:		GetIgnoredPatchesPath							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:103:		updateTransformDirPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:107:		updateIgnoredPatchesDirPath						0.0%
github.com/konveyor/crane/internal/file/file_helper.go:114:		updatePath								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:121:		GetOutputFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:131:		GetStageDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:137:		GetInputDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:143:		GetPatchesDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:149:		GetKustomizationPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:155:		GetMetadataPath								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:161:		GetResourceTypeFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:167:		GetPatchFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:174:		GetStageTransformDir							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:180:		GetStageOutputDir							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:187:		GetResourceFilename							75.0%
github.com/konveyor/crane/internal/file/ordering.go:82:			GetResourceOrder							100.0%
github.com/konveyor/crane/internal/file/ordering.go:92:			GetOrderedResourceFilename						100.0%
github.com/konveyor/crane/internal/flags/global_flags.go:14:		ApplyFlags								0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:21:		GetLogger								0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:29:		initConfig								0.0%
github.com/konveyor/crane/internal/flags/help_groups.go:12:		KubernetesClientInheritedFlagNames					0.0%
github.com/konveyor/crane/internal/flags/help_groups.go:40:		SetGroupedHelp								0.0%
github.com/konveyor/crane/internal/kustomize/args.go:20:		ParseAndValidateArgs							100.0%
github.com/konveyor/crane/internal/kustomize/args.go:92:		splitArgs								100.0%
github.com/konveyor/crane/internal/kustomize/runner.go:21:		Build									82.4%
github.com/konveyor/crane/internal/kustomize/runner.go:55:		buildOptions								100.0%
github.com/konveyor/crane/internal/kustomize/runner.go:105:		setEnvVars								46.2%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:21:		GetPlugins								0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:38:		getBinaryPlugins							0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:63:		IsExecAny								0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:67:		GetFilteredPlugins							0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:109:		isPluginInList								0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:24:	BuildManifestMap							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:68:	GetYamlFromUrl								75.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:82:	YamlToManifest								72.7%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:104:	FilterPluginForOsArch							100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:119:	GetDefaultSource							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:128:	LocateBinaryInPluginDir							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:140:	IsUrl									100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:146:	getData									80.0%
github.com/konveyor/crane/internal/transform/instructions.go:31:	LoadInstructions							61.1%
github.com/konveyor/crane/internal/transform/instructions.go:63:	friendlyInstructionsDecodeError						87.5%
github.com/konveyor/crane/internal/transform/instructions.go:78:	ValidateInstructions							100.0%
github.com/konveyor/crane/internal/transform/instructions.go:112:	GenerateStageDirNames							100.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:41:	RunMultiStage								75.6%
github.com/konveyor/crane/internal/transform/orchestrator.go:142:	executeStage								68.4%
github.com/konveyor/crane/internal/transform/orchestrator.go:189:	transformResources							68.4%
github.com/konveyor/crane/internal/transform/orchestrator.go:240:	formatResourceID							0.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:247:	getPluginForStage							90.9%
github.com/konveyor/crane/internal/transform/orchestrator.go:274:	getAvailablePluginNames							0.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:287:	applyStageTransforms							82.1%
github.com/konveyor/crane/internal/transform/orchestrator.go:354:	loadResourcesFromDirectory						85.7%
github.com/konveyor/crane/internal/transform/orchestrator.go:369:	writeResourcesToDirectory						73.1%
github.com/konveyor/crane/internal/transform/stages.go:22:		DiscoverStages								90.5%
github.com/konveyor/crane/internal/transform/stages.go:83:		FilterStages								100.0%
github.com/konveyor/crane/internal/transform/stages.go:112:		GetFirstStage								100.0%
github.com/konveyor/crane/internal/transform/stages.go:122:		GetLastStage								66.7%
github.com/konveyor/crane/internal/transform/stages.go:132:		GetPreviousStage							100.0%
github.com/konveyor/crane/internal/transform/stages.go:142:		GetNextStage								100.0%
github.com/konveyor/crane/internal/transform/stages.go:152:		ValidateStageName							100.0%
github.com/konveyor/crane/internal/transform/stages.go:161:		GenerateStageName							100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:8:		hasKustomizeCommand							100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:14:	contains								100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:23:	findInString								100.0%
github.com/konveyor/crane/internal/transform/writer.go:28:		NewKustomizeWriter							100.0%
github.com/konveyor/crane/internal/transform/writer.go:37:		WriteStage								68.4%
github.com/konveyor/crane/internal/transform/writer.go:218:		getResourceID								100.0%
github.com/konveyor/crane/internal/transform/writer.go:231:		filterValidRemoveOps							76.2%
github.com/konveyor/crane/internal/transform/writer.go:275:		pathExists								93.5%
github.com/konveyor/crane/internal/transform/writer.go:352:		generateKustomizationWithComments					93.8%
github.com/konveyor/crane/internal/transform/writer.go:383:		checkStageDirectory							23.1%
github.com/konveyor/crane/internal/validate/api_resources.go:24:	ParseAPIResourcesJSON							89.7%
github.com/konveyor/crane/internal/validate/matcher.go:25:		MatchResults								75.0%
github.com/konveyor/crane/internal/validate/matcher.go:36:		MatchResultsFromIndex							100.0%
github.com/konveyor/crane/internal/validate/matcher.go:76:		buildDiscoveryIndex							71.4%
github.com/konveyor/crane/internal/validate/matcher.go:110:		matchEntry								100.0%
github.com/konveyor/crane/internal/validate/matcher.go:139:		buildKindIndex								100.0%
github.com/konveyor/crane/internal/validate/matcher.go:151:		addSuggestion								91.7%
github.com/konveyor/crane/internal/validate/report.go:17:		FormatTable								91.3%
github.com/konveyor/crane/internal/validate/report.go:60:		FormatJSON								100.0%
github.com/konveyor/crane/internal/validate/report.go:67:		FormatYAML								0.0%
github.com/konveyor/crane/internal/validate/report.go:79:		WriteFailures								0.0%
github.com/konveyor/crane/internal/validate/report.go:115:		failureFileName								0.0%
github.com/konveyor/crane/internal/validate/report.go:129:		safeFilePart								0.0%
github.com/konveyor/crane/internal/validate/report.go:145:		parseAPIVersion								0.0%
github.com/konveyor/crane/internal/validate/scanner.go:34:		ScanManifests								76.5%
github.com/konveyor/crane/internal/validate/types.go:46:		HasIncompatible								100.0%
github.com/konveyor/crane/internal/validate/types.go:49:		IncompatibleResults							0.0%
github.com/konveyor/crane/main.go:22:					main									0.0%
total:									(statements)								49.6%

Posted by CI

@coderabbitai coderabbitai 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.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e-tests/framework/resources.go`:
- Around line 136-141: Add tests for the ServiceAccount labeling logic in the
resource creation flow around the sa.Label branch: verify empty labels skip
k.Run, non-empty labels invoke the expected label command successfully, and
label command errors are propagated with the ServiceAccount context. Use the
existing test patterns and helpers in the resources tests.
- Line 139: Update the error returned by the ServiceAccount labeling operation
to include the ServiceAccount namespace and the label being applied, while
preserving the existing resource name and wrapped error. Ensure the message
identifies the full attempted mutation for parallel E2E debugging.

In `@e2e-tests/testdata/gadget_cr.yaml`:
- Around line 1-7: Rename e2e-tests/testdata/gadget_cr.yaml to
Gadget_crane-e2e.openshift.io_v1_simple-nginx-nopv_test-gadget.yaml and
e2e-tests/testdata/gadget_crd.yaml to
CustomResourceDefinition_apiextensions.k8s.io_v1_clusterscoped_gadgets.crane-e2e.openshift.io.yaml;
update both ReadTestdataFile arguments in ca10_crd_flags_test.go to reference
the new filenames.

In `@e2e-tests/tests/tier0/ca8_label_scoped_export_test.go`:
- Around line 99-108: Update the CA-8 test assertions around
AssertResourcesExist so every outOfScopeResources item is checked individually
and each must be absent, rather than relying on the aggregate result. Add
equivalent per-resource assertions for in-scope and out-of-scope ServiceAccounts
in the namespace export directory, while preserving the existing ClusterRole and
ClusterRoleBinding checks.

In `@e2e-tests/utils/utils_test.go`:
- Around line 1484-1513: Extend the resource-matching table around the existing
ClusterRole and ClusterRoleBinding cases with regression tests for filename
component collisions: distinguish ClusterRole from ClusterRoleBinding, reject
partial Group and Version values, and verify Version matching without Group. Use
representative fixture filenames and set wantFound to reflect exact component
matching.

In `@e2e-tests/utils/utils.go`:
- Around line 1250-1268: Update the resource filename matching logic in the
relevant utility function so every specified prefix component, including Kind,
Group, and Version, is terminated with an underscore before matching, and reject
resources that specify Version without Group. In e2e-tests/utils/utils_test.go
lines 1484-1513, add regression cases covering kind, group, and version prefix
collisions plus the invalid version-only resource case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aeb8335e-df0f-408d-a1ec-fe6eca8958e1

📥 Commits

Reviewing files that changed from the base of the PR and between b6e8a70 and 6857756.

📒 Files selected for processing (8)
  • e2e-tests/framework/resources.go
  • e2e-tests/testdata/gadget_cr.yaml
  • e2e-tests/testdata/gadget_crd.yaml
  • e2e-tests/tests/tier0/ca10_crd_flags_test.go
  • e2e-tests/tests/tier0/ca8_label_scoped_export_test.go
  • e2e-tests/tests/tier1/ca7_unrelated_crb_test.go
  • e2e-tests/utils/utils.go
  • e2e-tests/utils/utils_test.go

Comment on lines +136 to +141
if sa.Label != "" {
_, err = k.Run("label", "serviceaccount", sa.Name, "-n", sa.Namespace, sa.Label)
if err != nil {
return fmt.Errorf("failed to label ServiceAccount %s: %w", sa.Name, err)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add tests for optional ServiceAccount labeling.

Cover the empty-label path, successful label invocation, and propagated label failure. As per coding guidelines, all new features require tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/framework/resources.go` around lines 136 - 141, Add tests for the
ServiceAccount labeling logic in the resource creation flow around the sa.Label
branch: verify empty labels skip k.Run, non-empty labels invoke the expected
label command successfully, and label command errors are propagated with the
ServiceAccount context. Use the existing test patterns and helpers in the
resources tests.

Source: Coding guidelines

Comment thread e2e-tests/framework/resources.go Outdated
Comment on lines +1 to +7
apiVersion: crane-e2e.openshift.io/v1
kind: Gadget
metadata:
name: test-gadget
spec:
color: red
size: 3

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Rename the new YAML fixtures consistently with the repository convention.

  • e2e-tests/testdata/gadget_cr.yaml#L1-L7: rename to Gadget_crane-e2e.openshift.io_v1_simple-nginx-nopv_test-gadget.yaml.
  • e2e-tests/testdata/gadget_crd.yaml#L1-L27: rename to CustomResourceDefinition_apiextensions.k8s.io_v1_clusterscoped_gadgets.crane-e2e.openshift.io.yaml.
  • e2e-tests/tests/tier0/ca10_crd_flags_test.go#L120-L123: update both ReadTestdataFile arguments.

As per coding guidelines, YAML resource names should follow Kind_group_version_namespace_name.yaml.

📍 Affects 3 files
  • e2e-tests/testdata/gadget_cr.yaml#L1-L7 (this comment)
  • e2e-tests/testdata/gadget_crd.yaml#L1-L27
  • e2e-tests/tests/tier0/ca10_crd_flags_test.go#L120-L123
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/testdata/gadget_cr.yaml` around lines 1 - 7, Rename
e2e-tests/testdata/gadget_cr.yaml to
Gadget_crane-e2e.openshift.io_v1_simple-nginx-nopv_test-gadget.yaml and
e2e-tests/testdata/gadget_crd.yaml to
CustomResourceDefinition_apiextensions.k8s.io_v1_clusterscoped_gadgets.crane-e2e.openshift.io.yaml;
update both ReadTestdataFile arguments in ca10_crd_flags_test.go to reference
the new filenames.

Source: Coding guidelines

Comment thread e2e-tests/tests/tier0/ca8_label_scoped_export_test.go Outdated
Comment thread e2e-tests/utils/utils_test.go
Comment thread e2e-tests/utils/utils.go Outdated
…no file exist

Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
@RanWurmbrand RanWurmbrand changed the title Test/ca7 ca8 ca10 🧪 Test/ca7 ca8 ca10 Jul 14, 2026
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (6)
e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go (4)

42-61: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

In-scope/out-of-scope ServiceAccounts are created but never asserted on.

inScopeSA and outOfScopeSA are set up specifically to exercise --label-selector on a namespaced workload, but only ClusterRole/ClusterRoleBinding are checked afterward (Lines 99-108). Since the PR objective explicitly calls out validating "labeled workloads" (not just RBAC), add ResourceMatch entries for the SAs and assert their presence/absence in the namespace export directory to actually cover this.

♻️ Suggested addition
 		outOfScopeResources := []utils.ResourceMatch{
 			{Kind: "ClusterRoleBinding", Name: outOfScopeBinding.Name},
 			{Kind: "ClusterRole", Name: outOfScopeCR.Name},
+			{Kind: "ServiceAccount", Name: outOfScopeSA.Name, Scope: namespace},
 		}
 		inScopeResources := []utils.ResourceMatch{
 			{Kind: "ClusterRoleBinding", Name: inScopeBinding.Name},
 			{Kind: "ClusterRole", Name: inScopeCR.Name},
+			{Kind: "ServiceAccount", Name: inScopeSA.Name, Scope: namespace},
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go` around lines 42 -
61, Add ServiceAccount ResourceMatch entries using inScopeSA and outOfScopeSA to
the corresponding inScopeResources and outOfScopeResources collections, then
ensure the export assertions verify the in-scope account is present and the
out-of-scope account is absent in the namespace export directory.

1-1: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Both tests claim to verify export/transform/output stages but only assert against the export directory. The shared root cause: By() messages describe checking all three pipeline stages, while the actual AssertResourcesExist calls only target paths.ExportDir-derived paths, leaving transform/apply-stage regressions uncaught.

  • e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go#L105-108: either narrow the By() text to "export directory" or extend the assertions to also check paths.TransformDir and paths.OutputDir equivalents for the in-scope ClusterRole/ClusterRoleBinding.
  • e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go#L96-96: same fix — narrow the By() text or add corresponding transform/output directory assertions for testCRB/cr.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go` at line 1, The
test step descriptions overstate coverage because both tests only assert
resources under paths.ExportDir. Update the By() messages in the tier0 and tier1
test cases to say “export directory,” or extend their AssertResourcesExist calls
to validate the corresponding paths.TransformDir and paths.OutputDir resources
for the in-scope ClusterRole and ClusterRoleBinding objects.

105-108: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Verification scope narrower than the By() description claims.

The message says resources are checked "in export, transform, and output," but AssertResourcesExist is only called against exportClusterPath (the export stage). Transform/output stage regressions (e.g., a plugin accidentally dropping the CRB during transform) wouldn't be caught here. This same pattern repeats in e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go — see the consolidated comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go` around lines 105 -
108, The verification around AssertResourcesExist must cover export, transform,
and output stages as stated by the By() message. Invoke the appropriate existing
stage paths for inScopeResources and assert each result succeeds, applying the
same update to the corresponding verification in mta_870_unrelated_crb_test.go.

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test titles and temp-dir prefixes still reference the old CA-7/8/10 tags after the MTA rename. The commit renamed the files to mta_868/mta_869/mta_870, but the It() description strings and NewScenarioPaths prefixes were never updated, so Ginkgo reports/CI logs will still show [CA-8], [CA-7], [CA-10a]/[CA-10b] instead of the new MTA identifiers, making it harder to trace failures to the renamed Jira/MTA tickets.

  • e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go#L15-15: update the title to reference MTA-868 (and the "crane-ca8-*" prefix on Line 33 to a matching mta-868 prefix).
  • e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go#L15-15: update the title to reference MTA-870 (and the "crane-ca7-*" prefix on Line 32 to a matching mta-870 prefix).
  • e2e-tests/tests/tier0/mta_869_crd_flags_test.go#L18-18,103-103: update both titles to reference MTA-869 (and the "crane-ca10a-*"/"crane-ca10b-*" prefixes on Lines 33/118 to matching mta-869 prefixes).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go` at line 1, Update
the It() descriptions and NewScenarioPaths prefixes in the MTA-868, MTA-869, and
MTA-870 tests to use the renamed MTA identifiers: MTA-868 with mta-868, MTA-869
for both cases with mta-869 prefixes, and MTA-870 with mta-870. Replace the old
CA references and crane-ca prefixes while preserving the existing test behavior.
e2e-tests/tests/tier0/mta_869_crd_flags_test.go (1)

185-187: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove leftover commented-out verification code.

This dead block (By/path/Expect) should be deleted rather than left commented out.

🧹 Suggested cleanup
-		// By("Verifying CRD exists in output _cluster directory")
-		// outputClusterPath := filepath.Join(paths.OutputDir, "resources", "_cluster")
-		// Expect(ValidateDirResources(outputClusterPath, crdPatterns)).NotTo(HaveOccurred())
-
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier0/mta_869_crd_flags_test.go` around lines 185 - 187,
Remove the leftover commented-out By, outputClusterPath, and Expect verification
block from the test, leaving the surrounding test logic unchanged.
e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go (1)

90-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer AssertResourcesDontExist for exclusion checks, matching the sibling test's idiom.

mta_868_label_scoped_export_test.go (Line 101) uses utils.AssertResourcesDontExist for the same "resource must be absent" assertion. Using AssertResourcesExist(...) + BeFalse() here works but is a less direct, inconsistent idiom for the same helper API.

♻️ Suggested fix
-		found, err := utils.AssertResourcesExist(exportClusterPath, []utils.ResourceMatch{
-			{Kind: "ClusterRoleBinding", Name: unrelatedCRB.Name},
-		})
-		Expect(err).NotTo(HaveOccurred())
-		Expect(found).To(BeFalse())
+		excluded, err := utils.AssertResourcesDontExist(exportClusterPath, []utils.ResourceMatch{
+			{Kind: "ClusterRoleBinding", Name: unrelatedCRB.Name},
+		})
+		Expect(err).NotTo(HaveOccurred())
+		Expect(excluded).To(BeTrue())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go` around lines 90 - 94,
Replace the exclusion assertion in the test with utils.AssertResourcesDontExist,
passing exportClusterPath and the ClusterRoleBinding match for
unrelatedCRB.Name; retain the existing error assertion and remove the
AssertResourcesExist/BeFalse pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go`:
- Around line 42-61: Add ServiceAccount ResourceMatch entries using inScopeSA
and outOfScopeSA to the corresponding inScopeResources and outOfScopeResources
collections, then ensure the export assertions verify the in-scope account is
present and the out-of-scope account is absent in the namespace export
directory.
- Line 1: The test step descriptions overstate coverage because both tests only
assert resources under paths.ExportDir. Update the By() messages in the tier0
and tier1 test cases to say “export directory,” or extend their
AssertResourcesExist calls to validate the corresponding paths.TransformDir and
paths.OutputDir resources for the in-scope ClusterRole and ClusterRoleBinding
objects.
- Around line 105-108: The verification around AssertResourcesExist must cover
export, transform, and output stages as stated by the By() message. Invoke the
appropriate existing stage paths for inScopeResources and assert each result
succeeds, applying the same update to the corresponding verification in
mta_870_unrelated_crb_test.go.
- Line 1: Update the It() descriptions and NewScenarioPaths prefixes in the
MTA-868, MTA-869, and MTA-870 tests to use the renamed MTA identifiers: MTA-868
with mta-868, MTA-869 for both cases with mta-869 prefixes, and MTA-870 with
mta-870. Replace the old CA references and crane-ca prefixes while preserving
the existing test behavior.

In `@e2e-tests/tests/tier0/mta_869_crd_flags_test.go`:
- Around line 185-187: Remove the leftover commented-out By, outputClusterPath,
and Expect verification block from the test, leaving the surrounding test logic
unchanged.

In `@e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go`:
- Around line 90-94: Replace the exclusion assertion in the test with
utils.AssertResourcesDontExist, passing exportClusterPath and the
ClusterRoleBinding match for unrelatedCRB.Name; retain the existing error
assertion and remove the AssertResourcesExist/BeFalse pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73c0f852-e8b1-4425-a5f0-d7d125d17831

📥 Commits

Reviewing files that changed from the base of the PR and between a277b10 and f5b0e48.

📒 Files selected for processing (3)
  • e2e-tests/tests/tier0/mta_868_label_scoped_export_test.go
  • e2e-tests/tests/tier0/mta_869_crd_flags_test.go
  • e2e-tests/tests/tier1/mta_870_unrelated_crb_test.go

@RanWurmbrand

Copy link
Copy Markdown
Contributor Author

these tests passed on ocp

@RanWurmbrand

Copy link
Copy Markdown
Contributor Author

/rfr

@RanWurmbrand RanWurmbrand changed the title 🧪 Test/ca7 ca8 ca10 🧪 Test/mta868,869,870 Jul 14, 2026
@RanWurmbrand RanWurmbrand changed the title 🧪 Test/mta868,869,870 🧪 Add e2e tests for cluster-level export filtering: mta868,869,870 Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test]: add e2e tests for CRD flags, label-scoped export, and foreign-namespace CRB filtering

1 participant