From 45a639b16ca492f97f570482a2e109909d8edd56 Mon Sep 17 00:00:00 2001 From: Ming Date: Tue, 11 Apr 2023 08:27:43 +0000 Subject: [PATCH] Add resource policies E2E test Signed-off-by: Ming --- .../debug-bundle-1669709736054564976.tar.gz | Bin 22032 -> 0 bytes test/e2e/e2e_suite_test.go | 2 + test/e2e/pv-backup/pv-backup-filter.go | 10 +- test/e2e/resource-filtering/base.go | 2 +- test/e2e/resource-filtering/exclude_label.go | 2 +- test/e2e/resource-filtering/label_selector.go | 2 +- .../e2e/resourcepolicies/resource_policies.go | 281 ++++++++++++++++++ test/e2e/schedule/ordered_resources.go | 2 +- test/e2e/util/k8s/common.go | 24 +- test/e2e/util/k8s/configmap.go | 24 +- test/e2e/util/k8s/deployment.go | 73 +++-- test/e2e/util/k8s/pod.go | 4 + test/e2e/util/k8s/pvc.go | 71 ++++- test/e2e/util/k8s/sc.go | 10 + 14 files changed, 453 insertions(+), 54 deletions(-) delete mode 100644 test/e2e/debug-bundle-1669709736054564976.tar.gz create mode 100644 test/e2e/resourcepolicies/resource_policies.go diff --git a/test/e2e/debug-bundle-1669709736054564976.tar.gz b/test/e2e/debug-bundle-1669709736054564976.tar.gz deleted file mode 100644 index 293844e3504872e30d66d2edceb439cbc3a6f7d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22032 zcmV)=K!m>^iwFP!00000|LnbMbDPMvH=egUU*Wu=^x}W^*$Fatkn72*zvDQGXL51u zBy-EuJS}KsVgw2xJI>U6_oui>0t8r1HwaL(cU8uA-+sLotlwHJdfh@BdM-O%I))7& zHFI$s$ElJO{mXG&{@>`oc}bLbQB)OKdc^UfEOU<-xuNxBuB9IU?-9p&t{YUfd+6_Z za6P#)@;{ma{bsrNEB=QyrlM)ckYi0<&{;_`bym~4DXVIRDRTo?pz$<;7=k{zIA>;I$JMjOALBsO=f<<6xL+Qw zVfngy3%&cJYiKXx=OeGEqr^(S19OhJ#XAAhEP z{5$>Mq3n+ruHip@w|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5R4FRPsX02@tZouKL%HQyL zC6FayV2q5O?Hkb}+tC&-Em%n@ZPtXvk3h>Z# zLSI=<#fp04YamJsN}oxlUZk}D+&0|)|0Y{Kzt_msD->WUH9fPqhDwjEZ~~vXq>Lpm z7SqilOvVC6rHeIf*pkaH|vD}5&$UD>kmbG0Td~TQ(DmbBLIrLLIEi9&$F?2 z+AH#0`liW0fn7tEt{^Fa(#ThIDm{9S*-Z;>e6=$cWx&q^dpiWxo$yUF23((FX>V8 z8HVd5o3*95#VWG`)LkXu$i!-ja~-ft!ALYC@|64VPPKR8yS$8+{gpm@MN-@2oX}_o zy)c<>9%W0pqk$#V8P8`^KLi=*!&(usBSm%pw1&eiBVOPfi%0%Lez|;w_)TZ%N$$;| zr6aHTfe>OWF#>x#Fx3PIZdOr_2M@z;iy&Cms8omlxredrFU7TxAKIq@Jd6oQs=}5 zV$vdB^45+slq+$~v*pY3jrNF*&~8S5rKjehqE*09UEA&7i%*w+uhX2h?L(2&0gWyq3;)~mC?u33o)TV)T_tGI8VCjTFZ)e?)vl$1O!<;_Hh6Dwc!W?yv(^D{Pw$XdqZ)tt~Z`pN-Tq%)rJu=R#ON;$-)pr!?=S#2T z%76XEo3QVtv_AQnD8OirvxiDmLFmWBZ=GYZ5Mg|hO6B{xaoHfr<)A9g{pm*gPW|W# z(JA40c#qbe@UfOZt3EX1>lpW2jAF;Qo-lz4MykK0|pAh>i#T`!FR zQxgL=cu7xUT0}oG&d76E9sz@X;}4AI-r3UvzLB5$7=~M`=^4id0uQPP_>QIZkh?5> zoK;|nlH~)v8|NY`kWFssnT1$AlyW#{MDcR6ESS~Z!p@VigNPBi3wd#`a4TQ1bqQ0o UwaoxAF) /%s/%s", namespace, podName, volume, volume, filename)} cmd := exec.CommandContext(ctx, "kubectl", arg...) fmt.Printf("Kubectl exec cmd =%v\n", cmd) return cmd.Run() } -func ReadFileFromPodVolume(ctx context.Context, namespace, podName, volume, filename string) (string, error) { - arg := []string{"exec", "-n", namespace, "-c", podName, podName, +func ReadFileFromPodVolume(ctx context.Context, namespace, podName, containerName, volume, filename string) (string, error) { + arg := []string{"exec", "-n", namespace, "-c", containerName, podName, "--", "cat", fmt.Sprintf("/%s/%s", volume, filename)} cmd := exec.CommandContext(ctx, "kubectl", arg...) fmt.Printf("Kubectl exec cmd =%v\n", cmd) diff --git a/test/e2e/util/k8s/configmap.go b/test/e2e/util/k8s/configmap.go index 0f311fa1d2..e4edd0667b 100644 --- a/test/e2e/util/k8s/configmap.go +++ b/test/e2e/util/k8s/configmap.go @@ -42,6 +42,20 @@ func CreateConfigMap(c clientset.Interface, ns, name string, labels, data map[st return c.CoreV1().ConfigMaps(ns).Create(context.TODO(), cm, metav1.CreateOptions{}) } +func CreateConfigMapFromYAMLData(c clientset.Interface, yamlData, cmName, namespace string) error { + cmData := make(map[string]string) + cmData[cmName] = yamlData + cm := &v1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: cmName, + Namespace: namespace, + }, + Data: cmData, + } + _, err := c.CoreV1().ConfigMaps(namespace).Create(context.TODO(), cm, metav1.CreateOptions{}) + return err +} + // WaitForConfigMapComplete uses c to wait for completions to complete for the Job jobName in namespace ns. func WaitForConfigMapComplete(c clientset.Interface, ns, configmapName string) error { return wait.Poll(PollInterval, PollTimeout, func() (bool, error) { @@ -57,10 +71,18 @@ func GetConfigmap(c clientset.Interface, ns, secretName string) (*v1.ConfigMap, return c.CoreV1().ConfigMaps(ns).Get(context.TODO(), secretName, metav1.GetOptions{}) } -func WaitForConfigmapDelete(c clientset.Interface, ns, name string) error { +func DeleteConfigmap(c clientset.Interface, ns, name string) error { if err := c.CoreV1().ConfigMaps(ns).Delete(context.TODO(), name, metav1.DeleteOptions{}); err != nil { return errors.Wrap(err, fmt.Sprintf("failed to delete configmap in namespace %q", ns)) } + return nil +} + +func WaitForConfigmapDelete(c clientset.Interface, ns, name string) error { + if err := DeleteConfigmap(c, ns, name); err != nil { + return err + } + return waitutil.PollImmediateInfinite(5*time.Second, func() (bool, error) { if _, err := c.CoreV1().ConfigMaps(ns).Get(context.TODO(), ns, metav1.GetOptions{}); err != nil { diff --git a/test/e2e/util/k8s/deployment.go b/test/e2e/util/k8s/deployment.go index e9f5572fbf..bc4c30a3df 100644 --- a/test/e2e/util/k8s/deployment.go +++ b/test/e2e/util/k8s/deployment.go @@ -35,46 +35,73 @@ const ( PollTimeout = 15 * time.Minute ) +// DeploymentBuilder builds Deployment objects. +type DeploymentBuilder struct { + *apps.Deployment +} + +func (d *DeploymentBuilder) Result() *apps.Deployment { + return d.Deployment +} + // newDeployment returns a RollingUpdate Deployment with a fake container image -func NewDeployment(name, ns string, replicas int32, labels map[string]string, containers []v1.Container) *apps.Deployment { +func NewDeployment(name, ns string, replicas int32, labels map[string]string, containers []v1.Container) *DeploymentBuilder { if containers == nil { containers = []v1.Container{ { - Name: fmt.Sprintf("container-%s", "busybox"), + Name: "container-busybox", Image: "gcr.io/velero-gcp/busybox:latest", Command: []string{"sleep", "1000000"}, }, } } - return &apps.Deployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", - APIVersion: "apps/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns, - Name: name, - Labels: labels, - }, - Spec: apps.DeploymentSpec{ - Replicas: &replicas, - Selector: &metav1.LabelSelector{MatchLabels: labels}, - Strategy: apps.DeploymentStrategy{ - Type: apps.RollingUpdateDeploymentStrategyType, - RollingUpdate: new(apps.RollingUpdateDeployment), + return &DeploymentBuilder{ + &apps.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", }, - Template: v1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: labels, + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns, + Name: name, + Labels: labels, + }, + Spec: apps.DeploymentSpec{ + Replicas: &replicas, + Selector: &metav1.LabelSelector{MatchLabels: labels}, + Strategy: apps.DeploymentStrategy{ + Type: apps.RollingUpdateDeploymentStrategyType, + RollingUpdate: new(apps.RollingUpdateDeployment), }, - Spec: v1.PodSpec{ - Containers: containers, + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: labels, + }, + Spec: v1.PodSpec{ + Containers: containers, + }, }, }, }, } } +func (d *DeploymentBuilder) WithVolume(vols []*v1.Volume) *DeploymentBuilder { + vmList := []v1.VolumeMount{} + for i, v := range vols { + vmList = append(vmList, v1.VolumeMount{ + Name: v.Name, + MountPath: "/" + v.Name, + }) + d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, *vols[i]) + } + + // NOTE here just mount volumes to the first container + d.Spec.Template.Spec.Containers[0].VolumeMounts = vmList + + return d +} + func CreateDeploy(c clientset.Interface, ns string, deployment *apps.Deployment) error { _, err := c.AppsV1().Deployments(ns).Create(context.TODO(), deployment, metav1.CreateOptions{}) return err diff --git a/test/e2e/util/k8s/pod.go b/test/e2e/util/k8s/pod.go index 4caf299a33..9ed23d1a64 100644 --- a/test/e2e/util/k8s/pod.go +++ b/test/e2e/util/k8s/pod.go @@ -77,3 +77,7 @@ func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podNa return client.ClientGo.CoreV1().Pods(namespace).Update(ctx, newPod, metav1.UpdateOptions{}) } + +func ListPods(ctx context.Context, client TestClient, namespace string) (*corev1.PodList, error) { + return client.ClientGo.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{}) +} diff --git a/test/e2e/util/k8s/pvc.go b/test/e2e/util/k8s/pvc.go index 32e6b95287..428064e53a 100644 --- a/test/e2e/util/k8s/pvc.go +++ b/test/e2e/util/k8s/pvc.go @@ -24,28 +24,67 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func CreatePVC(client TestClient, ns, name, sc string, ann map[string]string) (*corev1.PersistentVolumeClaim, error) { +// PVCBuilder builds PVC objects. +type PVCBuilder struct { + *corev1.PersistentVolumeClaim +} + +func (p *PVCBuilder) Result() *corev1.PersistentVolumeClaim { + return p.PersistentVolumeClaim +} + +func NewPVC(ns, name string) *PVCBuilder { oMeta := metav1.ObjectMeta{} - oMeta = metav1.ObjectMeta{Name: name} - if ann != nil { - oMeta.Annotations = ann - } - pvc := &corev1.PersistentVolumeClaim{ - ObjectMeta: oMeta, - Spec: corev1.PersistentVolumeClaimSpec{ - AccessModes: []corev1.PersistentVolumeAccessMode{ - corev1.ReadWriteOnce, - }, - Resources: corev1.ResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceStorage: resource.MustParse("1Gi"), + oMeta = metav1.ObjectMeta{Name: name, Namespace: ns} + return &PVCBuilder{ + &corev1.PersistentVolumeClaim{ + ObjectMeta: oMeta, + Spec: corev1.PersistentVolumeClaimSpec{ + AccessModes: []corev1.PersistentVolumeAccessMode{ + corev1.ReadWriteOnce, // Default read write once + }, + Resources: corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceStorage: resource.MustParse("1Gi"), // Default 1Gi + }, }, }, - StorageClassName: &sc, }, } - return client.ClientGo.CoreV1().PersistentVolumeClaims(ns).Create(context.TODO(), pvc, metav1.CreateOptions{}) } + +func (p *PVCBuilder) WithAnnotation(ann map[string]string) *PVCBuilder { + p.Annotations = ann + return p +} + +func (p *PVCBuilder) WithStorageClass(sc string) *PVCBuilder { + p.Spec.StorageClassName = &sc + return p +} + +func (p *PVCBuilder) WithResourceStorage(q resource.Quantity) *PVCBuilder { + p.Spec.Resources.Requests[corev1.ResourceStorage] = q + return p +} + +func CreatePVC(client TestClient, ns, name, sc string, ann map[string]string) (*corev1.PersistentVolumeClaim, error) { + pvcBulder := NewPVC(ns, name) + if ann != nil { + pvcBulder.WithAnnotation(ann) + } + if sc != "" { + pvcBulder.WithStorageClass(sc) + } + + return client.ClientGo.CoreV1().PersistentVolumeClaims(ns).Create(context.TODO(), pvcBulder.Result(), metav1.CreateOptions{}) +} + +func CreatePvc(client TestClient, pvcBulder *PVCBuilder) error { + _, err := client.ClientGo.CoreV1().PersistentVolumeClaims(pvcBulder.Namespace).Create(context.TODO(), pvcBulder.Result(), metav1.CreateOptions{}) + return err +} + func GetPVC(ctx context.Context, client TestClient, namespace string, pvcName string) (*corev1.PersistentVolumeClaim, error) { return client.ClientGo.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, pvcName, metav1.GetOptions{}) } diff --git a/test/e2e/util/k8s/sc.go b/test/e2e/util/k8s/sc.go index bcc5cbfed6..3878018b2f 100644 --- a/test/e2e/util/k8s/sc.go +++ b/test/e2e/util/k8s/sc.go @@ -3,6 +3,9 @@ package k8s import ( "context" "fmt" + + "github.com/pkg/errors" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func InstallStorageClass(ctx context.Context, yaml string) error { @@ -10,3 +13,10 @@ func InstallStorageClass(ctx context.Context, yaml string) error { err := KubectlApplyByFile(ctx, yaml) return err } + +func DeleteStorageClass(ctx context.Context, client TestClient, name string) error { + if err := client.ClientGo.StorageV1().StorageClasses().Delete(ctx, name, v1.DeleteOptions{}); err != nil { + return errors.Wrapf(err, "Could not retrieve storage classes %s", name) + } + return nil +}