Documentation ¶
Index ¶
- Constants
- Variables
- func AddBeforeSuiteCallback(callback func()) bool
- func BuildContainerMetadata(containerName string, attempt uint32) *runtimeapi.ContainerMetadata
- func BuildPodSandboxMetadata(podSandboxName, uid, namespace string, attempt uint32) *runtimeapi.PodSandboxMetadata
- func CreateContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, ...) string
- func CreateContainerWithError(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, ...) (string, error)
- func CreateDefaultContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, ...) string
- func CreatePauseContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, ...) string
- func CreatePodSandboxForContainer(c internalapi.RuntimeService) (string, *runtimeapi.PodSandboxConfig)
- func ExpectNoError(err error, explain ...interface{})
- func Failf(format string, args ...interface{})
- func ImageStatus(c internalapi.ImageManagerService, imageName string) *runtimeapi.Image
- func KubeDescribe(text string, body func()) bool
- func ListImage(c internalapi.ImageManagerService, filter *runtimeapi.ImageFilter) []*runtimeapi.Image
- func Logf(format string, args ...interface{})
- func NewUUID() string
- func PullPublicImage(c internalapi.ImageManagerService, imageName string, ...) string
- func RegisterFlags()
- func RunDefaultPodSandbox(c internalapi.RuntimeService, prefix string) string
- func RunPodSandbox(c internalapi.RuntimeService, config *runtimeapi.PodSandboxConfig) string
- type Framework
- type InternalAPIClient
- type TestContextType
Constants ¶
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 = "busybox:1.28" // DefaultWindowsContainerImage default container image for Windows DefaultWindowsContainerImage string = "mcr.microsoft.com/windows/servercore:ltsc2019" )
const DefaultRegistryPrefix = "docker.io/library"
DefaultRegistryPrefix specifies the default prefix used for images
Variables ¶
var ( // DefaultPodLabels are labels used by default in pods DefaultPodLabels map[string]string // DefaultContainerImage is the default image used for containers DefaultContainerImage 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 ¶
func CreateContainer(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, config *runtimeapi.ContainerConfig, podID string, podConfig *runtimeapi.PodSandboxConfig) string
CreateContainer creates a container with the prefix of containerName.
func CreateContainerWithError ¶
func CreateContainerWithError(rc internalapi.RuntimeService, ic internalapi.ImageManagerService, config *runtimeapi.ContainerConfig, podID string, podConfig *runtimeapi.PodSandboxConfig) (string, error)
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 ImageStatus ¶
func ImageStatus(c internalapi.ImageManagerService, imageName string) *runtimeapi.Image
ImageStatus gets the status of the image named imageName.
func KubeDescribe ¶
KubeDescribe is a wrapper on Describe.
func ListImage ¶
func ListImage(c internalapi.ImageManagerService, filter *runtimeapi.ImageFilter) []*runtimeapi.Image
ListImage list the image filtered by the image filter.
func PullPublicImage ¶
func PullPublicImage(c internalapi.ImageManagerService, imageName string, podConfig *runtimeapi.PodSandboxConfig) string
PullPublicImage pulls the public image named imageName.
func RunDefaultPodSandbox ¶
func RunDefaultPodSandbox(c internalapi.RuntimeService, prefix string) string
RunDefaultPodSandbox runs a PodSandbox with default options.
func RunPodSandbox ¶
func RunPodSandbox(c internalapi.RuntimeService, config *runtimeapi.PodSandboxConfig) string
RunPodSandbox runs a PodSandbox.
Types ¶
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).
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 // Benchmark setting. Number int // Test configuration. IsLcow bool RegistryPrefix string }
TestContextType is the type of test context.
var TestContext TestContextType
TestContext is a test context.