tests

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 39 Imported by: 0

README

Integration tests

Integration tests require a running Kubevirt cluster. Once you have a running Kubevirt cluster, you can use the -master and the -kubeconfig flags to point the tests to the cluster.

Run them on an arbitrary KubeVirt installation

cd tests # from the git repo root folder
go test -kubeconfig=path/to/my/config

Run them on one of the core KubeVirt providers

There is a make target to run this with the config taken from hack/config.sh:

# from the git repo root folder
make functest

Documentation

Index

Constants

View Source
const (
	SubresourceServiceAccountName = "kubevirt-subresource-test-sa"
	AdminServiceAccountName       = "kubevirt-admin-test-sa"
	EditServiceAccountName        = "kubevirt-edit-test-sa"
	ViewServiceAccountName        = "kubevirt-view-test-sa"
)
View Source
const (
	// tests.NamespaceTestDefault is the default namespace, to test non-infrastructure related KubeVirt objects.
	NamespaceTestDefault = "kubevirt-test-default"
	// NamespaceTestAlternative is used to test controller-namespace independency.
	NamespaceTestAlternative = "kubevirt-test-alternative"
)
View Source
const (
	HostPathAlpine = "/tmp/hostImages/alpine"
	HostPathCustom = "/tmp/hostImages/custom"
)
View Source
const (
	DiskAlpineHostPath = "disk-alpine-host-path"
	DiskWindows        = "disk-windows"
	DiskCustomHostPath = "disk-custom-host-path"
)
View Source
const (
	CustomHostPath = "custom-host-path"
)
View Source
const (
	SecretLabel = "kubevirt.io/secret"
)
View Source
const SubresourceTestLabel = "subresource-access-test-pod"
View Source
const VMIResource = "virtualmachineinstances"

Variables

View Source
var KubeVirtInstallNamespace = "kube-system"
View Source
var KubeVirtKubectlPath = ""
View Source
var KubeVirtOcPath = ""
View Source
var KubeVirtRepoPrefix = "kubevirt"
View Source
var KubeVirtVersionTag = "latest"

Functions

func AddBootOrderToDisk added in v0.6.0

func AddBootOrderToDisk(vmi *v1.VirtualMachineInstance, diskName string, bootorder *uint) *v1.VirtualMachineInstance

func AddEphemeralDisk

func AddEphemeralDisk(vmi *v1.VirtualMachineInstance, name string, bus string, image string) *v1.VirtualMachineInstance

func AddEphemeralFloppy

func AddEphemeralFloppy(vmi *v1.VirtualMachineInstance, name string, image string) *v1.VirtualMachineInstance

func AddExplicitPodNetworkInterface added in v0.7.0

func AddExplicitPodNetworkInterface(vmi *v1.VirtualMachineInstance)

func AddPVCDisk added in v0.5.0

func AddPVCDisk(vmi *v1.VirtualMachineInstance, name string, bus string, claimName string) *v1.VirtualMachineInstance

func AfterTestSuitCleanup

func AfterTestSuitCleanup()

func BeforeAll added in v0.4.1

func BeforeAll(fn func())

func BeforeTestCleanup

func BeforeTestCleanup()

func BeforeTestSuitSetup

func BeforeTestSuitSetup()

func CheckForTextExpecter added in v0.6.0

func CheckForTextExpecter(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, wait int) error

func CreateHostPathPv added in v0.6.1

func CreateHostPathPv(os string, hostPath string)

func CreatePVC added in v0.5.0

func CreatePVC(os string, size string)

func DeletePV added in v0.5.0

func DeletePV(os string)

func DeletePVC added in v0.5.0

func DeletePVC(os string)

func EnsureKVMPresent added in v0.7.0

func EnsureKVMPresent()

func ExecuteCommandOnPod added in v0.4.1

func ExecuteCommandOnPod(virtCli kubecli.KubevirtClient, pod *k8sv1.Pod, containerName string, command []string) (string, error)

func GenerateTemplateJson added in v0.7.0

func GenerateTemplateJson(template *Template) (string, error)

func GenerateVMIJson added in v0.6.1

func GenerateVMIJson(vmi *v1.VirtualMachineInstance) (string, error)

