const ( ResourceTypeDeployment = "deployment" ResourceTypePod = "pod" ResourceTypeJob = "job" ResourceTypePVC = "pvc" ResourceTypeService = "service" )
const ( LabelNoCluster = "nocluster" LabelUnauth = "unauth" LabelPodman = "podman" LabelServiceBinding = "servicebinding" LabelSkipOnOpenShift = "skiponopenshift" )
const (
DebugTelemetryFileEnv = "ODO_DEBUG_TELEMETRY_FILE"
)
const (
TelemetryCaller = "TELEMETRY_CALLER"
)
DevfileCommandGroupUpdater updates the group definition of the specified command. It returns an error if the command was not found in the Devfile, or if there are multiple commands with the same name and type.
var DevfileCommandGroupUpdater = func(cmdName string, cmdType v1alpha2.CommandType, group *v1alpha2.CommandGroup) DevfileUpdater { return func(d *parser.DevfileObj) error { cmds, err := d.Data.GetCommands(parsercommon.DevfileOptions{ CommandOptions: parsercommon.CommandOptions{ CommandType: cmdType, }, FilterByName: cmdName, }) if err != nil { return err } if len(cmds) != 1 { return fmt.Errorf("found %v command(s) with name %q", len(cmds), cmdName) } cmd := cmds[0] switch cmdType { case v1alpha2.ApplyCommandType: cmd.Apply.Group = group case v1alpha2.CompositeCommandType: cmd.Composite.Group = group case v1alpha2.CustomCommandType: cmd.Custom.Group = group case v1alpha2.ExecCommandType: cmd.Exec.Group = group default: return fmt.Errorf("command type not handled: %q", cmdType) } return nil } }
DevfileMetadataNameRemover removes the 'metadata.name' field from the given Devfile
var DevfileMetadataNameRemover = DevfileMetadataNameSetter("")
DevfileMetadataNameSetter sets the 'metadata.name' field into the given Devfile
var DevfileMetadataNameSetter = func(name string) DevfileUpdater { return func(d *parser.DevfileObj) error { return d.SetMetadataName(name) } }
func AppendToFile(filepath string, s string) error
func Chdir(dir string)
Chdir change current working dir
func ClearTelemetryFile()
func CmdRunner(program string, args ...string) *gexec.Session
func CommonAfterEach(commonVar CommonVar)
CommonAfterEach is common function that cleans up after every test Spec (It)
func CopyExample(exampleName string, targetDir string)
CopyExample copies an example from tests/examples/<binaryOrSource>/<componentName>/<exampleName> into targetDir
func CopyExampleDevFile(devfilePath, targetDst string, newName string, updaters ...DevfileUpdater)
CopyExampleDevFile copies an example devfile from tests/examples/source/devfiles/<componentName>/devfile.yaml into targetDst. If newName is not empty, it will replace the component name in the target Devfile. The Devfile updaters allow to perform operations against the target Devfile, like removing the component name (via DevfileMetadataNameRemover).
func CopyManifestFile(fileName, targetDst string)
func CreateFileWithContent(path string, fileContent string) error
CreateFileWithContent creates a file at the given path and writes the given content path is the path to the required file fileContent is the content to be written to the given file
func CreateFileWithContentAndPerm(path string, fileContent string, perm os.FileMode) error
CreateFileWithContentAndPerm creates a file at the given path using the given file permissions, and writes the given content. path is the path to the required file fileContent is the content to be written to the given file
func CreateInvalidDevfile(dir string)
func CreateLocalEnv(context, compName, projectName string)
CreateLocalEnv creates a .odo/env/env.yaml file Useful for commands that require this file and cannot create one on their own, for e.g. url, list
func CreateNewContext() string
CreateNewContext create new empty temporary directory
func CreateRandProject() string
CreateRandProject create new project with random name (10 letters) without writing to the config file (without switching project)
func CreateSimpleFile(context, filePrefix, fileExtension string) (string, string)
CreateSimpleFile creates a simple file return the file path with random string
func DeleteDir(dir string)
DeleteDir deletes the specified path; due to Windows behaviour (for example https://github.com/redhat-developer/odo/issues/3371) where Windows temporarily holds a lock on files and folders, we keep trying to delete until the operation passes (or it expires)
func DeleteFile(filepath string)
DeleteFile deletes file
func DeleteInvalidDevfile(dir string)
func DeleteProject(projectName string)
DeleteProject deletes a specified project
func DontMatchAllInOutput(output string, tonotmatch []string)
DontMatchAllInOutput ensures all strings are not in output
func EnableExperimentalMode()
EnableExperimentalMode enables the experimental mode, so that experimental features of odo can be used.
func EnableTelemetryDebug() preference.Client
EnableTelemetryDebug creates a temp file to use for debugging telemetry. it also sets up envs and cfg for the same
func ExpectString(ctx InteractiveContext, line string)
func ExtractK8sAndOcComponentsFromOutputOnPodman(out string) []string
ExtractK8sAndOcComponentsFromOutputOnPodman extracts the list of Kubernetes and OpenShift components from the "odo" output on Podman.
func ExtractLines(output string) ([]string, error)
ExtractLines returns all lines of the given `output` string
func FileShouldContainSubstring(file string, subString string)
FileShouldContainSubstring check if file contains subString
func FileShouldNotContainSubstring(file string, subString string)
FileShouldNotContainSubstring check if file does not contain subString
func FindFirstElementIndexByPredicate(slice []string, predicate func(string) bool) (int, bool)
FindFirstElementIndexByPredicate returns the index of the first element in `slice` that satisfies the given `predicate`.
func FindFirstElementIndexMatchingRegExp(slice []string, regularExpression string) (int, bool)
FindFirstElementIndexMatchingRegExp returns the index of the first element in `slice` that contains any match of the given regular expression `regularExpression`.
func GenerateAndSetContainersConf(dir string)
func GenerateDelayedPodman(commonVarContext string, delaySecond int) string
GenerateDelayedPodman returns a podman cmd that sleeps for delaySecond before responding; this function is usually used in combination with PODMAN_CMD_INIT_TIMEOUT odo preference
func GenerateProjectName() string
GenerateProjectName generates a new projectName based on the name of the test file name (without path and replacing _ with -), line number of current ginkgo execution, and a random string of 3 letters
func GetAnnotationsDeployment(path, componentName, appName, projectName string) map[string]string
GetAnnotationsDeployment gets the annotations from the deployment belonging to the given component, app and project
func GetCustomStartPort() int
GetCustomStartPort returns a port that can be used as starting value for custom port mapping. Because of the way Ginkgo runs specs in parallel (by isolating them in different processes), this function needs to be called in a Before* node or test spec. It returns a starting value that aims at minimizing the probability of collisions. Callers can then safely increment the returned value in their specs if needed.
func GetDebugTelemetryFile() string
func GetDevfileComponents(devfilePath, componentName string) []v1alpha2.Component
func GetEnvFromEntry(path string, componentName string, appName string, projectName string) string
GetEnvFromEntry returns envFrom entry of the deployment
func GetEnvRefNames(path, componentName, appName, projectName string) []string
GetEnvRefNames gets the ref values from the envFroms of the deployment belonging to the given data
func GetExamplePath(args ...string) string
func GetFirstProcess() int
func GetMDXContent(filePath string) (mdxContent string)
GetMDXContent reads the content of MDX files, strips it of extra spaces and returns the string it strips the extra space for an easy comparison
func GetMetadataFromDevfile(devfilePath string) devfilepkg.DevfileMetadata
GetMetadataFromDevfile retrieves the metadata from devfile
func GetOdoVersion() (version string, gitCommit string)
func GetPodmanVersion() string
Returns version of installed podman
func GetPreferenceValue(key string) string
GetPreferenceValue a global config value of given key or returns an empty string if value is not set
func GetSecrets(path, project string) string
GetSecrets gets all the secrets belonging to the project
func GetTelemetryDebugData() segment.TelemetryData
GetTelemetryDebugData gets telemetry data dumped into temp file for testing/debugging
func GetUserHomeDir() string
GetUserHomeDir gets the user home directory
func GetVersions(registryName string, stackName string) []string
GetVersions returns the list of all versions for the given stack name in the given Devfile registry. It uses the "odo registry" command to find out this information.
The registry name is optional, and defaults to DefaultDevfileRegistry if not set.
func GetVolumeNamesFromDeployment(path, componentName, appName, projectName string) map[string]string
GetVolumeNamesFromDeployment gets the volumes from the deployment belonging to the given data
func Getwd() string
Getwd returns current working dir
func HasAtLeastTwoVersions(registryName string, stackName string) bool
HasAtLeastTwoVersions returns whether the given stack in the given Devfile registry has at least two versions. This is useful to determine if the "Select version" prompt will be displayed in the interactive "odo init" tests. Otherwise, "odo init" would just skip this "Select version" prompt if the stack selected has no version or only a single one.
Note that the registry name is optional, and defaults to DefaultDevfileRegistry if not set.
func HttpWaitForWithStatus(url string, match string, maxRetry int, interval int, expectedCode int)
HttpWaitForWithStatus periodically (every interval) calls GET to given url ends when result response contains match string and status code, or after the maxRetry
func IsAuth(labels []string) bool
func IsJSON(s string) bool
IsJSON returns true if a string is in json format
func IsKubernetesCluster() bool
func JsonPathContentContain(json string, path string, value string)
JsonPathContentContain expects that the content of the path to contain value
func JsonPathContentHasLen(json string, path string, len int)
func JsonPathContentIs(json string, path string, value string)
JsonPathContentIs expects that the content of the path to equal value
func JsonPathContentIsValidUserPort(json string, path string)
func JsonPathDoesNotExist(json string, path string)
JsonPathDoesNotExist expects that the content of the path does not exist in the JSON string
func JsonPathExist(json string, path string)
JsonPathExist expects that the content of the path exists in the JSON string
func JsonPathSatisfiesAll(json string, path string, matchers ...types.GomegaMatcher)
JsonPathSatisfiesAll expects content of the path to satisfy all the matchers passed to it
func LabelPodmanIf(value bool, args ...interface{}) []interface{}
func ListFilesInDir(directoryName string) []string
ListFilesInDir lists all the files in the directory directoryName is the name of the directory
func LocalKubeconfigSet(context string)
LocalKubeconfigSet sets the KUBECONFIG to the temporary config file
func MakeDir(dir string)
MakeDir creates a new dir
func MatchAllInOutput(output string, tomatch []string)
MatchAllInOutput ensures all strings are in output
func NeedsCluster(labels []string) bool
func NeedsPodman(labels []string) bool
func PressKey(ctx InteractiveContext, c byte)
func RandString(n int) string
RandString returns a random string of given length
func ReadFile(filePath string) (string, error)
ReadFile reads the file from the filePath
func ReadRawDevfile(devfilePath string) parser.DevfileObj
ReadRawDevfile parses and validates the Devfile specified and returns its raw content.
func ReplaceAllForwardedPorts(docString string, cmdEndpointsMap map[string]string, mdxEndpointsMap map[string]string) (returnString string)
ReplaceAllForwardedPorts replaces the actual endpoints in cmd out with the ones in mdx out
func ReplaceAllTimeInString(docString string, timeString string) string
ReplaceAllTimeInString replaces the time taken to download a Devfile or a starter project for an odo command with a custom value; this function is helpful because the time value is variable and replacing it with the value in mdx content helps in comparing.
func ReplaceRegistryUrl(commonVar CommonVar, docString string) string
ReplaceRegistryUrl replaces the registry URL used for testing by a more static one
func ReplaceString(filename string, oldString string, newString string)
ReplaceString replaces oldString with newString in text file
func ReplaceStrings(filename string, oldStrings []string, newStrings []string)
ReplaceStrings replaces oldStrings with newStrings in text file two arrays must be of same length, else will fail
func ResetExperimentalMode()
ResetExperimentalMode disables the experimental mode.
Note that calling any experimental feature of odo right is expected to error out if experimental mode is not enabled.
func ResetTelemetry()
ResetTelemetry resets the telemetry back to original values
func RunDevMode(options DevSessionOpts, inside func(session *gexec.Session, outContents string, errContents string, ports map[string]string)) error
RunDevMode runs a dev session and executes the `inside` code when the dev mode is completely started The inside handler is passed the internal session pointer, the contents of the standard and error outputs, and a slice of strings - ports - giving the redirections in the form localhost:<port_number> to access ports opened by component
func RunInteractive(command []string, env []string, tester Tester) (string, error)
RunInteractive runs the command in interactive mode and returns the output, and error. It takes command as array of strings, and a function `tester` that contains steps to run the test as an argument. The command is executed as a separate process, the environment of which is controlled via the `env` argument. The initial value of the sub-process environment is a copy of the environment of the current process. If `env` is not `nil`, it will be appended to the end of the sub-process environment. If there are duplicate environment keys, only the last value in the slice for each duplicate key is used.
func RunTestSpecs(t *testing.T, description string)
RunTestSpecs defines a common way how test specs in test suite are executed
func RunWithExponentialBackoff(fxn func() error, maxDelayInSeconds int, expireDuration time.Duration) error
RunWithExponentialBackoff keeps trying to run 'fxn' until it no longer returns an error; if the function never succeeded, then the most recent error is returned.
func SendLine(ctx InteractiveContext, line string)
func SetDefaultDevfileRegistry(commonVar *CommonVar)
func StripAnsi(docString string) (returnString string)
StripAnsi strips the cmd out of ansi values used for fomatting(underline, colored line, etc.) the cmd out; this function should be called before StripSpinner for better results and is essential because mdx content does not support ansi The regex used by this function is copied from https://github.com/acarl005/stripansi/
func StripGitCommitFromVersion(docString string) string
StripGitCommitFromVersion removes any git commit hash from the full odo version string. For example, given a version string like "vX.Y.Z (6721c668b)", it will simply return "vX.Y.Z"
func StripInteractiveQuestion(docString string) (returnString string)
StripInteractiveQuestion strips the extra output from interactive questions, leaving the final output e.g. "? Is this correct? (Y/n) No? Is this correct? No"
func StripSpinner(docString string) (returnString string)
StripSpinner strips the cmd out string of spaces, spinner statements and spinner frames
func Unindented(jsonStr string) (string, error)
Unindented returns the unindented version of the jsonStr passed to it
func UpdateDevfileContent(path string, handlers []DevfileUpdater)
UpdateDevfileContent parses the Devfile at the given path, then updates its content using the given handlers, and writes the updated Devfile to the given path.
The handlers are invoked in the order they are provided.
No operation is performed if no handler function is specified.
See DevfileMetadataNameRemover for an example of handler function that can operate on the Devfile content.
func VerifyContainerSyncEnv(podName, containerName, namespace, projectSourceValue, projectsRootValue string, cliRunner CliRunner)
VerifyContainerSyncEnv verifies the sync env in the container
func VerifyFileExists(filename string) bool
VerifyFileExists receives a path to a file, and returns whether or not it points to an existing file
func WaitAndCheckForTerminatingState(path, resourceType, namespace string, timeoutMinutes int) bool
WaitAndCheckForTerminatingState waits for the given interval and checks if the given resource type has been deleted on the cluster or is in the terminating state path is the path to the program's binary
func WaitAppReadyInContainer( cmp Component, container string, cmd []string, pollingInterval time.Duration, timeout time.Duration, stdoutMatcher types.GomegaMatcher, stderrMatcher types.GomegaMatcher, )
WaitAppReadyInContainer probes the remote container using the specified command (cmd). It waits until the specified timeout is reached or until the provided matchers match the remote command output. At least one of the matchers must be provided.
func WaitForCmdOut(program string, args []string, timeoutInMinutes int, errOnFail bool, check func(output string) bool, includeStdErr ...bool) bool
WaitForCmdOut runs a command until it gets the expected output. It accepts 5 arguments, program (program to be run) args (arguments to the program) timeoutInMinutes (the time to wait for the output) errOnFail (flag to set if test should fail if command fails) check (function with output check logic) It times out if the command doesn't fetch the expected output within the timeout period.
func WaitForErroutToContain(substring string, timeoutInSeconds int, intervalInSeconds int, session *gexec.Session)
WaitForErroutToContain waits for the session stdout output to contain a particular substring if the session exits, it checks for the substring and returns early
func WaitForOutputToContain(substring string, timeoutInSeconds int, intervalInSeconds int, session *gexec.Session)
WaitForOutputToContain waits for the session stdout output to contain a particular substring; if the session exits, it checks for the substring and returns early
func WaitForOutputToContainOne(substrings []string, timeoutInSeconds int, intervalInSeconds int, session *gexec.Session)
CliRunner requires functions which are common for oc and kubectl By abstracting these functions into an interface, it handles the cli runner and calls the functions specified to particular cluster only
type CliRunner interface { Run(args ...string) *gexec.Session ExecListDir(podName string, projectName string, dir string) string // Exec executes the command in the specified pod and project/namespace. // If expectedSuccess is nil, the command is just supposed to run, with no assertion on its exit code. // If *expectedSuccess is true, the command exit code is expected to be 0. // If *expectedSuccess is false, the command exit code is expected to be non-zero. Exec(podName string, projectName string, args []string, expectedSuccess *bool) (string, string) CheckCmdOpInRemoteDevfilePod(podName string, containerName string, prjName string, cmd []string, checkOp func(cmdOp string, err error) bool) bool GetRunningPodNameByComponent(compName string, namespace string) string GetJobNameByComponent(compName string, namespace string) string GetVolumeMountNamesandPathsFromContainer(deployName string, containerName, namespace string) string WaitAndCheckForExistence(resourceType, namespace string, timeoutMinutes int) bool GetServices(namespace string) string CreateAndSetRandNamespaceProject() string CreateAndSetRandNamespaceProjectOfLength(i int) string SetProject(namespace string) string // DeleteNamespaceProject deletes the specified namespace or project, optionally waiting until it is gone DeleteNamespaceProject(projectName string, wait bool) DeletePod(podName string, projectName string) GetAllNamespaceProjects() []string GetNamespaceProject() string // HasNamespaceProject returns whether the specified namespace or project exists in the cluster HasNamespaceProject(name string) bool // ListNamespaceProject checks if the namespace is present in the list of namespaces ListNamespaceProject(name string) GetActiveNamespace() string GetEnvsDevFileDeployment(componentName, appName, projectName string) map[string]string GetEnvRefNames(componentName, appName, projectName string) []string GetPVCSize(compName, storageName, namespace string) string GetAllPVCNames(namespace string) []string GetPodInitContainers(compName, namespace string) []string GetContainerEnv(podName, containerName, namespace string) string WaitAndCheckForTerminatingState(resourceType, namespace string, timeoutMinutes int) bool VerifyResourceDeleted(ri ResourceInfo) VerifyResourceToBeDeleted(ri ResourceInfo) GetAnnotationsDeployment(cmpName, appName, projectName string) map[string]string GetAllPodsInNs(namespace string) string WaitForRunnerCmdOut(args []string, timeout int, errOnFail bool, check func(output string) bool, includeStdErr ...bool) bool PodsShouldBeRunning(project string, regex string) CreateSecret(secretName, secretPass, project string) GetSecrets(project string) string GetEnvFromEntry(componentName string, appName string, projectName string) string GetVolumeNamesFromDeployment(componentName, appName, projectName string) map[string]string ScalePodToZero(componentName, appName, projectName string) GetAllPodNames(namespace string) []string EnsureOperatorIsInstalled(partialOperatorName string) GetBindableKinds() (string, string) GetServiceBinding(name, projectName string) (string, string) GetLogs(podName string) string AssertContainsLabel(kind, namespace, componentName, appName, mode, key, value string) AssertNoContainsLabel(kind, namespace, componentName, appName, mode, key string) EnsurePodIsUp(namespace, podName string) AssertNonAuthenticated() GetVersion() string SetLabelsOnNamespace(ns string, labelValues ...string) }
func GetCliRunner() CliRunner
GetCliRunner gets the running cli against Kubernetes or OpenShift
ClusterComponent is an abstraction for a Devfile Component deployed on a cluster (either Kubernetes or OpenShift)
type ClusterComponent struct {
// contains filtered or unexported fields
}
func NewClusterComponent(name string, app string, mode string, namespace string, cli CliRunner) *ClusterComponent
func (o *ClusterComponent) Exec(container string, args []string, expectedSuccess *bool) (string, string)
func (o *ClusterComponent) ExpectIsDeployed()
func (o *ClusterComponent) ExpectIsNotDeployed()
func (o *ClusterComponent) GetAnnotations() map[string]string
func (o *ClusterComponent) GetEnvVars(string) map[string]string
func (o *ClusterComponent) GetJobDef() *batchv1.Job
func (o *ClusterComponent) GetLabels() map[string]string
func (o *ClusterComponent) GetPodDef() *corev1.Pod
func (o *ClusterComponent) GetPodLogs() string
type CmdWrapper struct { Cmd *exec.Cmd // contains filtered or unexported fields }
func Cmd(program string, args ...string) *CmdWrapper
func (cw *CmdWrapper) AddEnv(args ...string) *CmdWrapper
func (cw *CmdWrapper) Err() string
func (cw *CmdWrapper) Out() string
func (cw *CmdWrapper) OutAndErr() (string, string)
func (cw *CmdWrapper) Runner() *CmdWrapper
func (cw *CmdWrapper) Should(f func(session *gexec.Session))
func (cw *CmdWrapper) ShouldFail() *CmdWrapper
func (cw *CmdWrapper) ShouldPass() *CmdWrapper
func (cw *CmdWrapper) ShouldRun() *CmdWrapper
func (cw *CmdWrapper) WithEnv(args ...string) *CmdWrapper
func (cw *CmdWrapper) WithRetry(maxRetry int, intervalSeconds time.Duration) *CmdWrapper
func (cw *CmdWrapper) WithTerminate(timeoutAfter time.Duration, stop chan bool) *CmdWrapper
func (cw *CmdWrapper) WithTimeout(timeoutAfter time.Duration) *CmdWrapper
func (cw *CmdWrapper) WithWorkingDir(dir string) *CmdWrapper
type CommonVar struct { // Project is new clean project/namespace for each test Project string // Context is a new temporary directory Context string // ConfigDir is a new temporary directory ConfigDir string // CliRunner is program command (oc or kubectl runner) according to cluster CliRunner CliRunner // original values to get restored after the test is done OriginalWorkingDirectory string OriginalKubeconfig string // contains filtered or unexported fields }
func CommonBeforeEach() CommonVar
CommonBeforeEach is common function runs before every test Spec (It) returns CommonVar values that are used within the test script
func (c CommonVar) GetDevfileRegistryURL() string
Component is an abstraction for a Devfile Component deployed on a specific platform
type Component interface { // ExpectIsDeployed checks that the component is deployed ExpectIsDeployed() // ExpectIsNotDeployed checks that the component is not deployed ExpectIsNotDeployed() // Exec executes the command in specific container of the component. // If expectedSuccess is nil, the command is just supposed to run, with no assertion on its exit code. // If *expectedSuccess is true, the command exit code is expected to be 0. // If *expectedSuccess is false, the command exit code is expected to be non-zero. Exec(container string, args []string, expectedSuccess *bool) (string, string) // GetEnvVars returns the environment variables defined for the container GetEnvVars(container string) map[string]string // GetLabels returns the labels defined for the component GetLabels() map[string]string // GetAnnotations returns the annotations defined for the component GetAnnotations() map[string]string // GetPodDef returns the definition of the pod GetPodDef() *corev1.Pod // GetJobDef returns the definition of the job GetJobDef() *batchv1.Job // GetPodLogs returns logs for the pod GetPodLogs() string }
func NewComponent(componentName string, app string, mode string, namespace string, cli CliRunner) Component
type DevSession struct { StdOut string ErrOut string Endpoints map[string]string APIServerEndpoint string // contains filtered or unexported fields }
func StartDevMode(options DevSessionOpts) (devSession DevSession, err error)
StartDevMode starts a dev session with `odo dev` It returns a session structure, the contents of the standard and error outputs and the redirections endpoints to access ports opened by component when the dev mode is completely started
func WaitForDevModeToContain(options DevSessionOpts, substring string, stopSessionAfter bool, checkErrOut bool) (DevSession, error)
WaitForDevModeToContain runs `odo dev` until it contains a given substring in output or errOut(depending on checkErrOut arg). `odo dev` runs in an infinite reconciliation loop, and hence running it with Cmd will not work for a lot of failing cases, this function is helpful in such cases. If stopSessionAfter is false, it is up to the caller to stop the DevSession returned. TODO(pvala): Modify StartDevMode to take substring arg into account, and replace this method with it.
func (o DevSession) CheckNotSynced(timeout time.Duration)
func (o DevSession) GetExitCode() int
func (o DevSession) Kill()
Kill a Dev session abruptly, without handling any cleanup
func (o DevSession) PID() int
func (o *DevSession) PressKey(p byte)
func (o *DevSession) Stop()
Stop a Dev session cleanly (equivalent as hitting Ctrl-c)
func (o *DevSession) UpdateInfo() error
UpdateInfo returns the contents of the standard and error outputs and the list of forwarded ports since the end of the dev mode or the last time WaitSync/UpdateInfo has been called
func (o DevSession) WaitEnd()
func (o *DevSession) WaitRestartPortforward() error
func (o *DevSession) WaitSync() error
WaitSync waits for the synchronization of files to be finished It returns the contents of the standard and error outputs and the list of forwarded ports since the end of the dev mode or the last time WaitSync/UpdateInfo has been called
type DevSessionOpts struct { EnvVars []string CmdlineArgs []string RunOnPodman bool TimeoutInSeconds int NoRandomPorts bool NoWatch bool NoCommands bool CustomAddress string StartAPIServer bool APIServerPort int SyncGitDir bool ShowLogs bool VerboseLevel string }
DevfileUpdater is a helper type that can mutate a Devfile object. It is intended to be used in conjunction with the UpdateDevfileContent function.
type DevfileUpdater func(*parser.DevfileObj) error
func SetFsGroup(containerName string, fsGroup int) DevfileUpdater
SetFsGroup is a DevfileUpdater which sets an attribute to a container to set a specific fsGroup for the container's pod
InteractiveContext represents the context of an interactive command to be run.
type InteractiveContext struct { // Command represents the original command ran Command []string // A function to call to stop the process StopCommand func() // contains filtered or unexported fields }
type KubectlRunner struct {
// contains filtered or unexported fields
}
func NewKubectlRunner(kubectlPath string) KubectlRunner
NewKubectlRunner initializes new KubectlRunner
func (kubectl KubectlRunner) AssertContainsLabel(kind, namespace, componentName, appName, mode, key, value string)
func (kubectl KubectlRunner) AssertNoContainsLabel(kind, namespace, componentName, appName, mode, key string)
func (kubectl KubectlRunner) AssertNonAuthenticated()
func (kubectl KubectlRunner) CheckCmdOpInRemoteDevfilePod(podName string, containerName string, prjName string, cmd []string, checkOp func(cmdOp string, err error) bool) bool
CheckCmdOpInRemoteDevfilePod runs the provided command on remote component pod and returns the return value of command output handler function passed to it
func (kubectl KubectlRunner) CreateAndSetRandNamespaceProject() string
CreateAndSetRandNamespaceProject create and set new project
func (kubectl KubectlRunner) CreateAndSetRandNamespaceProjectOfLength(i int) string
CreateRandNamespaceProjectOfLength create new project with i as the length of the name and sets it to the current context
func (kubectl KubectlRunner) CreateSecret(secretName, secretPass, project string)
CreateSecret takes secret name, password and the namespace where we want to create the specific secret into the cluster
func (kubectl KubectlRunner) DeleteNamespaceProject(projectName string, wait bool)
DeleteNamespaceProject deletes a specified project in kubernetes cluster
func (kubectl KubectlRunner) DeletePod(podName string, namespace string)
DeletePod deletes a specified pod in the namespace
func (kubectl KubectlRunner) EnsureOperatorIsInstalled(partialOperatorName string)
func (kubectl KubectlRunner) EnsurePodIsUp(namespace, podName string)
func (kubectl KubectlRunner) Exec(podName string, projectName string, args []string, expectedSuccess *bool) (string, string)
Exec allows generic execution of commands, returning the contents of stdout
func (kubectl KubectlRunner) ExecListDir(podName string, projectName string, dir string) string
ExecListDir returns dir list in specified location of pod
func (kubectl KubectlRunner) GetActiveNamespace() string
func (kubectl KubectlRunner) GetAllNamespaceProjects() []string
func (kubectl KubectlRunner) GetAllPVCNames(namespace string) []string
func (kubectl KubectlRunner) GetAllPodNames(namespace string) []string
GetAllPodNames gets the names of pods in given namespace
func (kubectl KubectlRunner) GetAllPodsInNs(namespace string) string
GetAllPodsInNs gets the list of pods in given namespace. It waits for reasonable amount of time for pods to come up
func (kubectl KubectlRunner) GetAnnotationsDeployment(componentName, appName, projectName string) map[string]string
GetAnnotationsDeployment gets the annotations from the deployment belonging to the given component, app and project
func (kubectl KubectlRunner) GetBindableKinds() (string, string)
func (kubectl KubectlRunner) GetContainerEnv(podName, containerName, namespace string) string
GetContainerEnv returns the container env in the format name:value\n
func (kubectl KubectlRunner) GetEnvFromEntry(componentName string, appName string, projectName string) string
GetEnvFromEntry returns envFrom entry of the deployment
func (kubectl KubectlRunner) GetEnvRefNames(componentName, appName, projectName string) []string
GetEnvRefNames gets the ref values from the envFroms of the deployment belonging to the given data
func (kubectl KubectlRunner) GetEnvsDevFileDeployment(componentName, appName, projectName string) map[string]string
func (kubectl KubectlRunner) GetJobNameByComponent(compName string, namespace string) string
GetJobNameByComponent executes kubectl command and returns the running job name
func (kubectl KubectlRunner) GetLogs(podName string) string
func (kubectl KubectlRunner) GetNamespaceProject() string
func (kubectl KubectlRunner) GetPVCSize(compName, storageName, namespace string) string
GetPVCSize executes kubectl command and returns the bound storage size
func (kubectl KubectlRunner) GetPodInitContainers(compName string, namespace string) []string
GetPodInitContainers executes kubectl command and returns the init containers of the pod
func (kubectl KubectlRunner) GetRunningPodNameByComponent(compName string, namespace string) string
GetRunningPodNameByComponent executes kubectl command and returns the running pod name of a deployed devfile component by passing component name as a argument
func (kubectl KubectlRunner) GetSecrets(project string) string
GetSecrets gets all the secrets belonging to the project
func (kubectl KubectlRunner) GetServiceBinding(name, projectName string) (string, string)
func (kubectl KubectlRunner) GetServices(namespace string) string
GetServices gets services on the cluster
func (kubectl KubectlRunner) GetVersion() string
func (kubectl KubectlRunner) GetVolumeMountNamesandPathsFromContainer(deployName string, containerName, namespace string) string
GetVolumeMountNamesandPathsFromContainer returns the volume name and mount path in the format name:path\n
func (kubectl KubectlRunner) GetVolumeNamesFromDeployment(componentName, appName, projectName string) map[string]string
GetVolumeNamesFromDeployment gets the volumes from the deployment belonging to the given data
func (kubectl KubectlRunner) HasNamespaceProject(name string) bool
func (kubectl KubectlRunner) ListNamespaceProject(name string)
func (kubectl KubectlRunner) PodsShouldBeRunning(project string, regex string)
func (kubectl KubectlRunner) Run(args ...string) *gexec.Session
Run kubectl with given arguments
func (kubectl KubectlRunner) ScalePodToZero(componentName, appName, projectName string)
ScalePodToZero scales the pod of the deployment to zero. It waits for the pod to get deleted from the cluster before returning
func (kubectl KubectlRunner) SetLabelsOnNamespace(ns string, labelValues ...string)
func (kubectl KubectlRunner) SetProject(namespace string) string
func (kubectl KubectlRunner) VerifyResourceDeleted(ri ResourceInfo)
VerifyResourceDeleted verifies if the given resource is deleted from cluster.
func (kubectl KubectlRunner) VerifyResourceToBeDeleted(ri ResourceInfo)
VerifyResourceToBeDeleted verifies if a resource if deleted, or if not, if it is marked for deletion
func (kubectl KubectlRunner) WaitAndCheckForExistence(resourceType, namespace string, timeoutMinutes int) bool
WaitAndCheckForExistence wait for the given and checks if the given resource type gets deleted on the cluster
func (kubectl KubectlRunner) WaitAndCheckForTerminatingState(resourceType, namespace string, timeoutMinutes int) bool
WaitAndCheckForTerminatingState waits for the given interval and checks if the given resource type has been deleted on the cluster or is in the terminating state
func (kubectl KubectlRunner) WaitForRunnerCmdOut(args []string, timeout int, errOnFail bool, check func(output string) bool, includeStdErr ...bool) bool
WaitForRunnerCmdOut runs "kubectl" command until it gets the expected output. It accepts 4 arguments args (arguments to the program) timeout (the time to wait for the output) errOnFail (flag to set if test should fail if command fails) check (function with output check logic) It times out if the command doesn't fetch the expected output within the timeout period.
type LogsSession struct {
// contains filtered or unexported fields
}
func StartLogsFollow(podman bool, opts ...string) (LogsSession, []byte, []byte, error)
StartLogsFollow starts a session with `odo logs --follow` It returns a session structure, the contents of the standard and error outputs
func (o *LogsSession) Kill()
Kill the `odo logs --follow` session
func (o *LogsSession) OutContents() []byte
OutContents returns the contents of the session's stdout
type OcRunner struct {
// contains filtered or unexported fields
}
func NewOcRunner(ocPath string) OcRunner
NewOcRunner initializes new OcRunner
func (oc OcRunner) AddSecret(comvar CommonVar)
AddSecret adds pull-secret to the namespace, for e2e-test
func (oc OcRunner) AssertContainsLabel(kind, namespace, componentName, appName, mode, key, value string)
func (oc OcRunner) AssertNoContainsLabel(kind, namespace, componentName, appName, mode, key string)
func (oc OcRunner) AssertNonAuthenticated()
func (oc OcRunner) CheckCmdOpInRemoteCmpPod(cmpName string, appName string, prjName string, cmd []string, checkOp func(cmdOp string, err error) bool) bool
CheckCmdOpInRemoteCmpPod runs the provided command on remote component pod and returns the return value of command output handler function passed to it
func (oc OcRunner) CheckCmdOpInRemoteDevfilePod(podName string, containerName string, prjName string, cmd []string, checkOp func(cmdOp string, err error) bool) bool
CheckCmdOpInRemoteDevfilePod runs the provided command on remote component pod and returns the return value of command output handler function passed to it
func (oc OcRunner) CreateAndSetRandNamespaceProject() string
CreateAndSetRandNamespaceProject create and set new project
func (oc OcRunner) CreateAndSetRandNamespaceProjectOfLength(i int) string
CreateAndSetRandNamespaceProjectOfLength creates a new project with name of length i and sets it to the current context
func (oc OcRunner) CreateSecret(secretName, secretPass, project string)
CreateSecret takes secret name, password and the namespace where we want to create the specific secret into the cluster
func (oc OcRunner) DeleteNamespaceProject(projectName string, wait bool)
DeleteNamespaceProject deletes a specified project in oc cluster
func (oc OcRunner) DeletePod(podName string, namespace string)
DeletePod deletes a specified pod in the namespace
func (oc OcRunner) EnsureOperatorIsInstalled(partialOperatorName string)
func (oc OcRunner) EnsurePodIsUp(namespace, podName string)
func (oc OcRunner) Exec(podName string, projectName string, args []string, expectedSuccess *bool) (string, string)
Exec allows generic execution of commands, returning the contents of stdout
func (oc OcRunner) ExecListDir(podName string, projectName string, dir string) string
ExecListDir returns dir list in specified location of pod
func (oc OcRunner) GetActiveNamespace() string
func (oc OcRunner) GetAllNamespaceProjects() []string
func (oc OcRunner) GetAllPVCNames(namespace string) []string
func (oc OcRunner) GetAllPodNames(namespace string) []string
GetAllPodNames gets the names of pods in given namespace
func (oc OcRunner) GetAllPodsInNs(namespace string) string
GetAllPodsInNs gets the list of pods in given namespace. It waits for reasonable amount of time for pods to come up
func (oc OcRunner) GetAnnotationsDeployment(componentName, appName, projectName string) map[string]string
GetAnnotationsDeployment gets the annotations from the deployment belonging to the given component, app and project
func (oc OcRunner) GetBindableKinds() (string, string)
func (oc OcRunner) GetContainerEnv(podName, containerName, namespace string) string
GetContainerEnv returns the container env in the format name:value\n
func (oc OcRunner) GetCurrentProject() string
GetCurrentProject get currently active project in oc returns empty string if there no active project, or no access to the project
func (oc OcRunner) GetCurrentServerURL() string
GetCurrentServerURL retrieves the URL of the server we're currently connected to returns empty if not connected or an error occurred
func (oc OcRunner) GetEnvFromEntry(componentName string, appName string, projectName string) string
GetEnvFromEntry returns envFrom entry of the deployment
func (oc OcRunner) GetEnvRefNames(componentName, appName, projectName string) []string
GetEnvRefNames gets the ref values from the envFroms of the deployment belonging to the given data
func (oc OcRunner) GetEnvsDevFileDeployment(componentName, appName, projectName string) map[string]string
func (oc OcRunner) GetJobNameByComponent(compName string, namespace string) string
GetJobNameByComponent executes kubectl command and returns the running job name
func (oc OcRunner) GetLoginUser() string
GetLoginUser returns current user name
func (oc OcRunner) GetLogs(podName string) string
func (oc OcRunner) GetNamespaceProject() string
func (oc OcRunner) GetPVCSize(compName, storageName, namespace string) string
GetPVCSize executes oc command and returns the bound storage size
func (oc OcRunner) GetPodInitContainers(compName string, namespace string) []string
GetPodInitContainers executes oc command and returns the init containers of the pod
func (oc OcRunner) GetRoute(urlName string, appName string) string
GetRoute returns route URL
func (oc OcRunner) GetRunningPodNameByComponent(compName string, namespace string) string
GetRunningPodNameByComponent executes oc command and returns the running pod name of a deployed devfile component by passing component name as a argument
func (oc OcRunner) GetRunningPodNameOfComp(compName string, namespace string) string
GetRunningPodNameOfComp executes oc command and returns the running pod name of a deployed component by passing component name as a argument
func (oc OcRunner) GetSecrets(project string) string
GetSecrets gets all the secrets belonging to the project
func (oc OcRunner) GetServiceBinding(name, projectName string) (string, string)
func (oc OcRunner) GetServices(namespace string) string
GetServices gets services on the cluster
func (oc OcRunner) GetToken() string
GetToken returns current user token
func (oc OcRunner) GetVersion() string
func (oc OcRunner) GetVolumeMountNamesandPathsFromContainer(deployName string, containerName, namespace string) string
GetVolumeMountNamesandPathsFromContainer returns the volume name and mount path in the format name:path\n
func (oc OcRunner) GetVolumeNamesFromDeployment(componentName, appName, projectName string) map[string]string
GetVolumeNamesFromDeployment gets the volumes from the deployment belonging to the given data
func (oc OcRunner) HasNamespaceProject(name string) bool
func (oc OcRunner) ListNamespaceProject(name string)
func (oc OcRunner) LoginUsingToken(token string) string
LoginUsingToken returns output after successful login
func (oc OcRunner) Logout()
func (oc OcRunner) PodsShouldBeRunning(project string, regex string)
func (oc OcRunner) Run(args ...string) *gexec.Session
Run oc with given arguments
func (oc OcRunner) ScalePodToZero(componentName, appName, projectName string)
ScalePodToZero scales the pod of the deployment to zero. It waits for the pod to get deleted from the cluster before returning
func (oc OcRunner) ServiceInstanceStatus(serviceInstanceName string) string
ServiceInstanceStatus returns service instance
func (oc OcRunner) SetLabelsOnNamespace(ns string, labelValues ...string)
func (oc OcRunner) SetProject(namespace string) string
func (oc OcRunner) StatFileInPod(cmpName, appName, project, filepath string) string
StatFileInPod returns stat result of filepath in pod of given component, in a given app, in a given project. It also strips access time information as it vaires accross file systems/kernel configs, and we are not interested in it anyway
func (oc OcRunner) VerifyResourceDeleted(ri ResourceInfo)
VerifyResourceDeleted verifies if the given resource is deleted from cluster
func (oc OcRunner) VerifyResourceToBeDeleted(ri ResourceInfo)
func (oc OcRunner) WaitAndCheckForExistence(resourceType, namespace string, timeoutMinutes int) bool
WaitAndCheckForExistence wait for the given and checks if the given resource type gets deleted on the cluster
func (oc OcRunner) WaitAndCheckForTerminatingState(resourceType, namespace string, timeoutMinutes int) bool
WaitAndCheckForTerminatingState waits for the given interval and checks if the given resource type has been deleted on the cluster or is in the terminating state
func (oc OcRunner) WaitForRunnerCmdOut(args []string, timeout int, errOnFail bool, check func(output string) bool, includeStdErr ...bool) bool
WaitForRunnerCmdOut runs "oc" command until it gets the expected output. It accepts 4 arguments args (arguments to the program) timeout (the time to wait for the output) errOnFail (flag to set if test should fail if command fails) check (function with output check logic) It times out if the command doesn't fetch the expected output within the timeout period.
type OdoV2Watch struct { CmpName string StringsToBeMatched []string StringsNotToBeMatched []string FolderToCheck string SrcType string }
PodmanComponent is an abstraction for a Devfile Component deployed on podman
type PodmanComponent struct {
// contains filtered or unexported fields
}
func NewPodmanComponent(componentName string, app string) *PodmanComponent
func (o *PodmanComponent) Exec(container string, args []string, expectedSuccess *bool) (string, string)
func (o *PodmanComponent) ExpectIsDeployed()
func (o *PodmanComponent) ExpectIsNotDeployed()
func (o *PodmanComponent) GetAnnotations() map[string]string
func (o *PodmanComponent) GetEnvVars(container string) map[string]string
func (o *PodmanComponent) GetJobDef() *batchv1.Job
func (o *PodmanComponent) GetLabels() map[string]string
func (o *PodmanComponent) GetPodDef() *corev1.Pod
func (o *PodmanComponent) GetPodLogs() string
func (o *PodmanComponent) ListImages() string
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry(url string) Registry
func (o Registry) GetIndex() ([]api.DevfileStack, error)
func (o Registry) GetStack(name string) (api.DevfileStack, error)
type RegistryServer interface { Start() (url string, err error) Stop() error IsStarted() bool GetUrl() string }
type ResourceInfo struct { ResourceType string ResourceName string Namespace string }
Tester represents the function that contains all steps to test the given interactive command. The InteractiveContext argument needs to be passed to the various helper.SendLine and helper.ExpectString methods.
type Tester func(InteractiveContext)
Name | Synopsis |
---|---|
.. | |
registry_server | |
reporter |