Documentation ¶
Overview ¶
Package framework contains the shared test framework for Submariner projects.
Index ¶
- Constants
- Variables
- func AddBeforeSuite(beforeSuite func())
- func AwaitAllocatedEgressIPs(client dynamic.ResourceInterface, name string) []string
- func AwaitGlobalEgressIPs(cluster ClusterIndex, name, namespace string) []string
- func AwaitResultOrError(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) (interface{}, string, error)
- func AwaitUntil(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) interface{}
- func BeforeSuite()
- func CreateGlobalEgressIP(cluster ClusterIndex, obj *unstructured.Unstructured) error
- func DetectFIPSConfig(cluster ClusterIndex) (bool, error)
- func DetectGlobalnet()
- func DetectProvider(ctx context.Context, cluster ClusterIndex, nodeName string) string
- func Errorf(format string, args ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func Failf(format string, args ...interface{})
- func FailfWithOffset(offset int, format string, args ...interface{})
- func FindGatewayNodes(cluster ClusterIndex) []v1.Node
- func FindNonGatewayNodes(cluster ClusterIndex) []v1.Node
- func FindOtherClusterIndex(mainCluster int) int
- func InitNumClusterNodes() error
- func IsTransientError(err error, opMsg string) bool
- func Logf(format string, args ...interface{})
- func NestedString(obj map[string]interface{}, fields ...string) string
- func NewRequirement(key string, op selection.Operator, vals []string) labels.Requirement
- func NoopCheckResult(interface{}) (bool, string, error)
- func PatchInt(path string, value uint32, patchFunc PatchFunc)
- func PatchString(path, value string, patchFunc PatchFunc)
- func RemoveCleanupAction(p CleanupActionHandle)
- func RunCleanupActions()
- func SetFailFunction(fail func(string, ...int))
- func SetStatusFunction(by func(string, ...func()))
- func SetUserAgentFunction(uaf func() string)
- func Skipf(format string, args ...interface{})
- func ValidateFlags(t *TestContextType)
- type CheckResultFunc
- type CleanupActionHandle
- type ClusterIndex
- type DoOperationFunc
- type Docker
- type ExecOptions
- type Framework
- func (f *Framework) AddNamespacesToDelete(namespaces ...*corev1.Namespace)
- func (f *Framework) AfterEach()
- func (f *Framework) AwaitActiveGatewayPod(cluster ClusterIndex, checkPod func(*v1.Pod) bool) *v1.Pod
- func (f *Framework) AwaitClusterGlobalEgressIPs(cluster ClusterIndex, name string) []string
- func (f *Framework) AwaitGatewayFullyConnected(cluster ClusterIndex, name string) *unstructured.Unstructured
- func (f *Framework) AwaitGatewayRemoved(cluster ClusterIndex, name string)
- func (f *Framework) AwaitGatewayWithStatus(cluster ClusterIndex, name, status string) *unstructured.Unstructured
- func (f *Framework) AwaitGatewaysWithStatus(cluster ClusterIndex, status string) []unstructured.Unstructured
- func (f *Framework) AwaitGlobalIngressIP(cluster ClusterIndex, name, namespace string) string
- func (f *Framework) AwaitGlobalIngressIPRemoved(cluster ClusterIndex, name, namespace string)
- func (f *Framework) AwaitPodsByAppLabel(cluster ClusterIndex, appName, namespace string, expectedCount int) *v1.PodList
- func (f *Framework) AwaitPodsByLabelSelector(cluster ClusterIndex, labelSelector, namespace string, expectedCount int) *v1.PodList
- func (f *Framework) AwaitRouteAgentPodOnNode(cluster ClusterIndex, nodeName string, prevPodUID types.UID) *v1.Pod
- func (f *Framework) AwaitSubmarinerGatewayPod(cluster ClusterIndex) *v1.Pod
- func (f *Framework) AwaitUntilAnnotationOnPod(cluster ClusterIndex, annotation, podName, namespace string) *v1.Pod
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateHeadlessTCPService(cluster ClusterIndex, selectorName string, port int32) *corev1.Service
- func (f *Framework) CreateNamespace(clientSet *kubeclientset.Clientset, baseName string, labels map[string]string) *corev1.Namespace
- func (f *Framework) CreateService(sc typedv1.ServiceInterface, serviceSpec *corev1.Service) *corev1.Service
- func (f *Framework) CreateServiceExport(cluster ClusterIndex, name string)
- func (f *Framework) CreateTCPEndpoints(cluster ClusterIndex, epName, portName, address string, port int32) *corev1.Endpoints
- func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string, port int32) *corev1.Service
- func (f *Framework) CreateTCPServiceWithoutSelector(cluster ClusterIndex, svcName, portName string, port int32) *corev1.Service
- func (f *Framework) DeleteEndpoints(cluster ClusterIndex, endpointsName string)
- func (f *Framework) DeleteGateway(cluster ClusterIndex, name string)
- func (f *Framework) DeletePod(cluster ClusterIndex, podName, namespace string)
- func (f *Framework) DeleteService(cluster ClusterIndex, serviceName string)
- func (f *Framework) DeleteServiceExport(cluster ClusterIndex, name string)
- func (f *Framework) DoFailover(ctx context.Context, cluster ClusterIndex, gwNode, gwPod string)
- func (f *Framework) ExecWithOptions(ctx context.Context, options *ExecOptions, index ClusterIndex) (string, string, error)
- func (f *Framework) FindClusterWithMultipleGateways() int
- func (f *Framework) FindFIPSEnabledCluster() ClusterIndex
- func (f *Framework) GatewayCleanup()
- func (f *Framework) GetGatewaysWithHAStatus(cluster ClusterIndex, status string) []unstructured.Unstructured
- func (f *Framework) NewNetworkPod(config *NetworkPodConfig) *NetworkPod
- func (f *Framework) NewNginxService(cluster ClusterIndex) *corev1.Service
- func (f *Framework) NewService(name, portName string, port int32, protocol corev1.Protocol, ...) *corev1.Service
- func (f *Framework) SaveGatewayNode(cluster ClusterIndex, gwNode string)
- func (f *Framework) SetGatewayLabelOnNode(ctx context.Context, cluster ClusterIndex, nodeName string, isGateway bool)
- func (f *Framework) TestGatewayNodeFIPSMode(cluster ClusterIndex, gwPod string)
- type NetworkPod
- func (np *NetworkPod) AwaitFinish()
- func (np *NetworkPod) AwaitFinishVerbose(verbose bool)
- func (np *NetworkPod) AwaitReady()
- func (np *NetworkPod) CheckSuccessfulFinish()
- func (np *NetworkPod) CreateService() *v1.Service
- func (np *NetworkPod) GetLog() string
- func (np *NetworkPod) RunCommand(ctx context.Context, cmd []string) (string, string)
- type NetworkPodConfig
- type NetworkPodScheduling
- type NetworkPodType
- type NetworkingType
- type PatchFunc
- type PatchStringValue
- type PatchUInt32Value
- type TestContextType
Constants ¶
const ( SubmarinerGateway = "submariner-gateway" RouteAgent = "submariner-routeagent" GatewayLabel = "submariner.io/gateway" ActiveGatewayLabel = "gateway.submariner.io/status=active" TestNonGWNodeLabel = "test.submariner.io/non-gateway-node=true" BasicTestLabel = "basic" )
const ( // Polling interval while trying to create objects. PollInterval = 100 * time.Millisecond )
const (
TestAppLabel = "test-app"
)
const (
TestPort = 1234
)
Variables ¶
var ( RestConfigs []*rest.Config KubeClients []*kubeclientset.Clientset DynClients []dynamic.Interface )
var ( By func(string, ...func()) Fail func(string, ...int) )
var TestContext = &TestContextType{
ClientQPS: 20,
ClientBurst: 50,
NettestImageURL: "quay.io/submariner/nettest:devel",
}
Functions ¶
func AddBeforeSuite ¶
func AddBeforeSuite(beforeSuite func())
func AwaitAllocatedEgressIPs ¶ added in v0.10.1
func AwaitAllocatedEgressIPs(client dynamic.ResourceInterface, name string) []string
func AwaitGlobalEgressIPs ¶ added in v0.10.1
func AwaitGlobalEgressIPs(cluster ClusterIndex, name, namespace string) []string
func AwaitResultOrError ¶
func AwaitResultOrError(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) (interface{}, string, error)
func AwaitUntil ¶
func AwaitUntil(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) interface{}
AwaitUntil periodically performs the given operation until the given CheckResultFunc returns true, an error, or a timeout is reached.
func BeforeSuite ¶
func BeforeSuite()
func CreateGlobalEgressIP ¶ added in v0.10.1
func CreateGlobalEgressIP(cluster ClusterIndex, obj *unstructured.Unstructured) error
func DetectFIPSConfig ¶ added in v0.15.0
func DetectFIPSConfig(cluster ClusterIndex) (bool, error)
func DetectGlobalnet ¶ added in v0.7.2
func DetectGlobalnet()
func DetectProvider ¶ added in v0.14.0
func DetectProvider(ctx context.Context, cluster ClusterIndex, nodeName string) string
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
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 FailfWithOffset ¶
FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").
func FindGatewayNodes ¶ added in v0.14.0
func FindGatewayNodes(cluster ClusterIndex) []v1.Node
FindGatewayNodes finds nodes in a given cluster by matching 'submariner.io/gateway' value.
func FindNonGatewayNodes ¶ added in v0.14.0
func FindNonGatewayNodes(cluster ClusterIndex) []v1.Node
FindNonGatewayNodes finds nodes in a given cluster that doesn't match 'submariner.io/gateway' value.
func FindOtherClusterIndex ¶ added in v0.14.0
FindOtherClusterIndex looks within the environment for another cluster besides the one provided and returns its index or -1 if none other is found.
func InitNumClusterNodes ¶ added in v0.12.0
func InitNumClusterNodes() error
func IsTransientError ¶
identify API errors which could be considered transient/recoverable due to server state.
func NestedString ¶ added in v0.9.0
func NewRequirement ¶ added in v0.14.0
func NoopCheckResult ¶
func PatchString ¶
PatchString performs a REST patch operation for the given path and string value.
func RemoveCleanupAction ¶
func RemoveCleanupAction(p CleanupActionHandle)
RemoveCleanupAction removes a function that was installed by AddCleanupAction.
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 SetFailFunction ¶ added in v0.7.0
func SetStatusFunction ¶ added in v0.7.0
func SetStatusFunction(by func(string, ...func()))
func SetUserAgentFunction ¶ added in v0.7.0
func SetUserAgentFunction(uaf func() string)
func ValidateFlags ¶
func ValidateFlags(t *TestContextType)
Types ¶
type CheckResultFunc ¶
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 DoOperationFunc ¶
type DoOperationFunc func() (interface{}, error)
type Docker ¶ added in v0.9.0
type Docker struct {
Name string
}
func (*Docker) RunCommand ¶ added in v0.9.0
type ExecOptions ¶
type ExecOptions struct { Command []string Namespace string PodName string ContainerName string Stdin io.Reader CaptureStdout bool CaptureStderr bool // If false, whitespace in std{err,out} will be removed. PreserveWhitespace bool }
ExecOptions passed to ExecWithOptions.
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 SkipNamespaceCreation bool // Whether to skip creating a namespace Namespace string // Every test has a namespace at least unless creation is skipped NamespaceDeletionTimeout time.Duration // contains filtered or unexported fields }
Framework supports common operations used by e2e tests; it will keep a client & a namespace for you. Eventual goal is to merge this with integration test framework.
func NewBareFramework ¶ added in v0.7.0
NewBareFramework creates a test framework, without ginkgo dependencies.
func NewFramework ¶
NewFramework creates a test framework, under ginkgo.
func (*Framework) AddNamespacesToDelete ¶
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach deletes the namespace, after reading its events.
func (*Framework) AwaitActiveGatewayPod ¶ added in v0.14.0
func (f *Framework) AwaitActiveGatewayPod(cluster ClusterIndex, checkPod func(*v1.Pod) bool) *v1.Pod
AwaitActiveGatewayPod looks for active gateway pod. Returns pod object or nil.
func (*Framework) AwaitClusterGlobalEgressIPs ¶ added in v0.10.1
func (f *Framework) AwaitClusterGlobalEgressIPs(cluster ClusterIndex, name string) []string
func (*Framework) AwaitGatewayFullyConnected ¶ added in v0.9.0
func (f *Framework) AwaitGatewayFullyConnected(cluster ClusterIndex, name string) *unstructured.Unstructured
func (*Framework) AwaitGatewayRemoved ¶ added in v0.9.0
func (f *Framework) AwaitGatewayRemoved(cluster ClusterIndex, name string)
func (*Framework) AwaitGatewayWithStatus ¶ added in v0.9.0
func (f *Framework) AwaitGatewayWithStatus(cluster ClusterIndex, name, status string) *unstructured.Unstructured
func (*Framework) AwaitGatewaysWithStatus ¶ added in v0.9.0
func (f *Framework) AwaitGatewaysWithStatus(cluster ClusterIndex, status string) []unstructured.Unstructured
func (*Framework) AwaitGlobalIngressIP ¶ added in v0.10.1
func (f *Framework) AwaitGlobalIngressIP(cluster ClusterIndex, name, namespace string) string
func (*Framework) AwaitGlobalIngressIPRemoved ¶ added in v0.10.1
func (f *Framework) AwaitGlobalIngressIPRemoved(cluster ClusterIndex, name, namespace string)
func (*Framework) AwaitPodsByAppLabel ¶
func (f *Framework) AwaitPodsByAppLabel(cluster ClusterIndex, appName, namespace string, expectedCount int) *v1.PodList
AwaitPodsByAppLabel finds pods in a given cluster whose 'app' label value matches a specified value. If the specified expectedCount >= 0, the function waits until the number of pods equals the expectedCount.
func (*Framework) AwaitPodsByLabelSelector ¶ added in v0.10.1
func (f *Framework) AwaitPodsByLabelSelector(cluster ClusterIndex, labelSelector, namespace string, expectedCount int) *v1.PodList
AwaitPodsByLabelSelector finds pods in a given cluster whose labels match a specified label selector. If the specified expectedCount >= 0, the function waits until the number of pods equals the expectedCount.
func (*Framework) AwaitRouteAgentPodOnNode ¶ added in v0.9.0
func (f *Framework) AwaitRouteAgentPodOnNode(cluster ClusterIndex, nodeName string, prevPodUID types.UID) *v1.Pod
AwaitRouteAgentPodOnNode finds the route agent pod on a given node in a cluster, waiting if necessary for a period of time for the pod to materialize. If prevPodUID is non-empty, the found pod's UID must not match it.
func (*Framework) AwaitSubmarinerGatewayPod ¶ added in v0.9.0
func (f *Framework) AwaitSubmarinerGatewayPod(cluster ClusterIndex) *v1.Pod
AwaitSubmarinerGatewayPod finds the submariner gateway pod in a given cluster, waiting if necessary for a period of time for the pod to materialize.
func (*Framework) AwaitUntilAnnotationOnPod ¶ added in v0.4.0
func (f *Framework) AwaitUntilAnnotationOnPod(cluster ClusterIndex, annotation, podName, namespace string) *v1.Pod
AwaitUntilAnnotationOnPod queries the Pod and looks for the presence of annotation.
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
func (*Framework) CreateHeadlessTCPService ¶ added in v0.10.1
func (*Framework) CreateNamespace ¶
func (f *Framework) CreateNamespace(clientSet *kubeclientset.Clientset, baseName string, labels map[string]string, ) *corev1.Namespace
CreateNamespace creates a namespace for e2e testing.
func (*Framework) CreateService ¶ added in v0.10.1
func (*Framework) CreateServiceExport ¶ added in v0.9.0
func (f *Framework) CreateServiceExport(cluster ClusterIndex, name string)
func (*Framework) CreateTCPEndpoints ¶ added in v0.10.1
func (*Framework) CreateTCPService ¶
func (*Framework) CreateTCPServiceWithoutSelector ¶ added in v0.10.1
func (*Framework) DeleteEndpoints ¶ added in v0.10.1
func (f *Framework) DeleteEndpoints(cluster ClusterIndex, endpointsName string)
func (*Framework) DeleteGateway ¶ added in v0.9.0
func (f *Framework) DeleteGateway(cluster ClusterIndex, name string)
func (*Framework) DeletePod ¶
func (f *Framework) DeletePod(cluster ClusterIndex, podName, namespace string)
DeletePod deletes the pod for the given name and namespace.
func (*Framework) DeleteService ¶
func (f *Framework) DeleteService(cluster ClusterIndex, serviceName string)
func (*Framework) DeleteServiceExport ¶ added in v0.9.0
func (f *Framework) DeleteServiceExport(cluster ClusterIndex, name string)
func (*Framework) DoFailover ¶ added in v0.14.0
func (f *Framework) DoFailover(ctx context.Context, cluster ClusterIndex, gwNode, gwPod string)
Perform a gateway failover. The failover for the real environment will crash the gateway node. The failover for the kind environment will set the submariner.io/gateway label to "false" on the gw node.
func (*Framework) ExecWithOptions ¶
func (f *Framework) ExecWithOptions(ctx context.Context, options *ExecOptions, index ClusterIndex) (string, string, error)
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.
func (*Framework) FindClusterWithMultipleGateways ¶ added in v0.14.0
FindClusterWithMultipleGateways finds the cluster with multiple GW nodes. Returns cluster index.
func (*Framework) FindFIPSEnabledCluster ¶ added in v0.15.0
func (f *Framework) FindFIPSEnabledCluster() ClusterIndex
func (*Framework) GatewayCleanup ¶ added in v0.9.0
func (f *Framework) GatewayCleanup()
GatewayCleanup will be executed only on kind environment. It will restore the gateway nodes to its initial state. Other environments do not need any gw cleanup as MachineSet is responsible to keeping the gw nodes in active states.
func (*Framework) GetGatewaysWithHAStatus ¶ added in v0.9.0
func (f *Framework) GetGatewaysWithHAStatus( cluster ClusterIndex, status string, ) []unstructured.Unstructured
func (*Framework) NewNetworkPod ¶
func (f *Framework) NewNetworkPod(config *NetworkPodConfig) *NetworkPod
func (*Framework) NewNginxService ¶
func (f *Framework) NewNginxService(cluster ClusterIndex) *corev1.Service
func (*Framework) NewService ¶ added in v0.10.1
func (*Framework) SaveGatewayNode ¶ added in v0.14.0
func (f *Framework) SaveGatewayNode(cluster ClusterIndex, gwNode string)
func (*Framework) SetGatewayLabelOnNode ¶
func (f *Framework) SetGatewayLabelOnNode(ctx context.Context, cluster ClusterIndex, nodeName string, isGateway bool)
SetGatewayLabelOnNode sets the 'submariner.io/gateway' value for a node to the specified value.
func (*Framework) TestGatewayNodeFIPSMode ¶ added in v0.15.0
func (f *Framework) TestGatewayNodeFIPSMode(cluster ClusterIndex, gwPod string)
type NetworkPod ¶
type NetworkPod struct { Pod *v1.Pod Config *NetworkPodConfig TerminationError error TerminationErrorMsg string TerminationCode int32 TerminationMessage string // contains filtered or unexported fields }
func (*NetworkPod) AwaitFinish ¶
func (np *NetworkPod) AwaitFinish()
func (*NetworkPod) AwaitFinishVerbose ¶ added in v0.7.2
func (np *NetworkPod) AwaitFinishVerbose(verbose bool)
func (*NetworkPod) AwaitReady ¶
func (np *NetworkPod) AwaitReady()
func (*NetworkPod) CheckSuccessfulFinish ¶
func (np *NetworkPod) CheckSuccessfulFinish()
func (*NetworkPod) CreateService ¶
func (np *NetworkPod) CreateService() *v1.Service
func (*NetworkPod) GetLog ¶ added in v0.9.0
func (np *NetworkPod) GetLog() string
GetLog returns container log from this NetworkPod.
func (*NetworkPod) RunCommand ¶ added in v0.9.0
RunCommand run the specified command in this NetworkPod.
type NetworkPodConfig ¶
type NetworkPodConfig struct { Type NetworkPodType Cluster ClusterIndex Scheduling NetworkPodScheduling Data string NumOfDataBufs uint RemoteIP string ConnectionTimeout uint ConnectionAttempts uint Port int32 Networking NetworkingType ContainerName string ImageName string Command []string }
type NetworkPodScheduling ¶
type NetworkPodScheduling int
const ( InvalidScheduling NetworkPodScheduling = iota GatewayNode NonGatewayNode )
type NetworkPodType ¶
type NetworkPodType int
const ( InvalidPodType NetworkPodType = iota ListenerPod ConnectorPod ThroughputClientPod ThroughputServerPod LatencyClientPod LatencyServerPod CustomPod )
type NetworkingType ¶
type NetworkingType bool
const ( HostNetworking NetworkingType = true PodNetworking NetworkingType = false )
type PatchStringValue ¶
type PatchUInt32Value ¶
type TestContextType ¶
type TestContextType struct { ReporterConfig *types.ReporterConfig SuiteConfig *types.SuiteConfig KubeConfigs []string // KubeConfigs provides an alternative to KubeConfig + KubeContexts KubeConfig string KubeContexts contextArray ClusterIDs []string NumNodesInCluster map[ClusterIndex]int SubmarinerNamespace string ConnectionTimeout uint ConnectionAttempts uint OperationTimeout uint PacketSize uint GlobalnetEnabled bool ClientQPS float32 ClientBurst int GroupVersion *schema.GroupVersion NettestImageURL string }
func (*TestContextType) OperationTimeoutToDuration ¶ added in v0.19.0
func (t *TestContextType) OperationTimeoutToDuration() time.Duration
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. |