framework

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostNetworking = true
	PodNetworking  = false
)
View Source
const (
	SubmarinerEngine = "submariner-engine"
	GatewayLabel     = "submariner.io/gateway"
)
View Source
const (
	// Polling interval while trying to create objects
	PollInterval = 100 * time.Millisecond
)
View Source
const (
	TestAppLabel = "test-app"
)
View Source
const (
	TestPort = 1234
)

Variables

This section is empty.

Functions

func AwaitResultOrError added in v0.1.0

func AwaitResultOrError(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) (interface{}, string, error)

func AwaitUntil added in v0.0.3

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 Errorf

func Errorf(format string, args ...interface{})

func ExpectNoError

func ExpectNoError(err error, explain ...interface{})

func ExpectNoErrorWithOffset

func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})

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 Failf

func Failf(format string, args ...interface{})

func FailfWithOffset

func FailfWithOffset(offset int, format string, args ...interface{})

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 IsTransientError

func IsTransientError(err error, opMsg string) bool

identify API errors which could be considered transient/recoverable due to server state.

func Logf

func Logf(format string, args ...interface{})

func NoopCheckEndpoint added in v0.1.0

func NoopCheckEndpoint(endpoint *submarinerv1.Endpoint) (bool, string, error)

func NoopCheckResult added in v0.0.3

func NoopCheckResult(interface{}) (bool, string, error)

func ParseFlags

func ParseFlags()

func PatchInt added in v0.1.0

func PatchInt(path string, value uint32, patchFunc PatchFunc)

PatchInt performs a REST patch operation for the given path and int value.

func PatchString added in v0.1.0

func PatchString(path string, value string, patchFunc PatchFunc)

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 Skipf

func Skipf(format string, args ...interface{})

Types

type CheckEndpointFunc added in v0.1.0

type CheckEndpointFunc func(endpoint *submarinerv1.Endpoint) (bool, string, error)

type CheckResultFunc added in v0.0.3

type CheckResultFunc func(result interface{}) (bool, string, error)

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 ClusterIndex

type ClusterIndex int
const (
	ClusterA ClusterIndex = iota
	ClusterB
	ClusterC
)

type DoOperationFunc added in v0.0.3

type DoOperationFunc func() (interface{}, error)

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

	ClusterClients    []*kubeclientset.Clientset
	SubmarinerClients []*submarinerClientset.Clientset

	SkipNamespaceCreation bool   // Whether to skip creating a namespace
	Namespace             string // Every test has a namespace at least unless creation is skipped

	NamespaceDeletionTimeout time.Duration

	// configuration for framework's client
	Options Options
	// 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 NewDefaultFramework

func NewDefaultFramework(baseName string) *Framework

NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).

func NewFramework

func NewFramework(baseName string, options Options) *Framework

NewFramework creates a test framework.

func (*Framework) AddNamespacesToDelete

func (f *Framework) AddNamespacesToDelete(namespaces ...*v1.Namespace)

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach deletes the namespace, after reading its events.

func (*Framework) AwaitNewSubmarinerEndpoint added in v0.1.0

func (f *Framework) AwaitNewSubmarinerEndpoint(cluster ClusterIndex, prevEndpointUID types.UID) *submarinerv1.Endpoint

func (*Framework) AwaitPodsByAppLabel added in v0.0.3

func (f *Framework) AwaitPodsByAppLabel(cluster ClusterIndex, appName string, 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) AwaitSubmarinerEndpoint added in v0.1.0

func (f *Framework) AwaitSubmarinerEndpoint(cluster ClusterIndex, checkEndpoint CheckEndpointFunc) *submarinerv1.Endpoint

func (*Framework) AwaitSubmarinerEnginePod added in v0.0.3

func (f *Framework) AwaitSubmarinerEnginePod(cluster ClusterIndex) *v1.Pod

