e2e

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPorchServerRunningInCluster

func IsPorchServerRunningInCluster(t *testing.T) bool

func IsRepoControllerRunningInCluster added in v1.6.0

func IsRepoControllerRunningInCluster(t *testing.T) bool

func KubectlCreateNamespace

func KubectlCreateNamespace(t *testing.T, name string)

func KubectlDeleteNamespace

func KubectlDeleteNamespace(t *testing.T, name string)

func KubectlDeleteNamespaceV1Alpha2 added in v1.6.0

func KubectlDeleteNamespaceV1Alpha2(t *testing.T, name string)

KubectlDeleteNamespaceV1Alpha2 removes v1alpha2 PackageRevision finalizers then deletes the namespace.

func KubectlTriggerRepoSync added in v1.6.0

func KubectlTriggerRepoSync(t *testing.T, repoName, namespace string)

KubectlTriggerRepoSync annotates a repository to force the controller to reconcile it.

func KubectlWaitForLoadBalancerIp

func KubectlWaitForLoadBalancerIp(t *testing.T, namespace, name string) string

func KubectlWaitForPackageRevisionPublished added in v1.6.0

func KubectlWaitForPackageRevisionPublished(t *testing.T, name, namespace string)

KubectlWaitForPackageRevisionPublished polls a v1alpha2 PackageRevision until it is Published with a non-zero status.revision. This is needed when downstream operations depend on the revision number being set (e.g. upgrade resolution).

func KubectlWaitForPackageRevisionReady added in v1.6.0

func KubectlWaitForPackageRevisionReady(t *testing.T, name, namespace string)

KubectlWaitForPackageRevisionReady polls a v1alpha2 PackageRevision until its Ready condition is True with observedGeneration matching the current generation, and its PackageRevisionResources are visible.

func KubectlWaitForPackageRevisionRendered added in v1.6.3

func KubectlWaitForPackageRevisionRendered(t *testing.T, name, namespace string)

KubectlWaitForPackageRevisionRendered polls a v1alpha2 PackageRevision until its Rendered condition is True. This is needed when pushing content with pipelines to ensure async render completes before propose/approve.

func KubectlWaitForRepoReady

func KubectlWaitForRepoReady(t *testing.T, repoName, namespace string)

func RemovePackageRevisionFinalizers added in v1.6.0

func RemovePackageRevisionFinalizers(t *testing.T, namespace string)

RemovePackageRevisionFinalizers removes finalizers from v1alpha2 PackageRevision CRDs (packagerevisions.porch.kpt.dev) in the given namespace to unblock namespace deletion. First transitions Published packages to DeletionProposed (webhook requirement), then removes finalizers.

func RemovePackagerevFinalizers

func RemovePackagerevFinalizers(t *testing.T, namespace string)

func WriteTestCaseConfig

func WriteTestCaseConfig(t *testing.T, tc *TestCaseConfig)

Types

type CliTestSuite

type CliTestSuite struct {
	// The path of the directory containing the test cases.
	TestDataPath string
	// SearchAndReplace contains (search, replace) pairs that will be applied to the command output before comparison.
	SearchAndReplace map[string]string
	// GitServerURL is the URL of the git server to use for the tests.
	GitServerURL string
	// PorchctlCommand is the full path to the porchctl command to be tested.
	PorchctlCommand string
	// DeleteNamespaceFunc is the function used to clean up test namespaces.
	// Defaults to KubectlDeleteNamespace. Override for v1alpha2 to handle CRD finalizers.
	DeleteNamespaceFunc func(t *testing.T, name string)
}

func NewCliTestSuite

func NewCliTestSuite(t *testing.T, testdataDir string) *CliTestSuite

NewCliTestSuite creates a new CliTestSuite based on the configuration in the testdata directory.

func (*CliTestSuite) RunTestCase

func (s *CliTestSuite) RunTestCase(t *testing.T, tc TestCaseConfig)

RunTestCase runs a single test case.

func (*CliTestSuite) RunTests

func (s *CliTestSuite) RunTests(t *testing.T)

RunTests runs the test cases in the testdata directory.

func (*CliTestSuite) ScanTestCases

func (s *CliTestSuite) ScanTestCases(t *testing.T) []TestCaseConfig

ScanTestCases parses the test case configs from the testdata directory.

type Command

type Command struct {
	// Args is a list of args for the kpt CLI.
	Args []string `yaml:"args,omitempty"`
	// StdIn contents will be passed as the command's standard input, if not empty.
	Stdin string `yaml:"stdin,omitempty"`
	// StdOut is the standard output expected from the command.
	Stdout string `yaml:"stdout,omitempty"`
	// StdErr is the standard error output expected from the command.
	Stderr string `yaml:"stderr,omitempty"`
	// ExitCode is the expected exit code frm the command.
	ExitCode int `yaml:"exitCode,omitempty"`
	// Yaml indicates that stdout is yaml and the test will reformat it for stable ordering
	Yaml bool `yaml:"yaml,omitempty"`
	// IgnoreWhitespace indicates that whitespace differences should be ignored in the output
	IgnoreWhitespace bool `yaml:"ignoreWhitespace,omitempty"`
	// IgnoreColumns lists column names to strip from both expected and actual table output
	// before comparison. Useful for non-deterministic columns like AGE.
	IgnoreColumns []string `yaml:"ignoreColumns,omitempty"`
	// StdErrTabToWhitespace replaces "\t" (tab) character with whitespace "  "
	StdErrTabToWhitespace bool `yaml:"stdErrTabToWhitespace,omitempty"`
	// ContainsErrorString changes Stderr check from exact string match to contains string match
	ContainsErrorString bool `yaml:"containsErrorString,omitempty"`
	// WaitForReady waits for the PackageRevision named in stdout to become Ready.
	// Use for v1alpha2 async operations (clone, init, copy, push, etc.).
	WaitForReady bool `yaml:"waitForReady,omitempty"`
	// WaitForPublished waits for the PackageRevision named in stdout to be Published
	// with a non-zero status.revision. Use after approve commands where downstream
	// consumers need the revision number to be set.
	WaitForPublished bool `yaml:"waitForPublished,omitempty"`
	// WaitForRendered waits for the PackageRevision named in stdout to have Rendered=True.
	// Use after push commands with pipelines to ensure async render completes before propose/approve.
	WaitForRendered bool `yaml:"waitForRendered,omitempty"`
}

type TestCaseConfig

type TestCaseConfig struct {
	// TestCase is the name of the test case.
	TestCase string `yaml:"-"`
	// ConfigFile stores the name of the config file from which the config was loaded.
	// Used when generating or updating golden files.
	ConfigFile string `yaml:"-"`
	// UsesPorchTestRepo indicates if this test modifies the porch-test repo and needs it recreated after
	UsesPorchTestRepo bool `yaml:"usesPorchTestRepo,omitempty"`
	// Commands is a list of porchctl commands to be executed by the test.
	Commands []Command `yaml:"commands,omitempty"`
	// Skip the test? If the value is not empty, it will be used as a message with which to skip the test.
	Skip string `yaml:"skip,omitempty"`
}

func ReadTestCaseConfig

func ReadTestCaseConfig(t *testing.T, name, path string) TestCaseConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL