framework

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 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) ([]byte, []byte, []byte)

func CleanupSentinel

func CleanupSentinel(_ context.Context) error

CleanupSentinel is a helper for returning a no-op cleanup function.

func CommonName

func CommonName() 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 Run

func Run(ctx context.Context, logger logr.Logger, globalOpts *Options, t *testing.T, test func(t *testing.T, ctx *TestContext))

func RunCommand

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

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, 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 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 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 InjectKubeconfigMode

type InjectKubeconfigMode string
const (
	InjectKubeconfigFlag InjectKubeconfigMode = "flag"
	InjectKubeconfigEnv  InjectKubeconfigMode = "env"
)

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 {
	Opts          *Options
	HostedCluster *hypershiftv1beta1.HostedCluster
	MgmtCluster   *Clients
	GuestCluster  *Clients
}

Jump to

Keyboard shortcuts

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