util

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2015 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckBuildFailedFunc = func(b *buildapi.Build) bool {
	return b.Status.Phase == buildapi.BuildPhaseFailed || b.Status.Phase == buildapi.BuildPhaseError
}

CheckBuildFailedFunc return true if the build failed

View Source
var CheckBuildSuccessFunc = func(b *buildapi.Build) bool {
	return b.Status.Phase == buildapi.BuildPhaseComplete
}

CheckBuildSuccessFunc returns true if the build succeeded

View Source
var CheckDeploymentCompletedFunc = func(d *kapi.ReplicationController) bool {
	return d.Annotations[deployapi.DeploymentStatusAnnotation] == string(deployapi.DeploymentStatusComplete)
}

CheckDeploymentCompletedFunc returns true if the deployment completed

View Source
var CheckDeploymentFailedFunc = func(d *kapi.ReplicationController) bool {
	return d.Annotations[deployapi.DeploymentStatusAnnotation] == string(deployapi.DeploymentStatusFailed)
}

CheckDeploymentFailedFunc returns true if the deployment failed

View Source
var CheckImageStreamLatestTagPopulatedFunc = func(i *imageapi.ImageStream) bool {
	_, ok := i.Status.Tags["latest"]
	return ok
}

CheckImageStreamLatestTagPopulatedFunc returns true if the imagestream has a ':latest' tag filed

View Source
var CheckImageStreamTagNotFoundFunc = func(i *imageapi.ImageStream) bool {
	return strings.Contains(i.Annotations[imageapi.DockerImageRepositoryCheckAnnotation], "not") ||
		strings.Contains(i.Annotations[imageapi.DockerImageRepositoryCheckAnnotation], "error")
}

CheckImageStreamTagNotFoundFunc return true if the imagestream update was not successful

View Source
var CheckPodIsRunningFunc = func(pod kapi.Pod) bool {
	return pod.Status.Phase == kapi.PodRunning
}

CheckPodIsRunningFunc returns true if the pod is running

View Source
var TestContext e2e.TestContextType

Functions

func ArtifactDirPath added in v1.0.7

func ArtifactDirPath() string

ArtifactDirPath returns the value of ARTIFACT_DIR environment variable

func ArtifactPath added in v1.0.7

func ArtifactPath(elem ...string) string

ArtifactPath returns the absolute path to the fix artifact file The path is relative to ARTIFACT_DIR

func BuildAuthConfiguration added in v1.0.7

func BuildAuthConfiguration(credKey string, oc *CLI) (*dockerClient.AuthConfiguration, error)

BuildAuthConfiguration constructs a non-standard dockerClient.AuthConfiguration that can be used to communicate with the openshift internal docker registry

func CleanupHostPathVolumes added in v1.0.7

func CleanupHostPathVolumes(c kclient.PersistentVolumeInterface, prefix string) error

CleanupHostPathVolumes removes all PersistentVolumes created by SetupHostPathVolumes, with a given prefix

func CorruptImage

func CorruptImage(corruptee, corruptor string)

CorruptImage is a helper that tags the image to be corrupted, the corruptee, as the corruptor string, resulting in the wrong image being used when corruptee is referenced later on; strategy is for ginkgo debug; ginkgo error checking leveraged

func CreatePersistentVolume added in v1.0.7

func CreatePersistentVolume(name, capacity, hostPath string) *kapi.PersistentVolume

CreatePersistentVolume creates a HostPath Persistent Volume.

func CreateResource added in v1.0.7

func CreateResource(jsonFilePath string, oc *CLI) error

CreateResource creates the resources from the supplied json file (not a template); ginkgo error checking included

func DumpAndReturnTagging added in v1.0.7

func DumpAndReturnTagging(tags []string) []string

DumpAndReturnTagging takes and array of tags and obtains the hex image IDs, dumps them to ginkgo for printing, and then returns them

func ExecuteTest added in v1.0.7

func ExecuteTest(t *testing.T, suite string)

func ExtendedTestPath

func ExtendedTestPath() string

ExtendedTestPath returns absolute path to extended tests directory

func FatalErr

func FatalErr(msg interface{})

FatalErr exits the test in case a fatal error has occured.

func FetchURL added in v1.0.7

func FetchURL(url string, retryTimeout time.Duration) (response string, err error)

FetchURL grabs the output from the specified url and returns it. It will retry once per second for duration retryTimeout if an error occurs during the request.

func FixturePath

func FixturePath(elem ...string) string

