Documentation ¶
Overview ¶
Package testing provides helpers for tests, like wrappers for kubectl and helm
Index ¶
- Constants
- func Apply(namespace string, yamlFilePath string) error
- func Create(namespace string, yamlFilePath string) error
- func CreateNamespace(name string) error
- func CreateSecretFromLiteral(namespace string, secretName string, literalValues map[string]string) error
- func Delete(namespace string, yamlFilePath string) error
- func DeleteLabelFilter(namespace string, resourceName string, labelName string) error
- func DeleteNamespace(ns string) error
- func DeleteResource(namespace string, resourceName string, name string) error
- func DeleteSecret(namespace string, secretName string) error
- func DeleteWebhooks(ns string, name string) error
- func GetData(namespace string, resourceName string, name string, templatePath string) ([]byte, error)
- func HelmBinaryVersion() (string, error)
- func NewContext() context.Context
- func PatchNamespace(name string, patch string) error
- func RestartOperator(namespace string) error
- func RunCommandWithOutput(namespace string, podName string, commandInPod string) (string, error)
- func RunHelmBinaryWithCustomErr(args ...string) error
- func SecretCheckData(namespace string, secretName string, fieldPath string) error
- func TriggerQJob(namespace, qjob string) error
- type BDPL
- type ClusterCrd
- type ConfigMap
- type CustomError
- type Kubectl
- func (k *Kubectl) ApplyYAML(namespace string, name string, v interface{}) error
- func (k *Kubectl) CreateRoleBinding(namespace string, clusterrole, serviceaccount, role string) error
- func (k *Kubectl) CreateServiceAccount(namespace string, serviceaccount string) error
- func (k *Kubectl) Curl(namespace, url string) ([]byte, error)
- func (k *Kubectl) Delete(args ...string) error
- func (k *Kubectl) DeleteRoleBinding(namespace string, role string) error
- func (k *Kubectl) DeleteServiceAccount(namespace string, serviceaccount string) error
- func (k *Kubectl) Exists(namespace, resource, name string) (bool, error)
- func (k *Kubectl) GetBoshDeployment(namespace string, name string) (BDPL, error)
- func (k *Kubectl) GetConfigMap(namespace string, name string) (ConfigMap, error)
- func (k *Kubectl) GetPodNames(namespace string, selector string) ([]string, error)
- func (k *Kubectl) PodExists(namespace string, labelName string, podName string) (bool, error)
- func (k *Kubectl) PodStatus(namespace string, podName string) (*v1.PodStatus, error)
- func (k *Kubectl) RunCommandWithCheckString(namespace string, podName string, commandInPod string, result string) error
- func (k *Kubectl) SecretExists(namespace string, secretName string) (bool, error)
- func (k *Kubectl) Service(namespace string, serviceName string) (v1.Service, error)
- func (k *Kubectl) ServiceExists(namespace string, serviceName string) (bool, error)
- func (k *Kubectl) ServiceWorks(namespace, serviceName string) (bool, error)
- func (k *Kubectl) Wait(namespace string, requiredStatus string, resourceName string, ...) error
- func (k *Kubectl) WaitForData(namespace string, resourceName string, name string, template string, ...) error
- func (k *Kubectl) WaitForPVC(namespace string, pvcName string) error
- func (k *Kubectl) WaitForPod(namespace string, labelName string, podName string) error
- func (k *Kubectl) WaitForPodDelete(namespace string, podName string) error
- func (k *Kubectl) WaitForSecret(namespace string, secretName string) error
- func (k *Kubectl) WaitForService(namespace string, serviceName string) error
- func (k *Kubectl) WaitLabelFilter(namespace string, requiredStatus string, resourceName string, labelName string) error
Constants ¶
const (
// QuarksHelmRelease is the default quarks-operator helm release name
QuarksHelmRelease = "quarks"
)
Variables ¶
This section is empty.
Functions ¶
func CreateNamespace ¶
CreateNamespace create the namespace using kubectl command
func CreateSecretFromLiteral ¶
func CreateSecretFromLiteral(namespace string, secretName string, literalValues map[string]string) error
CreateSecretFromLiteral creates a generic type secret using kubectl command
func DeleteLabelFilter ¶
DeleteLabelFilter deletes the resource based on label using kubectl command
func DeleteResource ¶
DeleteResource deletes the resource using kubectl command
func DeleteSecret ¶
DeleteSecret deletes the namespace using kubectl command
func DeleteWebhooks ¶
DeleteWebhooks removes existing webhookconfiguration and validatingwebhookconfiguration
func GetData ¶
func GetData(namespace string, resourceName string, name string, templatePath string) ([]byte, error)
GetData fetches the specified output by the given templatePath
func HelmBinaryVersion ¶
HelmBinaryVersion executes helm version and return 2 or 3
func NewContext ¶
NewContext returns a non-nil empty context, for usage when it is unclear which context to use. Mostly used in tests.
func PatchNamespace ¶
PatchNamespace patche the namespace resource using kubectl command
func RestartOperator ¶
RestartOperator restart Operator Deployment
func RunCommandWithOutput ¶
RunCommandWithOutput runs the command specified in the container and returns output
func RunHelmBinaryWithCustomErr ¶
RunHelmBinaryWithCustomErr executes a desire binary
func SecretCheckData ¶
SecretCheckData checks the field specified in the given field
Types ¶
type BDPL ¶
type BDPL struct { APIVersion string `json:"apiVersion" yaml:"apiVersion"` Kind string `json:"kind" yaml:"kind"` Metadata struct { Name string `json:"name" yaml:"name"` } `json:"metadata" yaml:"metadata"` Spec struct { Manifest map[string]string `json:"manifest" yaml:"manifest"` Ops []map[string]string `json:"ops" yaml:"ops"` } `json:"spec" yaml:"spec"` }
BDPL defines a bdpl
type ClusterCrd ¶
type ClusterCrd struct { Items []struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata struct { Name string `json:"name"` } `json:"metadata"` } `json:"items"` }
ClusterCrd defines a list of CRDs
func (*ClusterCrd) ContainsElement ¶
func (c *ClusterCrd) ContainsElement(element string) bool
ContainsElement verify if a CRD exist
type ConfigMap ¶
type ConfigMap struct { APIVersion string `json:"apiVersion" yaml:"apiVersion"` Kind string `json:"kind" yaml:"kind"` Metadata struct { Name string `json:"name" yaml:"name"` } `json:"metadata" yaml:"metadata"` Data map[string]string `json:"data" yaml:"data"` }
ConfigMap defines a kube ConfigMap
type CustomError ¶
CustomError containing stdOutput of a binary execution
func (*CustomError) Error ¶
func (e *CustomError) Error() string
type Kubectl ¶
type Kubectl struct { Log *zap.SugaredLogger Namespace string PollTimeout time.Duration // contains filtered or unexported fields }
Kubectl is used as a command to test e2e tests
func (*Kubectl) CreateRoleBinding ¶
func (k *Kubectl) CreateRoleBinding(namespace string, clusterrole, serviceaccount, role string) error
CreateRoleBinding Create a new rolebinding in a namespace from a cluster role
func (*Kubectl) CreateServiceAccount ¶
CreateServiceAccount Create a new serviceaccount in a namespace
func (*Kubectl) DeleteRoleBinding ¶
DeleteRoleBinding Deletes a rolebinding in a namespace
func (*Kubectl) DeleteServiceAccount ¶
DeleteServiceAccount Deletes a serviceaccount in a namespace
func (*Kubectl) GetBoshDeployment ¶
GetBoshDeployment returns a BDPL
func (*Kubectl) GetConfigMap ¶
GetConfigMap blocks until the specified data is available. It fails after the timeout.
func (*Kubectl) GetPodNames ¶
GetPodNames returns the names of the pods matching the selector
func (*Kubectl) RunCommandWithCheckString ¶
func (k *Kubectl) RunCommandWithCheckString(namespace string, podName string, commandInPod string, result string) error
RunCommandWithCheckString runs the command specified helper in the container
func (*Kubectl) SecretExists ¶
SecretExists returns true if the pod by that name is in state running
func (*Kubectl) ServiceExists ¶
ServiceExists returns true if the pod by that name is in state running
func (*Kubectl) ServiceWorks ¶ added in v0.0.2
ServiceWorks returns true if the service is accessible
func (*Kubectl) Wait ¶
func (k *Kubectl) Wait(namespace string, requiredStatus string, resourceName string, customTimeout time.Duration) error
Wait waits for the condition on the resource using kubectl command
func (*Kubectl) WaitForData ¶
func (k *Kubectl) WaitForData(namespace string, resourceName string, name string, template string, expectation string) error
WaitForData blocks until the specified data is available. It fails after the timeout.
func (*Kubectl) WaitForPVC ¶
WaitForPVC blocks until the pvc is available. It fails after the timeout.
func (*Kubectl) WaitForPod ¶
WaitForPod blocks until the pod is available. It fails after the timeout.
func (*Kubectl) WaitForPodDelete ¶
WaitForPodDelete blocks until the pod is available. It fails after the timeout.
func (*Kubectl) WaitForSecret ¶
WaitForSecret blocks until the secret is available. It fails after the timeout.
func (*Kubectl) WaitForService ¶
WaitForService blocks until the service is available. It fails after the timeout.
Directories ¶
Path | Synopsis |
---|---|
Package e2ehelper has common functionality for the end-to-end test suites
|
Package e2ehelper has common functionality for the end-to-end test suites |
Package environment adds everything around mgr.Start() to run a local operator for the integration test suites
|
Package environment adds everything around mgr.Start() to run a local operator for the integration test suites |
Package machine builds k8s resources for use in integration tests
|
Package machine builds k8s resources for use in integration tests |
Package testhelper has common helpers for tests
|
Package testhelper has common helpers for tests |