diff --git a/pkg/operator/cluster/controller.go b/pkg/operator/cluster/controller.go index 9b785916b..a7d8e709c 100644 --- a/pkg/operator/cluster/controller.go +++ b/pkg/operator/cluster/controller.go @@ -207,12 +207,6 @@ func (c *ClusterController) onUpdate(oldObj, newObj interface{}) { return } - // start a new cluster if it wasn't yet created because the finalizer was only added in the create method - if _, ok := c.initializedClusters[newClust.Namespace]; !ok { - c.createNewCluster(newClust) - return - } - if !clusterChanged(oldClust.Spec, newClust.Spec) { logger.Debugf("no updates made in the cluster") return diff --git a/tests/framework/installer/install_data.go b/tests/framework/installer/install_data.go index af7af6246..3210b4d59 100644 --- a/tests/framework/installer/install_data.go +++ b/tests/framework/installer/install_data.go @@ -180,12 +180,7 @@ spec: //GetRookCluster returns rook-cluster manifest func (i *InstallData) GetRookCluster(namespace, storeType, dataDirHostPath string, useAllDevices bool, mons int) string { - return `apiVersion: v1 -kind: Namespace -metadata: - name: ` + namespace + ` ---- -apiVersion: rook.io/v1alpha1 + return `apiVersion: rook.io/v1alpha1 kind: Cluster metadata: name: ` + namespace + ` diff --git a/tests/framework/installer/install_helper.go b/tests/framework/installer/install_helper.go index 0995d91bf..1fc56ef49 100644 --- a/tests/framework/installer/install_helper.go +++ b/tests/framework/installer/install_helper.go @@ -25,11 +25,15 @@ import ( "flag" "github.com/coreos/pkg/capnslog" + rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha1" "github.com/rook/rook/pkg/util/exec" "github.com/rook/rook/pkg/util/sys" "github.com/rook/rook/tests/framework/objects" "github.com/rook/rook/tests/framework/utils" "github.com/stretchr/testify/assert" + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" ) @@ -65,7 +69,6 @@ func (h *InstallHelper) CreateK8sRookOperator(namespace string) (err error) { rookOperator := h.installData.GetRookOperator(namespace) _, err = h.k8shelper.KubectlWithStdin(rookOperator, createArgs...) - if err != nil { return fmt.Errorf("Failed to create rook-operator pod : %v ", err) } @@ -136,21 +139,54 @@ func (h *InstallHelper) CreateK8sRookToolbox(namespace string) (err error) { } func (h *InstallHelper) CreateK8sRookCluster(namespace string, storeType string) (err error) { - return h.CreateK8sRookClusterWithHostPath(namespace, storeType, "", 1) -} - -func (h *InstallHelper) CreateK8sRookClusterWithHostPath(namespace string, storeType string, dataDirHostPath string, mons int) (err error) { - return h.CreateK8sRookClusterWithHostPathAndDevices(namespace, storeType, "", false, mons) + return h.CreateK8sRookClusterWithHostPathAndDevices(namespace, storeType, "", false, 1) } //CreateK8sRookCluster creates rook cluster via kubectl func (h *InstallHelper) CreateK8sRookClusterWithHostPathAndDevices(namespace, storeType, dataDirHostPath string, useAllDevices bool, mons int) error { - logger.Infof("Starting Rook Cluster") + ns := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}} + _, err := h.k8shelper.Clientset.CoreV1().Namespaces().Create(ns) + if err != nil && !errors.IsAlreadyExists(err) { + return fmt.Errorf("failed to create namespace %s. %+v", namespace, err) + } - rookCluster := h.installData.GetRookCluster(namespace, storeType, dataDirHostPath, useAllDevices, mons) + if h.k8shelper.VersionAtLeast("v1.8.0") { + logger.Infof("Starting Rook cluster with strongly typed clientset") - if _, err := h.k8shelper.KubectlWithStdin(rookCluster, createArgs...); err != nil { - return fmt.Errorf("Failed to create rook cluster : %v ", err) + clust := &rookalpha.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: namespace, + Namespace: namespace, + }, + Spec: rookalpha.ClusterSpec{ + DataDirHostPath: dataDirHostPath, + HostNetwork: false, + MonCount: mons, + Storage: rookalpha.StorageSpec{ + UseAllNodes: true, + Selection: rookalpha.Selection{ + UseAllDevices: &useAllDevices, + }, + Config: rookalpha.Config{ + StoreConfig: rookalpha.StoreConfig{ + StoreType: storeType, + DatabaseSizeMB: 1024, + JournalSizeMB: 1024, + }, + }, + }, + }, + } + _, err = h.k8shelper.RookClientset.RookV1alpha1().Clusters(namespace).Create(clust) + if err != nil { + return fmt.Errorf("failed to create cluster %s. %+v", clust.Name, err) + } + } else { + logger.Infof("Starting Rook Cluster with yaml") + rookCluster := h.installData.GetRookCluster(namespace, storeType, dataDirHostPath, useAllDevices, mons) + if _, err := h.k8shelper.KubectlWithStdin(rookCluster, createArgs...); err != nil { + return fmt.Errorf("Failed to create rook cluster : %v ", err) + } } if !h.k8shelper.IsServiceUp("rook-api", namespace) { @@ -166,11 +202,7 @@ func SystemNamespace(namespace string) string { return fmt.Sprintf("%s-system", namespace) } -func (h *InstallHelper) InstallRookOnK8s(namespace, storeType string, mons int) (bool, error) { - return h.InstallRookOnK8sWithHostPathAndDevices(namespace, storeType, "", false, false, mons) -} - -//InstallRookOnK8s installs rook on k8s +//InstallRookOnK8sWithHostPathAndDevices installs rook on k8s func (h *InstallHelper) InstallRookOnK8sWithHostPathAndDevices(namespace, storeType, dataDirHostPath string, helmInstalled, useDevices bool, mons int) (bool, error) { var err error //flag used for local debuggin purpose, when rook is pre-installed @@ -194,7 +226,7 @@ func (h *InstallHelper) InstallRookOnK8sWithHostPathAndDevices(namespace, storeT } } else { onamespace = SystemNamespace(namespace) - err := h.CreateK8sRookOperator(SystemNamespace(namespace)) + err := h.CreateK8sRookOperator(onamespace) if err != nil { logger.Errorf("Rook Operator not installed ,error -> %v", err) return false, err @@ -216,14 +248,14 @@ func (h *InstallHelper) InstallRookOnK8sWithHostPathAndDevices(namespace, storeT //Create rook cluster err = h.CreateK8sRookClusterWithHostPathAndDevices(namespace, storeType, dataDirHostPath, useDevices, mons) if err != nil { - logger.Errorf("Rook cluster %s not installed ,error -> %v", namespace, err) + logger.Errorf("Rook cluster %s not installed, error -> %v", namespace, err) return false, err } //Create rook client err = h.CreateK8sRookToolbox(namespace) if err != nil { - logger.Errorf("Rook toolbox in cluster %s not installed ,error -> %v", namespace, err) + logger.Errorf("Rook toolbox in cluster %s not installed, error -> %v", namespace, err) return false, err } logger.Infof("installed rook operator and cluster : %s on k8s %s", namespace, h.k8sVersion) @@ -231,7 +263,12 @@ func (h *InstallHelper) InstallRookOnK8sWithHostPathAndDevices(namespace, storeT } //UninstallRookFromK8s uninstalls rook from k8s -func (h *InstallHelper) UninstallRookFromK8s(namespace string, helmInstalled bool) { +func (h *InstallHelper) UninstallRook(helmInstalled bool, namespace string) { + h.UninstallRookFromMultipleNS(helmInstalled, SystemNamespace(namespace), namespace) +} + +//UninstallRookFromK8s uninstalls rook from multiple namespaces in k8s +func (h *InstallHelper) UninstallRookFromMultipleNS(helmInstalled bool, systemNamespace string, namespaces ...string) { //flag used for local debugging purpose, when rook is pre-installed skipRookInstall := strings.EqualFold(h.Env.SkipInstallRook, "true") if skipRookInstall { @@ -239,52 +276,91 @@ func (h *InstallHelper) UninstallRookFromK8s(namespace string, helmInstalled boo } logger.Infof("Uninstalling Rook") - k8sHelp, err := utils.CreateK8sHelper(h.T) - assert.NoError(h.T(), err, "cannot uninstall rook err -> %v", err) + var err error + for _, namespace := range namespaces { + + if !h.k8shelper.VersionAtLeast("v1.8.0") { + // make sure service accounts are removed before continuing on pre-1.8 + _, err = h.k8shelper.DeleteResource([]string{"-n", namespace, "serviceaccount", "rook-api"}) + h.checkError(err, "cannot remove serviceaccount rook-api in namespace") + + _, err = h.k8shelper.DeleteResource([]string{"-n", namespace, "serviceaccount", "rook-ceph-osd"}) + h.checkError(err, "cannot remove serviceaccount rook-ceph-osd") + assert.NoError(h.T(), err, "%s err -> %v", namespace, err) + + err = h.k8shelper.DeleteRoleAndBindings("rook-api", namespace) + h.checkError(err, "rook-api cluster role and binding cannot be deleted") + assert.NoError(h.T(), err, ": %+v", err) + + err = h.k8shelper.DeleteRoleAndBindings("rook-ceph-osd", namespace) + h.checkError(err, "rook-ceph-osd cluster role and binding cannot be deleted") + assert.NoError(h.T(), err, "rook-ceph-osd cluster role and binding cannot be deleted: %+v", err) + } + + _, err = h.k8shelper.DeleteResource([]string{"-n", namespace, "cluster", namespace}) + h.checkError(err, fmt.Sprintf("cannot remove cluster %s", namespace)) + + err = h.waitForCustomResourceDeletion(namespace) + h.checkError(err, fmt.Sprintf("failed to wait for namespace %s deletion", namespace)) + + _, err = h.k8shelper.DeleteResource([]string{"namespace", namespace}) + h.checkError(err, fmt.Sprintf("cannot delete namespace %s", namespace)) + } + + logger.Infof("removing the operator from namespace %s", systemNamespace) + if h.k8shelper.VersionAtLeast("v1.7.0") { + _, err = h.k8shelper.DeleteResource([]string{"crd", "clusters.rook.io", "pools.rook.io", "objectstores.rook.io", "filesystems.rook.io"}) + h.checkError(err, "cannot delete CRDs") + } else { + _, err = h.k8shelper.DeleteResource([]string{"thirdpartyresources", "cluster.rook.io", "pool.rook.io", "objectstore.rook.io", "filesystem.rook.io"}) + h.checkError(err, "cannot delete TPRs") + } if helmInstalled { err = h.helmHelper.DeleteLocalRookHelmChart(helmDeployName) - assert.NoError(h.T(), err, "cannot uninstall Rook helm chart err -> %v", err) } else { - rookOperator := h.installData.GetRookOperator(SystemNamespace(namespace)) + rookOperator := h.installData.GetRookOperator(systemNamespace) _, err = h.k8shelper.KubectlWithStdin(rookOperator, deleteArgs...) - assert.NoError(h.T(), err, "cannot uninstall rook-operator err -> %v", err) } + h.checkError(err, "cannot uninstall rook-operator") h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-agent", nil) h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("rook-agent", nil) - - _, err = k8sHelp.DeleteResource([]string{"-n", namespace, "cluster", namespace}) - assert.NoError(h.T(), err, "cannot remove cluster %s in namespace %s err -> %v", namespace, namespace, err) - - _, err = k8sHelp.DeleteResource([]string{"-n", namespace, "serviceaccount", "rook-api"}) - assert.NoError(h.T(), err, "cannot remove serviceaccount rook-api in namespace %s err -> %v", namespace, err) - - _, err = k8sHelp.DeleteResource([]string{"-n", namespace, "serviceaccount", "rook-ceph-osd"}) - assert.NoError(h.T(), err, "cannot remove serviceaccount rook-ceph-osd in namespace %s err -> %v", namespace, err) - - if h.k8shelper.VersionAtLeast("v1.6.0") { - err = h.k8shelper.DeleteRoleAndBindings("rook-api", namespace) - assert.NoError(h.T(), err, "rook-api cluster role and binding cannot be deleted: %+v", err) - - err = k8sHelp.DeleteRoleAndBindings("rook-ceph-osd", namespace) - assert.NoError(h.T(), err, "rook-ceph-osd cluster role and binding cannot be deleted: %+v", err) - } - - if h.k8shelper.VersionAtLeast("v1.7.0") { - _, err = k8sHelp.DeleteResource([]string{"crd", "clusters.rook.io", "pools.rook.io", "objectstores.rook.io", "filesystems.rook.io"}) - assert.NoError(h.T(), err, "cannot delete CRDs err -> %+v", err) - } else { - _, err = k8sHelp.DeleteResource([]string{"thirdpartyresources", "cluster.rook.io", "pool.rook.io", "objectstore.rook.io", "filesystem.rook.io"}) - assert.NoError(h.T(), err, "cannot delete TPRs err -> %+v", err) - } - - _, err = k8sHelp.DeleteResource([]string{"namespace", namespace}) - assert.NoError(h.T(), err, "cannot delete namespace %s err -> %+v", namespace, err) - h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("anon-user-access", nil) + logger.Infof("done removing the operator from namespace %s", systemNamespace) +} - logger.Infof("Rook cluster %s uninstalled", namespace) +func (h *InstallHelper) checkError(err error, message string) { + // During cleanup the resource might not be found because the test might have failed before the test was done and never created the resource + if err == nil || errors.IsNotFound(err) { + return + } + assert.NoError(h.T(), err, "%s. %+v", message, err) +} + +func (h *InstallHelper) waitForCustomResourceDeletion(namespace string) error { + if !h.k8shelper.VersionAtLeast("v1.8.0") { + // v1.6 does not have finalizers for TPRs + // v1.7 has an intermittent issue with long delay to delete resources so we will skip waiting + return nil + } + + // wait for the operator to finalize and delete the cluster CRD + for i := 0; i < 10; i++ { + _, err := h.k8shelper.RookClientset.RookV1alpha1().Clusters(namespace).Get(namespace, metav1.GetOptions{}) + if err == nil { + logger.Infof("cluster %s still exists", namespace) + time.Sleep(2 * time.Second) + continue + } + if errors.IsNotFound(err) { + logger.Infof("cluster %s deleted", namespace) + return nil + } + return err + } + logger.Errorf("gave up deleting custom cluster resource %s", namespace) + return nil } //CleanupCluster deletes a rook cluster for a namespace diff --git a/tests/framework/utils/exec_utils.go b/tests/framework/utils/exec_utils.go index df4831b2d..738f910b0 100644 --- a/tests/framework/utils/exec_utils.go +++ b/tests/framework/utils/exec_utils.go @@ -116,7 +116,7 @@ func ExecuteCommand(cmdStruct CommandArgs) CommandOut { // The program has exited with an exit code != 0 if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { log.Printf("Exit Status: %d", status.ExitStatus()) - return CommandOut{StdErr: errBuffer.String(), StdOut: outBuffer.String(), Err: exiterr} + return CommandOut{StdErr: errBuffer.String(), StdOut: outBuffer.String(), ExitCode: status.ExitStatus(), Err: exiterr} } } else { return CommandOut{StdErr: errBuffer.String(), StdOut: outBuffer.String(), Err: nil} diff --git a/tests/framework/utils/k8s_helper.go b/tests/framework/utils/k8s_helper.go index 2225685ea..f93d2328b 100644 --- a/tests/framework/utils/k8s_helper.go +++ b/tests/framework/utils/k8s_helper.go @@ -23,20 +23,21 @@ import ( "html/template" "os" "path" + "strconv" "strings" "testing" "time" - "strconv" - "github.com/coreos/pkg/capnslog" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha1" + rookclient "github.com/rook/rook/pkg/client/clientset/versioned" "github.com/rook/rook/pkg/daemon/agent/flexvolume/attachment" "github.com/rook/rook/pkg/util/exec" "github.com/stretchr/testify/require" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/kubernetes/pkg/util/version" @@ -46,6 +47,7 @@ import ( type K8sHelper struct { executor *exec.CommandExecutor Clientset *kubernetes.Clientset + RookClientset *rookclient.Clientset RunningInCluster bool T func() *testing.T } @@ -68,8 +70,12 @@ func CreateK8sHelper(t func() *testing.T) (*K8sHelper, error) { if err != nil { return nil, fmt.Errorf("failed to get clientset. %+v", err) } + rookClientset, err := rookclient.NewForConfig(config) + if err != nil { + return nil, fmt.Errorf("failed to get rook clientset. %+v", err) + } - h := &K8sHelper{executor: executor, Clientset: clientset, T: t} + h := &K8sHelper{executor: executor, Clientset: clientset, RookClientset: rookClientset, T: t} if strings.Index(config.Host, "//10.") != -1 { h.RunningInCluster = true } @@ -111,6 +117,9 @@ func (k8sh *K8sHelper) KubectlWithStdin(stdin string, args ...string) (string, e if cmdOut.ExitCode != 0 { k8slogger.Errorf("Errors Encountered while executing kubectl command : %v", cmdOut.Err.Error()) + if strings.Index(cmdOut.Err.Error(), "(NotFound)") != -1 { + return cmdOut.StdErr, errors.NewNotFound(schema.GroupResource{}, "") + } return cmdOut.StdErr, fmt.Errorf("Failed to run kubectl commands on args %v : %v", args, cmdOut.StdErr) } if cmdOut.StdOut == "" { @@ -274,7 +283,7 @@ func (k8sh *K8sHelper) DeleteResource(args []string) (string, error) { } //GetResource performs a kubectl get on give args -func (k8sh *K8sHelper) GetResource(args []string) (string, error) { +func (k8sh *K8sHelper) GetResource(args ...string) (string, error) { args = append([]string{"get"}, args...) result, err := k8sh.Kubectl(args...) if err == nil { @@ -779,10 +788,9 @@ func (k8sh *K8sHelper) CheckPodCountAndState(podName string, namespace string, m //WaitUntilPodInNamespaceIsDeleted waits for 90s for a pod in a namespace to be terminated //If the pod disappears within 90s true is returned, if not false func (k8sh *K8sHelper) WaitUntilPodInNamespaceIsDeleted(podNamePattern string, namespace string) bool { - args := []string{"-n", namespace, "pods", "-l", "app=" + podNamePattern} inc := 0 for inc < RetryLoop { - out, _ := k8sh.GetResource(args) + out, _ := k8sh.GetResource("-n", namespace, "pods", "-l", "app="+podNamePattern) if !strings.Contains(out, podNamePattern) { return true } @@ -797,10 +805,9 @@ func (k8sh *K8sHelper) WaitUntilPodInNamespaceIsDeleted(podNamePattern string, n //WaitUntilPodIsDeleted waits for 90s for a pod to be terminated //If the pod disappears within 90s true is returned, if not false func (k8sh *K8sHelper) WaitUntilPodIsDeleted(podNamePattern string) bool { - args := []string{"pods", "-l", "app=" + podNamePattern} inc := 0 for inc < RetryLoop { - out, _ := k8sh.GetResource(args) + out, _ := k8sh.GetResource("pods", "-l", "app="+podNamePattern) if !strings.Contains(out, podNamePattern) { return true } diff --git a/tests/integration/.gitignore b/tests/integration/.gitignore new file mode 100644 index 000000000..061c12b36 --- /dev/null +++ b/tests/integration/.gitignore @@ -0,0 +1 @@ +_output/ \ No newline at end of file diff --git a/tests/integration/base_deploy_test.go b/tests/integration/base_deploy_test.go index 8833e5bfe..61a4b60b2 100644 --- a/tests/integration/base_deploy_test.go +++ b/tests/integration/base_deploy_test.go @@ -20,6 +20,8 @@ import ( "fmt" "time" + "testing" + "github.com/coreos/pkg/capnslog" "github.com/rook/rook/pkg/model" "github.com/rook/rook/tests/framework/clients" @@ -29,7 +31,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "testing" ) var ( @@ -129,7 +130,7 @@ func (op BaseTestOperations) SetUp() { isRookInstalled, err := op.installer.InstallRookOnK8sWithHostPathAndDevices(op.namespace, op.storeType, op.dataDirHostPath, op.helmInstalled, op.useDevices, op.mons) assert.NoError(op.T(), err) if !isRookInstalled { - logger.Errorf("Rook Was not installed successfully") + logger.Errorf("Rook was not installed successfully") op.T().Fail() op.TearDown() op.T().FailNow() @@ -141,5 +142,5 @@ func (op BaseTestOperations) TearDown() { if op.installer.T().Failed() { op.installer.GatherAllRookLogs(op.namespace, op.installer.T().Name()) } - op.installer.UninstallRookFromK8s(op.namespace, op.helmInstalled) + op.installer.UninstallRook(op.helmInstalled, op.namespace) } diff --git a/tests/integration/block_createBlock_k8s_test.go b/tests/integration/block_createBlock_k8s_test.go index c4e0a0591..19c636f52 100644 --- a/tests/integration/block_createBlock_k8s_test.go +++ b/tests/integration/block_createBlock_k8s_test.go @@ -133,8 +133,7 @@ func (s *K8sBlockImageCreateSuite) TestCreateSamePVCTwice() { logger.Infof("Create same pvc again") result3, err3 := installer.BlockResourceOperation(s.kh, installer.GetBlockPvcDef(claimName, storageClassName, "ReadWriteOnce"), "create") - require.Contains(s.T(), result3, fmt.Sprintf("persistentvolumeclaims \"%s\" already exists", claimName), "make sure PVC is not created again. "+result3) - require.NoError(s.T(), err3) + require.Contains(s.T(), err3.Error(), fmt.Sprintf("persistentvolumeclaims \"%s\" already exists", claimName), "make sure PVC is not created again. "+result3) logger.Infof("check status of PVC") require.True(s.T(), s.kh.WaitUntilPVCIsBound(defaultNamespace, claimName)) diff --git a/tests/integration/block_mount_unmount_test.go b/tests/integration/block_mount_unmount_test.go index e688ea56f..560861374 100644 --- a/tests/integration/block_mount_unmount_test.go +++ b/tests/integration/block_mount_unmount_test.go @@ -20,6 +20,7 @@ import ( "testing" "fmt" + "github.com/rook/rook/tests/framework/clients" "github.com/rook/rook/tests/framework/contracts" "github.com/rook/rook/tests/framework/installer" @@ -83,8 +84,6 @@ func (s *BlockMountUnMountSuite) SetupSuite() { poolNameRWO := "block-pool-rwo" storageClassNameRWO := "rook-block-rwo" s.pvcNameRWX = "block-persistent-rwx" - poolNameRWX := "block-pool-rwo" - storageClassNameRWX := "rook-block-rwo" s.op, s.kh = NewBaseTestOperations(s.T, s.namespace, "bluestore", "", false, false, 1) s.testClient = GetTestClient(s.kh, s.namespace, s.op, s.T) s.bc = s.testClient.GetBlockClient() @@ -94,7 +93,7 @@ func (s *BlockMountUnMountSuite) SetupSuite() { require.Nil(s.T(), cbErr) require.True(s.T(), s.kh.WaitUntilPVCIsBound(defaultNamespace, s.pvcNameRWO), "Make sure PVC is Bound") - _, cbErr2 := installer.BlockResourceOperation(s.kh, installer.GetBlockPoolStorageClassAndPvcDef(s.namespace, poolNameRWX, storageClassNameRWX, s.pvcNameRWX, "ReadWriteMany"), "create") + _, cbErr2 := installer.BlockResourceOperation(s.kh, installer.GetBlockPvcDef(s.pvcNameRWX, storageClassNameRWO, "ReadWriteMany"), "create") require.Nil(s.T(), cbErr2) require.True(s.T(), s.kh.WaitUntilPVCIsBound(defaultNamespace, s.pvcNameRWX), "Make sure PVC is Bound") @@ -119,7 +118,7 @@ func (s *BlockMountUnMountSuite) SetupSuite() { _, wtErr2 := s.bc.BlockWrite("setup-block-rwx", blockMountPath, "Persisted message one", "bsFile1", "") require.Nil(s.T(), wtErr2) - //Unmound pod + // Unmount pod _, unmtErr1 := s.bc.BlockUnmap(getBlockPodDefintion("setup-block-rwo", s.pvcNameRWO, false), blockMountPath) _, unmtErr2 := s.bc.BlockUnmap(getBlockPodDefintion("setup-block-rwx", s.pvcNameRWO, false), blockMountPath) require.Nil(s.T(), unmtErr1) diff --git a/tests/integration/multi_cluster_deploy_test.go b/tests/integration/multi_cluster_deploy_test.go index 43273f3a9..f57a08302 100644 --- a/tests/integration/multi_cluster_deploy_test.go +++ b/tests/integration/multi_cluster_deploy_test.go @@ -18,7 +18,6 @@ package integration import ( "fmt" - "strings" "testing" "time" @@ -187,51 +186,8 @@ func (o MCTestOperations) TearDown() { o.installer.GatherAllRookLogs(o.namespace1, o.T().Name()) o.installer.GatherAllRookLogs(o.namespace2, o.T().Name()) } - deleteArgs := []string{"delete", "-f", "-"} - - skipRookInstall := strings.EqualFold(o.installer.Env.SkipInstallRook, "true") - if skipRookInstall { - return - } - - logger.Infof("Uninstalling All Rook Clusters") - k8sHelp, err := utils.CreateK8sHelper(o.T) - if err != nil { - panic(err) - } - rookOperator := o.installData.GetRookOperator(installer.SystemNamespace(o.namespace1)) - o.kh.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-agent", nil) - o.kh.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("rook-agent", nil) - - //Delete rook operator - _, err = o.kh.KubectlWithStdin(rookOperator, deleteArgs...) - if err != nil { - logger.Errorf("Rook operator cannot be deleted,err -> %v", err) - panic(err) - } - - //delete rook cluster - o.installer.CleanupCluster(o.namespace1) - o.installer.CleanupCluster(o.namespace2) - - // Delete crd/tpr - if o.kh.VersionAtLeast("v1.7.0") { - _, err = k8sHelp.DeleteResource([]string{"crd", "clusters.rook.io", "pools.rook.io", "objectstores.rook.io"}) - if err != nil { - logger.Errorf("crd cannot be deleted") - panic(err) - } - } else { - _, err = k8sHelp.DeleteResource([]string{"thirdpartyresources", "cluster.rook.io", "pool.rook.io", "objectstore.rook.io"}) - if err != nil { - logger.Errorf("tpr cannot be deleted") - panic(err) - } - } - - o.kh.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("anon-user-access", nil) - logger.Infof("Rook clusters %s and %s uninstalled", o.namespace1, o.namespace2) + o.installer.UninstallRookFromMultipleNS(false, installer.SystemNamespace(o.namespace1), o.namespace1, o.namespace2) } func (o MCTestOperations) startCluster(namespace, store string, errCh chan error) { diff --git a/tests/longhaul/base_block_test.go b/tests/longhaul/base_block_test.go index e50901df6..0663a0f45 100644 --- a/tests/longhaul/base_block_test.go +++ b/tests/longhaul/base_block_test.go @@ -4,12 +4,13 @@ import ( "sync" "testing" + "time" + "github.com/coreos/pkg/capnslog" "github.com/rook/rook/tests/framework/clients" "github.com/rook/rook/tests/framework/installer" "github.com/rook/rook/tests/framework/utils" "github.com/stretchr/testify/require" - "time" ) var ( @@ -154,7 +155,6 @@ func (o BaseLoadTestOperations) SetUp() { isRookInstalled, err := o.installer.InstallRookOnK8sWithHostPathAndDevices(o.namespace, "bluestore", "/temp/rookBackup", false, true, 3) require.NoError(o.T(), err) require.True(o.T(), isRookInstalled) - } }