Documentation ¶
Index ¶
- func AddLabelsToNamespace(client kubernetes.Interface, name string, additionalLabels map[string]string) error
- func CreateCRD(client clientset.Clientset, namespace string, ...) error
- func CreateDeployment(client kubernetes.Interface, namespace string, deployment *appv1.Deployment) error
- func CreateNamespace(client kubernetes.Interface, name string) (*corev1.Namespace, error)
- func CreateOrUpdateClusterRole(client kubernetes.Interface, relativeFilePath string) error
- func DeleteClusterRole(client kubernetes.Interface, relativeFilePath string) error
- func DeleteClusterRoleBinding(client kubernetes.Interface, relativeFilePath string) error
- func DeleteDeployment(client kubernetes.Interface, namespace, name string) error
- func DeleteNamespace(client kubernetes.Interface, name string) error
- func DeleteRoleBinding(client kubernetes.Interface, namespace string, relativeFilePath string) error
- func DeleteServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) error
- func GetFileDescriptor(relativeFilePath string) (*os.File, error)
- func MakeBasicBalancer(namespace, name string, versions []string, weights []int32) *balancerv1alpha1.Balancer
- func ParseCRDYaml(relativeFilePath string) (*apiextensionsv1beta1.CustomResourceDefinition, error)
- func ParseClusterRoleBindingYaml(relativeFilePath string) (*rbacv1.ClusterRoleBinding, error)
- func ParseClusterRoleYaml(relativeFilePath string) (*rbacv1.ClusterRole, error)
- func ParseDeploymentYaml(relativeFilePath string) (*appv1.Deployment, error)
- func ParsePodYaml(relativeFilePath string) (*corev1.Pod, error)
- func ParseRoleBindingYaml(relativeFilePath string) (*rbacv1.RoleBinding, error)
- func ParseServiceAccountYaml(relativeFilePath string) (*corev1.ServiceAccount, error)
- func PodRunningAndReady(pod *corev1.Pod) (bool, error)
- func WaitForCRDReady(listFunc func(opts metav1.ListOptions) (runtime.Object, error)) error
- func WaitForPodReady(client kubernetes.Interface, namespace string, timeout time.Duration, ...) error
- func WaitUntilDeploymentGone(client kubernetes.Interface, namespace, name string, timeout time.Duration) error
- type FinalizeFunc
- func CreateOrUpdateClusterRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
- func CreateRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
- func CreateServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
- type Framework
- func (f *Framework) CreateBalancer(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
- func (f *Framework) CreateBalancerAndWaitUntilReady(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
- func (f *Framework) CreateBalancerOperator(namespace string, operatorImage string, namespacesToWatch []string) error
- func (f *Framework) CreatePod(namespace string, pod *corev1.Pod) error
- func (f *Framework) CreatePodAndWaitUntilReady(namespace string, pod *corev1.Pod) error
- func (f *Framework) GetPodRestartCount(namespace, name string) (map[string]int32, error)
- func (f *Framework) NewTestContext(t *testing.T) TestContext
- func (f *Framework) UpdateBalancer(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
- func (f *Framework) UpdateBalancerAndWaitUntilReady(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
- func (f *Framework) WaitForBalancerReady(balancer *balancerv1alpha1.Balancer, timeout time.Duration) error
- func (f *Framework) WaitForDeploymentCreated(namespace, name string, timeout time.Duration) error
- func (f *Framework) WaitForPodReady(pod *corev1.Pod, timeout time.Duration) error
- func (f *Framework) WaitForServiceCreated(namespace, name string, timeout time.Duration) error
- func (f *Framework) WaitUntilServiceGone(namespace, name string, timeout time.Duration) error
- type TestContext
- func (ctx *TestContext) AddFinalizerFunc(fn FinalizeFunc)
- func (ctx *TestContext) Cleanup(t *testing.T)
- func (ctx *TestContext) CreateNamespace(t *testing.T, client kubernetes.Interface) string
- func (ctx *TestContext) GetObjId() string
- func (ctx *TestContext) SetupBalancerRBAC(t *testing.T, namespace string, kubeClient kubernetes.Interface)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLabelsToNamespace ¶
func CreateCRD ¶
func CreateCRD(client clientset.Clientset, namespace string, crd *apiextensionsv1beta1.CustomResourceDefinition) error
func CreateDeployment ¶
func CreateDeployment(client kubernetes.Interface, namespace string, deployment *appv1.Deployment) error
func CreateNamespace ¶
func CreateOrUpdateClusterRole ¶
func CreateOrUpdateClusterRole(client kubernetes.Interface, relativeFilePath string) error
func DeleteClusterRole ¶
func DeleteClusterRole(client kubernetes.Interface, relativeFilePath string) error
func DeleteClusterRoleBinding ¶
func DeleteClusterRoleBinding(client kubernetes.Interface, relativeFilePath string) error
func DeleteDeployment ¶
func DeleteDeployment(client kubernetes.Interface, namespace, name string) error
func DeleteNamespace ¶
func DeleteNamespace(client kubernetes.Interface, name string) error
func DeleteRoleBinding ¶
func DeleteRoleBinding(client kubernetes.Interface, namespace string, relativeFilePath string) error
func DeleteServiceAccount ¶
func DeleteServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) error
func GetFileDescriptor ¶
GetFileDescriptor returns the file descriptor for the given relative file path.
func MakeBasicBalancer ¶
func MakeBasicBalancer(namespace, name string, versions []string, weights []int32) *balancerv1alpha1.Balancer
func ParseCRDYaml ¶
func ParseCRDYaml(relativeFilePath string) (*apiextensionsv1beta1.CustomResourceDefinition, error)
func ParseClusterRoleBindingYaml ¶
func ParseClusterRoleBindingYaml(relativeFilePath string) (*rbacv1.ClusterRoleBinding, error)
ParseClusterRoleBindingYaml creates a ClusterRoleBinding resource with given yaml file path.
func ParseClusterRoleYaml ¶
func ParseClusterRoleYaml(relativeFilePath string) (*rbacv1.ClusterRole, error)
ParseClusterRoleYaml creates a ClusterRole resource with given yaml file path.
func ParseDeploymentYaml ¶
func ParseDeploymentYaml(relativeFilePath string) (*appv1.Deployment, error)
func ParseRoleBindingYaml ¶
func ParseRoleBindingYaml(relativeFilePath string) (*rbacv1.RoleBinding, error)
func ParseServiceAccountYaml ¶
func ParseServiceAccountYaml(relativeFilePath string) (*corev1.ServiceAccount, error)
func PodRunningAndReady ¶
PodRunningAndReady returns true if pod is ready and its current status is running.
func WaitForCRDReady ¶
func WaitForPodReady ¶
func WaitForPodReady(client kubernetes.Interface, namespace string, timeout time.Duration, expectedReplicas int, opts metav1.ListOptions) error
WaitForPodReady checks whether expectedReplicas pods are running and ready.
func WaitUntilDeploymentGone ¶
func WaitUntilDeploymentGone(client kubernetes.Interface, namespace, name string, timeout time.Duration) error
WaitUntilDeploymentGone returns true only if the deployment is deleted.
Types ¶
type FinalizeFunc ¶
type FinalizeFunc func() error
func CreateOrUpdateClusterRoleBinding ¶
func CreateOrUpdateClusterRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
func CreateRoleBinding ¶
func CreateRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
func CreateServiceAccount ¶
func CreateServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)
type Framework ¶
type Framework struct { // client for operate k8s core resources KubeClient kubernetes.Interface // client for operate hliangzhao.io resources ExposerClientV1alpha1 exposerv1alpha1.ExposerV1alpha1Interface // client for operate extension resources ApiextensionsClientV1 apiextensionsv1.Interface HttpClient *http.Client MasterHost string DefaultTimeout time.Duration }
Framework is a test framework
func NewFramework ¶
func (*Framework) CreateBalancer ¶
func (f *Framework) CreateBalancer(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
func (*Framework) CreateBalancerAndWaitUntilReady ¶
func (f *Framework) CreateBalancerAndWaitUntilReady(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
func (*Framework) CreateBalancerOperator ¶
func (*Framework) CreatePodAndWaitUntilReady ¶
func (*Framework) GetPodRestartCount ¶
GetPodRestartCount gets a map recording each container's restart count for the given pod.
func (*Framework) NewTestContext ¶
func (f *Framework) NewTestContext(t *testing.T) TestContext
func (*Framework) UpdateBalancer ¶
func (f *Framework) UpdateBalancer(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
func (*Framework) UpdateBalancerAndWaitUntilReady ¶
func (f *Framework) UpdateBalancerAndWaitUntilReady(namespace string, balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)
func (*Framework) WaitForBalancerReady ¶
func (*Framework) WaitForDeploymentCreated ¶
WaitForDeploymentCreated returns true only if the deployment is created.
func (*Framework) WaitForPodReady ¶
WaitForPodReady detects pod is ready or not within timeout.
func (*Framework) WaitForServiceCreated ¶
WaitForServiceCreated returns true only if the service is created.
type TestContext ¶
type TestContext struct { Id string // contains filtered or unexported fields }
func (*TestContext) AddFinalizerFunc ¶
func (ctx *TestContext) AddFinalizerFunc(fn FinalizeFunc)
func (*TestContext) Cleanup ¶
func (ctx *TestContext) Cleanup(t *testing.T)
func (*TestContext) CreateNamespace ¶
func (ctx *TestContext) CreateNamespace(t *testing.T, client kubernetes.Interface) string
func (*TestContext) GetObjId ¶
func (ctx *TestContext) GetObjId() string
GetObjId returns an ascending ID based on the length of cleanUpFns. It is based on the premise that every new object also appends a new finalizerFn on cleanUpFns. This can e.g. be used to create multiple namespaces in the same test context.
func (*TestContext) SetupBalancerRBAC ¶
func (ctx *TestContext) SetupBalancerRBAC(t *testing.T, namespace string, kubeClient kubernetes.Interface)