AwaitSubmarinerEnginePod finds the submariner engine pod in a given cluster, waiting if necessary for a period of time for the pod to materialize.

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(clientSet *kubeclientset.Clientset,
	baseName string, labels map[string]string) *v1.Namespace

CreateNamespace creates a namespace for e2e testing.

func (*Framework) CreateTCPService

func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string, port int) *v1.Service

func (*Framework) DeletePod added in v0.0.3

func (f *Framework) DeletePod(cluster ClusterIndex, podName string, namespace string)

DeletePod deletes the pod for the given name and namespace.

func (*Framework) FindDeployment added in v0.1.0

func (f *Framework) FindDeployment(cluster ClusterIndex, appName string, namespace string) *appsv1.Deployment

func (*Framework) FindNodesByGatewayLabel added in v0.0.3

func (f *Framework) FindNodesByGatewayLabel(cluster ClusterIndex, isGateway bool) []*v1.Node

FindNodesByGatewayLabel finds the nodes in a given cluster by matching 'submariner.io/gateway' value. A missing label is treated as false. Note the control plane node labeled as master is ignored.

func (*Framework) NewNetworkPod added in v0.0.3

func (f *Framework) NewNetworkPod(config *NetworkPodConfig) *NetworkPod

func (*Framework) SetGatewayLabelOnNode added in v0.0.3

func (f *Framework) SetGatewayLabelOnNode(cluster ClusterIndex, nodeName string, isGateway bool)

SetGatewayLabelOnNode sets the 'submariner.io/gateway' value for a node to the specified value.

type NetworkPod added in v0.0.3

type NetworkPod struct {
	Pod                 *v1.Pod
	Config              *NetworkPodConfig
	TerminationError    error
	TerminationErrorMsg string
	TerminationCode     int32
	TerminationMessage  string
	// contains filtered or unexported fields
}

func (*NetworkPod) AwaitFinish added in v0.1.0

func (np *NetworkPod) AwaitFinish()

func (*NetworkPod) AwaitReady added in v0.0.3

func (np *NetworkPod) AwaitReady()

func (*NetworkPod) CheckSuccessfulFinish added in v0.1.0

func (np *NetworkPod) CheckSuccessfulFinish()

func (*NetworkPod) CreateService added in v0.0.3

func (np *NetworkPod) CreateService() *v1.Service

type NetworkPodConfig added in v0.0.3

type NetworkPodConfig struct {
	Type               NetworkPodType
	Cluster            ClusterIndex
	Scheduling         NetworkPodScheduling
	Port               int
	Data               string
	RemoteIP           string
	ConnectionTimeout  uint
	ConnectionAttempts uint
	NetworkType        bool
}

type NetworkPodScheduling added in v0.0.3

type NetworkPodScheduling int
const (
	InvalidScheduling NetworkPodScheduling = iota
	GatewayNode
	NonGatewayNode
)

type NetworkPodType added in v0.0.3

type NetworkPodType int
const (
	InvalidPodType NetworkPodType = iota
	ListenerPod
	ConnectorPod
)

type Options

type Options struct {
	ClientQPS    float32
	ClientBurst  int
	GroupVersion *schema.GroupVersion
}

Options is a struct for managing test framework options.

type PatchFunc added in v0.0.3

type PatchFunc func(pt types.PatchType, payload []byte) error

type PatchStringValue added in v0.0.3

type PatchStringValue struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value string `json:"value"`
}

type PatchUInt32Value added in v0.1.0

type PatchUInt32Value struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value uint32 `json:"value"`
}

type TestContextType

type TestContextType struct {
	KubeConfigs         []string // KubeConfigs provides an alternative to KubeConfig + KubeContexts
	KubeConfig          string
	KubeContexts        contextArray
	ClusterIDs          []string
	ReportDir           string
	ReportPrefix        string
	SubmarinerNamespace string
	ConnectionTimeout   uint
	ConnectionAttempts  uint
	OperationTimeout    uint
}
var TestContext *TestContextType = &TestContextType{}

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.

Jump to

Keyboard shortcuts

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