func GetNodeLibvirtCapabilities added in v0.6.2

func GetNodeLibvirtCapabilities(nodeName string) string

GetNodeLibvirtCapabilities returns node libvirt capabilities

func GetNodeWithHugepages added in v0.6.1

func GetNodeWithHugepages(virtClient kubecli.KubevirtClient, hugepages k8sv1.ResourceName) *k8sv1.Node

func GetRunningPodByLabel

func GetRunningPodByLabel(label string, labelType string, namespace string) *k8sv1.Pod

func LoggedInAlpineExpecter added in v0.6.0

func LoggedInAlpineExpecter(vmi *v1.VirtualMachineInstance) (expect.Expecter, error)

func LoggedInCirrosExpecter

func LoggedInCirrosExpecter(vmi *v1.VirtualMachineInstance) (expect.Expecter, error)

func NewBool

func NewBool(x bool) *bool

func NewConsoleExpecter

func NewConsoleExpecter(virtCli kubecli.KubevirtClient, vmi *v1.VirtualMachineInstance, timeout time.Duration, opts ...expect.Option) (expect.Expecter, <-chan error, error)

func NewHelloWorldJob added in v0.6.0

func NewHelloWorldJob(host string, port string) *k8sv1.Pod

NewHelloWorldJob takes a DNS entry or an IP and a port which it will use create a pod which tries to contact the host on the provided port. It expects to receive "Hello World!" to succeed.

func NewHelloWorldJobUDP added in v0.6.0

func NewHelloWorldJobUDP(host string, port string) *k8sv1.Pod

NewHelloWorldJobUDP takes a DNS entry or an IP and a port which it will use create a pod which tries to contact the host on the provided port. It expects to receive "Hello World!" to succeed. Note that in case of UDP, the server will not see the connection unless something is sent over it However, netcat does not work well with UDP and closes before the answer arrives, for that another netcat call is needed, this time as a UDP listener

func NewInt32

func NewInt32(x int32) *int32

func NewRandomReplicaSetFromVMI added in v0.6.1

func NewRandomReplicaSetFromVMI(vmi *v1.VirtualMachineInstance, replicas int32) *v1.VirtualMachineInstanceReplicaSet

func NewRandomVMI added in v0.6.1

func NewRandomVMI() *v1.VirtualMachineInstance

func NewRandomVMIWithCDRom added in v0.6.1

func NewRandomVMIWithCDRom(claimName string) *v1.VirtualMachineInstance

func NewRandomVMIWithCustomMacAddress added in v0.7.0

func NewRandomVMIWithCustomMacAddress() *v1.VirtualMachineInstance

func NewRandomVMIWithEphemeralDisk added in v0.6.1

func NewRandomVMIWithEphemeralDisk(containerImage string) *v1.VirtualMachineInstance

func NewRandomVMIWithEphemeralDiskAndUserdata added in v0.6.1

func NewRandomVMIWithEphemeralDiskAndUserdata(containerImage string, userData string) *v1.VirtualMachineInstance

func NewRandomVMIWithEphemeralDiskAndUserdataHighMemory added in v0.6.1

func NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(containerImage string, userData string) *v1.VirtualMachineInstance

func NewRandomVMIWithEphemeralDiskHighMemory added in v0.6.1

func NewRandomVMIWithEphemeralDiskHighMemory(containerImage string) *v1.VirtualMachineInstance

func NewRandomVMIWithEphemeralPVC added in v0.6.1

func NewRandomVMIWithEphemeralPVC(claimName string) *v1.VirtualMachineInstance

func NewRandomVMIWithNS added in v0.6.1

func NewRandomVMIWithNS(namespace string) *v1.VirtualMachineInstance

func NewRandomVMIWithPVC added in v0.6.1

func NewRandomVMIWithPVC(claimName string) *v1.VirtualMachineInstance

func NewRandomVMIWithSlirpInterfaceEphemeralDiskAndUserdata added in v0.7.0

func NewRandomVMIWithSlirpInterfaceEphemeralDiskAndUserdata(containerImage string, userData string, Ports []v1.Port) *v1.VirtualMachineInstance

func NewRandomVMIWithWatchdog added in v0.6.1

