diff --git a/functests/1_performance/cpu_management.go b/functests/1_performance/cpu_management.go index 1873e3a20..852266388 100644 --- a/functests/1_performance/cpu_management.go +++ b/functests/1_performance/cpu_management.go @@ -50,8 +50,9 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", func() { Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("error looking for the optional selector: %v", err)) Expect(workerRTNodes).ToNot(BeEmpty()) workerRTNode = &workerRTNodes[0] - profile, err = profiles.GetByNodeLabels(testutils.NodeSelectorLabels) + By(fmt.Sprintf("Checking the profile %s with cpus %#v", profile.Name, profile.Spec.CPU)) + Expect(err).ToNot(HaveOccurred()) Expect(profile.Spec.HugePages).ToNot(BeNil()) diff --git a/functests/1_performance/performance.go b/functests/1_performance/performance.go index bfc1b3716..b1e2bfa6f 100644 --- a/functests/1_performance/performance.go +++ b/functests/1_performance/performance.go @@ -318,6 +318,7 @@ var _ = Describe("[rfe_id:27368][performance]", func() { By("Remove second profile and verify that KubeletConfig and MachineConfig were removed") Expect(testclient.Client.Delete(context.TODO(), secondProfile)).ToNot(HaveOccurred()) + Expect(profiles.WaitForDeletion(secondProfile, 60*time.Second)).ToNot(HaveOccurred()) Consistently(func() corev1.ConditionStatus { return mcps.GetConditionStatus(testutils.RoleWorkerCNF, machineconfigv1.MachineConfigPoolUpdating) diff --git a/functests/4_latency/latency.go b/functests/4_latency/latency.go index bfe1c0d8a..99796fe67 100644 --- a/functests/4_latency/latency.go +++ b/functests/4_latency/latency.go @@ -108,7 +108,13 @@ var _ = Describe("[performance] Latency Test", func() { }) AfterEach(func() { - if err := testclient.Client.Delete(context.TODO(), oslatPod); err != nil { + var err error + err = testclient.Client.Delete(context.TODO(), oslatPod) + if err != nil { + klog.Error(err) + } + err = pods.WaitForDeletion(oslatPod, 60*time.Second) + if err != nil { klog.Error(err) } }) diff --git a/functests/utils/clean/clean.go b/functests/utils/clean/clean.go index 11c738207..507704738 100644 --- a/functests/utils/clean/clean.go +++ b/functests/utils/clean/clean.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "time" "github.com/openshift-kni/performance-addon-operators/pkg/controller/performanceprofile/components/profile" @@ -12,6 +13,7 @@ import ( "github.com/openshift-kni/performance-addon-operators/functests/utils" testclient "github.com/openshift-kni/performance-addon-operators/functests/utils/client" "github.com/openshift-kni/performance-addon-operators/functests/utils/mcps" + "github.com/openshift-kni/performance-addon-operators/functests/utils/profiles" performancev1 "github.com/openshift-kni/performance-addon-operators/pkg/apis/performance/v1" "github.com/openshift-kni/performance-addon-operators/pkg/controller/performanceprofile/components" mcv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" @@ -45,6 +47,8 @@ func All() { Expect(err).ToNot(HaveOccurred(), "Failed to find perf profile") err = testclient.Client.Delete(context.TODO(), &perfProfile) Expect(err).ToNot(HaveOccurred(), "Failed to delete perf profile") + err = profiles.WaitForDeletion(&perfProfile, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Failed to wait for perf profile deletion") mcpLabel := profile.GetMachineConfigLabel(&perfProfile) key, value := components.GetFirstKeyAndValue(mcpLabel) diff --git a/functests/utils/profiles/profiles.go b/functests/utils/profiles/profiles.go index 7655e234b..44ee42d1d 100644 --- a/functests/utils/profiles/profiles.go +++ b/functests/utils/profiles/profiles.go @@ -4,9 +4,14 @@ import ( "context" "fmt" "reflect" + "time" . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/wait" + testclient "github.com/openshift-kni/performance-addon-operators/functests/utils/client" performancev1 "github.com/openshift-kni/performance-addon-operators/pkg/apis/performance/v1" v1 "github.com/openshift/custom-resource-status/conditions/v1" @@ -36,6 +41,21 @@ func GetByNodeLabels(nodeLabels map[string]string) (*performancev1.PerformancePr return result, nil } +// WaitForDeletion waits until the pod will be removed from the cluster +func WaitForDeletion(prof *performancev1.PerformanceProfile, timeout time.Duration) error { + key := types.NamespacedName{ + Name: prof.Name, + Namespace: prof.Namespace, + } + return wait.PollImmediate(time.Second, timeout, func() (bool, error) { + prof := &performancev1.PerformanceProfile{} + if err := testclient.Client.Get(context.TODO(), key, prof); errors.IsNotFound(err) { + return true, nil + } + return false, nil + }) +} + // GetConditionMessage gets the performance profile message for the given type func GetConditionMessage(nodeLabels map[string]string, conditionType v1.ConditionType) string { profile, err := GetByNodeLabels(nodeLabels)