runner

package
v0.0.0-...-604da00 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Overview

Package runner provides a wrapper for the OpenShift extended test suite image.

Index

Constants

View Source
const (
	// GitImage is the Docker image used to invoke Git.
	GitImage = "docker.io/alpine/git:v2.26.2"
)

Variables

View Source
var DefaultContainer = kubev1.Container{
	Ports: []kubev1.ContainerPort{
		{
			Name:          resultsPortName,
			ContainerPort: resultsPort,
			Protocol:      kubev1.ProtocolTCP,
		},
	},
	ImagePullPolicy: kubev1.PullAlways,
	ReadinessProbe: &kubev1.Probe{
		ProbeHandler: kubev1.ProbeHandler{
			HTTPGet: &kubev1.HTTPGetAction{
				Path: "/",
				Port: intstr.FromInt(resultsPort),
			},
		},
		PeriodSeconds: 7,
	},
	SecurityContext: &kubev1.SecurityContext{
		RunAsUser: pointer.Int64(0),
	},
}

DefaultContainer is used by the DefaultRunner to run workloads

View Source
var DefaultRunner = &Runner{
	Name:                 defaultName,
	ImageStreamName:      testImageStreamName,
	ImageStreamNamespace: testImageStreamNamespace,
	PodSpec: kubev1.PodSpec{
		Containers: []kubev1.Container{
			DefaultContainer,
		},
		RestartPolicy: kubev1.RestartPolicyNever,
	},
	OutputDir: "/test-run-results",
	Server:    "https://kubernetes.default",
	CA:        serviceAccountDir + "/ca.crt",
	TokenFile: serviceAccountDir + "/token",
	Logger:    ginkgo.GinkgoLogr,
}

DefaultRunner is a runner with the most commonly desired settings.

Functions

This section is empty.

Types

type GitRepo

type GitRepo struct {
	// Name is used to identify the cloned repository.
	Name string

	// URL where the repository to be cloned is located.
	URL string

	// MountPath is the path where the cloned repository should be mounted.
	MountPath string

	// Branch is the branch to mount
	Branch string
}

GitRepo specifies a repository to be cloned and how it should be unpacked.

func (GitRepo) Container

func (r GitRepo) Container() kubev1.Container

Container configured to clone the specified repository. Typically used as an init container.

func (GitRepo) Volume

func (r GitRepo) Volume() kubev1.Volume

Volume configured as empty-dir to hold clone data.

func (GitRepo) VolumeMount

func (r GitRepo) VolumeMount() kubev1.VolumeMount

VolumeMount configured to mount the cloned repository in the primary container.

type Repos

type Repos []GitRepo

Repos can modify a Pod to clone each contained GitRepo.

func (Repos) ConfigurePod

func (repos Repos) ConfigurePod(podSpec *kubev1.PodSpec)

ConfigurePod modifies the given Pod to clone the Repo and make it available to any containers.

type Runner

type Runner struct {
	// Kube client used to run test in-cluster.
	Kube kube.Interface

	// Image client used to gather ImageStream information.
	Image image.Interface

	// Name of the operation being performed.
	Name string

	// Server is the endpoint within the pod the Kubernetes API should be
	Server string

	// CA is the CA bundle used to auth against the Kubernetes API
	CA string

	// TokenFile is the credentials used to auth against the Kubernetes API
	TokenFile string

	// Namespace runner resources should be created in.
	Namespace string

	// ImageStreamName is the name of the ImageStream containing the suite.
	ImageStreamName string

	// ImageStreamNamespace is the namespace of the ImageStream containing the suite.
	ImageStreamNamespace string

	// ImageName is a container image used for the runner.
	ImageName string

	// Cmd is run within the test pod. If PodSpec is also set it overrides the container of the same name.
	Cmd string

	// PodSpec defines the Pod used by the runner.
	PodSpec kubev1.PodSpec

	// OutputDir is the directory that is copied from the Pod to the local host.
	OutputDir string

	// Tarball will create a single .tgz file for the entire OutputDir.
	Tarball bool

	// SkipLogsFromPod should be set to true if logs should not be collected.
	SkipLogsFromPod bool

	// Repos are cloned and mounted into the test Pod.
	Repos

	// Logger receives all messages.
	logr.Logger
	// contains filtered or unexported fields
}

Runner runs the OpenShift extended test suite within a cluster.

func (*Runner) Command

func (r *Runner) Command() ([]byte, error)

Command generates the templated command.

func (*Runner) DeepCopy

func (r *Runner) DeepCopy() *Runner

DeepCopy returns a deep copy of a runner.

func (*Runner) GetLatestImageStreamTag

func (r *Runner) GetLatestImageStreamTag() (string, error)

GetLatestImageStreamTag returns the From name of the latest ImageStream tag.

func (*Runner) RetrieveResults

func (r *Runner) RetrieveResults() (map[string][]byte, error)

RetrieveResults gathers the results from the test Pod. Should only be called after tests are finished.

func (*Runner) RetrieveTestResults

func (r *Runner) RetrieveTestResults() (map[string][]byte, error)

RetrieveTestResults gathers and validates the results from the test Pod. Should only be called after tests are finished. This method both fetches the results and ensures that they contain valid JUnit XML indicating that all tests passed.

func (*Runner) Run

func (r *Runner) Run(timeoutInSeconds int, stopCh <-chan struct{}) (err error)

Run deploys the suite into a cluster, waits for it to finish, and gathers the results.

func (*Runner) Status

func (r *Runner) Status() Status

Status returns the current state of the runner.

type Status

type Status string

Status is the current state of the runner.

var (
	StatusSetup   Status = "setup"
	StatusRunning Status = "running"
	StatusDone    Status = "done"
)

Jump to

Keyboard shortcuts

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