Documentation ¶
Index ¶
- Constants
- Variables
- func AfterReadingAllFlags(t *TestContextType)
- func ContainsAll(model, target []interface{}) bool
- func DeleteNamespaces(c clientset.Interface, deleteFilter, skipFilter []string) ([]string, error)
- func ExpectError(err error, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNoErrorWithRetries(fn func() error, maxRetries int, explain ...interface{})
- func FromInts(m []int) []interface{}
- func FromStrings(m []string) []interface{}
- func GetPorts(service corev1.Service) []int
- func HandleFlags()
- func KubectlCmd(ctxData ContextData, args ...string) *exec.Cmd
- func LoadClientset() (*clientset.Clientset, error)
- func LoadConfig() (*restclient.Config, error)
- func LookForRegexp(expectedRegexp string, timeout time.Duration, fn func() string) (result string, err error)
- func LookForRegexpInLog(ctxData ContextData, podName, container, expectedRegexp string, ...) (result string, err error)
- func LookForString(expectedString string, timeout time.Duration, fn func() string) (result string, err error)
- func LookForStringInLog(ctxData ContextData, podName, container, expectedString string, ...) (result string, err error)
- func RegisterFlags()
- func RemoveCleanupAction(action ActionType, p CleanupActionHandle)
- func RestclientConfig(kubeContext string) (*clientcmdapi.Config, error)
- func RunCleanupActions(action ActionType)
- func RunKubectl(ctxData ContextData, args ...string) (string, error)
- func RunKubectlOrDie(ctxData ContextData, args ...string) string
- func WaitForDaemonSet(kubeclient kubernetes.Interface, namespace, name string, count int, ...) error
- func WaitForDeletion(t *testing.T, dynclient client.Client, obj runtime.Object, ...) error
- func WaitForDeployment(kubeclient kubernetes.Interface, namespace, name string, replicas int, ...) error
- func WaitForNamespacesDeleted(c clientset.Interface, namespaces []string, timeout time.Duration) error
- type ActionType
- type CleanupActionHandle
- type ClientSet
- type ContextData
- func (c *ContextData) AddNamespacesToDelete(namespaces ...*corev1.Namespace)
- func (c *ContextData) CreateInterconnect(namespace string, size int32, fn ...InterconnectCustomizer) (*v1alpha1.Interconnect, error)
- func (c *ContextData) CreateInterconnectFromSpec(size int32, name string, spec v1alpha1.InterconnectSpec) (*v1alpha1.Interconnect, error)
- func (c *ContextData) CreateNamespace(clientSet *clientset.Clientset, baseName string, labels map[string]string) *corev1.Namespace
- func (c *ContextData) DeleteInterconnect(interconnect *v1alpha1.Interconnect) error
- func (c *ContextData) DeleteNamespace(ns *corev1.Namespace) []error
- func (c *ContextData) GenerateNamespace() (*corev1.Namespace, error)
- func (c *ContextData) GetDaemonSet(name string) (*appsv1.DaemonSet, error)
- func (c *ContextData) GetDeployment(name string) (*appsv1.Deployment, error)
- func (c *ContextData) GetInterconnect(name string) (*v1alpha1.Interconnect, error)
- func (c *ContextData) GetSecret(name string) (*corev1.Secret, error)
- func (c *ContextData) GetService(name string) (*corev1.Service, error)
- func (c *ContextData) ListPodsForDeployment(deployment *appsv1.Deployment) (*corev1.PodList, error)
- func (c *ContextData) ListPodsForDeploymentName(name string) (*corev1.PodList, error)
- func (c *ContextData) UpdateInterconnect(interconnect *v1alpha1.Interconnect) (*v1alpha1.Interconnect, error)
- type Framework
- type InterconnectCustomizer
- type KubectlBuilder
- func NewKubectlCommand(ctxData ContextData, args ...string) *KubectlBuilder
- func NewKubectlCommandTimeout(ctxData ContextData, timeout time.Duration, args ...string) *KubectlBuilder
- func NewKubectlExecCommand(ctxData ContextData, pod string, timeout time.Duration, commandArgs ...string) *KubectlBuilder
- type TestContextType
Constants ¶
const (
NamespaceCleanupTimeout = 2 * time.Minute
)
const ( // Poll is how often to Poll pods Poll = 2 * time.Second )
Variables ¶
var ( RetryInterval = time.Second * 5 Timeout = time.Second * 600 CleanupRetryInterval = time.Second * 1 CleanupTimeout = time.Second * 5 GVR = groupName + "/" + apiVersion )
var (
RunID = uuid.NewUUID()
)
Functions ¶
func AfterReadingAllFlags ¶
func AfterReadingAllFlags(t *TestContextType)
AfterReadingAllFlags makes changes to the context after all flags have been read.
func ContainsAll ¶
func ContainsAll(model, target []interface{}) bool
ContainsAll can be used to compare two sorted slices and validate both are not nil and all elements from given model are present on the target instance.
func DeleteNamespaces ¶
DeleteNamespaces deletes all namespaces that match the given delete and skip filters. Filter is by simple strings.Contains; first skip filter, then delete filter. Returns the list of deleted namespaces or an error.
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNoErrorWithRetries ¶
ExpectNoErrorWithRetries checks if an error occurs with the given retry count.
func FromInts ¶
func FromInts(m []int) []interface{}
FromInts returns an interface array with sorted elements from int array
func FromStrings ¶
func FromStrings(m []string) []interface{}
FromStrings returns an interface array with sorted elements from string array
func GetPorts ¶
GetPorts returns an int slice with all ports exposed by the provided corev1.Service object
func KubectlCmd ¶
func KubectlCmd(ctxData ContextData, args ...string) *exec.Cmd
KubectlCmd runs the kubectl executable through the wrapper script.
func LoadClientset ¶
LoadClientset returns clientset for connecting to kubernetes clusters.
func LoadConfig ¶
func LoadConfig() (*restclient.Config, error)
LoadConfig returns a config for a rest client.
func LookForRegexp ¶
func LookForRegexp(expectedRegexp string, timeout time.Duration, fn func() string) (result string, err error)
LookForRegexp looks for the given regexp in results from given "func() string"
func LookForRegexpInLog ¶
func LookForRegexpInLog(ctxData ContextData, podName, container, expectedRegexp string, timeout time.Duration) (result string, err error)
LookForRegexpInLog looks for the given regexp in the log of a specific pod container
func LookForString ¶
func LookForString(expectedString string, timeout time.Duration, fn func() string) (result string, err error)
LookForString looks for the given string in the output of fn, repeatedly calling fn until the timeout is reached or the string is found. Returns last log and possibly error if the string was not found. TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
func LookForStringInLog ¶
func LookForStringInLog(ctxData ContextData, podName, container, expectedString string, timeout time.Duration) (result string, err error)
LookForStringInLog looks for the given string in the log of a specific pod container
func RemoveCleanupAction ¶
func RemoveCleanupAction(action ActionType, p CleanupActionHandle)
RemoveCleanupAction removes a function that was installed by AddCleanupAction.
func RestclientConfig ¶
func RestclientConfig(kubeContext string) (*clientcmdapi.Config, error)
RestclientConfig returns a config holds the information needed to build connection to kubernetes clusters.
func RunCleanupActions ¶
func RunCleanupActions(action ActionType)
RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.
func RunKubectl ¶
func RunKubectl(ctxData ContextData, args ...string) (string, error)
RunKubectl is a convenience wrapper over kubectlBuilder
func RunKubectlOrDie ¶
func RunKubectlOrDie(ctxData ContextData, args ...string) string
RunKubectlOrDie is a convenience wrapper over kubectlBuilder
func WaitForDaemonSet ¶
func WaitForDeletion ¶
func WaitForDeployment ¶
Types ¶
type ActionType ¶
type ActionType int
Action type to be enqueued
const ( AfterEach ActionType = iota AfterSuite )
type CleanupActionHandle ¶
type CleanupActionHandle *int
CleanupActionHandle is an integer pointer type for handling cleanup action
func AddCleanupAction ¶
func AddCleanupAction(action ActionType, fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of completion of a test Spec or a test Suite. This allows arbitrary pieces of the overall test to hook into AfterEach() and SynchronizedAfterSuite().
type ContextData ¶
type ContextData struct { Id string Clients ClientSet Namespace string // Set together with creating the ClientSet and the namespace. // Guaranteed to be unique in the cluster even when running the same // test multiple times in parallel. UniqueName string CertManagerPresent bool // if crd is detected // contains filtered or unexported fields }
ContextData holds clients and data related with namespaces
created within
func (*ContextData) AddNamespacesToDelete ¶
func (c *ContextData) AddNamespacesToDelete(namespaces ...*corev1.Namespace)
func (*ContextData) CreateInterconnect ¶
func (c *ContextData) CreateInterconnect(namespace string, size int32, fn ...InterconnectCustomizer) (*v1alpha1.Interconnect, error)
CreateInterconnect creates an interconnect resource
func (*ContextData) CreateInterconnectFromSpec ¶
func (c *ContextData) CreateInterconnectFromSpec(size int32, name string, spec v1alpha1.InterconnectSpec) (*v1alpha1.Interconnect, error)
CreateInterconnectFromSpec creates an Interconnect resource using the provided InterconnectSpec
func (*ContextData) CreateNamespace ¶
func (c *ContextData) CreateNamespace(clientSet *clientset.Clientset, baseName string, labels map[string]string) *corev1.Namespace
CreateNamespace creates a namespace for e2e testing.
func (*ContextData) DeleteInterconnect ¶
func (c *ContextData) DeleteInterconnect(interconnect *v1alpha1.Interconnect) error
func (*ContextData) DeleteNamespace ¶
func (c *ContextData) DeleteNamespace(ns *corev1.Namespace) []error
func (*ContextData) GenerateNamespace ¶
func (c *ContextData) GenerateNamespace() (*corev1.Namespace, error)
GenerateNamespace creates a namespace with a random name.
func (*ContextData) GetDaemonSet ¶
func (c *ContextData) GetDaemonSet(name string) (*appsv1.DaemonSet, error)
func (*ContextData) GetDeployment ¶
func (c *ContextData) GetDeployment(name string) (*appsv1.Deployment, error)
func (*ContextData) GetInterconnect ¶
func (c *ContextData) GetInterconnect(name string) (*v1alpha1.Interconnect, error)
func (*ContextData) GetSecret ¶
func (c *ContextData) GetSecret(name string) (*corev1.Secret, error)
func (*ContextData) GetService ¶
func (c *ContextData) GetService(name string) (*corev1.Service, error)
func (*ContextData) ListPodsForDeployment ¶
func (c *ContextData) ListPodsForDeployment(deployment *appsv1.Deployment) (*corev1.PodList, error)
func (*ContextData) ListPodsForDeploymentName ¶
func (c *ContextData) ListPodsForDeploymentName(name string) (*corev1.PodList, error)
func (*ContextData) UpdateInterconnect ¶
func (c *ContextData) UpdateInterconnect(interconnect *v1alpha1.Interconnect) (*v1alpha1.Interconnect, error)
type Framework ¶
type Framework struct { BaseName string // Map that ties clients and namespaces for each available context ContextMap map[string]*ContextData SkipNamespaceCreation bool // Whether to skip creating a namespace // contains filtered or unexported fields }
func NewFramework ¶
NewFramework creates a test framework
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach deletes the namespace, after reading its events.
func (*Framework) AfterSuite ¶
func (f *Framework) AfterSuite()
AfterSuite deletes the cluster level resources
func (*Framework) BeforeEach ¶
BeforeEach gets clients and makes a namespace
func (*Framework) GetFirstContext ¶
func (f *Framework) GetFirstContext() *ContextData
GetFirstContext returns the first entry in the ContextMap or nil if none
func (*Framework) TeardownEach ¶
func (*Framework) TeardownSuite ¶
type InterconnectCustomizer ¶
type InterconnectCustomizer func(interconnect *v1alpha1.Interconnect)
InterconnectCustomizer represents a function that allows for customizing an Interconnect resource before it is created.
type KubectlBuilder ¶
type KubectlBuilder struct {
// contains filtered or unexported fields
}
KubectlBuilder is used to build, customize and execute a kubectl Command. Add more functions to customize the builder as needed.
func NewKubectlCommand ¶
func NewKubectlCommand(ctxData ContextData, args ...string) *KubectlBuilder
NewKubectlCommand returns a KubectlBuilder for running kubectl.
func NewKubectlCommandTimeout ¶
func NewKubectlCommandTimeout(ctxData ContextData, timeout time.Duration, args ...string) *KubectlBuilder
NewKubectlCommandTimeout returns a KubectlBuilder with a timeout defined, for running kubectl.
func NewKubectlExecCommand ¶
func NewKubectlExecCommand(ctxData ContextData, pod string, timeout time.Duration, commandArgs ...string) *KubectlBuilder
NewKubectlExecCommand returns a KubectlBuilder prepared to execute a given command in a running pod.
func (KubectlBuilder) Exec ¶
func (b KubectlBuilder) Exec() (string, error)
Exec runs the kubectl executable.
func (KubectlBuilder) ExecOrDie ¶
func (b KubectlBuilder) ExecOrDie() string
ExecOrDie runs the kubectl executable or dies if error occurs.
type TestContextType ¶
type TestContextType struct { KubeConfig string KubeContexts contextNames CertDir string Host string RepoRoot string KubectlPath string OutputDir string ReportDir string ReportPrefix string Prefix string QdrImage string OperatorImage string DeleteNamespace bool DeleteNamespaceOnFailure bool CleanStart bool }
TestContextType contains test settings and global state.
var TestContext TestContextType
TestContext should be used by all tests to access validation context data.
func (TestContextType) ContextsAvailable ¶
func (t TestContextType) ContextsAvailable() int
ContextsAvailable returns the number of contexts available after parsing command line arguments.
func (TestContextType) GetContexts ¶
func (t TestContextType) GetContexts() []string
GetContexts returns a list of contexts from provided flags or the current-context if none. If KubeConfig not provided or not generated, it returns nil.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string. |