framework

package
v0.1.52 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const HostedClusterNamespace = "hosted-clusters"

Variables

This section is empty.

Functions

func Artifact

func Artifact(opts *Options, relPath string) (*os.File, error)

Artifact opens relPath under the artifact dir, ensuring that owning directories exist. Closing the file is the responsibility of the caller.

func ArtifactDirectoryFor

func ArtifactDirectoryFor(t *testing.T) string

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

func CleanupSentinel(_ context.Context) error

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

func HostedClusterFor(t *testing.T) string

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 InterruptableContext

func InterruptableContext(parent context.Context) context.Context

func LoadKubeConfig

func LoadKubeConfig(path string) (*rest.Config, error)

LoadKubeConfig loads a kubeconfig from the file and uses the default context

func RunCommand

func RunCommand(logger logr.Logger, opts *Options, logPath string, cmd *exec.Cmd) error

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

func SkippedCleanupSteps() sets.Set[string]

SkippedCleanupSteps parses $SKIP_CLEANUP as a comma-delimited list of cleanup steps to skip.

func StartCommand

func StartCommand(logger logr.Logger, opts *Options, logPath string, cmd *exec.Cmd) error

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 Builder

type Builder func(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)

type Cleanup

type Cleanup func(ctx context.Context) error

func InstallAssets

func InstallAssets(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)

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

func InstallHyperShiftCRDs(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)

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 WaitForHostedClusterAvailable(ctx context.Context, logger logr.Logger, opts *Options, t *testing.T) (Cleanup, error)

func WaitForHyperShiftCRDs added in v0.1.23

func WaitForHyperShiftCRDs(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)

WaitForHyperShiftCRDs waits for the HyperShift CRDs to be established.

A closure is returned that knows how to clean this emulated process up.

func WaitForHyperShiftOperator

func WaitForHyperShiftOperator(ctx context.Context, logger logr.Logger, opts *Options) (Cleanup, error)

WaitForHyperShiftOperator waits for the HyperShift Operator to be running and ready.

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
}

func NewClients

func NewClients(cfg *rest.Config) (*Clients, error)

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

func (*Options) Bind

func (o *Options) Bind(fs *flag.FlagSet)

func (*Options) Validate

func (o *Options) Validate() error

type TestContext

type TestContext struct {
	*ManagementTestContext
	GuestCluster *Clients
}

Jump to

Keyboard shortcuts

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