Documentation ¶
Index ¶
- Constants
- Variables
- func AfterReadingAllFlags(t *TestContextType)
- func ContainsAll(model, target []interface{}) bool
- func CreateResourcesFromYAML(kubeClient clientset.Interface, dynClient dynamic.Interface, ...) error
- 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 HasAlreadyExistsSuffix(err error) bool
- func IsRetryFailure(err error) bool
- func KubectlCmd(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(ns, podName, container, expectedRegexp string, timeout time.Duration) (result string, err error)
- func LookForString(expectedString string, timeout time.Duration, fn func() string) (result string, err error)
- func LookForStringInLog(ns, podName, container, expectedString string, timeout time.Duration) (result string, err error)
- func RegisterFlags()
- func RemoveCleanupAction(p CleanupActionHandle)
- func RestclientConfig(kubeContext string) (*clientcmdapi.Config, error)
- func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
- func RetryWithContext(ctx context.Context, interval time.Duration, f ConditionFunc) error
- func RunCleanupActions()
- func RunKubectl(args ...string) (string, error)
- func RunKubectlOrDie(args ...string) string
- func WaitForDaemonSet(kubeclient kubernetes.Interface, namespace, name string, count int, ...) error
- func WaitForDeletion(dynclient client.Client, obj runtime.Object, ...) error
- func WaitForDeployment(kubeclient kubernetes.Interface, namespace, name string, replicas int, ...) error
- func WaitForDeploymentDeleted(ctx context.Context, kubeclient kubernetes.Interface, namespace, name string) error
- func WaitForNamespacesDeleted(c clientset.Interface, namespaces []string, timeout time.Duration) error
- type CleanupActionHandle
- type ConditionFunc
- type Framework
- func (f *Framework) AddNamespacesToDelete(namespaces ...*corev1.Namespace)
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateInterconnect(namespace string, size int32, fn ...InterconnectCustomizer) (*v1alpha1.Interconnect, error)
- func (f *Framework) CreateNamespace(clientSet *clientset.Clientset, baseName string, labels map[string]string) *corev1.Namespace
- func (f *Framework) DeleteInterconnect(interconnect *v1alpha1.Interconnect) error
- func (f *Framework) DeleteNamespace(ns *corev1.Namespace) []error
- func (f *Framework) GenerateNamespace() (*corev1.Namespace, error)
- func (f *Framework) GetDaemonSet(name string) (*appsv1.DaemonSet, error)
- func (f *Framework) GetDeployment(name string) (*appsv1.Deployment, error)
- func (f *Framework) GetInterconnect(name string) (*v1alpha1.Interconnect, error)
- func (f *Framework) GetInterconnectPodNames(ic *v1alpha1.Interconnect) ([]string, error)
- func (f *Framework) GetInterconnectPods(ic *v1alpha1.Interconnect) ([]v1.Pod, error)
- func (f *Framework) GetResource(resourceType ResourceType, name string) (*unstructured.Unstructured, error)
- func (f *Framework) GetSecret(name string) (*corev1.Secret, error)
- func (f *Framework) GetService(name string) (*corev1.Service, error)
- func (f *Framework) InterconnectHasExpectedSize(interconnect *v1alpha1.Interconnect, expectedSize int) (bool, error)
- func (f *Framework) InterconnectHasExpectedVersion(interconnect *v1alpha1.Interconnect, expectedVersion string) (bool, error)
- func (f *Framework) IsOpenShift() bool
- func (f *Framework) ListPodsForDeployment(deployment *appsv1.Deployment) (*corev1.PodList, error)
- func (f *Framework) ListResources(resourceType ResourceType) (*unstructured.UnstructuredList, error)
- func (f *Framework) PodsForInterconnect(interconnect *v1alpha1.Interconnect) ([]corev1.Pod, error)
- func (f *Framework) Setup() error
- func (f *Framework) Teardown() error
- func (f *Framework) UpdateInterconnect(interconnect *v1alpha1.Interconnect) (*v1alpha1.Interconnect, error)
- func (f *Framework) VersionForPod(pod corev1.Pod) (string, error)
- func (f *Framework) WaitForNewInterconnectPods(ctx context.Context, initialPodNames []string, ...) error
- func (f *Framework) WaitForPodStatus(podName string, status v1.PodPhase, timeout time.Duration, ...) (*v1.Pod, error)
- func (f *Framework) WaitUntilFullInterconnectWithSize(ctx context.Context, interconnect *v1alpha1.Interconnect, expectedSize int) error
- func (f *Framework) WaitUntilFullInterconnectWithVersion(ctx context.Context, interconnect *v1alpha1.Interconnect, expectedSize int, ...) error
- type InterconnectCustomizer
- type KubectlBuilder
- type ResourceType
- type RetryError
- 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 * 180 TimeoutSuite = time.Second * 1200 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 CreateResourcesFromYAML ¶
func CreateResourcesFromYAML(kubeClient clientset.Interface, dynClient dynamic.Interface, namespace, fileOrUrl string) error
CreateResourcesFromYAML creates all resources from the provided YAML file or URL using an initialized VanClient 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 HasAlreadyExistsSuffix ¶
HasAlreadyExistsSuffix returns true if the string representation of the error ends with "already exists".
func IsRetryFailure ¶
func KubectlCmd ¶
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(ns, 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(ns, 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(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 Retry ¶
func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
Retry retries f every interval until after maxRetries. The interval won't be affected by how long f takes. For example, if interval is 3s, f takes 1s, another f will be called 2s later. However, if f takes longer than interval, it will be delayed.
func RetryWithContext ¶
RetryWithContext retries f every interval until the specified context times out.
func RunCleanupActions ¶
func RunCleanupActions()
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 ¶
RunKubectl is a convenience wrapper over kubectlBuilder
func RunKubectlOrDie ¶
RunKubectlOrDie is a convenience wrapper over kubectlBuilder
func WaitForDaemonSet ¶
func WaitForDeletion ¶
func WaitForDeployment ¶
Types ¶
type CleanupActionHandle ¶
type CleanupActionHandle *int
CleanupActionHandle is an integer pointer type for handling cleanup action
func AddCleanupAction ¶
func AddCleanupAction(fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite().
type ConditionFunc ¶
type Framework ¶
type Framework struct { BaseName 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 KubeClient clientset.Interface ExtClient apiextension.Interface QdrClient qdrclient.Interface DynClient dynamic.Interface OcpClient ocpClient CertManagerPresent bool // if crd is detected SkipNamespaceCreation bool // Whether to skip creating a namespace KeepCRD bool // Whether to preserve CRD on cleanup Namespace string // contains filtered or unexported fields }
func NewFramework ¶
NewFramework creates a test framework
func (*Framework) AddNamespacesToDelete ¶
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach deletes the namespace, after reading its events.
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
BeforeEach gets clients and makes a namespace
func (*Framework) CreateInterconnect ¶
func (f *Framework) CreateInterconnect(namespace string, size int32, fn ...InterconnectCustomizer) (*v1alpha1.Interconnect, error)
CreateInterconnect creates an interconnect resource
func (*Framework) CreateNamespace ¶
func (f *Framework) CreateNamespace(clientSet *clientset.Clientset, baseName string, labels map[string]string) *corev1.Namespace
CreateNamespace creates a namespace for e2e testing.
func (*Framework) DeleteInterconnect ¶
func (f *Framework) DeleteInterconnect(interconnect *v1alpha1.Interconnect) error
func (*Framework) DeleteNamespace ¶
func (*Framework) GenerateNamespace ¶
GenerateNamespace creates a namespace with a random name.
func (*Framework) GetDaemonSet ¶
func (*Framework) GetDeployment ¶
func (f *Framework) GetDeployment(name string) (*appsv1.Deployment, error)
func (*Framework) GetInterconnect ¶
func (f *Framework) GetInterconnect(name string) (*v1alpha1.Interconnect, error)
func (*Framework) GetInterconnectPodNames ¶
func (f *Framework) GetInterconnectPodNames(ic *v1alpha1.Interconnect) ([]string, error)
GetInterconnectPodNames returns all pod names for the given interconnect instance
func (*Framework) GetInterconnectPods ¶
GetInterconnectPods returns all pods for the given interconnect instance
func (*Framework) GetResource ¶
func (f *Framework) GetResource(resourceType ResourceType, name string) (*unstructured.Unstructured, error)
GetResource returns the given resource type, identified by its given name
func (*Framework) InterconnectHasExpectedSize ¶
func (*Framework) InterconnectHasExpectedVersion ¶
func (*Framework) IsOpenShift ¶
func (*Framework) ListPodsForDeployment ¶
func (*Framework) ListResources ¶
func (f *Framework) ListResources(resourceType ResourceType) (*unstructured.UnstructuredList, error)
ListResources returns a list of resources found in the related Framework's namespace, for the given resource type
func (*Framework) PodsForInterconnect ¶
func (*Framework) UpdateInterconnect ¶
func (f *Framework) UpdateInterconnect(interconnect *v1alpha1.Interconnect) (*v1alpha1.Interconnect, error)
func (*Framework) WaitForNewInterconnectPods ¶
func (*Framework) WaitForPodStatus ¶
func (f *Framework) WaitForPodStatus(podName string, status v1.PodPhase, timeout time.Duration, interval time.Duration) (*v1.Pod, error)
WaitForPodStatus waits for given podName to be available with a matching PodPhase
or it returns a timeout.
func (*Framework) WaitUntilFullInterconnectWithSize ¶
func (f *Framework) WaitUntilFullInterconnectWithSize(ctx context.Context, interconnect *v1alpha1.Interconnect, expectedSize int) error
WaitUntilFullInterconnectWithSize waits until all the pods belonging to the Interconnect deployment report the expected state and size. The expected state will differs for interior versus edge roles
func (*Framework) WaitUntilFullInterconnectWithVersion ¶
func (f *Framework) WaitUntilFullInterconnectWithVersion(ctx context.Context, interconnect *v1alpha1.Interconnect, expectedSize int, expectedVersion string) error
WaitUntilFullInterconnectWithVersion waits until all the pods belonging to the Interconnect deployment report the expected state and expected version (if one has been provided). The expected state will differs for interior versus edge roles
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(args ...string) *KubectlBuilder
NewKubectlCommand returns a KubectlBuilder for running kubectl.
func NewKubectlCommandTimeout ¶
func NewKubectlCommandTimeout(timeout time.Duration, args ...string) *KubectlBuilder
NewKubectlCommandTimeout returns a KubectlBuilder with a timeout defined, for running kubectl.
func NewKubectlExecCommand ¶
func NewKubectlExecCommand(f *Framework, 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 RetryError ¶
type RetryError struct {
// contains filtered or unexported fields
}
func (*RetryError) Error ¶
func (e *RetryError) Error() string
type TestContextType ¶
type TestContextType struct { KubeConfig string KubeContext string 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 common context data.
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. |