Skip to content

Commit

Permalink
Merge pull request rook#4962 from travisn/pool-tests
Browse files Browse the repository at this point in the history
Ensure pools are purged during integration tests
  • Loading branch information
leseb authored Mar 4, 2020
2 parents 2e74f47 + 65f3f84 commit 545630c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions pkg/operator/ceph/pool/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (r *ReconcileCephBlockPool) reconcile(request reconcile.Request) (reconcile
logger.Debugf("deleting pool %q", cephBlockPool.Name)
err := deletePool(r.context, cephBlockPool)
if err != nil {
logger.Errorf("could not delete pool %q. %v", cephBlockPool.Name, err)
return opcontroller.ImmediateRetryResult, errors.Wrapf(err, "failed to delete pool %q. ", cephBlockPool.Name)
}

Expand Down
5 changes: 1 addition & 4 deletions tests/framework/clients/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ func (p *PoolOperation) Create(name, namespace string, replicas int) error {
return p.createOrUpdatePool(name, namespace, "apply", replicas)
}

func (p *PoolOperation) Delete(name string, namespace string) error {
return p.k8sh.ResourceOperation("delete", p.manifests.GetBlockPoolDef(name, namespace, "1"))
}

func (p *PoolOperation) Update(name, namespace string, replicas int) error {
return p.createOrUpdatePool(name, namespace, "apply", replicas)
}
Expand Down Expand Up @@ -119,5 +115,6 @@ func (p *PoolOperation) DeletePool(blockClient *BlockOperation, namespace, poolN
}
}

logger.Infof("deleting pool %q", poolName)
return p.k8sh.RookClientset.CephV1().CephBlockPools(namespace).Delete(poolName, &metav1.DeleteOptions{})
}
7 changes: 7 additions & 0 deletions tests/framework/installer/ceph_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ func (h *CephInstaller) UninstallRookFromMultipleNS(gatherLogs bool, systemNames
}
}

// The pool CRs should already be removed by the tests that created them
pools, err := h.k8shelper.RookClientset.CephV1().CephBlockPools(namespace).List(metav1.ListOptions{})
assert.NoError(h.T(), err, "failed to retrieve pool CRs")
for _, pool := range pools.Items {
assert.Failf(h.T(), "pool %q still exists", pool.Name)
}

roles := h.Manifests.GetClusterRoles(namespace, systemNamespace)
_, err = h.k8shelper.KubectlWithStdin(roles, deleteFromStdinArgs...)

Expand Down
19 changes: 15 additions & 4 deletions tests/integration/ceph_multi_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ type MultiClusterDeploySuite struct {
namespace1 string
namespace2 string
op *MCTestOperations
poolName string
}

// Deploy Multiple Rook clusters
func (mrc *MultiClusterDeploySuite) SetupSuite() {

mrc.poolName = "multi-cluster-pool1"
mrc.namespace1 = "mrc-n1"
mrc.namespace2 = "mrc-n2"

Expand All @@ -83,13 +84,23 @@ func (mrc *MultiClusterDeploySuite) AfterTest(suiteName, testName string) {

func (mrc *MultiClusterDeploySuite) createPools() {
// create a test pool in each cluster so that we get some PGs
poolName := "multi-cluster-pool1"
logger.Infof("Creating pool %s", poolName)
err := mrc.testClient.PoolClient.Create(poolName, mrc.namespace1, 1)
logger.Infof("Creating pool %s", mrc.poolName)
err := mrc.testClient.PoolClient.Create(mrc.poolName, mrc.namespace1, 1)
require.Nil(mrc.T(), err)
}

func (mrc *MultiClusterDeploySuite) deletePools() {
// create a test pool in each cluster so that we get some PGs
logger.Infof("Deleting pool %s", mrc.poolName)
if err := mrc.testClient.PoolClient.DeletePool(mrc.testClient.BlockClient, mrc.namespace1, mrc.poolName); err != nil {
logger.Errorf("failed to delete pool %q. %v", mrc.poolName, err)
} else {
logger.Infof("deleted pool %q", mrc.poolName)
}
}

func (mrc *MultiClusterDeploySuite) TearDownSuite() {
mrc.deletePools()
mrc.op.Teardown()
}

Expand Down
3 changes: 3 additions & 0 deletions tests/integration/ceph_smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func (suite *SmokeSuite) TestPoolResize() {
}

require.Equal(suite.T(), true, poolFound, fmt.Sprintf("pool %s not found", poolName))

// clean up the pool
suite.helper.PoolClient.DeletePool(suite.helper.BlockClient, suite.namespace, poolName)
}

// Smoke Test for Client CRD
Expand Down

0 comments on commit 545630c

Please sign in to comment.