framework

package
v0.0.0-...-71bf7b1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 29 Imported by: 4

Documentation

Overview

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Copyright 2022 Authors of spidernet-io SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	E2E_CLUSTER_NAME            = "E2E_CLUSTER_NAME"
	E2E_KUBECONFIG_PATH         = "E2E_KUBECONFIG_PATH"
	E2E_IPV4_ENABLED            = "E2E_IPV4_ENABLED"
	E2E_IPV6_ENABLED            = "E2E_IPV6_ENABLED"
	E2E_MULTUS_CNI_ENABLED      = "E2E_MULTUS_CNI_ENABLED"
	E2E_SPIDERPOOL_IPAM_ENABLED = "E2E_SPIDERPOOL_IPAM_ENABLED"
	E2E_WHEREABOUT_IPAM_ENABLED = "E2E_WHEREABOUT_IPAM_ENABLED"
	E2E_KIND_CLUSTER_NODE_LIST  = "E2E_KIND_CLUSTER_NODE_LIST"
	E2E_Multus_DefaultCni       = "E2E_Multus_DefaultCni"
	E2E_Multus_AdditionalCni    = "E2E_Multus_AdditionalCni"
	E2E_SPIDERSUBNET_ENABLED    = "E2E_SPIDERSUBNET_ENABLED"
)

Variables

View Source
var (
	Default_k8sClient_QPS   float32 = 200
	Default_k8sClient_Burst int     = 300

	Default_k8sClient_ApiOperateTimeout     = 15 * time.Second
	Default_k8sClient_ResourceDeleteTimeout = 60 * time.Second
)
View Source
var ClusterInformation = &ClusterInfo{}
View Source
var ErrAlreadyExisted = errors.New("resource already exists")
View Source
var ErrChanelClosed = errors.New("channel is closed")
View Source
var ErrEvent = errors.New("received error event")
View Source
var ErrGetObj = errors.New("failed to get metaObject")
View Source
var ErrResDel = errors.New("resource is deleted")
View Source
var ErrTimeOut = errors.New("context timeout")
View Source
var ErrWatch = errors.New("failed to Watch")
View Source
var ErrWrongInput = errors.New("input variable is not valid")

Functions

This section is empty.

Types

type ClusterInfo

type ClusterInfo struct {
	IpV4Enabled           bool
	IpV6Enabled           bool
	MultusEnabled         bool
	SpiderIPAMEnabled     bool
	WhereaboutIPAMEnabled bool
	ClusterName           string
	KubeConfigPath        string
	// docker container name for kind cluster
	KindNodeList    []string
	KindNodeListRaw string
	// multus
	MultusDefaultCni    string
	MultusAdditionalCni string
	SpiderSubnetEnabled bool
}

type FConfig

type FConfig struct {
	ApiOperateTimeout     time.Duration
	ResourceDeleteTimeout time.Duration
}

type Framework

type Framework struct {
	// clienset
	KClient client.WithWatch
	KConfig *rest.Config

	// cluster info
	Info ClusterInfo

	Config    FConfig
	EnableLog bool
	// contains filtered or unexported fields
}

func NewFramework

func NewFramework(t TestingT, schemeRegisterList []func(*runtime.Scheme) error, fakeClient ...client.WithWatch) (*Framework, error)

NewFramework init Framework struct fakeClient for unitest

func (*Framework) CheckNodeStatus

func (f *Framework) CheckNodeStatus(node *corev1.Node, expectReady bool) bool

func (*Framework) CheckPodListIpReady

func (f *Framework) CheckPodListIpReady(podList *corev1.PodList) error

func (*Framework) CheckPodListRunning

func (f *Framework) CheckPodListRunning(podList *corev1.PodList) bool

func (*Framework) CreateConfigmap

func (f *Framework) CreateConfigmap(configMap *corev1.ConfigMap, opts ...client.CreateOption) error

func (*Framework) CreateDaemonSet

func (f *Framework) CreateDaemonSet(ds *appsv1.DaemonSet, opts ...client.CreateOption) error

func (*Framework) CreateDaemonsetUntilReady

func (f *Framework) CreateDaemonsetUntilReady(ctx context.Context, dsObj *appsv1.DaemonSet, opts ...client.CreateOption) (*corev1.PodList, error)

Create Daemonset and wait for ready and check that the IP of the Pod is assigned correctly

