Documentation
¶
Index ¶
- func IsPorchServerRunningInCluster(t *testing.T) bool
- func IsRepoControllerRunningInCluster(t *testing.T) bool
- func KubectlCreateNamespace(t *testing.T, name string)
- func KubectlDeleteNamespace(t *testing.T, name string)
- func KubectlDeleteNamespaceV1Alpha2(t *testing.T, name string)
- func KubectlTriggerRepoSync(t *testing.T, repoName, namespace string)
- func KubectlWaitForLoadBalancerIp(t *testing.T, namespace, name string) string
- func KubectlWaitForPackageRevisionPublished(t *testing.T, name, namespace string)
- func KubectlWaitForPackageRevisionReady(t *testing.T, name, namespace string)
- func KubectlWaitForRepoReady(t *testing.T, repoName, namespace string)
- func RemovePackageRevisionFinalizers(t *testing.T, namespace string)
- func RemovePackagerevFinalizers(t *testing.T, namespace string)
- func WriteTestCaseConfig(t *testing.T, tc *TestCaseConfig)
- type CliTestSuite
- type Command
- type TestCaseConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRepoControllerRunningInCluster ¶ added in v1.6.0
func KubectlCreateNamespace ¶
func KubectlDeleteNamespace ¶
func KubectlDeleteNamespaceV1Alpha2 ¶ added in v1.6.0
KubectlDeleteNamespaceV1Alpha2 removes v1alpha2 PackageRevision finalizers then deletes the namespace.
func KubectlTriggerRepoSync ¶ added in v1.6.0
KubectlTriggerRepoSync annotates a repository to force the controller to reconcile it.
func KubectlWaitForPackageRevisionPublished ¶ added in v1.6.0
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
KubectlWaitForPackageRevisionReady polls a v1alpha2 PackageRevision until its Ready condition is True with observedGeneration matching the current generation, and its PackageRevisionResources are visible.
func KubectlWaitForRepoReady ¶
func RemovePackageRevisionFinalizers ¶ added in v1.6.0
RemovePackageRevisionFinalizers removes finalizers from v1alpha2 PackageRevision CRDs (packagerevisions.porch.kpt.dev) in the given namespace to unblock namespace deletion.
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"`
}
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