util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RetryInterval is time for test to retry.
	RetryInterval = time.Second * 5
	// Timeout is time after which tests stops and fails.
	Timeout = time.Minute * 5
	// TimeoutSlow is time after which tests stops and fails.
	TimeoutSlow = time.Minute * 9
)
View Source
const (
	// PlatformAWS is for AWS
	PlatformAWS = "aws"

	// PlatformAWSEdge is for AWS with FCL Edge.
	PlatformAWSEdge = "aws_edge"

	// PlatformEquinixMetal is for Equinix Metal.
	PlatformEquinixMetal = "equinixmetal"

	// PlatformEquinixMetalARM is for Equinix Metal on ARM.
	PlatformEquinixMetalARM = "equinixmetal_arm"

	// PlatformBaremetal is for Baremetal
	PlatformBaremetal = "baremetal"

	// PlatformAKS is for AKS.
	PlatformAKS = "aks"
)
View Source
const TestNamespacePrefix = "test-"

TestNamespacePrefix is testing namespace prefix.

Variables

This section is empty.

Functions

func BuildKubeConfig added in v0.8.0

func BuildKubeConfig(t *testing.T) *restclient.Config

BuildKubeConfig reads the environment variable KUBECONFIG and then builds the rest client config object which can be either used to create kube client to talk to apiserver or to just read the kubeconfig data.

func CreateKubeClient

func CreateKubeClient(t *testing.T) *kubernetes.Clientset

CreateKubeClient returns a kubernetes client reading the KUBECONFIG environment variable.

func IsPlatformSupported added in v0.2.0

func IsPlatformSupported(t *testing.T, platforms []Platform) bool

IsPlatformSupported takes in the test object and the list of supported platforms. The function detects the supported platform from environment variable. And if the platform is available in the supported platforms provided then this returns true otherwise false. If the supported platforms list is empty it is interpreted as all platforms are supported.

func IsTestNamespace added in v0.4.0

func IsTestNamespace(name string) bool

IsTestNamespace checks if namespace is a testing namespace or not.

func IsUserNamespace added in v0.4.0

func IsUserNamespace(ns string) bool

IsUserNamespace checks for user namespace.

func Kubeconfig added in v0.4.0

func Kubeconfig(t *testing.T) []byte

Kubeconfig returns content of kubeconfig file defined with KUBECONFIG environment variable.

func KubeconfigPath

func KubeconfigPath(t *testing.T) string

func LokocfgPath added in v0.8.0

func LokocfgPath(t *testing.T) string

LokocfgPath gives the LOKOCFG_LOCATION value.

func PrintPodsLogs added in v0.4.0

func PrintPodsLogs(t *testing.T, p corev1typed.PodInterface, selector *metav1.LabelSelector) error

PrintPodsLogs print logs from all pods and containers selected by given selector.

func TestNamespace added in v0.4.0

func TestNamespace(name string) string

TestNamespace creates a test namespace.

func WaitForDaemonSet

func WaitForDaemonSet(t *testing.T, client kubernetes.Interface, ns, name string, retryInterval, timeout time.Duration)

func WaitForDeployment

func WaitForDeployment(t *testing.T, client kubernetes.Interface, ns, name string, retryInterval, timeout time.Duration)

func WaitForPVCToBeBound added in v0.5.0

func WaitForPVCToBeBound(
	t *testing.T, client kubernetes.Interface, ns, name string, retryInterval, timeout time.Duration,
)

WaitForPVCToBeBound is a helper utility function to test if given PVC reaches Bound phase in given time.

func WaitForStatefulSet

func WaitForStatefulSet(t *testing.T, client kubernetes.Interface, ns, name string, replicas int, retryInterval, timeout time.Duration)

Types

type Platform added in v0.2.0

type Platform string

Platform is a type tests will use to specify which platform they are supported on.

type PortForwardInfo added in v0.1.0

type PortForwardInfo struct {

	// TODO: Add support providing service name and the API figures out the pod to forward the
	// connection to. Port forwarding works with pods only.
	PodName   string
	Namespace string
	PodPort   int
	LocalPort int
	// contains filtered or unexported fields
}

PortForwardInfo allows user to provide information needed to forward port from a Kubernetes Pod to local machine.

func (*PortForwardInfo) CloseChan added in v0.1.0

func (p *PortForwardInfo) CloseChan()

CloseChan closes the stopChan which essentially disables port forwarding. User should call this method once they are done using port forwarding. This is generally called using `defer` immediately after `PortFoward`.

func (*PortForwardInfo) PortForward added in v0.1.0

func (p *PortForwardInfo) PortForward(t *testing.T)

PortForward initiates the port forward in an asynchronous mode. The user is responsible to stop port forwarding by calling `CloseChan` method on the object. Also user should use the helper method to wait until port forwarding is enabled by calling `WaitUntilForwardingAvailable`. So the user of the this method should always call this API in following sequence for correct functionality:

p.PortForward(t) defer p.CloseChan() p.WaitUntilForwardingAvailable(t)

func (*PortForwardInfo) WaitUntilForwardingAvailable added in v0.1.0

func (p *PortForwardInfo) WaitUntilForwardingAvailable(t *testing.T)

WaitUntilForwardingAvailable is a blocking call which waits until the port-forwarding is made available.

Jump to

Keyboard shortcuts

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