func (*Framework) CreateDeployment

func (f *Framework) CreateDeployment(dpm *appsv1.Deployment, opts ...client.CreateOption) error

func (*Framework) CreateDeploymentUntilReady

func (f *Framework) CreateDeploymentUntilReady(deployObj *appsv1.Deployment, timeOut time.Duration, opts ...client.CreateOption) (*appsv1.Deployment, error)

func (*Framework) CreateEndpoint

func (f *Framework) CreateEndpoint(ep *corev1.Endpoints, opts ...client.CreateOption) error

CreateEndpoint create an endpoint to testing GetEndpoint/ListEndpoint

func (*Framework) CreateJob

func (f *Framework) CreateJob(jb *batchv1.Job, opts ...client.CreateOption) error

func (*Framework) CreateMultusInstance

func (f *Framework) CreateMultusInstance(nad *v1.NetworkAttachmentDefinition, opts ...client.CreateOption) error

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(nsName string, opts ...client.CreateOption) error

func (*Framework) CreateNamespaceUntilDefaultServiceAccountReady

func (f *Framework) CreateNamespaceUntilDefaultServiceAccountReady(nsName string, timeoutForSA time.Duration, opts ...client.CreateOption) error

func (*Framework) CreatePod

func (f *Framework) CreatePod(pod *corev1.Pod, opts ...client.CreateOption) error

func (*Framework) CreateReplicaSet

func (f *Framework) CreateReplicaSet(rs *appsv1.ReplicaSet, opts ...client.CreateOption) error

func (*Framework) CreateResource

func (f *Framework) CreateResource(obj client.Object, opts ...client.CreateOption) error

func (*Framework) CreateService

func (f *Framework) CreateService(service *corev1.Service, opts ...client.CreateOption) error

func (*Framework) CreateSpiderMultusInstance

func (f *Framework) CreateSpiderMultusInstance(nad *spiderv2beta1.SpiderMultusConfig, opts ...client.CreateOption) error

func (*Framework) CreateStatefulSet

func (f *Framework) CreateStatefulSet(sts *appsv1.StatefulSet, opts ...client.CreateOption) error

func (*Framework) DeleteConfigmap

