framework

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCSIRule = rbacv1.PolicyRule{
		APIGroups: []string{"csi.aliyun.com"},
		Resources: []string{
			"nodelocalstorages",
			"nodelocalstorages/status",
			"nodelocalstorageinitconfigs",
		},
		Verbs: []string{
			"create",
			"get",
			"list",
			"watch",
			"update",
			"delete",
			"patch",
		},
	}

	DefaultEventsRule = rbacv1.PolicyRule{
		APIGroups: []string{""},
		Resources: []string{"events"},
		Verbs:     []string{"create", "update", "patch"},
	}

	DefaultCoreRule = rbacv1.PolicyRule{
		APIGroups: []string{""},
		Resources: []string{
			"nodes",
			"pods",
			"pods/binding",
			"pods/status",
			"bindings",
			"persistentvolumeclaims",
			"persistentvolumeclaims/status",
			"persistentvolumes",
			"persistentvolumes/status",
			"namespaces",
			"secrets",
		},
		Verbs: []string{"create", "get", "list", "watch", "update", "delete", "patch"},
	}

	DefaultStorageRule = rbacv1.PolicyRule{
		APIGroups: []string{"storage.k8s.io"},
		Resources: []string{
			"storageclasses",
			"csinodes",
			"volumeattachments",
		},
		Verbs: []string{"get", "list", "watch"},
	}

	DefaultSnapshotRule = rbacv1.PolicyRule{
		APIGroups: []string{"snapshot.storage.k8s.io"},
		Resources: []string{
			"volumesnapshotclasses",
			"volumesnapshots",
			"volumesnapshots/status",
			"volumesnapshotcontents",
			"volumesnapshotcontents/status",
		},
		Verbs: []string{"create", "get", "list", "watch", "update", "delete", "patch"},
	}

	DefaultCoordinationRule = rbacv1.PolicyRule{
		APIGroups: []string{"coordination.k8s.io"},
		Resources: []string{
			"leases",
		},
		Verbs: []string{"create", "get", "list", "watch", "update", "delete", "patch"},
	}
)

Functions

func MakeDaemonSet

func MakeDaemonSet(source string) (*appsv1.DaemonSet, error)

func MakeDeployment

func MakeDeployment(source string) (*appsv1.Deployment, error)

func MakeJob

func MakeJob(source string) (*batchv1.Job, error)

func PathToOSFile

func PathToOSFile(relativePath string) (*os.File, error)

func SourceToIOReader

func SourceToIOReader(source string) (io.Reader, error)

func StartPortForward

func StartPortForward(ctx context.Context, config *rest.Config, scheme string, name string, ns string, port string) (func(), error)

func URLToIOReader

func URLToIOReader(url string) (io.Reader, error)

Types

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 FinalizerFn

type FinalizerFn func() error

type Framework

type Framework struct {
	KubeClient      kubernetes.Interface
	APIServerClient apiclient.Interface
	HTTPClient      *http.Client
	MasterHost      string
	DefaultTimeout  time.Duration
	RestConfig      *rest.Config
	Image           string
	Version         semver.Version
	// contains filtered or unexported fields
}

func New

func New(kubeconfig, image, exampleDir, resourcesDir string, version semver.Version) (*Framework, error)

New setups a test framework and returns it.

func (*Framework) AddLabelsToNamespace

func (f *Framework) AddLabelsToNamespace(ctx context.Context, name string, additionalLabels map[string]string) error

func (*Framework) CreateDaemonSet

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

func (*Framework) CreateDeployment

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

func (*Framework) CreateJob

func (f *Framework) CreateJob(ctx context.Context, namespace string, job *batchv1.Job) error

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(ctx context.Context, t *testing.T, testCtx *TestCtx) string

func (*Framework) CreateOrUpdateCSIDriver

func (f *Framework) CreateOrUpdateCSIDriver(ctx context.Context, source string) (*storagev1.CSIDriver, error)

func (*Framework) CreateOrUpdateClusterRole

func (f *Framework) CreateOrUpdateClusterRole(ctx context.Context, source string) (*rbacv1.ClusterRole, error)

func (*Framework) CreateOrUpdateDaemonSetAndWaitUntilReady

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

func (*Framework) CreateOrUpdateDeploymentAndWaitUntilReady

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

func (*Framework) CreateOrUpdateJobAndWaitUntilReady

func (f *Framework) CreateOrUpdateJobAndWaitUntilReady(ctx context.Context, namespace string, job *batchv1.Job) error

func (*Framework) CreateOrUpdateStorageClass

func (f *Framework) CreateOrUpdateStorageClass(ctx context.Context, source string) (*storagev1.StorageClass, error)

func (*Framework) DeleteCSIDriver

func (f *Framework) DeleteCSIDriver(ctx context.Context, source string) error

func (*Framework) DeleteClusterRole

