Documentation ¶
Index ¶
- Constants
- Variables
- func CreateFramework(ctx context.Context, scheme *runtime.Scheme) error
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectMatchRegexp(actual string, regexp string, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- func RunKubectl(kubeconfigPath, namespace string, args ...string) (string, error)
- func RunKubectlInput(kubeconfigPath, namespace string, data string, args ...string) (string, error)
- func RunKubectlOrDie(kubeconfigPath, namespace string, args ...string) string
- func RunKubectlOrDieInput(kubeconfigPath, namespace string, data string, args ...string) string
- func RunKubectlWithFullOutput(kubeconfigPath, namespace string, args ...string) (string, string, error)
- type Framework
- func (f *Framework) ApplyOrUpdate(obj ctrlclient.Object) error
- func (f *Framework) Cleanup() error
- func (f *Framework) CreateTestNamespace(ns string) error
- func (f *Framework) DeleteTestNamespace(ns string, waitUntilDeleted bool) error
- func (f *Framework) GetDefaultSecurityContext() *corev1.SecurityContext
- func (f *Framework) GetNodes(options metav1.ListOptions) (*corev1.NodeList, error)
- func (f *Framework) GetPodByName(nameSpace string, podName string) (*corev1.Pod, error)
- func (f *Framework) GetPodImage(nameSpace string, podName string, containerName string) (string, error)
- func (f *Framework) GetPodLog(pod corev1.Pod, tailLines int64) (string, error)
- func (f *Framework) GetRunningPodsNames(nameSpace string, podNamePrefix string) []string
- func (f *Framework) GetRunningPodsNodeNames(nameSpace string, podNamePrefix string) []string
- func (f *Framework) GetSecret(nameSpace string, secretName string) (string, error)
- func (f *Framework) GetTaggedNodes(labelKey string) ([]string, error)
- func (f *Framework) LabelReadyEdgeNodes(nameSpace string, numNodes int, labelKey string) error
- func (f *Framework) NodeIsReady(n *corev1.Node) bool
- func (f *Framework) RemoveNodeLabel(node *corev1.Node, key string) error
- func (f *Framework) RemoveNodeLabels(labelKey string) error
- func (f *Framework) SetNodeLabel(node *corev1.Node, key string, value string) error
- func (f *Framework) SetSecret(nameSpace string, secretName string, key string, value string)
- func (f *Framework) WaitForNoPodsInNamespace(nameSpace string, timeout time.Duration) error
- func (f *Framework) WaitForPodRunning(podName string, ns string) error
- type KubectlBuilder
- func (b KubectlBuilder) Exec() (string, error)
- func (b KubectlBuilder) ExecOrDie(namespace string) string
- func (b KubectlBuilder) ExecWithFullOutput() (string, string, error)
- func (b *KubectlBuilder) WithEnv(env []string) *KubectlBuilder
- func (b KubectlBuilder) WithStdinData(data string) *KubectlBuilder
- func (b KubectlBuilder) WithStdinReader(reader io.Reader) *KubectlBuilder
- func (b *KubectlBuilder) WithTimeout(t <-chan time.Time) *KubectlBuilder
- type TestKubeconfig
Constants ¶
const ( PollTimeout = time.Minute DefaultClientTimeout = 32 * time.Second // the default in client-go is 32 )
Variables ¶
var DefaultFramework = &Framework{}
Functions ¶
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
func ExpectMatchRegexp ¶
ExpectMatchRegexp expects the string to match the provided regular expression
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
func RunKubectl ¶
RunKubectl is a convenience wrapper over kubectlBuilder
func RunKubectlInput ¶
RunKubectlInput is a convenience wrapper over kubectlBuilder that takes input to stdin
func RunKubectlOrDie ¶
RunKubectlOrDie is a convenience wrapper over kubectlBuilder
func RunKubectlOrDieInput ¶
RunKubectlOrDieInput is a convenience wrapper over kubectlBuilder that takes input to stdin
Types ¶
type Framework ¶
type Framework struct { // The context to use for testing Context context.Context // ClientSet is the kubernetes client of the current // host kubernetes cluster were we are testing in ClientSet *kubernetes.Clientset // CtrlClient is the kubernetes client originally supposed // to write controllers. It provides some convinience methods // e.g. create objects CtrlClient ctrlclient.Client // Scheme is the global scheme to use Scheme *runtime.Scheme // ClientTimeout value used in the clients ClientTimeout time.Duration }
func (*Framework) ApplyOrUpdate ¶
func (f *Framework) ApplyOrUpdate(obj ctrlclient.Object) error
ApplyOrUpdate applies or updates the given object.
func (*Framework) CreateTestNamespace ¶
func (*Framework) DeleteTestNamespace ¶
func (*Framework) GetDefaultSecurityContext ¶
func (f *Framework) GetDefaultSecurityContext() *corev1.SecurityContext
func (*Framework) GetNodes ¶
GetNodes returns a list of nodes in the cluster use options to filter nodes e.g. by label
func (*Framework) GetPodByName ¶
GetPodByName returns the pod with the given name
func (*Framework) GetPodImage ¶
func (f *Framework) GetPodImage(nameSpace string, podName string, containerName string) (string, error)
GetPodImage returns the image of the given pod/container
func (*Framework) GetPodLog ¶
GetPodLog returns the last log lines from the log Multiple calls to this func will return the same lines again, unless more than tailLines are available
func (*Framework) GetRunningPodsNames ¶
GetRunnningPodsNames returns a list of pod names for running pods matching podNamePrefix
func (*Framework) GetRunningPodsNodeNames ¶
GetRunningPodsNodeNames returns a list of node names for running pods matching podNamePrefix
func (*Framework) GetTaggedNodes ¶
func (*Framework) LabelReadyEdgeNodes ¶
func (*Framework) RemoveNodeLabel ¶
func (*Framework) RemoveNodeLabels ¶
func (*Framework) SetNodeLabel ¶
func (*Framework) WaitForNoPodsInNamespace ¶
type KubectlBuilder ¶
type KubectlBuilder struct {
// contains filtered or unexported fields
}
Adopted from k8s test suite - https://github.com/kubernetes/kubernetes/blob/f2576efecdf2d902b12a3fedae7995311d4febfa/test/e2e/framework/util.go#L552-L687 KubectlBuilder is used to build, customize and execute a kubectl Command. Add more functions to customize the builder as needed.
func NewKubectlCommand ¶
func NewKubectlCommand(kubeconfigPath, namespace string, args ...string) *KubectlBuilder
NewKubectlCommand returns a KubectlBuilder for running kubectl.
func (KubectlBuilder) Exec ¶
func (b KubectlBuilder) Exec() (string, error)
Exec runs the kubectl executable.
func (KubectlBuilder) ExecOrDie ¶
func (b KubectlBuilder) ExecOrDie(namespace string) string
ExecOrDie runs the kubectl executable or dies if error occurs.
func (KubectlBuilder) ExecWithFullOutput ¶
func (b KubectlBuilder) ExecWithFullOutput() (string, string, error)
ExecWithFullOutput runs the kubectl executable, and returns the stdout and stderr.
func (*KubectlBuilder) WithEnv ¶
func (b *KubectlBuilder) WithEnv(env []string) *KubectlBuilder
WithEnv sets the given environment and returns itself.
func (KubectlBuilder) WithStdinData ¶
func (b KubectlBuilder) WithStdinData(data string) *KubectlBuilder
WithStdinData sets the given data to stdin and returns itself.
func (KubectlBuilder) WithStdinReader ¶
func (b KubectlBuilder) WithStdinReader(reader io.Reader) *KubectlBuilder
WithStdinReader sets the given reader and returns itself.
func (*KubectlBuilder) WithTimeout ¶
func (b *KubectlBuilder) WithTimeout(t <-chan time.Time) *KubectlBuilder
WithTimeout sets the given timeout and returns itself.
type TestKubeconfig ¶
type TestKubeconfig struct { CertDir string Host string KubeConfig string KubeContext string KubectlPath string Namespace string // Every test has at least one namespace unless creation is skipped }
Adopted from k8s test suite - https://github.com/kubernetes/kubernetes/blob/f2576efecdf2d902b12a3fedae7995311d4febfa/test/e2e/framework/kubectl/kubectl_utils.go#L43-L100 TestKubeconfig is a struct containing the needed attributes from TestContext and Framework(Namespace).
func NewTestKubeconfig ¶
func NewTestKubeconfig(kubeconfig, namespace string) *TestKubeconfig
NewTestKubeconfig returns a new Kubeconfig struct instance.
func (*TestKubeconfig) KubectlCmd ¶
func (tk *TestKubeconfig) KubectlCmd(args ...string) *exec.Cmd
KubectlCmd runs the kubectl executable through the wrapper script.