helper

package
v0.0.0-...-17268cf Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 66 Imported by: 1

Documentation

Overview

Package helper provides utilities to assist with osde2e testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUserToGroup

func AddUserToGroup(ctx context.Context, userName string, groupName string, h *H) (result *userv1.Group, err error)

func ApplyYamlInFolder

func ApplyYamlInFolder(folder, namespace string, kube kubernetes.Interface) ([]runtime.Object, error)

ApplyYamlInFolder reads a folder and attempts to create objects in K8s with the yaml

func CreateNamespace

func CreateNamespace(ctx context.Context, namespace string, h *H) (*kv1.Namespace, error)

func CreatePod

func CreatePod(ctx context.Context, pod *kv1.Pod, namespace string, h *H) error

func CreateRuntimeObject

func CreateRuntimeObject(obj runtime.Object, ns string, kube kubernetes.Interface) (runtime.Object, error)

CreateRuntimeObject takes a runtime.Object and attempts to create an object in K8s with it

func CreateService

func CreateService(ctx context.Context, svc *kv1.Service, h *H) error

func CreateUser

func CreateUser(ctx context.Context, userName string, identities []string, groups []string, h *H) (*userv1.User, error)

func DeleteNamespace

func DeleteNamespace(ctx context.Context, namespace string, waitForDelete bool, h *H) error

func ReadK8sYaml

func ReadK8sYaml(file string) (runtime.Object, error)

ReadK8sYaml reads a file at the specified path and attempts to decode it into a runtime.Object

func SamplePod

func SamplePod(name, namespace, imageName string) *kv1.Pod

func SampleService

func SampleService(port int32, targetPort int, serviceName, serviceNamespace string, prometheusName string) *kv1.Service

Types

type H

type H struct {
	ServiceAccount string
	OutsideGinkgo  bool
	// contains filtered or unexported fields
}

H configures clients and sets up and destroys Projects for test isolation.

func Init

func Init() *H

Init is a common helper function to import the run state into Helper

func New

func New() *H

New instantiates a helper function to be used within a Ginkgo Test block

func NewOutsideGinkgo

func NewOutsideGinkgo() (*H, error)

NewOutsideGinkgo instantiates a helper function while not within a Ginkgo Test Block

func (*H) AddWorkload

func (h *H) AddWorkload(name, project string)

AddWorkload uniquely appends a workload to the workloads list

func (*H) AsClusterAdmin

func (h *H) AsClusterAdmin() *resources.Resources

func (*H) AsDedicatedAdmin

func (h *H) AsDedicatedAdmin() *resources.Resources

func (*H) AsServiceAccount

func (h *H) AsServiceAccount(name string) *resources.Resources

func (*H) AsUser

func (h *H) AsUser(username string, groups ...string) *resources.Resources

func (*H) Cfg

func (h *H) Cfg() config.Interface

Cfg return a client for the Config API.

func (*H) Cleanup

func (h *H) Cleanup(ctx context.Context)

Cleanup deletes a Project after tests have been ran.

func (*H) ConvertTemplateToString

func (h *H) ConvertTemplateToString(template *template.Template, data interface{}) (string, error)

ConvertTemplateToString takes a template and uses the provided data interface to construct a command string

func (*H) CreateClusterRoleBindingInProject

func (h *H) CreateClusterRoleBindingInProject(ctx context.Context, saName string, clusterRole string, project *projectv1.Project)

CreateClusterRoleBindingInProject takes an sa (presumably created by us) and applies a clusterRole to it The cr is bound to the given project and, thus, cleaned up when the project gets removed.

func (*H) CreateProject

func (h *H) CreateProject(ctx context.Context, name string)

CreateProject returns the project being used for testing.

func (*H) CreateServiceAccountsInProject

func (h *H) CreateServiceAccountsInProject(ctx context.Context, project *projectv1.Project) *H

CreateServiceAccountsInProject creates a set of serviceaccounts for test usage in given namespace

func (*H) CurrentProject

func (h *H) CurrentProject() string

CurrentProject returns the project being used for testing.

func (*H) DeleteProject

func (h *H) DeleteProject(ctx context.Context, name string) error

DeleteProject deletes the project provided

func (*H) Dynamic

func (h *H) Dynamic() dynamic.Interface

Dynamic returns a client that works on arbitrary types.

func (*H) GetClient

func (h *H) GetClient() *openshift.Client

func (*H) GetClusterVersion

func (h *H) GetClusterVersion(ctx context.Context) (*configv1.ClusterVersion, error)

GetClusterVersion returns the Cluster Version object

func (*H) GetConfig

func (h *H) GetConfig() *rest.Config

func (*H) GetGCPCreds

func (h *H) GetGCPCreds(ctx context.Context) (*google.Credentials, bool)

func (*H) GetNamespacedServiceAccount

func (h *H) GetNamespacedServiceAccount() string

GetNamespacedServiceAccount just gets the name, not the "full name"

func (*H) GetRunnerCommandString

func (h *H) GetRunnerCommandString(templatePath string, timeout int, latestImageStream string, harness string, suffix string, jobName string, serviceAccountDir string, command string, serviceAccountNamespacedName string) string

GetRunnerCommandString Generates templated command string to provide to test harness container

func (*H) GetWorkload

func (h *H) GetWorkload(name string) (string, bool)

GetWorkload takes a workload name and returns true or false depending on if it's installed

func (*H) GetWorkloads