FixturePath returns absolute path to given fixture file The path is relative to EXTENDED_TEST_PATH (./test/extended/*)

func GetDockerImageReference

func GetDockerImageReference(c client.ImageStreamInterface, name, tag string) (string, error)

GetDockerImageReference retrieves the full Docker pull spec from the given ImageStream and tag

func GetEndpointAddress added in v1.0.7

func GetEndpointAddress(oc *CLI, name string) (string, error)

GetEndpointAddress will return an "ip:port" string for the endpoint.

func GetImageIDForTags

func GetImageIDForTags(comps []string) ([]string, error)

GetImageIDForTags will obtain the hexadecimal IDs for the array of human readible image tags IDs provided

func GetPodForContainer added in v1.0.7

func GetPodForContainer(container kapi.Container) *kapi.Pod

GetPodForContainer creates a new Pod that runs specified container

func GetPodForImage added in v1.0.7

func GetPodForImage(dockerImageReference string) *kapi.Pod

GetPodForImage creates a new Pod that runs the containers from specified Docker image reference

func GetPodNamesByFilter added in v1.0.7

func GetPodNamesByFilter(c kclient.PodInterface, label labels.Selector, predicate func(kapi.Pod) bool) (podNames []string, err error)

GetPodNamesByFilter looks up pods that satisfy the predicate and returns their names.

func InitTest added in v1.0.7

func InitTest()

init initialize the extended testing suite. You can set these environment variables to configure extended tests: KUBECONFIG - Path to kubeconfig containing embedded authinfo TEST_REPORT_DIR - If set, JUnit output will be written to this directory for each test

func KubeConfigPath

func KubeConfigPath() string

KubeConfigPath returns the value of KUBECONFIG environment variable

func ParseLabelsOrDie added in v1.0.7

func ParseLabelsOrDie(str string) labels.Selector

ParseLabelsOrDie turns the given string into a label selector or panics; for tests or other cases where you know the string is valid. TODO: Move this to the upstream labels package.

func PullImage

func PullImage(name string, authCfg dockerClient.AuthConfiguration) error

PullImage initiates the equivalent of a `docker pull` for the "name" parameter

func PushImage added in v1.0.7

func PushImage(name string, authCfg dockerClient.AuthConfiguration) error

PushImage initiates the equivalent of a `docker push` for the "name" parameter to the local registry

func ResetImage

func ResetImage(tags map[string]string)

ResetImage is a helper the allows the programmer to undo any corruption performed by CorruptImage; ginkgo error checking leveraged

func SetupHostPathVolumes added in v1.0.7

func SetupHostPathVolumes(c kclient.PersistentVolumeInterface, prefix, capacity string, count int) (volumes []*kapi.PersistentVolume, err error)

SetupHostPathVolumes will create multiple PersistentVolumes with given capacity

func StartBuild

func StartBuild(buildPrefix string, oc *CLI)

StartBuild starts a build, with the assumption that the build config was previously created

func StartBuildFromJSON added in v1.0.7

func StartBuildFromJSON(jsonFile, buildPrefix string, oc *CLI)

StartBuildFromJSON creates a build config from the supplied json file (not a template) and then starts a build, using the supplied oc/cli client for both operations; ginkgo error checking included

func TagImage

func TagImage(tagee, tagor string) error

TagImage will apply the "tagor" tag string to the image current tagged by "tagee"

func VarSubOnFile added in v1.0.7

func VarSubOnFile(srcFile, destFile, varToSub, val string) error

VarSubOnFile reads in srcFile, finds instances inf varToSub, changes it to var, and writes out to destFile

func VerifyImagesDifferent

func VerifyImagesDifferent(comp1, comp2, strategy string)

VerifyImagesDifferent will that the two supplied image tags and see if they reference different hexadecimal image IDs; strategy is for ginkgo debug, also leverage ginkgo error checking

func VerifyImagesSame

func VerifyImagesSame(comp1, comp2, strategy string)

VerifyImagesSame will take the two supplied image tags and see if they reference the same hexadecimal image ID; strategy is for debug

func WaitForABuild

func WaitForABuild(c client.BuildInterface, name string, isOK, isFailed func(*buildapi.Build) bool) error

WaitForABuild waits for a Build object to match either isOK or isFailed conditions.

func WaitForADeployment added in v1.0.6

func WaitForADeployment(client kclient.ReplicationControllerInterface,
	name string,
	isOK, isFailed func(*kapi.ReplicationController) bool) error

WaitForADeployment waits for a Deployment to fulfill the isOK function

func WaitForAnImageStream added in v1.0.6

func WaitForAnImageStream(client client.ImageStreamInterface,
	name string,
	isOK, isFailed func(*imageapi.ImageStream) bool) error

WaitForAnImageStream waits for an ImageStream to fulfill the isOK function

func WaitForBuild

func WaitForBuild(context, buildName string, oc *CLI)

WaitForBuild is a wrapper for WaitForABuild in this package that takes in an oc/cli client; some ginkgo based debug along with ginkgo error checking

func WaitForBuilderAccount added in v1.0.6

func WaitForBuilderAccount(c kclient.ServiceAccountsInterface) error

WaitForBuilderAccount waits until the builder service account gets fully provisioned

func WaitForPods added in v1.0.7

func WaitForPods(c kclient.PodInterface, label labels.Selector, predicate func(kapi.Pod) bool, count int, timeout time.Duration) ([]string, error)

WaitForPods waits until given number of pods that match the label selector and satisfy the predicate are found

func WaitForQueryOutput added in v1.0.7

func WaitForQueryOutput(oc *CLI, d Database, timeout time.Duration, admin bool, query, resultSubstr string) error

WaitForQueryOutput will execute the query multiple times, until the specified substring is found in the results. This function should be used for testing replication, since it might take some time untill the data is propagated to slaves.

func WaitUntilAllHelpersAreUp added in v1.0.7

func WaitUntilAllHelpersAreUp(oc *CLI, helpers []Database) error

WaitUntilAllHelpersAreUp waits until all helpers are ready to serve requests

func WaitUntilPodIsGone added in v1.0.7

func WaitUntilPodIsGone(c kclient.PodInterface, podName string, timeout time.Duration) error

WaitUntilPodIsGone waits until the named Pod will disappear

func WaitUntilUp added in v1.0.7

func WaitUntilUp(oc *CLI, d Database, timeout time.Duration) error

WaitUntilUp continuously waits for the server to become ready, up until timeout.

func WriteObjectToFile

func WriteObjectToFile(obj runtime.Object, filename string) error

WriteObjectToFile writes the JSON representation of runtime.Object into a temporary file.

Types

type CLI

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

CLI provides function to call the OpenShift CLI and Kubernetes and OpenShift REST clients.

func NewCLI

func NewCLI(project, adminConfigPath string) *CLI

NewCLI initialize the upstream E2E framework and set the namespace to match with the project name. Note that this function does not initialize the project role bindings for the namespace.

func (*CLI) AdminKubeREST added in v1.0.7

func (c *CLI) AdminKubeREST() *kclient.Client

AdminKubeREST provides a Kubernetes REST client for the cluster admin user.

func (*CLI) AdminREST

func (c *CLI) AdminREST() *client.Client

AdminREST provides an OpenShift REST client for the cluster admin user.

func (*CLI) Args

func (c *CLI) Args(args ...string) *CLI

Args sets the additional arguments for the OpenShift CLI command

func (*CLI) AsAdmin added in v1.0.7

func (c *CLI) AsAdmin() *CLI

AsAdmin changes current config file path to the admin config.

func (*CLI) ChangeUser

func (c *CLI) ChangeUser(name string) *CLI

ChangeUser changes the user used by the current CLI session.

func (*CLI) Execute

func (c *CLI) Execute() error

Execute executes the current command and return error if the execution failed This function will set the default output to stdout.

func (*CLI) InputString added in v1.0.7

func (c *CLI) InputString(input string) *CLI

InputString adds expected input to the command

func (*CLI) KubeFramework

func (c *CLI) KubeFramework() *e2e.Framework

KubeFramework returns Kubernetes framework which contains helper functions specific for Kubernetes resources

func (*CLI) KubeREST

func (c *CLI) KubeREST() *kclient.Client

KubeREST provides a Kubernetes REST client for the current namespace

func (*CLI) Namespace

func (c *CLI) Namespace() string

Namespace returns the name of the namespace used in the current test case. If the namespace is not set, an empty string is returned.

func (*CLI) Output

func (c *CLI) Output() (string, error)

Output executes the command and return the output as string

func (*CLI) OutputToFile

func (c *CLI) OutputToFile(filename string) (string, error)

OutputToFile executes the command and store output to a file

func (*CLI) REST

func (c *CLI) REST() *client.Client

REST provides an OpenShift REST client for the current user. If the user is not set, then it provides REST client for the cluster admin user

func (*CLI) Run

func (c *CLI) Run(verb string) *CLI

Run executes given OpenShift CLI command verb (iow. "oc <verb>"). This function also override the default 'stdout' to redirect all output to a buffer and prepare the global flags such as namespace and config path.

func (*CLI) SetNamespace

func (c *CLI) SetNamespace(ns string) *CLI

SetNamespace sets a new namespace

func (*CLI) SetOutputDir

func (c *CLI) SetOutputDir(dir string) *CLI

SetOutputDir change the default output directory for temporary files

func (*CLI) SetupProject

func (c *CLI) SetupProject(name string, kubeClient *kclient.Client) (*kapi.Namespace, error)

SetupProject creates a new project and assign a random user to the project. All resources will be then created within this project and Kubernetes E2E suite will destroy the project after test case finish.

func (*CLI) Stdout added in v1.0.7

func (c *CLI) Stdout() io.Writer

Stdout returns the current stdout writer

func (*CLI) Template

func (c *CLI) Template(t string) *CLI

Template sets a Go template for the OpenShift CLI command. This is equivalent of running "oc get foo -o template --template='{{ .spec }}'"

func (*CLI) Username

func (c *CLI) Username() string

Username returns the name of currently logged user. If there is no user assigned for the current session, it returns 'admin'.

func (*CLI) Verbose

func (c *CLI) Verbose() *CLI

Verbose turns on printing verbose messages when executing OpenShift commands

type Database added in v1.0.7

type Database interface {
	// GetPodName returns the name of the Pod this helper is bound to
	GetPodName() string

	// IsReady indicates whether the underlying Pod is ready for queries
	IsReady(oc *CLI) (bool, error)

	// Query queries the database as a regular user
	Query(oc *CLI, query string) (string, error)

	// Query queries the database as a privileged user
	QueryPrivileged(oc *CLI, query string) (string, error)

	// TestRemoteLogin tests weather it is possible to remote login to hostAddress
	TestRemoteLogin(oc *CLI, hostAddress string) error
}

Database interface allows testing database images

func NewMysql added in v1.0.7

func NewMysql(c kclient.PodInterface, podName, masterPodName string) Database

NewMysql queries OpenShift for a pod with given name, saving environment variables like username and password for easier use.

type MissingTagError

type MissingTagError struct {
	Tags []string
}

func (MissingTagError) Error

func (mte MissingTagError) Error() string

type MySQL added in v1.0.7

type MySQL struct {
	PodName       string
	MasterPodName string
}

MySQL is a MySQL helper for executing commands

func (MySQL) GetPodName added in v1.0.7

func (m MySQL) GetPodName() string

func (MySQL) IsReady added in v1.0.7

func (m MySQL) IsReady(oc *CLI) (bool, error)

IsReady pings the MySQL server

func (MySQL) Query added in v1.0.7

func (m MySQL) Query(oc *CLI, query string) (string, error)

Query executes an SQL query as an ordinary user and returns the result.

func (MySQL) QueryPrivileged added in v1.0.7

func (m MySQL) QueryPrivileged(oc *CLI, query string) (string, error)

QueryPrivileged executes an SQL query as a root user and returns the result.

func (MySQL) TestRemoteLogin added in v1.0.7

func (m MySQL) TestRemoteLogin(oc *CLI, hostAddress string) error

TestRemoteLogin will test whether we can login through to a remote database.

type PodConfig added in v1.0.7

type PodConfig struct {
	Container string
	Env       map[string]string
}

PodConfig holds configuration for a pod

func GetPodConfig added in v1.0.7

func GetPodConfig(c kclient.PodInterface, podName string) (conf *PodConfig, err error)

type SimpleReporter added in v1.0.7

type SimpleReporter struct {
	Output io.Writer
	// contains filtered or unexported fields
}

func NewSimpleReporter added in v1.0.7

func NewSimpleReporter() *SimpleReporter

func (*SimpleReporter) AfterSuiteDidRun added in v1.0.7

func (r *SimpleReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary)

func (*SimpleReporter) BeforeSuiteDidRun added in v1.0.7

func (r *SimpleReporter) BeforeSuiteDidRun(*types.SetupSummary)

func (*SimpleReporter) SpecDidComplete added in v1.0.7

func (r *SimpleReporter) SpecDidComplete(spec *types.SpecSummary)

func (*SimpleReporter) SpecSuiteDidEnd added in v1.0.7

func (r *SimpleReporter) SpecSuiteDidEnd(summary *types.SuiteSummary)

func (*SimpleReporter) SpecSuiteWillBegin added in v1.0.7

func (r *SimpleReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)

func (*SimpleReporter) SpecWillRun added in v1.0.7

func (r *SimpleReporter) SpecWillRun(spec *types.SpecSummary)

Jump to

Keyboard shortcuts

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