util

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespaceDeletionTimeout is timeout duration for waiting for a namespace deletion.
	DefaultNamespaceDeletionTimeout = 5 * time.Minute

	// PodStartTimeout is how long to wait for the pod to be started.
	PodStartTimeout = 5 * time.Minute
)
View Source
const (
	NodePoolName = "yurt-pool2"
)

Variables

View Source
var AccessKeyID = flag.String("access-key-id", "", "aliyun AccessKeyId  for ailunyun:ecs/ens")
View Source
var AccessKeySecret = flag.String("access-key-secret", "", "aliyun AccessKeySecret  for ailunyun:ecs/ens")
View Source
var EnableYurtAutonomy = flag.Bool(
	"enable-yurt-autonomy",
	false,
	"switch of yurt node autonomy. If set to true, yurt node autonomy test can be run normally",
)
View Source
var Kubeconfig = flag.String("kubeconfig", "", "kubeconfig file path for OpenYurt cluster")
View Source
var NodeType = flag.String("node-type", "minikube", "node type such as ailunyun:ecs/ens, minikube and user_self")
View Source
var RegionID = flag.String("region-id", "", "aliyun region id for ailunyun:ecs/ens")
View Source
var ReportDir = flag.String(
	"report-dir",
	"",
	"Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.",
)

Functions

func BeEquivalentToError added in v1.3.0

func BeEquivalentToError(expected error) types.GomegaMatcher

BeEquivalentToError matches the error to take care of nil.

func CleanupNodePoolLabel added in v1.3.0

func CleanupNodePoolLabel(ctx context.Context, k8sClient client.Client) error

func DeleteNodePool added in v1.7.0

func DeleteNodePool(ctx context.Context, k8sClient client.Client, name string) error

DeleteNodePool will delete the nodepool with the given name

func ExpectConsistOf

func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})

ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.

func ExpectEmpty

func ExpectEmpty(actual interface{}, explain ...interface{})

ExpectEmpty expects actual is empty

func ExpectEqual

func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectEqual expects the specified two are the same, otherwise an exception raises

func ExpectError

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

ExpectError expects an error happens, otherwise an exception raises

func ExpectHaveKey

func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})

ExpectHaveKey expects the actual map has the key in the keyset

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

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 ExpectNotEqual

func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})

ExpectNotEqual expects the specified two are not the same, otherwise an exception raises

func GetNodepool added in v1.7.0

func GetNodepool(ctx context.Context, k8sClient client.Client, name string) (*v1beta2.NodePool, error)

GetNodepool will get the nodepool with the given name

func InitTestNodePool added in v1.7.0

func InitTestNodePool(
	ctx context.Context,
	k8sClient client.Client,
	pool TestNodePool,
) error

InitTestNodePool will create nodepools and add labels to nodes according to the pools

func JSONMarshal added in v1.3.0

func JSONMarshal(o interface{}) []byte

JSONMarshal returns the JSON encoding

func LoadRESTClientConfigFromEnv added in v1.1.0

func LoadRESTClientConfigFromEnv(kubeconfig string) (*restclient.Config, error)

Load restClientConfig from env

func LoadRestConfigAndClientset

func LoadRestConfigAndClientset(kubeconfig string) (*restclient.Config, *clientset.Clientset, error)

LoadRestConfigAndClientset returns rest config and clientset for connecting to kubernetes clusters.

func PrepareNodePoolWithNode added in v1.5.0

func PrepareNodePoolWithNode(ctx context.Context, k8sClient client.Client, nodeName string) error

PrepareNodePoolWithNode will create a edge nodepool named "nodepool-with-node" and add the "openyurt-e2e-test-worker" node to this nodepool. In order for Pods to be successfully deployed in e2e tests, a nodepool with nodes needs to be created

func SetYurtE2eCfg added in v1.1.0

func SetYurtE2eCfg() error

SetYurtE2eCfg for e2e-tests

func WaitForNamespacesDeleted

func WaitForNamespacesDeleted(c clientset.Interface, namespaces []string, timeout time.Duration) error

WaitForNamespacesDeleted waits for the namespaces to be deleted.

Types

type AlreadyExistMatcher added in v1.3.0

type AlreadyExistMatcher struct {
}

AlreadyExistMatcher matches the error to be already exist

func (AlreadyExistMatcher) FailureMessage added in v1.3.0

func (matcher AlreadyExistMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (AlreadyExistMatcher) Match added in v1.3.0

func (matcher AlreadyExistMatcher) Match(actual interface{}) (success bool, err error)

Match matches error.

func (AlreadyExistMatcher) NegatedFailureMessage added in v1.3.0

func (matcher AlreadyExistMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type ErrorMatcher added in v1.3.0

type ErrorMatcher struct {
	ExpectedError error
}

ErrorMatcher matches errors.

func (ErrorMatcher) FailureMessage added in v1.3.0

func (matcher ErrorMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (ErrorMatcher) Match added in v1.3.0

func (matcher ErrorMatcher) Match(actual interface{}) (success bool, err error)

Match matches an error.

func (ErrorMatcher) NegatedFailureMessage added in v1.3.0

func (matcher ErrorMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type NotFoundMatcher added in v1.3.0

type NotFoundMatcher struct {
}

NotFoundMatcher matches the error to be not found.

func (NotFoundMatcher) FailureMessage added in v1.3.0

func (matcher NotFoundMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (NotFoundMatcher) Match added in v1.3.0

func (matcher NotFoundMatcher) Match(actual interface{}) (success bool, err error)

Match matches the api error.

func (NotFoundMatcher) NegatedFailureMessage added in v1.3.0

func (matcher NotFoundMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type TestNodePool added in v1.7.0

type TestNodePool struct {
	NodePool v1beta2.NodePool
	Nodes    sets.Set[string]
}

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