Add v1alpha2 CLI e2e test suite#1006
Draft
efiacor wants to merge 2 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a parallel CLI end-to-end test suite that exercises the porchctl rpkg v1alpha2 dispatch path against v1alpha2 CRD-backed PackageRevision objects, using golden-file test cases and a dedicated make target.
Changes:
- Introduces a new v1alpha2 CLI e2e test entry point (
TestPorchV1Alpha2) that runs againsttestdata-v1alpha2/. - Adds 8 new golden-file CLI e2e scenarios under
test/e2e/cli/testdata-v1alpha2/. - Adds
make test-e2e-cli-v1alpha2to run only the v1alpha2 CLI e2e suite.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/cli/cli_e2e_v1alpha2_test.go | New v1alpha2 CLI e2e test entry point targeting testdata-v1alpha2/. |
| test/e2e/cli/testdata-v1alpha2/rpkg-clone/config.yaml | v1alpha2 golden test for rpkg clone flows. |
| test/e2e/cli/testdata-v1alpha2/rpkg-copy/config.yaml | v1alpha2 golden test for rpkg copy flow. |
| test/e2e/cli/testdata-v1alpha2/rpkg-get/config.yaml | v1alpha2 golden test for rpkg get and --show-kptfile behaviors. |
| test/e2e/cli/testdata-v1alpha2/rpkg-init/config.yaml | v1alpha2 golden test for rpkg init including duplicate-package error case. |
| test/e2e/cli/testdata-v1alpha2/rpkg-init-deploy/config.yaml | v1alpha2 golden test for deployment repos + rpkg init. |
| test/e2e/cli/testdata-v1alpha2/rpkg-lifecycle/config.yaml | v1alpha2 golden test for propose/approve/reject/delete lifecycle scenarios. |
| test/e2e/cli/testdata-v1alpha2/rpkg-push/config.yaml | v1alpha2 golden test for pull/edit/push workflow. |
| test/e2e/cli/testdata-v1alpha2/rpkg-upgrade/config.yaml | v1alpha2 golden test for upstream upgrade workflow. |
| make/testing.mk | Adds test-e2e-cli-v1alpha2 make target to run only the v1alpha2 suite. |
| func TestPorchV1Alpha2(t *testing.T) { | ||
| if os.Getenv("E2E") == "" { | ||
| t.Skip("set E2E to run this test") | ||
| } |
Comment on lines
+104
to
+105
| stderr: | | ||
| Error: cmdrpkginit.preRunE: package "init-package" already exists in repository "git" |
| - --workspace=clone-2 | ||
| - basens-clone | ||
| stderr: | | ||
| Error: cmdrpkgclone.preRunE: `clone` cannot create a new revision for package "basens-clone" that already exists in repo "git"; make subsequent revisions using `copy` |
| @@ -0,0 +1,30 @@ | |||
| // Copyright 2026 The kpt and Nephio Authors | |||
| .PHONY: test-e2e-cli-v1alpha2 | ||
| test-e2e-cli-v1alpha2: ## Run v1alpha2 CLI end-to-end tests | ||
| test-e2e-cli-v1alpha2: run-in-kind-v1alpha2 | ||
| E2E=1 go test -v -failfast -run TestPorchV1Alpha2 ./test/e2e/cli |
Comment on lines
+264
to
+268
| // Expect "<gen>,True,<observedGen>" where observedGen >= gen | ||
| if err == nil { | ||
| parts := strings.SplitN(output, ",", 3) | ||
| if len(parts) == 3 && parts[1] == "True" && parts[0] != "" && parts[2] != "" && parts[2] >= parts[0] { | ||
| t.Logf("PackageRevision %s/%s is Ready (generation=%s, observedGeneration=%s)", namespace, name, parts[0], parts[2]) |
Comment on lines
+316
to
+321
| // Expect "Published,<N>" where N > 0 | ||
| if err == nil && strings.HasPrefix(output, "Published,") { | ||
| parts := strings.SplitN(output, ",", 2) | ||
| if len(parts) == 2 && parts[1] != "" && parts[1] != "0" { | ||
| t.Logf("PackageRevision %s/%s is Published with revision=%s", namespace, name, parts[1]) | ||
| return |
Comment on lines
+264
to
+268
| // Expect "<gen>,True,<observedGen>" where observedGen >= gen | ||
| if err == nil { | ||
| parts := strings.SplitN(output, ",", 3) | ||
| if len(parts) == 3 && parts[1] == "True" && parts[0] != "" && parts[2] != "" && parts[2] >= parts[0] { | ||
| t.Logf("PackageRevision %s/%s is Ready (generation=%s, observedGeneration=%s)", namespace, name, parts[0], parts[2]) |
| clisuite "github.com/kptdev/porch/test/e2e/cli" | ||
| ) | ||
|
|
||
| func TestPorchCLIV1Alpha2(t *testing.T) { |
Add a standalone CLI e2e test suite for v1alpha2 in test/e2e/cli-v1alpha2/. Runs in complete isolation from the v1alpha1 CLI tests with its own CI job. Reuses the existing CliTestSuite framework from test/e2e/cli/ via import. Test cases exercise all v1alpha2-dispatched CLI commands end-to-end: - rpkg-init, rpkg-lifecycle, rpkg-get, rpkg-clone, rpkg-copy - rpkg-push, rpkg-upgrade, rpkg-init-deploy CI: added matrix entry 'Porch CLI E2E Tests (v1alpha2)' using run-in-kind-v1alpha2 deployment target. Makefile: added test-e2e-cli-v1alpha2 target. Golden file values are initial estimates; run with UPDATE_GOLDEN_FILES=1 against a live v1alpha2 cluster to capture actual output. Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Comment on lines
+3
to
+5
| - args: | ||
| - /home/fiachra/.kiro-work/git/nordix_github/porch/.build/porchctl | ||
| - repo |
Comment on lines
+427
to
+432
| // It looks for lines like "git.basens-clone.clone-1 created" and returns the name part. | ||
| func parsePRNameFromOutput(output string) string { | ||
| for _, line := range strings.Split(strings.TrimSpace(output), "\n") { | ||
| line = strings.TrimSpace(line) | ||
| // Match patterns like "<name> created", "<name> updated", "<name> proposed" | ||
| for _, suffix := range []string{" created", " updated", " proposed", " approved", " rejected"} { |
Comment on lines
+264
to
+268
| // Expect "<gen>,True,<observedGen>" where observedGen >= gen | ||
| if err == nil { | ||
| parts := strings.SplitN(output, ",", 3) | ||
| if len(parts) == 3 && parts[1] == "True" && parts[0] != "" && parts[2] != "" && parts[2] >= parts[0] { | ||
| t.Logf("PackageRevision %s/%s is Ready (generation=%s, observedGeneration=%s)", namespace, name, parts[0], parts[2]) |
- Add waitForReady/waitForPublished config fields for async v1alpha2 ops - Add KubectlWaitForPackageRevisionReady with generation + PRR visibility checks - Add KubectlWaitForPackageRevisionPublished for revision number resolution - Add KubectlDeleteNamespaceV1Alpha2 with v1alpha2 finalizer removal - Add DeleteNamespaceFunc to CliTestSuite for v1alpha2 cleanup override - Strip uid from yaml normalizer (dynamic field like resourceVersion) - Update rpkg-clone, rpkg-copy, rpkg-init, rpkg-init-deploy, rpkg-push, rpkg-upgrade - Add rpkg-nested-package test case - Skip rpkg-get (revision/latest display gaps), rpkg-lifecycle (webhook gap), rpkg-push-on-render-failure, rpkg-unready (server-side render semantics) Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Comment on lines
+151
to
155
| for j, arg := range execArgs { | ||
| for search, replace := range s.SearchAndReplace { | ||
| command.Args[i] = strings.ReplaceAll(arg, search, replace) | ||
| execArgs[j] = strings.ReplaceAll(arg, search, replace) | ||
| } | ||
| } |
Comment on lines
+148
to
+160
| // Build execution args without mutating the original command (preserves golden file content) | ||
| execArgs := make([]string, len(command.Args)) | ||
| copy(execArgs, command.Args) | ||
| for j, arg := range execArgs { | ||
| for search, replace := range s.SearchAndReplace { | ||
| command.Args[i] = strings.ReplaceAll(arg, search, replace) | ||
| execArgs[j] = strings.ReplaceAll(arg, search, replace) | ||
| } | ||
| } | ||
| if command.Args[0] == "porchctl" { | ||
| if execArgs[0] == "porchctl" { | ||
| // make sure that we are testing the porchctl command built from this codebase | ||
| command.Args[0] = s.PorchctlCommand | ||
| execArgs[0] = s.PorchctlCommand | ||
| } | ||
| cmd := exec.Command(command.Args[0], command.Args[1:]...) | ||
| cmd := exec.Command(execArgs[0], execArgs[1:]...) |
Comment on lines
+283
to
+288
| // Expect "<gen>,True,<observedGen>" where observedGen >= gen | ||
| if err == nil { | ||
| parts := strings.SplitN(output, ",", 3) | ||
| if len(parts) == 3 && parts[1] == "True" && parts[0] != "" && parts[2] != "" && parts[2] >= parts[0] { | ||
| t.Logf("PackageRevision %s/%s is Ready (generation=%s, observedGeneration=%s)", namespace, name, parts[0], parts[2]) | ||
| break |
Comment on lines
+245
to
+252
| if strings.Contains(string(out), "Operation cannot be fulfilled") { | ||
| t.Logf("Conflict removing finalizers from %q, retrying...", pr) | ||
| continue | ||
| } | ||
| if strings.Contains(string(out), "NotFound") { | ||
| break | ||
| } | ||
| t.Errorf("Failed to remove Finalizer from %q: %v\n%s", pr, err, string(out)) |
Comment on lines
+25
to
+32
| func TestPorchCLIV1Alpha2(t *testing.T) { | ||
| if os.Getenv("E2E") == "" { | ||
| t.Skip("set E2E to run this test") | ||
| } | ||
|
|
||
| suite := clisuite.NewCliTestSuite(t, filepath.Join(".", "testdata")) | ||
| suite.DeleteNamespaceFunc = clisuite.KubectlDeleteNamespaceV1Alpha2 | ||
| suite.RunTests(t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
Add v1alpha2 CLI e2e test suite
Description
TestPorchV1Alpha2), 8 golden-file test cases undertestdata-v1alpha2/, and amake test-e2e-cli-v1alpha2target.CliTestSuiteframework unchanged. A separatetestdata-v1alpha2/directory holds test cases that pass--api-version=v1alpha2to allrpkgcommands and--v1alpha2torepo register. When v1alpha1 is dropped, deletetestdata/+cli_e2e_test.goand renametestdata-v1alpha2/→testdata/.Related Issue(s)
Type of Change
Checklist
Testing Instructions (Optional)
make run-in-kind-v1alpha2to deploy porch with v1alpha2 CRD supportUPDATE_GOLDEN_FILES=1 E2E=1 go test -v -failfast -run TestPorchV1Alpha2 ./test/e2e/clito capture actual golden outputUPDATE_GOLDEN_FILESto verify tests passAdditional Notes (Optional)
UPDATE_GOLDEN_FILES=1is required to capture actual output (UIDs, timestamps, exact error strings).rpkg-nested-packageandrpkg-unreadytest cases once confirmed applicable to v1alpha2.push/pullcommands pass--api-version=v1alpha2for UX consistency even though it's currently a no-op (PRR stays at v1alpha1).AI Disclosure
If so, please describe how: