testclient

package
v0.0.0-...-b5cc2e9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package testclient defines an MCS test client with basic checks.

Package util provides utilities for e2e testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustGetBool

func MustGetBool(t *testing.T, u *unstructured.Unstructured, path ...string) (value, set bool)

Note: The functions below can be used in Polling because they are called on paths holding fields that should absolutely be of the specified type. If not, there is a fundamental error in which case we can exit the test immediately instead of telling Poll to err. MustGetBool - returns bool on u at path if set

func MustGetInt64

func MustGetInt64(t *testing.T, u *unstructured.Unstructured, path ...string) (int64, bool)

GetInt - return int64 on u at path if set

func MustGetString

func MustGetString(t *testing.T, u *unstructured.Unstructured, path ...string) (string, bool)

MustGetString - return string on u at path if set

func Poll

func Poll(t *testing.T, op func() error, timeout time.Duration)

Poll - polls for op to return without an error. If op has not executed without error by timeout, Poll fails the test.

Types

type Client

type Client struct {
	T   *testing.T
	Ctx context.Context

	client.Client
	// contains filtered or unexported fields
}

Client - test client of MCS target cluster

func New

func New(ctx context.Context, t *testing.T, config *rest.Config, name, testName string, logRoot string) *Client

func (*Client) ClearOldLogs

func (c *Client) ClearOldLogs()

func (*Client) MustBeReady

func (c *Client) MustBeReady(objs []*unstructured.Unstructured, timeout time.Duration)

MustBeReady - waits for all objs to be available

func (*Client) MustCreate

func (c *Client) MustCreate(u *unstructured.Unstructured, updateAllowed bool)

MustCreate - create object

func (*Client) MustDelete

func (c *Client) MustDelete(u *unstructured.Unstructured)

MustDelete - Delete object if exists

func (*Client) MustExist

func (c *Client) MustExist(objs []*unstructured.Unstructured, timeout time.Duration)

MustExist - waits for all objs to exist

func (*Client) MustHaveCondition

func (c *Client) MustHaveCondition(obj *unstructured.Unstructured, condition *metav1.Condition, timeout time.Duration)

MustHaveCondition - validate if the .status.conditions[] has the condition

func (*Client) MustHaveEvent

func (c *Client) MustHaveEvent(ns, reason, msg string, timeout time.Duration)

func (*Client) MustJSONPatch

func (c *Client) MustJSONPatch(obj *unstructured.Unstructured, patch map[string]any)

MustJSONPatch - applies JSON patch to obj

func (*Client) MustMatchSpec

func (c *Client) MustMatchSpec(objs []*unstructured.Unstructured, timeout time.Duration)

MustMatchSpec - verify specs of objects match objs

func (*Client) MustNotExist

func (c *Client) MustNotExist(objs []*unstructured.Unstructured, timeout time.Duration)

MustNotExist - checks none of objs exists

func (*Client) MustNotHaveCondition

func (c *Client) MustNotHaveCondition(obj *unstructured.Unstructured,
	condition *metav1.Condition, timeout time.Duration)

MustNotHaveCondition - validate if the .status.conditions[] does not have the condition

func (*Client) MustNotHaveEvent

func (c *Client) MustNotHaveEvent(ns, reason, msg string, timeout time.Duration)

func (*Client) Read

Read - read object with obj's gvknn

func (*Client) String

func (c *Client) String() string

func (*Client) WriteContainerLogs

func (c *Client) WriteContainerLogs(namespace, name, container string)

func (*Client) WriteNamespacePodLogs

func (c *Client) WriteNamespacePodLogs(namespace string)

type GVKNN

GVKNN - id for k8s object

func ExtractGVKNN

func ExtractGVKNN(obj client.Object) *GVKNN

ExtractGVKNN - returns GVKNN of obj

func ExtractGVKNNs

func ExtractGVKNNs(objs []*unstructured.Unstructured) []*GVKNN

ExtractGVKNNs - returns GVKNNs of objs

func (*GVKNN) MakeObject

func (id *GVKNN) MakeObject() *unstructured.Unstructured

MakeObject - create object with GVKNN of id

func (*GVKNN) String

func (id *GVKNN) String() string

String - returns GVKNN delimited by "/"

Jump to

Keyboard shortcuts

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