Documentation ¶
Overview ¶
Package helper provides utilities to assist with osde2e testing.
Index ¶
- func AddUserToGroup(ctx context.Context, userName string, groupName string, h *H) (result *userv1.Group, err error)
- func ApplyYamlInFolder(folder, namespace string, kube kubernetes.Interface) ([]runtime.Object, error)
- func CreateNamespace(ctx context.Context, namespace string, h *H) (*kv1.Namespace, error)
- func CreatePod(ctx context.Context, pod *kv1.Pod, namespace string, h *H) error
- func CreateRuntimeObject(obj runtime.Object, ns string, kube kubernetes.Interface) (runtime.Object, error)
- func CreateService(ctx context.Context, svc *kv1.Service, h *H) error
- func CreateUser(ctx context.Context, userName string, identities []string, groups []string, ...) (*userv1.User, error)
- func DeleteNamespace(ctx context.Context, namespace string, waitForDelete bool, h *H) error
- func ReadK8sYaml(file string) (runtime.Object, error)
- func SamplePod(name, namespace, imageName string) *kv1.Pod
- func SampleService(port int32, targetPort int, serviceName, serviceNamespace string, ...) *kv1.Service
- type H
- func (h *H) AddWorkload(name, project string)
- func (h *H) AsClusterAdmin() *resources.Resources
- func (h *H) AsDedicatedAdmin() *resources.Resources
- func (h *H) AsServiceAccount(name string) *resources.Resources
- func (h *H) AsUser(username string, groups ...string) *resources.Resources
- func (h *H) Cfg() config.Interface
- func (h *H) Cleanup(ctx context.Context)
- func (h *H) ConvertTemplateToString(template *template.Template, data interface{}) (string, error)
- func (h *H) CreateClusterRoleBindingInProject(ctx context.Context, saName string, clusterRole string, ...)
- func (h *H) CreateProject(ctx context.Context, name string)
- func (h *H) CreateServiceAccountsInProject(ctx context.Context, project *projectv1.Project) *H
- func (h *H) CurrentProject() string
- func (h *H) DeleteProject(ctx context.Context, name string) error
- func (h *H) Dynamic() dynamic.Interface
- func (h *H) GetClient() *openshift.Client
- func (h *H) GetClusterVersion(ctx context.Context) (*configv1.ClusterVersion, error)
- func (h *H) GetConfig() *rest.Config
- func (h *H) GetGCPCreds(ctx context.Context) (*google.Credentials, bool)
- func (h *H) GetNamespacedServiceAccount() string
- func (h *H) GetRunnerCommandString(templatePath string, timeout int, latestImageStream string, harness string, ...) string
- func (h *H) GetWorkload(name string) (string, bool)
- func (h *H) GetWorkloads() map[string]string
- func (h *H) Image() image.Interface
- func (h *H) Impersonate(user rest.ImpersonationConfig) *H
- func (h *H) InspectOLM(ctx context.Context) error
- func (h *H) InspectState(ctx context.Context)
- func (h *H) Kube() kubernetes.Interface
- func (h *H) Machine() machine.Interface
- func (h *H) OAuth() oauth.Interface
- func (h *H) Operator() operator.Interface
- func (h *H) Project() project.Interface
- func (h *H) Prometheusop() prometheusop.Interface
- func (h *H) Quota() (*quotaclient.Clientset, error)
- func (h *H) REST() *rest.RESTClient
- func (h *H) Route() route.Interface
- func (h *H) Runner(cmd string) *runner.Runner
- func (h *H) RunnerWithNoCommand() *runner.Runner
- func (h *H) Security() security.Interface
- func (h *H) SetPassthruSecretInProject(ctx context.Context, project *projectv1.Project) error
- func (h *H) SetProject(proj *projectv1.Project) *H
- func (h *H) SetProjectByName(ctx context.Context, projectName string) (*H, error)
- func (h *H) SetRunnerCommand(cmd string, r *runner.Runner) *runner.Runner
- func (h *H) SetRunnerProject(project string, r *runner.Runner) *runner.Runner
- func (h *H) SetServiceAccount(ctx context.Context, sa string) *H
- func (h *H) Setup() error
- func (h *H) SetupNewProject(ctx context.Context, suffix string) (*projectv1.Project, error)
- func (h *H) UploadResultsToS3(results map[string][]byte, key string) error
- func (h *H) User() user.Interface
- func (h *H) Velero() velero.Interface
- func (h *H) WaitForEndpointReady(ctx context.Context, svc *kubev1.Service, n int, dur time.Duration) error
- func (h *H) WaitForPodPhase(ctx context.Context, pod *kubev1.Pod, target kubev1.PodPhase, n int, ...) (phase kubev1.PodPhase)
- func (h *H) WaitTimeoutForDaemonSetInNamespace(ctx context.Context, daemonSetName string, namespace string, ...) error
- func (h *H) WaitTimeoutForServiceInNamespace(ctx context.Context, serviceName string, namespace string, ...) error
- func (h *H) WithToken(token string) *H
- func (h *H) WriteResults(results map[string][]byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUserToGroup ¶
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 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 CreateUser ¶
func DeleteNamespace ¶
func ReadK8sYaml ¶
ReadK8sYaml reads a file at the specified path and attempts to decode it into a runtime.Object
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 NewOutsideGinkgo ¶
NewOutsideGinkgo instantiates a helper function while not within a Ginkgo Test Block
func (*H) AddWorkload ¶
AddWorkload uniquely appends a workload to the workloads list
func (*H) AsClusterAdmin ¶
func (*H) AsDedicatedAdmin ¶
func (*H) ConvertTemplateToString ¶
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 ¶
CreateProject returns the project being used for testing.
func (*H) CreateServiceAccountsInProject ¶
CreateServiceAccountsInProject creates a set of serviceaccounts for test usage in given namespace
func (*H) CurrentProject ¶
CurrentProject returns the project being used for testing.
func (*H) DeleteProject ¶
DeleteProject deletes the project provided
func (*H) GetClusterVersion ¶
GetClusterVersion returns the Cluster Version object
func (*H) GetGCPCreds ¶
func (*H) GetNamespacedServiceAccount ¶
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 ¶
GetWorkload takes a workload name and returns true or false depending on if it's installed
func (*H) GetWorkloads ¶
GetWorkloads returns a list of workloads this osde2e run has installed
func (*H) Impersonate ¶
func (h *H) Impersonate(user rest.ImpersonationConfig) *H
Impersonate sets impersonate user headers
func (*H) InspectOLM ¶
InspectOLM inspects the OLM state of the cluster and saves the state to disk for later debugging
func (*H) InspectState ¶
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) 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) Runner ¶
Runner creates an extended test suite runner and configure RBAC for it and runs cmd in it.
func (*H) RunnerWithNoCommand ¶
RunnerWithNoCommand creates an extended test suite runner and configure RBAC for it.
func (*H) SetPassthruSecretInProject ¶
Adds essential secrets to harness namespace to load onto harness pod
func (*H) SetProject ¶
SetProject manually sets the project
func (*H) SetProjectByName ¶
SetProjectByName gets a project by name and sets it for the h.proj attribute
func (*H) SetRunnerCommand ¶
SetRunnerCommand sets given command to a pod runner
func (*H) SetRunnerProject ¶
SetRunnerProject sets namespace for runner pod
func (*H) SetServiceAccount ¶
SetServiceAccount sets the serviceAccount you want all helper commands to run as
func (*H) Setup ¶
Setup configures a *rest.Config using the embedded kubeconfig then sets up a Project for tests to run in.
func (*H) SetupNewProject ¶
SetupNewProject creates new project prefixed with osde2e-. Also creates essential serviceaccounts and rolebindings in the project.
func (*H) UploadResultsToS3 ¶
UploadResultsToS3 dumps runner results into the s3 bucket in given aws session.
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) WriteResults ¶
WriteResults dumps runner results into the ReportDir.