Skip to content

Add v1alpha2 CLI e2e test suite#1006

Draft
efiacor wants to merge 2 commits into
kptdev:mainfrom
Nordix:cli_e2e_v1alpha2
Draft

Add v1alpha2 CLI e2e test suite#1006
efiacor wants to merge 2 commits into
kptdev:mainfrom
Nordix:cli_e2e_v1alpha2

Conversation

@efiacor
Copy link
Copy Markdown
Contributor

@efiacor efiacor commented May 26, 2026

Title

Add v1alpha2 CLI e2e test suite


Description

  • What changed: Added a parallel CLI e2e test suite targeting v1alpha2 CRD-based PackageRevisions. New test entry point (TestPorchV1Alpha2), 8 golden-file test cases under testdata-v1alpha2/, and a make test-e2e-cli-v1alpha2 target.
  • Why it's needed: v1alpha2 is the migration target and all CLI commands now have v1alpha2 dispatch. We need e2e coverage for the CLI path exercising v1alpha2 CRDs end-to-end, separate from the existing v1alpha1 suite so v1alpha1 can be cleanly stripped later.
  • How it works: Reuses the existing CliTestSuite framework unchanged. A separate testdata-v1alpha2/ directory holds test cases that pass --api-version=v1alpha2 to all rpkg commands and --v1alpha2 to repo register. When v1alpha1 is dropped, delete testdata/ + cli_e2e_test.go and rename testdata-v1alpha2/testdata/.

Related Issue(s)

  • N/A

Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Tests
  • Other: ________

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

Testing Instructions (Optional)

  1. make run-in-kind-v1alpha2 to deploy porch with v1alpha2 CRD support
  2. UPDATE_GOLDEN_FILES=1 E2E=1 go test -v -failfast -run TestPorchV1Alpha2 ./test/e2e/cli to capture actual golden output
  3. Re-run without UPDATE_GOLDEN_FILES to verify tests pass

Additional Notes (Optional)

  • Known issues: Golden file expected values are initial estimates based on code analysis. First run against a live cluster with UPDATE_GOLDEN_FILES=1 is required to capture actual output (UIDs, timestamps, exact error strings).
  • Further improvements: Add rpkg-nested-package and rpkg-unready test cases once confirmed applicable to v1alpha2.
  • Review notes: push/pull commands pass --api-version=v1alpha2 for UX consistency even though it's currently a no-op (PRR stays at v1alpha1).

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:

  • Kiro to scaffold the test suite structure, generate golden-file test cases, and write the Makefile target.
  • The author has fully verified all code.

@efiacor efiacor self-assigned this May 26, 2026
Copilot AI review requested due to automatic review settings May 26, 2026 07:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 against testdata-v1alpha2/.
  • Adds 8 new golden-file CLI e2e scenarios under test/e2e/cli/testdata-v1alpha2/.
  • Adds make test-e2e-cli-v1alpha2 to 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`
Comment thread test/e2e/cli/cli_e2e_v1alpha2_test.go Outdated
@@ -0,0 +1,30 @@
// Copyright 2026 The kpt and Nephio Authors
Comment thread make/testing.mk Outdated
.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
@efiacor efiacor marked this pull request as draft May 26, 2026 09:53
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 3c9d426 to e81e3e4 Compare May 26, 2026 10:54
Copilot AI review requested due to automatic review settings May 26, 2026 16:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread test/e2e/cli-v1alpha2/testdata/rpkg-clone/config.yaml
Comment thread test/e2e/cli/cluster.go
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 thread test/e2e/cli/cluster.go
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
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from e0cc806 to e3ff325 Compare May 26, 2026 17:10
Copilot AI review requested due to automatic review settings May 26, 2026 21:17
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 406b188 to 3630aad Compare May 26, 2026 21:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comment thread test/e2e/cli/cluster.go
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>
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 3630aad to 256df6d Compare May 27, 2026 08:30
Copilot AI review requested due to automatic review settings May 27, 2026 09:18
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 256df6d to 142121f Compare May 27, 2026 09:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Comment on lines +3 to +5
- args:
- /home/fiachra/.kiro-work/git/nordix_github/porch/.build/porchctl
- repo
Comment thread test/e2e/cli/suite.go
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 thread test/e2e/cli/cluster.go
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])
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 142121f to 69b440d Compare May 27, 2026 09:43
- 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>
Copilot AI review requested due to automatic review settings May 27, 2026 10:49
@efiacor efiacor force-pushed the cli_e2e_v1alpha2 branch from 69b440d to 7a612d0 Compare May 27, 2026 10:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Comment thread test/e2e/cli/suite.go
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 thread test/e2e/cli/suite.go
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 thread test/e2e/cli/cluster.go
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 thread test/e2e/cli/cluster.go
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)
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.

2 participants