From 40295a989c15115890b28cd60db2ccae0b0372e5 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 7 Nov 2023 19:01:36 +0530 Subject: [PATCH] ci: fix objectsuite flakiness objectstore deletion was failing with not found error, Could Not get resource in k8s -- Failed to run: kubectl [get -n object-ns CephObjectStore other-tls-test-store -o json] So added a check if it not found then donot check its further condition Signed-off-by: parth-gr --- tests/framework/utils/k8s_helper.go | 2 +- tests/integration/ceph_base_object_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/framework/utils/k8s_helper.go b/tests/framework/utils/k8s_helper.go index c90c42de161c..c69b06dd4a0f 100644 --- a/tests/framework/utils/k8s_helper.go +++ b/tests/framework/utils/k8s_helper.go @@ -297,7 +297,7 @@ func (k8sh *K8sHelper) GetResource(args ...string) (string, error) { if err == nil { return result, nil } - return "", fmt.Errorf("Could Not get resource in k8s -- %v", err) + return result, fmt.Errorf("Could Not get resource in k8s -- %v", err) } func (k8sh *K8sHelper) CreateNamespace(namespace string) error { diff --git a/tests/integration/ceph_base_object_test.go b/tests/integration/ceph_base_object_test.go index e0620fb1da31..ae905786cee4 100644 --- a/tests/integration/ceph_base_object_test.go +++ b/tests/integration/ceph_base_object_test.go @@ -23,6 +23,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "testing" "time" @@ -35,6 +36,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" ) @@ -192,6 +194,12 @@ func assertObjectStoreDeletion(t *testing.T, k8sh *utils.K8sHelper, namespace, s sleepTime := 3 * time.Second for i = 0; i < retry; i++ { storeStr, err := k8sh.GetResource("-n", namespace, "CephObjectStore", storeName, "-o", "json") + // if cephobjectstore is not found, just return the test + // no need to check deletion phases as it is already deleted + if err != nil && strings.Contains(storeStr, errors.NewNotFound(v1.Resource("cephobjectstores.ceph.rook.io"), storeName).ErrStatus.Message) { + return + } + assert.NoError(t, err) logger.Infof("store: \n%s", storeStr)