func NewRandomVMIWithWatchdog() *v1.VirtualMachineInstance

func NewRandomVMIWithe1000NetworkInterface added in v0.6.1

func NewRandomVMIWithe1000NetworkInterface() *v1.VirtualMachineInstance

func NewRepeatableVirtctlCommand added in v0.4.0

func NewRepeatableVirtctlCommand(args ...string) func() error

func NewVirtctlCommand added in v0.4.0

func NewVirtctlCommand(args ...string) *cobra.Command

func NotDeleted added in v0.5.0

func NotDeleted(vmis *v1.VirtualMachineInstanceList) (notDeleted []v1.VirtualMachineInstance)

func PanicOnError

func PanicOnError(err error)

func RegistryDiskFor

func RegistryDiskFor(name RegistryDisk) string

RegistryDiskFor takes the name of an image and returns the full registry diks image path. Supported values are: cirros, fedora, alpine

func RenderJob

func RenderJob(name string, cmd []string, args []string) *k8sv1.Pod

func RunKubectlCommand added in v0.4.1

func RunKubectlCommand(args ...string) (string, error)

func RunOcCommand added in v0.7.0

func RunOcCommand(args ...string) (string, error)

func SkipIfNoKubectl added in v0.4.1

func SkipIfNoKubectl()

func SkipIfNoOc added in v0.7.0

func SkipIfNoOc()

func SkipIfNoWindowsImage added in v0.4.1

func SkipIfNoWindowsImage(virtClient kubecli.KubevirtClient)

func SkipIfVersionBelow added in v0.7.0

func SkipIfVersionBelow(message string, expectedVersion string)

SkipIfVersionBelow will skip tests if it runs on an environment with k8s version below specified

func UnfinishedVMIPodSelector added in v0.6.1

func UnfinishedVMIPodSelector(vmi *v1.VirtualMachineInstance) metav1.ListOptions

func WaitForSuccessfulVMIStart added in v0.6.1

func WaitForSuccessfulVMIStart(vmi runtime.Object) string

func WaitForSuccessfulVMIStartIgnoreWarnings added in v0.6.1

func WaitForSuccessfulVMIStartIgnoreWarnings(vmi runtime.Object) string

func WaitForSuccessfulVMIStartWithTimeout added in v0.6.1

func WaitForSuccessfulVMIStartWithTimeout(vmi runtime.Object, seconds int) (nodeName string)

func WaitForVirtualMachineToDisappearWithTimeout added in v0.5.0

func WaitForVirtualMachineToDisappearWithTimeout(vmi *v1.VirtualMachineInstance, seconds int)

Types

type BrokerTemplateInstance added in v0.7.0

type BrokerTemplateInstance struct {
	metav1.TypeMeta
	metav1.ObjectMeta

	// Spec describes the state of this BrokerTemplateInstance.
	Spec BrokerTemplateInstanceSpec
}

BrokerTemplateInstance holds the service broker-related state associated with a TemplateInstance. BrokerTemplateInstance is part of an experimental API.

type BrokerTemplateInstanceList added in v0.7.0

type BrokerTemplateInstanceList struct {
	metav1.TypeMeta
	metav1.ListMeta

	// Items is a list of BrokerTemplateInstances
	Items []BrokerTemplateInstance
}

BrokerTemplateInstanceList is a list of BrokerTemplateInstance objects.

type BrokerTemplateInstanceSpec added in v0.7.0

type BrokerTemplateInstanceSpec struct {
	// TemplateInstance is a reference to a TemplateInstance object residing
	// in a namespace.
	TemplateInstance k8sv1.ObjectReference

	// Secret is a reference to a Secret object residing in a namespace,
	// containing the necessary template parameters.
	Secret k8sv1.ObjectReference

	// BindingIDs is a list of 'binding_id's provided during successive bind
	// calls to the template service broker.
	BindingIDs []string
}

BrokerTemplateInstanceSpec describes the state of a BrokerTemplateInstance.

type EventType

type EventType string
const (
	NormalEvent  EventType = "Normal"
	WarningEvent EventType = "Warning"
)

type ExtraValue added in v0.7.0

type ExtraValue []string

