framework

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 17 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// DefaultRegistryPrefix specifies the default prefix used for images.
	DefaultRegistryPrefix = "registry.k8s.io"

	// DefaultRegistryE2ETestImagesPrefix is the default prefix for e2e test images.
	DefaultRegistryE2ETestImagesPrefix = DefaultRegistryPrefix + "/e2e-test-images/"

	ContainerdSockPathUnix    = "unix:///run/containerd/containerd.sock"
	ContainerdSockPathWindows = "npipe:////./pipe/containerd-containerd"
)
View Source
const (
	// DefaultUIDPrefix is a default UID prefix of PodSandbox
	DefaultUIDPrefix string = "cri-test-uid"

	// DefaultNamespacePrefix is a default namespace prefix of PodSandbox
	DefaultNamespacePrefix string = "cri-test-namespace"

	// DefaultAttempt is a default attempt prefix of PodSandbox or container
	DefaultAttempt uint32 = 2

	// DefaultStopContainerTimeout is the default timeout for stopping container
	DefaultStopContainerTimeout int64 = 60

	// DefaultLinuxContainerImage default container image for Linux
	DefaultLinuxContainerImage string = DefaultRegistryE2ETestImagesPrefix + "busybox:1.29-2"

	// DefaultWindowsContainerImage default container image for Windows
	DefaultWindowsContainerImage string = DefaultLinuxContainerImage
)

Variables

View Source
var (

	// DefaultPodLabels are labels used by default in pods
	DefaultPodLabels map[string]string

	// DefaultContainerCommand is the default command used for containers
	DefaultContainerCommand []string

	// DefaultPauseCommand is the default command used for containers
	DefaultPauseCommand []string

	// DefaultLinuxPodLabels default pod labels for Linux
	DefaultLinuxPodLabels = map[string]string{}

	// DefaultLinuxContainerCommand default container command for Linux
	DefaultLinuxContainerCommand = []string{"top"}

	// DefaultLinuxPauseCommand default container command for Linux pause
	DefaultLinuxPauseCommand = []string{"sh", "-c", "top"}

	// DefaultLcowPodLabels default pod labels for Linux containers on Windows
	DefaultLcowPodLabels = map[string]string{
		"sandbox-platform": "linux/amd64",
	}

	// DefaultWindowsPodLabels default pod labels for Windows
	DefaultWindowsPodLabels = map[string]string{}

	// DefaultWindowsContainerCommand default container command for Windows
	DefaultWindowsContainerCommand = []string{"cmd", "/c", "ping -t localhost"}

	// DefaultWindowsPauseCommand default container pause command for Windows
	DefaultWindowsPauseCommand = []string{"powershell", "-c", "ping -t localhost"}
)

Functions

func AddBeforeSuiteCallback added in v1.14.0

func AddBeforeSuiteCallback(callback func()) bool

AddBeforeSuiteCallback adds a callback to run during BeforeSuite

func BuildContainerMetadata

func BuildContainerMetadata(containerName string, attempt uint32) *runtimeapi.ContainerMetadata

BuildContainerMetadata builds containerMetadata.

func BuildPodSandboxMetadata

func BuildPodSandboxMetadata(podSandboxName, uid, namespace string, attempt uint32) *runtimeapi.PodSandboxMetadata

BuildPodSandboxMetadata builds PodSandboxMetadata.

func CreateContainer

CreateContainer creates a container with the prefix of containerName.

func CreateContainerWithError

CreateContainerWithError creates a container but leave error check to caller

func CreateDefaultContainer

func CreateDefaultContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, podID string, podConfig *runtimeapi.PodSandboxConfig, prefix string) string

CreateDefaultContainer creates a default container with default options.

func CreatePauseContainer added in v1.19.0

func CreatePauseContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, podID string, podConfig *runtimeapi.PodSandboxConfig, prefix string) string

CreatePauseContainer creates a container with default pause options.

func CreatePodSandboxForContainer

func CreatePodSandboxForContainer(c internalapi.RuntimeService) (string, *runtimeapi.PodSandboxConfig)

CreatePodSandboxForContainer creates a PodSandbox for creating containers.

func ExpectNoError

func ExpectNoError(err error, explain ...interface{})

ExpectNoError reports error if err is not nil.

func Failf

func Failf(format string, args ...interface{})

Failf prints an error message.

func ImageStatus

func ImageStatus(c internalapi.ImageManagerService, imageName string) *runtimeapi.Image

ImageStatus gets the status of the image named imageName.

func KubeDescribe

func KubeDescribe(text string, body func()) bool

KubeDescribe is a wrapper on Describe.

func ListImage

ListImage list the image filtered by the image filter.

func LoadYamlFile added in v1.24.2

func LoadYamlFile(filepath string, obj interface{}) error

LoadYamlFile attempts to load the given YAML file into the given struct.

func Logf

func Logf(format string, args ...interface{})

Logf prints a info message.

func NewUUID

func NewUUID() string

NewUUID creates a new UUID string.

func PullPublicImage

func PullPublicImage(c internalapi.ImageManagerService, imageName string, podConfig *runtimeapi.PodSandboxConfig) string