func (f *Framework) DeleteConfigmap(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteDaemonSet

func (f *Framework) DeleteDaemonSet(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteDeployment

func (f *Framework) DeleteDeployment(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteDeploymentUntilFinish

func (f *Framework) DeleteDeploymentUntilFinish(deployName, namespace string, timeOut time.Duration, opts ...client.DeleteOption) error

func (*Framework) DeleteEndpoint

func (f *Framework) DeleteEndpoint(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteJob

func (f *Framework) DeleteJob(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteMultusInstance

func (f *Framework) DeleteMultusInstance(name, namespace string) error

func (*Framework) DeleteNamespace

func (f *Framework) DeleteNamespace(nsName string, opts ...client.DeleteOption) error

func (*Framework) DeleteNamespaceUntilFinish

func (f *Framework) DeleteNamespaceUntilFinish(nsName string, ctx context.Context, opts ...client.DeleteOption) error

func (*Framework) DeletePod

func (f *Framework) DeletePod(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeletePodList

func (f *Framework) DeletePodList(podList *corev1.PodList, opts ...client.DeleteOption) error

func (*Framework) DeletePodListRepeatedly

func (f *Framework) DeletePodListRepeatedly(label map[string]string, interval time.Duration, ctx context.Context, opts ...client.DeleteOption) error

func (*Framework) DeletePodListUntilReady

func (f *Framework) DeletePodListUntilReady(podList *corev1.PodList, timeOut time.Duration, opts ...client.DeleteOption) (*corev1.PodList, error)

func (*Framework) DeletePodUntilFinish

func (f *Framework) DeletePodUntilFinish(name, namespace string, ctx context.Context, opts ...client.DeleteOption) error

func (*Framework) DeleteReplicaSet

func (f *Framework) DeleteReplicaSet(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteResource

func (f *Framework) DeleteResource(obj client.Object, opts ...client.DeleteOption) error

func (*Framework) DeleteService

func (f *Framework) DeleteService(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DeleteSpiderMultusInstance

func (f *Framework) DeleteSpiderMultusInstance(namespace, name string) error

func (*Framework) DeleteStatefulSet

func (f *Framework) DeleteStatefulSet(name, namespace string, opts ...client.DeleteOption) error

func (*Framework) DockerExecCommand

func (f *Framework) DockerExecCommand(ctx context.Context, containerId string, command string) ([]byte, error)

DockerExecCommand is eq to `docker exec $containerId $command `

func (*Framework) DockerRMCommand

func (f *Framework) DockerRMCommand(ctx context.Context, containerId string) ([]byte, error)

DockerRMCommand is eq to `docker rm $containerId`

func (*Framework) DockerRunCommand

func (f *Framework) DockerRunCommand(ctx context.Context, command string) ([]byte, error)

DockerRunCommand eq to `docker run $command`

func (*Framework) ExecCommandInPod

func (f *Framework) ExecCommandInPod(podName, nameSpace, command string, ctx context.Context) ([]byte, error)

func (*Framework) ExecKubectl

func (f *Framework) ExecKubectl(command string, ctx context.Context) ([]byte, error)

operate node container, like shutdown, ssh to login

func (*Framework) GetConfigmap

func (f *Framework) GetConfigmap(name, namespace string) (*corev1.ConfigMap, error)

func (*Framework) GetDaemonSet

func (f *Framework) GetDaemonSet(name, namespace string) (*appsv1.DaemonSet, error)

func (*Framework) GetDaemonSetPodList

func (f *Framework) GetDaemonSetPodList(ds *appsv1.DaemonSet) (*corev1.PodList, error)

func (*Framework) GetDeployment

func (f *Framework) GetDeployment(name, namespace string) (*appsv1.Deployment, error)

func (*Framework) GetDeploymentPodList

func (f *Framework) GetDeploymentPodList(dpm *appsv1.Deployment) (*corev1.PodList, error)

func (*Framework) GetEndpoint

func (f *Framework) GetEndpoint(name, namespace string) (*corev1.Endpoints, error)

func (*Framework) GetEvents

func (f *Framework) GetEvents(ctx context.Context, eventKind, objName, objNamespace string) (*corev1.EventList, error)

func (*Framework) GetJob

func (f *Framework) GetJob(name, namespace string) (*batchv1.Job, error)

func (*Framework) GetJobPodList

func (f *Framework) GetJobPodList(jb *batchv1.Job) (*corev1.PodList, error)

func (*Framework) GetMultusInstance

func (f *Framework) GetMultusInstance(name, namespace string) (*v1.NetworkAttachmentDefinition, error)

func (*Framework) GetNamespace

func (f *Framework) GetNamespace(nsName string) (*corev1.Namespace, error)

func (*Framework) GetNode

func (f *Framework) GetNode(nodeName string) (*corev1.Node, error)

func (*Framework) GetNodeList

func (f *Framework) GetNodeList(opts ...client.ListOption) (*corev1.NodeList, error)

func (*Framework) GetPod

func (f *Framework) GetPod(name, namespace string) (*corev1.Pod, error)

func (*Framework) GetPodList

func (f *Framework) GetPodList(opts ...client.ListOption) (*corev1.PodList, error)

func (*Framework) GetPodListByLabel

func (f *Framework) GetPodListByLabel(label map[string]string) (*corev1.PodList, error)

func (*Framework) GetReplicaSet

func (f *Framework) GetReplicaSet(name, namespace string) (*appsv1.ReplicaSet, error)

func (*Framework) GetReplicaSetPodList

func (f *Framework) GetReplicaSetPodList(rs *appsv1.ReplicaSet) (*corev1.PodList, error)

func (*Framework) GetResource

func (f *Framework) GetResource(key client.ObjectKey, obj client.Object) error

func (*Framework) GetService

func (f *Framework) GetService(name, namespace string) (*corev1.Service, error)

func (*Framework) GetServiceAccount

func (f *Framework) GetServiceAccount(saName, namespace string) (*corev1.ServiceAccount, error)

func (*Framework) GetSpiderMultusInstance

func (f *Framework) GetSpiderMultusInstance(namespace, name string) (*spiderv2beta1.SpiderMultusConfig, error)

func (*Framework) GetStatefulSet

func (f *Framework) GetStatefulSet(name, namespace string) (*appsv1.StatefulSet, error)

func (*Framework) GetStatefulSetPodList

func (f *Framework) GetStatefulSetPodList(sts *appsv1.StatefulSet) (*corev1.PodList, error)

func (*Framework) ListEndpoint

func (f *Framework) ListEndpoint(options ...client.ListOption) (*corev1.EndpointsList, error)

func (*Framework) ListMultusInstances

func (f *Framework) ListMultusInstances(opts ...client.ListOption) (*v1.NetworkAttachmentDefinitionList, error)

func (*Framework) ListResource

func (f *Framework) ListResource(list client.ObjectList, opts ...client.ListOption) error

func (*Framework) ListService

func (f *Framework) ListService(options ...client.ListOption) (*corev1.ServiceList, error)

func (*Framework) ListSpiderMultusInstances

func (f *Framework) ListSpiderMultusInstances(opts ...client.ListOption) (*spiderv2beta1.SpiderMultusConfigList, error)

func (*Framework) Log

func (f *Framework) Log(format string, args ...interface{})

func (*Framework) PatchResource

func (f *Framework) PatchResource(obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*Framework) RestartDeploymentPodUntilReady

func (f *Framework) RestartDeploymentPodUntilReady(deployName, namespace string, timeOut time.Duration, opts ...client.DeleteOption) error

func (*Framework) ScaleDeployment

func (f *Framework) ScaleDeployment(dpm *appsv1.Deployment, replicas int32) (*appsv1.Deployment, error)

func (*Framework) ScaleReplicaSet

func (f *Framework) ScaleReplicaSet(rs *appsv1.ReplicaSet, replicas int32) (*appsv1.ReplicaSet, error)

func (*Framework) ScaleStatefulSet

func (f *Framework) ScaleStatefulSet(sts *appsv1.StatefulSet, replicas int32) (*appsv1.StatefulSet, error)

func (*Framework) UpdateResource

func (f *Framework) UpdateResource(obj client.Object, opts ...client.UpdateOption) error

func (*Framework) UpdateResourceStatus

func (f *Framework) UpdateResourceStatus(obj client.Object, opts ...client.SubResourceUpdateOption) error

func (*Framework) WaitAllPodUntilRunning

func (f *Framework) WaitAllPodUntilRunning(ctx context.Context) error

Waiting for all pods in all namespaces to run

func (*Framework) WaitClusterNodeReady

func (f *Framework) WaitClusterNodeReady(ctx context.Context) (bool, error)

func (*Framework) WaitDaemonSetReady

func (f *Framework) WaitDaemonSetReady(name, namespace string, ctx context.Context) (*appsv1.DaemonSet, error)

func (*Framework) WaitDeploymentReady

func (f *Framework) WaitDeploymentReady(name, namespace string, ctx context.Context) (*appsv1.Deployment, error)

func (*Framework) WaitDeploymentReadyAndCheckIP

func (f *Framework) WaitDeploymentReadyAndCheckIP(depName string, nsName string, timeout time.Duration) (*corev1.PodList, error)

func (*Framework) WaitExceptEventOccurred

func (f *Framework) WaitExceptEventOccurred(ctx context.Context, eventKind, objName, objNamespace, message string) error

func (*Framework) WaitJobFinished

func (f *Framework) WaitJobFinished(jobName, namespace string, ctx context.Context) (*batchv1.Job, bool, error)

WaitJobFinished wait for all job pod finish , no matter succeed or fail

func (*Framework) WaitPodListDeleted

func (f *Framework) WaitPodListDeleted(namespace string, label map[string]string, ctx context.Context) error

func (*Framework) WaitPodListRunning

func (f *Framework) WaitPodListRunning(label map[string]string, expectedPodNum int, ctx context.Context) error

func (*Framework) WaitPodStarted

func (f *Framework) WaitPodStarted(name, namespace string, ctx context.Context) (*corev1.Pod, error)

func (*Framework) WaitReplicaSetReady

func (f *Framework) WaitReplicaSetReady(name, namespace string, ctx context.Context) (*appsv1.ReplicaSet, error)

func (*Framework) WaitServiceAccountReady

func (f *Framework) WaitServiceAccountReady(saName, namespace string, timeout time.Duration) error

func (*Framework) WaitStatefulSetReady

func (f *Framework) WaitStatefulSetReady(name, namespace string, ctx context.Context) (*appsv1.StatefulSet, error)

type TestingT

type TestingT interface {
	Logf(format string, args ...interface{})
}

-------------------------------------------

Jump to

Keyboard shortcuts

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