From 6ca573bb34495a50eeeef4c2818ebcb66ab807a4 Mon Sep 17 00:00:00 2001 From: travisn Date: Tue, 26 Feb 2019 15:41:08 -0700 Subject: [PATCH] tests: remove unreliable substring checking The integration tests check for the return of substrings from calls to kubectl in a number of places. On occasion these return something slightly different and cause an unnecessary failure in the integration tests. Signed-off-by: travisn --- tests/integration/base_block_test.go | 1 - tests/integration/block_create_test.go | 8 -------- tests/integration/multi_cluster_test.go | 2 -- tests/integration/smoke_test.go | 19 ------------------- 4 files changed, 30 deletions(-) diff --git a/tests/integration/base_block_test.go b/tests/integration/base_block_test.go index ba904a61a..8c685741c 100644 --- a/tests/integration/base_block_test.go +++ b/tests/integration/base_block_test.go @@ -201,7 +201,6 @@ func setupBlockLite(helper *clients.TestClient, k8sh *utils.K8sHelper, s suite.S logger.Infof("step : Create Pool,StorageClass and PVC") res1, err := helper.PoolClient.CreateStorageClassAndPvc(clusterNamespace, poolName, storageClassName, "Delete", blockName, "ReadWriteOnce") - checkOrderedSubstrings(s.T(), res1, poolName, "created", storageClassName, "created", blockName, "created") require.NoError(s.T(), err) require.True(s.T(), k8sh.WaitUntilPVCIsBound(defaultNamespace, blockName)) diff --git a/tests/integration/block_create_test.go b/tests/integration/block_create_test.go index 605e80d7e..260ab4df1 100644 --- a/tests/integration/block_create_test.go +++ b/tests/integration/block_create_test.go @@ -75,7 +75,6 @@ func (s *BlockCreateSuite) TestCreatePVCWhenNoStorageClassExists() { defer s.tearDownTest(claimName, poolName, storageClassName, reclaimPolicy, "ReadWriteOnce") result, err := s.testClient.BlockClient.CreatePvc(claimName, storageClassName, "ReadWriteOnce") - checkOrderedSubstrings(s.T(), result, "persistentvolumeclaim", claimName, "created") require.NoError(s.T(), err) // check status of PVC @@ -108,11 +107,9 @@ func (s *BlockCreateSuite) TestCreateSamePVCTwice() { logger.Infof("create pool and storageclass") result0, err0 := s.testClient.PoolClient.Create(poolName, s.namespace, 1) - checkOrderedSubstrings(s.T(), result0, poolName, "created") require.NoError(s.T(), err0) result1, err1 := s.testClient.BlockClient.CreateStorageClass(poolName, storageClassName, reclaimPolicy, s.namespace, true) - checkOrderedSubstrings(s.T(), result1, storageClassName, "created") require.NoError(s.T(), err1) logger.Infof("make sure storageclass is created") @@ -121,7 +118,6 @@ func (s *BlockCreateSuite) TestCreateSamePVCTwice() { logger.Infof("create pvc") result2, err2 := s.testClient.BlockClient.CreatePvc(claimName, storageClassName, "ReadWriteOnce") - checkOrderedSubstrings(s.T(), result2, claimName, "created") require.NoError(s.T(), err2) logger.Infof("check status of PVC") @@ -133,7 +129,6 @@ func (s *BlockCreateSuite) TestCreateSamePVCTwice() { logger.Infof("Create same pvc again") _, err3 := s.testClient.BlockClient.CreatePvc(claimName, storageClassName, "ReadWriteOnce") - checkOrderedSubstrings(s.T(), err3.Error(), claimName, "already exists") logger.Infof("check status of PVC") require.True(s.T(), s.kh.WaitUntilPVCIsBound(defaultNamespace, claimName)) @@ -224,10 +219,8 @@ func (s *BlockCreateSuite) CheckCreatingPVC(pvcName, pvcAccessMode string) { // create pool and storageclass result0, err0 := s.testClient.PoolClient.Create(poolName, s.namespace, 1) - checkOrderedSubstrings(s.T(), result0, poolName, "created") require.NoError(s.T(), err0) result1, err1 := s.testClient.BlockClient.CreateStorageClass(poolName, storageClassName, reclaimPolicy, s.namespace, true) - checkOrderedSubstrings(s.T(), result1, storageClassName, "created") require.NoError(s.T(), err1) // make sure storageclass is created @@ -236,7 +229,6 @@ func (s *BlockCreateSuite) CheckCreatingPVC(pvcName, pvcAccessMode string) { // create pvc result2, err2 := s.testClient.BlockClient.CreatePvc(claimName, storageClassName, pvcAccessMode) - checkOrderedSubstrings(s.T(), result2, claimName, "created") require.NoError(s.T(), err2) // check status of PVC diff --git a/tests/integration/multi_cluster_test.go b/tests/integration/multi_cluster_test.go index da481e990..a4f743b6f 100644 --- a/tests/integration/multi_cluster_test.go +++ b/tests/integration/multi_cluster_test.go @@ -77,13 +77,11 @@ func (mrc *MultiClusterDeploySuite) createPools() { poolName := "multi-cluster-pool1" logger.Infof("Creating pool %s", poolName) result, err := mrc.testClient.PoolClient.Create(poolName, mrc.namespace1, 1) - checkOrderedSubstrings(mrc.T(), result, poolName, "created") require.Nil(mrc.T(), err) poolName = "multi-cluster-pool2" logger.Infof("Creating pool %s", poolName) result, err = mrc.testClient.PoolClient.Create(poolName, mrc.namespace2, 1) - checkOrderedSubstrings(mrc.T(), result, poolName, "created") require.Nil(mrc.T(), err) } diff --git a/tests/integration/smoke_test.go b/tests/integration/smoke_test.go index c4b8d1f9a..f9f34fb81 100644 --- a/tests/integration/smoke_test.go +++ b/tests/integration/smoke_test.go @@ -17,14 +17,11 @@ limitations under the License. package integration import ( - "fmt" - "strings" "testing" "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/assert" "github.com/stretchr/testify/suite" ) @@ -105,19 +102,3 @@ func (suite *SmokeSuite) TestObjectStorage_SmokeTest() { func (suite *SmokeSuite) TestRookClusterInstallation_SmokeTest() { checkIfRookClusterIsInstalled(suite.Suite, suite.k8sh, installer.SystemNamespace(suite.namespace), suite.namespace, 3) } - -func checkOrderedSubstrings(t *testing.T, input string, substrings ...string) { - if len(input) == 0 { - // Nothing to compare. An error was likely returned, which should be checked elsewhere. - return - } - original := input - for i, substring := range substrings { - if !strings.Contains(input, substring) { - assert.Fail(t, fmt.Sprintf("missing substring %d. original=%s", i, original)) - return - } - index := strings.Index(input, substring) - input = input[index+len(substring):] - } -}