PullPublicImage pulls the public image named imageName.

func RegisterFlags

func RegisterFlags()

RegisterFlags registers flags to e2e test suites.

func RunDefaultPodSandbox

func RunDefaultPodSandbox(c internalapi.RuntimeService, prefix string) string

RunDefaultPodSandbox runs a PodSandbox with default options.

func RunPodSandbox

RunPodSandbox runs a PodSandbox.

func RunPodSandboxError added in v1.30.0

func RunPodSandboxError(c internalapi.RuntimeService, config *runtimeapi.PodSandboxConfig) string

RunPodSandboxError runs a PodSandbox and expects an error.

Types

type BenchmarkingParamsType added in v1.24.2

type BenchmarkingParamsType struct {
	// ContainersNumber is the number of Containers to run as part of
	// the container-related benchmarks.
	ContainersNumber int `yaml:"containersNumber"`

	// ContainersNumberParallel is the maximum number of container-related benchmarks
	// to run in parallel.
	ContainersNumberParallel int `yaml:"containersNumberParallel"`

	// ContainerBenchmarkTimeoutSeconds is the maximum number of seconds acceptable
	// for a Container lifecycle benchmark to take.
	ContainerBenchmarkTimeoutSeconds int `yaml:"containerBenchmarkTimeoutSeconds"`

	// PodsNumber is the number of Pods to run as part of the pod-related benchmarks.
	PodsNumber int `yaml:"podsNumber"`

	// PodsNumberParallel is the maximum number of pod -related benchmarks
	// to run in parallel.
	PodsNumberParallel int `yaml:"podsNumberParallel"`

	// PodBenchmarkTimeoutSeconds is the maximum number of seconds acceptable
	// for a Pod lifecycle benchmark to take.
	PodBenchmarkTimeoutSeconds int `yaml:"podBenchmarkTimeoutSeconds"`

	// ImagesNumber is the number of Images to run tests on in image-related benchmarks.
	ImagesNumber int `yaml:"imagesNumber"`

	// ImagesNumberParallel is the maximum number of image-related benchmarks
	// to run in parallel.
	ImagesNumberParallel int `yaml:"imagesNumberParallel"`

	// ImageBenchmarkTimeoutSeconds is the maximum of seconds acceptable for
	// image-related benchmarks.
	ImageBenchmarkTimeoutSeconds int `yaml:"imageBenchmarkTimeoutSeconds"`

	// ImagePullingBenchmarkImage is the string ref to the image to be used in
	// image pulling benchmarks. Internally defaults to BusyBox.
	ImagePullingBenchmarkImage string `yaml:"imagePullingBenchmarkImage"`

	// ImageListingBenchmarkImages is a list of string image refs to query
	// during image listing benchmarks.
	ImageListingBenchmarkImages []string `yaml:"imageListingBenchmarkImages"`

	// ImageBenchmarkTimeoutSeconds is the maximum of seconds acceptable for
	// benchmarks focused on Pod+Container start performance.
	PodContainerStartBenchmarkTimeoutSeconds int `yaml:"podContainerStartBenchmarkTimeoutSeconds"`
}

BenchmarkingParamsType is the type of benchmarking-related params.

type Framework

type Framework struct {
	// CRI client
	CRIClient *InternalAPIClient
}

Framework will keep a client for you.

func NewCRIFramework

func NewCRIFramework(client *InternalAPIClient) *Framework

NewCRIFramework creates a new Framework.

func NewDefaultCRIFramework

func NewDefaultCRIFramework() *Framework

NewDefaultCRIFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach clean resources

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach gets a client

type InternalAPIClient

type InternalAPIClient struct {
	CRIRuntimeClient internalapi.RuntimeService
	CRIImageClient   internalapi.ImageManagerService
}

InternalAPIClient is the CRI client.

func LoadCRIClient

func LoadCRIClient() (*InternalAPIClient, error)

LoadCRIClient creates a InternalAPIClient.

type TestContextType

type TestContextType struct {
	// Report related settings.
	ReportDir    string
	ReportPrefix string

	// CRI client configurations.
	ConfigPath            string
	ImageServiceAddr      string
	ImageServiceTimeout   time.Duration
	RuntimeServiceAddr    string
	RuntimeServiceTimeout time.Duration
	RuntimeHandler        string

	// Test images-related settings.
	TestImageList TestImageList

	// Benchmarking settings.
	BenchmarkingOutputDir string
	BenchmarkingParams    BenchmarkingParamsType

	// Test configuration.
	IsLcow bool

	RegistryPrefix string
}

TestContextType is the type of test context.

var TestContext TestContextType

TestContext is a test context.

func (TestContextType) LoadYamlConfigFiles added in v1.24.2

func (tc TestContextType) LoadYamlConfigFiles() error

Loads any external file-based parameters into the TestContextType.

type TestImageList added in v1.23.0

type TestImageList struct {
	DefaultTestContainerImage string `yaml:"defaultTestContainerImage"`
	WebServerTestImage        string `yaml:"webServerTestImage"`
}

TestImageList aggregates references to the images used in tests.

Jump to

Keyboard shortcuts

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