Skip to content

Commit

Permalink
MB-54116 Move ResetStats before waitForStatsUpdate
Browse files Browse the repository at this point in the history
This will help to avoid sporadic failures as stats/reset
is an asynchronous operation

Change-Id: Ib2d5410e615814722be5715eff134676b76a630b
  • Loading branch information
varunv-cb committed Nov 13, 2022
1 parent 73a99cc commit 423ea52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions secondary/tests/framework/secondaryindex/n1qlclient.go
Expand Up @@ -210,6 +210,7 @@ func N1QLScanAll(indexName, bucketName, scopeName, collectionName, server string
}

logging.SetLogLevel(logging.Error)

tctx := &testContext{}
conn, err := datastore.NewSizedIndexConnection(100000, tctx)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions secondary/tests/serverlesstests/common_test.go
Expand Up @@ -582,9 +582,15 @@ func execN1qlAndWaitForStatus(n1qlStatement, bucket, scope, collection, index, s
// scanIndexReplicas scan's the index and validates if all the replicas of the index are retruning
// valid results
func scanIndexReplicas(index, bucket, scope, collection string, replicaIds []int, numScans, numDocs, numPartitions int, t *testing.T) {
log.Printf("scanIndexReplicas: Scanning all for index: %v, bucket: %v, scope: %v, collection: %v", index, bucket, scope, collection)
// Scan the index num_scans times
for i := 0; i < numScans; i++ {
scanResults, err := secondaryindex.ScanAll2(index, bucket, scope, collection, indexScanAddress, defaultlimit, c.SessionConsistency, nil)
if err != nil {
errStr := fmt.Sprintf("Observed error: %v while scanning index: %v, bucket: %v, scope: %v, collection: %v, scanResults: %v",
numDocs, index, bucket, scope, collection, len(scanResults))
FailTestIfError(err, errStr, t)
}
if len(scanResults) != numDocs {
errStr := fmt.Sprintf("Error in ScanAll. Expected len(scanResults): %v, actual: %v", numDocs, len(scanResults))
FailTestIfError(err, errStr, t)
Expand Down
4 changes: 2 additions & 2 deletions secondary/tests/serverlesstests/set01_rebalance_test.go
Expand Up @@ -87,6 +87,8 @@ func performSwapRebalance(addNodes []string, removeNodes []string, t *testing.T)
FailTestIfError(err, fmt.Sprintf("Error while removing nodes: %v from cluster", removeNodes), t)
}

secondaryindex.ResetAllIndexerStats(clusterconfig.Username, clusterconfig.Password, kvaddress)

// This sleep will ensure that the stats are propagated to client
// Also, any pending rebalance cleanup is expected to be done during
// this time - so that validateShardFiles can see cleaned up directories
Expand All @@ -103,8 +105,6 @@ func performSwapRebalance(addNodes []string, removeNodes []string, t *testing.T)
validateShardIdMapping(addedNode, t)
}

secondaryindex.ResetAllIndexerStats(clusterconfig.Username, clusterconfig.Password, kvaddress)

verifyStorageDirContents(t)
}

Expand Down

0 comments on commit 423ea52

Please sign in to comment.