From 4743abf1e43ffff57dd2ea0a20ec3c19d3c11cf6 Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Fri, 5 Apr 2024 12:16:31 +0530 Subject: [PATCH] fetch busycpusImage using environment variables This patch uses env variable IMAGE_REGISTRY and BUSY_CPUS_IMAGE for QE image registry and busycpus image This is required to execute tests in disconnected environment where quay.io is not accessible and have to use internal private registry Signed-off-by: Niranjan M.R --- .../functests/1_performance/cpu_management.go | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/e2e/performanceprofile/functests/1_performance/cpu_management.go b/test/e2e/performanceprofile/functests/1_performance/cpu_management.go index fb59cbc37e..fe4536da93 100644 --- a/test/e2e/performanceprofile/functests/1_performance/cpu_management.go +++ b/test/e2e/performanceprofile/functests/1_performance/cpu_management.go @@ -3,6 +3,7 @@ package __performance import ( "context" "fmt" + "os" "regexp" "strconv" "strings" @@ -537,6 +538,7 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() { Context("Crio Annotations", func() { var testpod *corev1.Pod var allTestpods map[types.UID]*corev1.Pod + var busyCpusImage string annotations := map[string]string{ "cpu-load-balancing.crio.io": "disable", "cpu-quota.crio.io": "disable", @@ -544,7 +546,7 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() { BeforeAll(func() { var err error allTestpods = make(map[types.UID]*corev1.Pod) - + busyCpusImage = busyCpuImageEnv() testpod = getTestPodWithAnnotations(annotations, smtLevel) // workaround for https://github.com/kubernetes/kubernetes/issues/107074 // until https://github.com/kubernetes/kubernetes/pull/120661 lands @@ -576,7 +578,7 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() { By("Starting the pod") testpod.Spec.NodeSelector = testutils.NodeSelectorLabels - testpod.Spec.Containers[0].Image = "quay.io/ocp-edge-qe/busycpus" + testpod.Spec.Containers[0].Image = busyCpusImage testpod.Spec.Containers[0].Resources.Limits[corev1.ResourceCPU] = resource.MustParse("2") err = testclient.Client.Create(context.TODO(), testpod) Expect(err).ToNot(HaveOccurred()) @@ -951,3 +953,20 @@ func checkSchedulingDomains(workerRTNode *corev1.Node, podCpus cpuset.CPUSet, te }).WithTimeout(2*time.Minute).WithPolling(5*time.Second).ShouldNot(HaveOccurred(), errMsg) } + +// busyCpuImageEnv return busycpus image used for crio quota annotations test +// This is required for running tests on disconnected environment where images are mirrored +// in private registries. +func busyCpuImageEnv() string { + qeImageRegistry := os.Getenv("IMAGE_REGISTRY") + busyCpusImage := os.Getenv("BUSY_CPUS_IMAGE") + + if busyCpusImage == "" { + busyCpusImage = "busycpus" + } + + if qeImageRegistry == "" { + qeImageRegistry = "quay.io/ocp-edge-qe/" + } + return fmt.Sprintf("%s%s", qeImageRegistry, busyCpusImage) +}