From 9bbd08db026ea39b625e3791ca060f026f9b6c44 Mon Sep 17 00:00:00 2001 From: Talor Itzhak Date: Thu, 21 Dec 2023 18:54:04 +0200 Subject: [PATCH] e2e: check env variable exsitance Signed-off-by: Talor Itzhak --- .../functests/11_mixedcpus/mixedcpus.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/e2e/performanceprofile/functests/11_mixedcpus/mixedcpus.go b/test/e2e/performanceprofile/functests/11_mixedcpus/mixedcpus.go index 12ba3b58ff..8d69fd1633 100644 --- a/test/e2e/performanceprofile/functests/11_mixedcpus/mixedcpus.go +++ b/test/e2e/performanceprofile/functests/11_mixedcpus/mixedcpus.go @@ -173,6 +173,30 @@ var _ = Describe("Mixedcpus", Ordered, func() { Expect(err).ToNot(HaveOccurred()) Expect(cfg.Quota).To(Or(Equal("max"), Equal("-1"))) }) + It("should have OPENSHIFT_ISOLATED_CPUS and OPENSHIFT_SHARED_CPUS env variables under the container", func() { + rl := &corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("1"), + corev1.ResourceMemory: resource.MustParse("100Mi"), + sharedCpusResource: resource.MustParse("1"), + } + p, err := createPod(ctx, testclient.Client, testutils.NamespaceTesting, + withRequests(rl), + withLimits(rl), + withRuntime(components.GetComponentName(profile.Name, components.ComponentNamePrefix))) + Expect(err).ToNot(HaveOccurred()) + cmd := printMixedCPUsEnvCmd() + output, err := pods.ExecCommandOnPod(testclient.K8sClient, p, "", cmd) + Expect(err).ToNot(HaveOccurred(), "failed to execute command on pod; cmd=%q pod=%q", cmd, client.ObjectKeyFromObject(p).String()) + isolatedAndShared := strings.Split(string(output), "\r\n") + isolated, err := cpuset.Parse(isolatedAndShared[0]) + Expect(err).ToNot(HaveOccurred()) + Expect(isolated.IsEmpty()).ToNot(BeTrue()) + shared, err := cpuset.Parse(isolatedAndShared[1]) + ppShared, _ := cpuset.Parse(string(*profile.Spec.CPU.Shared)) + Expect(err).ToNot(HaveOccurred()) + Expect(shared.Equals(ppShared)).To(BeTrue(), "OPENSHIFT_SHARED_CPUS value not equal to what configure in the performance profile."+ + "OPENSHIFT_SHARED_CPUS=%s spec.cpu.shared=%s", shared.String(), ppShared.String()) + }) }) }) @@ -217,6 +241,14 @@ func cpuSetToPerformanceCPUSet(set *cpuset.CPUSet) *performancev2.CPUSet { return &c } +func printMixedCPUsEnvCmd() []string { + return []string{ + "/bin/printenv", + "OPENSHIFT_ISOLATED_CPUS", + "OPENSHIFT_SHARED_CPUS", + } +} + // checks whether file exists and not empty func isFileExistCmd(absoluteFileName string) []string { return []string{