types

package
v0.0.0-...-4294dbe Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 1 Imported by: 18

Documentation

Overview

Package types defines the common types / interfaces for kubetest2 deployer and tester implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIncorrectUsage

func NewIncorrectUsage(helpText string) error

NewIncorrectUsage returns a simple IncorrectUsage implementation wrapping helpText

Types

type Deployer

type Deployer interface {
	// Up should provision a new cluster for testing
	Up() error
	// Down should tear down the test cluster if any
	Down() error
	// IsUp should return true if a test cluster is successfully provisioned
	IsUp() (up bool, err error)
	// DumpClusterLogs should export logs from the cluster. It may be called
	// multiple times. Options for this should come from New(...)
	DumpClusterLogs() error
	// Build should build kubernetes and package it in whatever format
	// the deployer consumes
	Build() error
}

Deployer defines the interface between kubetest and a deployer

If any returned error meets the: sigs.k8s.io/kubetest2/pkg/metadata.JUnitError interface, then this metadata will be pulled out when writing out the results

type DeployerWithFinish

type DeployerWithFinish interface {
	Deployer

	// Finish finalizes the deployer. This will be called after any other deployer action and immediately before exit.
	Finish() error
}

DeployerWithFinish adds the ability to define finalizer behavior

type DeployerWithInit

type DeployerWithInit interface {
	Deployer

	// Init initializes the deployer. This will be called prior to any other lifecycle action.
	Init() error
}

DeployerWithInit adds the ability to define initialization behavior

type DeployerWithKubeconfig

type DeployerWithKubeconfig interface {
	Deployer

	// Kubeconfig returns a path to a kubeconfig file for the cluster.
	Kubeconfig() (string, error)
}

DeployerWithKubeconfig adds the ability to return a path to kubeconfig file.

type DeployerWithPostTester

type DeployerWithPostTester interface {
	Deployer

	// PostTest runs after the tester completes.
	// testErr is the error returned from the tester's Run()
	PostTest(testErr error) error
}

DeployerWithPostTester adds the ability to define after-test behavior based on the results of the test.

type DeployerWithProvider

type DeployerWithProvider interface {
	Deployer

	// Provider returns the kubernetes provider for legacy deployers.
	Provider() string
}

DeployerWithProvider adds the ability to return a specific provider string. This is reuired for some legacy deployers, which need a specific string to be passed through to e2e.test.

type DeployerWithVersion

type DeployerWithVersion interface {
	Deployer

	// Version determines the version of the deployer binary
	Version() string
}

DeployerWithVersion allows the deployer to specify it's version

type IncorrectUsage

type IncorrectUsage interface {
	error
	HelpText() string
}

IncorrectUsage is an error with an addition HelpText() method NewDeployer and NewTester implementations should return a type meeting this interface if they want to display usage to the user when incorrect arguments or flags are supplied

type NewDeployer

type NewDeployer func(opts Options) (deployer Deployer, flags *pflag.FlagSet)

NewDeployer should return a new instance of a Deployer along with a flagset bound to the deployer with any additional Deployer specific CLI flags

kubetest2 will call this once at startup for the injected deployer

opts will provide access to options defined by common flags and kubetest2 logic

type Options

type Options interface {
	// TODO(BenTheElder): provide getters to more common options
	// if this returns true, help text will be shown to the user after instancing
	// the deployer and tester
	HelpRequested() bool
	// if this is true, kubetest2 will be calling deployer.Build
	ShouldBuild() bool
	// if this is true, kubetest2 will be calling deployer.Up
	ShouldUp() bool
	// if this is true, kubetest2 will be calling deployer.Down
	ShouldDown() bool
	// if this is true, kubetest2 will be calling tester.Test
	ShouldTest() bool
	// if this is true, kubetest2 will be skipping reporting the test result as a JUnit test case.
	SkipTestJUnitReport() bool
	// RunID returns a unique identifier for a kubetest2 run.
	RunID() string
	// RunDir returns the directory to put run-specific output files.
	RunDir() string
	// if this is true, kubetest2 will copy the RunDIR to ARTIFACTS
	RundirInArtifacts() bool
}

Options is an interface to get common options supplied by kubetest2 to all implementations

type Tester

type Tester struct {
	TesterPath string
	TesterArgs []string
}

Tester defines the "interface" between kubetest2 and a tester The tester is executed as a separate binary during the Test() phase

Jump to

Keyboard shortcuts

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