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 <tnielsen@redhat.com>
This commit is contained in:
travisn committed 2019-03-01 16:16:41 -07:00
1 parent 816d698655
commit 6ca573bb34
4 files changed
-30

No files matched your search

-1
View File
@@ -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))
-8
View File
@@ -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
-2
View File
@@ -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)
}
-19
View File
@@ -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):]
}
}