ExtraValue masks the value so protobuf can generate

type ObjectEventWatcher

type ObjectEventWatcher struct {
	// contains filtered or unexported fields
}

func NewObjectEventWatcher

func NewObjectEventWatcher(object runtime.Object) *ObjectEventWatcher

func (*ObjectEventWatcher) FailOnWarnings

func (w *ObjectEventWatcher) FailOnWarnings() *ObjectEventWatcher

func (*ObjectEventWatcher) SinceNow

func (w *ObjectEventWatcher) SinceNow() *ObjectEventWatcher

SinceNow sets a watch starting point for events, from the moment on the connection to the apiserver was established.

func (*ObjectEventWatcher) SinceObjectResourceVersion

func (w *ObjectEventWatcher) SinceObjectResourceVersion(object runtime.Object) *ObjectEventWatcher

SinceObjectResourceVersion takes the resource version of the passed in runtime object and takes it as the starting point for all events to watch for.

func (*ObjectEventWatcher) SinceResourceVersion

func (w *ObjectEventWatcher) SinceResourceVersion(rv string) *ObjectEventWatcher

SinceResourceVersion sets the passed in resourceVersion as the starting point for all events to watch for.

func (*ObjectEventWatcher) SinceWatchedObjectResourceVersion

func (w *ObjectEventWatcher) SinceWatchedObjectResourceVersion() *ObjectEventWatcher

SinceWatchedObjectResourceVersion takes the resource version of the runtime object which is watched, and takes it as the starting point for all events to watch for.

func (*ObjectEventWatcher) Timeout

func (w *ObjectEventWatcher) Timeout(duration time.Duration) *ObjectEventWatcher

func (*ObjectEventWatcher) WaitFor

func (w *ObjectEventWatcher) WaitFor(eventType EventType, reason interface{}) (e *k8sv1.Event)

func (*ObjectEventWatcher) Watch

func (w *ObjectEventWatcher) Watch(processFunc ProcessFunc)

type Parameter added in v0.7.0

type Parameter struct {
	// Required: Parameter name must be set and it can be referenced in Template
	// Items using ${PARAMETER_NAME}
	Name string `json:"name"`

	// Optional: The name that will show in UI instead of parameter 'Name'
	DisplayName string `json:"displayName,omitempty"`

	// Optional: Parameter can have description
	Description string `json:"description,omitempty"`

	// Optional: Value holds the Parameter data. If specified, the generator
	// will be ignored. The value replaces all occurrences of the Parameter
	// ${Name} expression during the Template to Config transformation.
	Value string `json:"value,omitempty"`

	// Optional: Generate specifies the generator to be used to generate
	// random string from an input value specified by From field. The result
	// string is stored into Value field. If empty, no generator is being
	// used, leaving the result Value untouched.
	Generate string `json:"generate,omitempty"`

	// Optional: From is an input value for the generator.
	From string `json:"from,omitempty"`

	// Optional: Indicates the parameter must have a value.  Defaults to false.
	Required bool `json:"required,omitempty"`
}

Parameter defines a name/value variable that is to be processed during the Template to Config transformation.

type ProcessFunc

type ProcessFunc func(event *k8sv1.Event) (done bool)

type RegistryDisk

type RegistryDisk string
const (
	RegistryDiskCirros RegistryDisk = "cirros"
	RegistryDiskAlpine RegistryDisk = "alpine"
	RegistryDiskFedora RegistryDisk = "fedora-cloud"
)

type Template added in v0.7.0

type Template struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// message is an optional instructional message that will
	// be displayed when this template is instantiated.
	// This field should inform the user how to utilize the newly created resources.
	// Parameter substitution will be performed on the message before being
	// displayed so that generated credentials and other parameters can be
	// included in the output.
	Message string `json:"message,omitempty"`

	// parameters is an optional array of Parameters used during the
	// Template to Config transformation.
	Parameters []Parameter `json:"parameters"`

	// objects is an array of resources to include in this template.
	// If a namespace value is hardcoded in the object, it will be removed
	// during template instantiation, however if the namespace value
	// is, or contains, a ${PARAMETER_REFERENCE}, the resolved
	// value after parameter substitution will be respected and the object
	// will be created in that namespace.
	Objects []runtime.Object `json:"objects"`

	// objectLabels is an optional set of labels that are applied to every
	// object during the Template to Config transformation.
	ObjectLabels map[string]string `json:"labels,omitempty"`
}

