Documentation ¶
Index ¶
- Constants
- func Artifact(opts *Options, relPath string) (*os.File, error)
- func ArtifactDirectoryFor(t *testing.T) string
- func CertKeyRequest(t *testing.T, signer certificates.SignerClass) ([]byte, []byte, []byte, []byte)
- func CleanupSentinel(_ context.Context) error
- func CommonNameFor(signer certificates.SignerClass) string
- func GetFreePort(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T) (string, error)
- func HostedClusterFor(t *testing.T) string
- func InterruptableContext(parent context.Context) context.Context
- func LoadKubeConfig(path string) (*rest.Config, error)
- func RunCommand(logger logr.Logger, opts *Options, logPath string, cmd *exec.Cmd) error
- func RunHostedClusterTest(ctx context.Context, logger logr.Logger, globalOpts *Options, t *testing.T, ...)
- func RunHyperShiftOperatorTest(ctx context.Context, logger logr.Logger, globalOpts *Options, ...)
- func SkippedCleanupSteps() sets.Set[string]
- func StartCommand(logger logr.Logger, opts *Options, logPath string, cmd *exec.Cmd) error
- func WaitForGuestRestConfig(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T, ...) (*rest.Config, error)
- type Builder
- type Cleanup
- func InstallAssets(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
- func InstallHostedCluster(ctx context.Context, logger logr.Logger, opts *Options, ...) (Cleanup, error)
- func InstallHyperShiftCRDs(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
- func InstallHyperShiftOperator(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
- func WaitForHostedClusterAvailable(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T) (Cleanup, error)
- func WaitForHyperShiftCRDs(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
- func WaitForHyperShiftOperator(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
- type Clients
- type HostedClusterOptions
- type InjectKubeconfigMode
- type ManagementTestContext
- type Mode
- type Options
- type TestContext
Constants ¶
const HostedClusterNamespace = "hosted-clusters"
Variables ¶
This section is empty.
Functions ¶
func Artifact ¶
Artifact opens relPath under the artifact dir, ensuring that owning directories exist. Closing the file is the responsibility of the caller.
func ArtifactDirectoryFor ¶
ArtifactDirectoryFor transforms t.Name() into a string that can be used for a directory name. Adapted from the core testutil golden fixture logic.
func CertKeyRequest ¶
func CertKeyRequest(t *testing.T, signer certificates.SignerClass) ([]byte, []byte, []byte, []byte)
func CleanupSentinel ¶
CleanupSentinel is a helper for returning a no-op cleanup function.
func CommonNameFor ¶ added in v0.1.20
func CommonNameFor(signer certificates.SignerClass) string
func GetFreePort ¶
func GetFreePort(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T) (string, error)
GetFreePort asks the kernel for a free open port that is ready to use.
func HostedClusterFor ¶
HostedClusterFor hashes t.Name() to create a name for the HostedCluster. base36(sha224(value)) produces a useful, deterministic value that fits the requirements to be a Kubernetes object name (honoring length requirement, is a valid DNS subdomain, etc)
func LoadKubeConfig ¶
LoadKubeConfig loads a kubeconfig from the file and uses the default context
func RunCommand ¶
func RunHostedClusterTest ¶ added in v0.1.23
func RunHostedClusterTest(ctx context.Context, logger logr.Logger, globalOpts *Options, t *testing.T, test func(t *testing.T, ctx *TestContext))
RunHostedClusterTest takes a test closure and invokes it once the HostedCluster is available. Tests for HostedCluster functionality should use this entrypoint.
func RunHyperShiftOperatorTest ¶ added in v0.1.23
func RunHyperShiftOperatorTest(ctx context.Context, logger logr.Logger, globalOpts *Options, hostedClusterOpts HostedClusterOptions, t *testing.T, test func(t *testing.T, ctx *ManagementTestContext))
RunHyperShiftOperatorTest takes a test closure and invokes it once the HostedCluster resource is created, but without waiting for the guest to be available, nor giving the test access to the guest cluster. Tests for the HyperShift Operator are best suited for this entrypoint.
func SkippedCleanupSteps ¶
SkippedCleanupSteps parses $SKIP_CLEANUP as a comma-delimited list of cleanup steps to skip.
func StartCommand ¶
func WaitForGuestRestConfig ¶
func WaitForGuestRestConfig(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T, hc *hypershiftv1beta1.HostedCluster) (*rest.Config, error)
WaitForGuestRestConfig returns the raw content of a KubeConfig for the guest cluster's API server. In order to get connectivity to the server, we start a process that port-forwards to the Service.
Types ¶
type Cleanup ¶
func InstallAssets ¶
InstallAssets applies static assets to the cluster for setup.
A closure is returned that knows how to clean this emulated process up.
func InstallHostedCluster ¶
func InstallHostedCluster(ctx context.Context, logger logr.Logger, opts *Options, hostedClusterOpts HostedClusterOptions, t *testing.T, args ...string) (Cleanup, error)
InstallHostedCluster generates and applies assets to the cluster for setup of a HostedCluster.
A closure is returned that knows how to clean this emulated process up.
func InstallHyperShiftCRDs ¶ added in v0.1.23
InstallHyperShiftCRDs generates and applies CRDs to the cluster for setup of the HyperShift Operator.
A closure is returned that knows how to clean up the content on the cluster.
func InstallHyperShiftOperator ¶
func InstallHyperShiftOperator(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)
InstallHyperShiftOperator generates and applies assets to the cluster for setup of the HyperShift Operator.
A closure is returned that knows how to clean up the content on the cluster.
func WaitForHostedClusterAvailable ¶ added in v0.1.23
func WaitForHyperShiftCRDs ¶ added in v0.1.23
WaitForHyperShiftCRDs waits for the HyperShift CRDs to be established.
A closure is returned that knows how to clean this emulated process up.
type Clients ¶
type Clients struct { Cfg *rest.Config KubeClient kubernetes.Interface HyperShiftClient hypershiftclient.Interface CRClient controllerruntimeclient.Client }
type HostedClusterOptions ¶ added in v0.1.23
type HostedClusterOptions struct { // Note: this is not well tested. If you ask for a CPO debug deployment, for instance, // we won't be able to give a guest cluster kubeconfig. Use with care. // Options: control-plane-operator,ignition-server,hosted-cluster-config-operator,control-plane-pki-operator DebugDeployments []string }
type InjectKubeconfigMode ¶
type InjectKubeconfigMode string
const ( InjectKubeconfigFlag InjectKubeconfigMode = "flag" InjectKubeconfigEnv InjectKubeconfigMode = "env" )
type ManagementTestContext ¶ added in v0.1.23
type ManagementTestContext struct { Opts *Options HostedCluster *hypershiftv1beta1.HostedCluster MgmtCluster *Clients }
type Mode ¶
type Mode string
Mode describes what the test process should be doing.
const ( // SetupMode sets up the HyperShift Operator, HostedClusters, and other infrastructure // but does not run any test code. Test processes will wait on SIGINT after setup is // complete, and run cleanup when interrupted. SetupMode Mode = "setup" // TestMode runs test code and expects the environment to already be set up. TestMode Mode = "test" // AllInOneMode is the default mode, where the process expects to both set up // the test environment and run the test code. AllInOneMode Mode = "all-in-one" )
type Options ¶
type Options struct { OCPath string HyperShiftCLIPath string HyperShiftOperatorImage string ControlPlaneOperatorImage string ControlPlaneOperatorImageLabels string ReleaseImage string Kubeconfig string ArtifactDir string PullSecret string Mode Mode }
Options are global test options applicable to all scenarios.
func DefaultOptions ¶
func DefaultOptions() *Options
type TestContext ¶
type TestContext struct { *ManagementTestContext GuestCluster *Clients }