func (f *Framework) DeleteClusterRole(ctx context.Context, source string) error

func (*Framework) DeleteClusterRoleBinding

func (f *Framework) DeleteClusterRoleBinding(ctx context.Context, ns string, source string) error

func (*Framework) DeleteDaemonSet

func (f *Framework) DeleteDaemonSet(ctx context.Context, namespace, name string) error

func (*Framework) DeleteDeployment

func (f *Framework) DeleteDeployment(ctx context.Context, namespace, name string) error

func (*Framework) DeleteJob

func (f *Framework) DeleteJob(ctx context.Context, namespace, name string) error

func (*Framework) DeleteNamespace

func (f *Framework) DeleteNamespace(ctx context.Context, name string) error

func (*Framework) DeleteStorageClass

func (f *Framework) DeleteStorageClass(ctx context.Context, source string) error

func (*Framework) ExecWithOptions

func (f *Framework) ExecWithOptions(ctx context.Context, options ExecOptions) (string, string, error)

ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed. Inspired by https://github.com/kubernetes/kubernetes/blob/dde6e8e7465468c32642659cb708a5cc922add64/test/e2e/framework/exec_util.go#L36-L51

func (*Framework) GetCSIDriver

func (f *Framework) GetCSIDriver(ctx context.Context, name string) (*storagev1.CSIDriver, error)

func (*Framework) GetDaemonSet

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

func (*Framework) GetDeployment

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

func (*Framework) GetJob

func (f *Framework) GetJob(ctx context.Context, ns, name string) (*batchv1.Job, error)

func (*Framework) GetPodRestartCount

func (f *Framework) GetPodRestartCount(ctx context.Context, ns, podName string) (map[string]int32, error)

GetPodRestartCount returns a map of container names and their restart counts for a given pod.

func (*Framework) GetStorageClass

func (f *Framework) GetStorageClass(ctx context.Context, name string) (*storagev1.StorageClass, error)

func (*Framework) NewTestCtx

func (f *Framework) NewTestCtx(t *testing.T) *TestCtx

func (*Framework) PrintEvents

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

func (*Framework) PrintPodLogs

func (f *Framework) PrintPodLogs(ctx context.Context, ns, p string) error

func (*Framework) RemoveLabelsFromNamespace

func (f *Framework) RemoveLabelsFromNamespace(ctx context.Context, name string, labels ...string) error

func (*Framework) UpdateCSIDriver

func (f *Framework) UpdateCSIDriver(ctx context.Context, csiDriver *storagev1.CSIDriver) error

func (*Framework) UpdateClusterRole

func (f *Framework) UpdateClusterRole(ctx context.Context, clusterRole *rbacv1.ClusterRole) error

func (*Framework) UpdateDaemonSet

func (f *Framework) UpdateDaemonSet(ctx context.Context, daemonset *appsv1.DaemonSet) (*appsv1.DaemonSet, error)

func (*Framework) UpdateDeployment

func (f *Framework) UpdateDeployment(ctx context.Context, deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func (*Framework) UpdateJob

func (f *Framework) UpdateJob(ctx context.Context, job *batchv1.Job) (*batchv1.Job, error)

func (*Framework) UpdateStorageClass

func (f *Framework) UpdateStorageClass(ctx context.Context, storageClass *storagev1.StorageClass) error

func (*Framework) WaitForDaemonSetReady

func (f *Framework) WaitForDaemonSetReady(ctx context.Context, namespace, daemonsetName string, expectedGeneration int64) error

func (*Framework) WaitForDeploymentReady

func (f *Framework) WaitForDeploymentReady(ctx context.Context, namespace, deploymentName string, expectedGeneration int64) error

func (*Framework) WaitForJobReady

func (f *Framework) WaitForJobReady(ctx context.Context, namespace, jobName string, expectedGeneration int32) error

func (*Framework) WaitUntilDaemonSetGone

func (f *Framework) WaitUntilDaemonSetGone(ctx context.Context, _ kubernetes.Interface, namespace, name string, timeout time.Duration) error

func (*Framework) WaitUntilDeploymentGone

func (f *Framework) WaitUntilDeploymentGone(ctx context.Context, _ kubernetes.Interface, namespace, name string, timeout time.Duration) error

func (*Framework) WaitUntilJobGone

func (f *Framework) WaitUntilJobGone(ctx context.Context, _ kubernetes.Interface, namespace, name string, timeout time.Duration) error

type TestCtx

type TestCtx struct {
	// contains filtered or unexported fields
}

func (*TestCtx) AddFinalizerFn

func (ctx *TestCtx) AddFinalizerFn(fn FinalizerFn)

func (*TestCtx) Cleanup

func (ctx *TestCtx) Cleanup(t *testing.T)

func (*TestCtx) ID

func (ctx *TestCtx) ID() string

Jump to

Keyboard shortcuts

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