Template contains the inputs needed to produce a Config.

type TemplateInstance added in v0.7.0

type TemplateInstance struct {
	metav1.TypeMeta
	metav1.ObjectMeta

	// Spec describes the desired state of this TemplateInstance.
	Spec TemplateInstanceSpec

	// Status describes the current state of this TemplateInstance.
	Status TemplateInstanceStatus
}

TemplateInstance requests and records the instantiation of a Template. TemplateInstance is part of an experimental API.

type TemplateInstanceCondition added in v0.7.0

type TemplateInstanceCondition struct {
	// Type of the condition, currently Ready or InstantiateFailure.
	Type TemplateInstanceConditionType
	// Status of the condition, one of True, False or Unknown.
	Status k8sv1.ConditionStatus
	// LastTransitionTime is the last time a condition status transitioned from
	// one state to another.
	LastTransitionTime metav1.Time
	// Reason is a brief machine readable explanation for the condition's last
	// transition.
	Reason string
	// Message is a human readable description of the details of the last
	// transition, complementing reason.
	Message string
}

TemplateInstanceCondition contains condition information for a TemplateInstance.

type TemplateInstanceConditionType added in v0.7.0

type TemplateInstanceConditionType string

TemplateInstanceConditionType is the type of condition pertaining to a TemplateInstance.

const (
	// TemplateInstanceReady indicates the readiness of the template
	// instantiation.
	TemplateInstanceReady TemplateInstanceConditionType = "Ready"
	// TemplateInstanceInstantiateFailure indicates the failure of the template
	// instantiation
	TemplateInstanceInstantiateFailure TemplateInstanceConditionType = "InstantiateFailure"
)

type TemplateInstanceList added in v0.7.0

type TemplateInstanceList struct {
	metav1.TypeMeta
	metav1.ListMeta

	// Items is a list of Templateinstances
	Items []TemplateInstance
}

TemplateInstanceList is a list of TemplateInstance objects.

type TemplateInstanceObject added in v0.7.0

type TemplateInstanceObject struct {
	// ref is a reference to the created object.
	Ref k8sv1.ObjectReference
}

TemplateInstanceObject references an object created by a TemplateInstance.

type TemplateInstanceRequester added in v0.7.0

type TemplateInstanceRequester struct {
	// username uniquely identifies this user among all active users.
	Username string

	// uid is a unique value that identifies this user across time; if this user is
	// deleted and another user by the same name is added, they will have
	// different UIDs.
	UID string

	// groups represent the groups this user is a part of.
	Groups []string

	// extra holds additional information provided by the authenticator.
	Extra map[string]ExtraValue
}

TemplateInstanceRequester holds the identity of an agent requesting a template instantiation.

type TemplateInstanceSpec added in v0.7.0

type TemplateInstanceSpec struct {
	// Template is a full copy of the template for instantiation.
	Template Template

	// Secret is a reference to a Secret object containing the necessary
	// template parameters.
	Secret *k8sv1.LocalObjectReference

	// Requester holds the identity of the agent requesting the template
	// instantiation.
	Requester *TemplateInstanceRequester
}

TemplateInstanceSpec describes the desired state of a TemplateInstance.

type TemplateInstanceStatus added in v0.7.0

type TemplateInstanceStatus struct {
	// Conditions represent the latest available observations of a
	// TemplateInstance's current state.
	Conditions []TemplateInstanceCondition

	// Objects references the objects created by the TemplateInstance.
	Objects []TemplateInstanceObject
}

TemplateInstanceStatus describes the current state of a TemplateInstance.

type TemplateList added in v0.7.0

type TemplateList struct {
	metav1.TypeMeta
	metav1.ListMeta
	Items []Template
}

TemplateList is a list of Template objects.

type VMIExpecterFactory added in v0.6.1

type VMIExpecterFactory func(*v1.VirtualMachineInstance) (expect.Expecter, error)

Jump to

Keyboard shortcuts

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