func (h *H) GetWorkloads() map[string]string

GetWorkloads returns a list of workloads this osde2e run has installed

func (*H) Image

func (h *H) Image() image.Interface

Image returns the clientset for images.

func (*H) Impersonate

func (h *H) Impersonate(user rest.ImpersonationConfig) *H

Impersonate sets impersonate user headers

func (*H) InspectOLM

func (h *H) InspectOLM(ctx context.Context) error

InspectOLM inspects the OLM state of the cluster and saves the state to disk for later debugging

func (*H) InspectState

func (h *H) InspectState(ctx context.Context)

InspectState inspects the project used for testing, and saves the state to disk for later debugging

func (*H) Kube

func (h *H) Kube() kubernetes.Interface

Kube returns the clientset for Kubernetes upstream.

func (*H) Machine

func (h *H) Machine() machine.Interface

Machine returns the clientset for openshift-machine-api

func (*H) OAuth

func (h *H) OAuth() oauth.Interface

OAuth returns the clientset for oauth resources

func (*H) Operator

func (h *H) Operator() operator.Interface

Operator returns the clientset for operator-lifecycle-manager

func (*H) Project

func (h *H) Project() project.Interface

Project returns the clientset for projects.

func (*H) Prometheusop

func (h *H) Prometheusop() prometheusop.Interface

Monitoring returns the clientset for prometheus-operator

func (*H) Quota

func (h *H) Quota() (*quotaclient.Clientset, error)

Quota returns the client for Quota operations.

func (*H) REST

func (h *H) REST() *rest.RESTClient

REST returns a client for generic operations.

func (*H) Route

func (h *H) Route() route.Interface

Route returns the clientset for routing.

func (*H) Runner

func (h *H) Runner(cmd string) *runner.Runner

Runner creates an extended test suite runner and configure RBAC for it and runs cmd in it.

func (*H) RunnerWithNoCommand

func (h *H) RunnerWithNoCommand() *runner.Runner

RunnerWithNoCommand creates an extended test suite runner and configure RBAC for it.

func (*H) Security

func (h *H) Security() security.Interface

Security returns the clientset for Security objects.

func (*H) SetPassthruSecretInProject

func (h *H) SetPassthruSecretInProject(ctx context.Context, project *projectv1.Project) error

Adds essential secrets to harness namespace to load onto harness pod

func (*H) SetProject

func (h *H) SetProject(proj *projectv1.Project) *H

SetProject manually sets the project

func (*H) SetProjectByName

func (h *H) SetProjectByName(ctx context.Context, projectName string) (*H, error)

SetProjectByName gets a project by name and sets it for the h.proj attribute

func (*H) SetRunnerCommand

func (h *H) SetRunnerCommand(cmd string, r *runner.Runner) *runner.Runner

SetRunnerCommand sets given command to a pod runner

func (*H) SetRunnerProject

func (h *H) SetRunnerProject(project string, r *runner.Runner) *runner.Runner

SetRunnerProject sets namespace for runner pod

func (*H) SetServiceAccount

func (h *H) SetServiceAccount(ctx context.Context, sa string) *H

SetServiceAccount sets the serviceAccount you want all helper commands to run as

func (*H) Setup

func (h *H) Setup() error

Setup configures a *rest.Config using the embedded kubeconfig then sets up a Project for tests to run in.

func (*H) SetupNewProject

func (h *H) SetupNewProject(ctx context.Context, suffix string) (*projectv1.Project, error)

SetupNewProject creates new project prefixed with osde2e-. Also creates essential serviceaccounts and rolebindings in the project.

func (*H) UploadResultsToS3

func (h *H) UploadResultsToS3(results map[string][]byte, key string) error

UploadResultsToS3 dumps runner results into the s3 bucket in given aws session.

func (*H) User

func (h *H) User() user.Interface

User returns the clientset for users

func (*H) Velero

func (h *H) Velero() velero.Interface

Velero returns the clientset for Velero objects.

func (*H) WaitForEndpointReady

func (h *H) WaitForEndpointReady(ctx context.Context, svc *kubev1.Service, n int, dur time.Duration) error

WaitForEndpointReady until Endpoint for svc is ready, checking n times and sleeping dur between them.

func (*H) WaitForPodPhase

func (h *H) WaitForPodPhase(ctx context.Context, pod *kubev1.Pod, target kubev1.PodPhase, n int, dur time.Duration) (phase kubev1.PodPhase)

WaitForPodPhase until in target, checking n times and sleeping dur between them. Last known phase is returned.

func (*H) WaitTimeoutForDaemonSetInNamespace

func (h *H) WaitTimeoutForDaemonSetInNamespace(ctx context.Context, daemonSetName string, namespace string, timeout time.Duration, poll time.Duration) error

WaitTimeoutForDaemonSetInNamespace waits the given timeout duration for the specified ds.

func (*H) WaitTimeoutForServiceInNamespace

func (h *H) WaitTimeoutForServiceInNamespace(ctx context.Context, serviceName string, namespace string, timeout time.Duration, poll time.Duration) error

WaitTimeoutForServiceInNamespace waits the given timeout duration for the specified service.

func (*H) WithToken

func (h *H) WithToken(token string) *H

WithToken returns helper with a given bearer token

func (*H) WriteResults

func (h *H) WriteResults(results map[string][]byte)

WriteResults dumps runner results into the ReportDir.

Jump to

Keyboard shortcuts

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