Skip to content

Commit

Permalink
MB-100: Reduce wait times in functional tests
Browse files Browse the repository at this point in the history
Avoid unnecessary waiting in tests for various operations.
FlushBucket wait duration is reduced from 60s to 30s
Create/Delete/Edit bucket operation wait duration is
reduced from 30s to 15s.
Other misc wait reductions are done too.

Change-Id: I3d14b9b63d0210b087b7f8cf0872b8deb9f84eef
  • Loading branch information
prathibha-cb committed Jan 30, 2020
1 parent 18b4110 commit cb540ce
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 53 deletions.
2 changes: 1 addition & 1 deletion secondary/tests/framework/kvutility/kvdataoperations.go
Expand Up @@ -192,7 +192,7 @@ func FlushBucket(bucketName, bucketPassword, serverUserName, serverPassword, hos
}
// todo : error out if response is error
tc.HandleError(err, "Flush Bucket "+address)
time.Sleep(60 * time.Second)
time.Sleep(30 * time.Second)
log.Printf("Flushed the bucket %v", bucketName)
}

Expand Down
Expand Up @@ -167,7 +167,6 @@ func ChangeIndexerSettings(configKey string, configValue interface{}, serverUser
return err
}
nodes, err := qpclient.Nodes()
log.Printf("DBG: ChangeIndexerSettings: nodes = %v", nodes)
if err != nil {
return err
}
Expand All @@ -179,11 +178,10 @@ func ChangeIndexerSettings(configKey string, configValue interface{}, serverUser
}

host, sport, _ := net.SplitHostPort(adminurl)
log.Printf("DBG: ChangeIndexerSettings: adminurl = %v host %v sport %v", adminurl, host, sport)
iport, _ := strconv.Atoi(sport)

if host == "" || iport == 0 {
log.Printf("DBG: ChangeIndexerSettings: Host %v Port %v Nodes %+v", host, iport, nodes)
log.Printf("ChangeIndexerSettings: Host %v Port %v Nodes %+v", host, iport, nodes)
}

client := http.Client{}
Expand Down
3 changes: 1 addition & 2 deletions secondary/tests/functionaltests/common_test.go
Expand Up @@ -30,6 +30,7 @@ var dataFilePath, mutationFilePath string
var defaultIndexActiveTimeout int64 = 600 // 10 mins to wait for index to become active
var skipsetup bool
var indexerLogLevel string
var bucketOpWaitDur = time.Duration(15)

func init() {
log.Printf("In init()")
Expand Down Expand Up @@ -86,7 +87,6 @@ func init() {

secondaryindex.CheckCollation = true

time.Sleep(5 * time.Second)
// Working with Users10k and Users_mut dataset.
u, _ := user.Current()
dataFilePath = filepath.Join(u.HomeDir, "testdata/Users10k.txt.gz")
Expand All @@ -103,7 +103,6 @@ func init() {
log.Printf("Emptying the default bucket")
kvutility.EnableBucketFlush("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
kvutility.FlushBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
time.Sleep(5 * time.Second)

log.Printf("Create Index On the empty default Bucket()")
var indexName = "index_eyeColor"
Expand Down
10 changes: 5 additions & 5 deletions secondary/tests/functionaltests/set00_indexoperations_test.go
Expand Up @@ -40,7 +40,7 @@ func TestRestartNilSnapshot(t *testing.T) {
// Restart indexer process and wait for some time.
log.Printf("Restarting indexer process ...")
tc.KillIndexer()
time.Sleep(10 * time.Second)
time.Sleep(20 * time.Second)
docScanResults := datautility.ExpectedScanResponse_string(docs, "eyeColor", "b", "c", 3)
scanResults, err1 := secondaryindex.Range("index_eyeColor", "default", indexScanAddress, []interface{}{"b"}, []interface{}{"c"}, 3, false, defaultlimit, c.SessionConsistency, nil)
FailTestIfError(err1, "Error in scan", t)
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestIndexingOnBinaryBucketMeta(t *testing.T) {
numDocs := 10
kvutility.EditBucket(bucket1, "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256")
kvutility.CreateBucket(bucket2, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "")
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

docs := GenerateBinaryDocs(numDocs, bucket2, "", clusterconfig.KVAddress, clusterconfig.Username, clusterconfig.Password)

Expand Down Expand Up @@ -434,7 +434,7 @@ func TestIndexingOnBinaryBucketMeta(t *testing.T) {
kvutility.DeleteBucket(bucket2, "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucket2)
kvutility.EditBucket(bucket1, "", clusterconfig.Username, clusterconfig.Password, kvaddress, "512")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete
}

func TestRetainDeleteXATTRBinaryDocs(t *testing.T) {
Expand All @@ -450,7 +450,7 @@ func TestRetainDeleteXATTRBinaryDocs(t *testing.T) {
numDocs := 10
kvutility.EditBucket(bucket1, "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256")
kvutility.CreateBucket(bucket2, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "")
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

docs := GenerateBinaryDocsWithXATTRS(numDocs, bucket2, "", "http://"+kvaddress, clusterconfig.Username, clusterconfig.Password)

Expand Down Expand Up @@ -485,5 +485,5 @@ func TestRetainDeleteXATTRBinaryDocs(t *testing.T) {
kvutility.DeleteBucket(bucket2, "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucket2)
kvutility.EditBucket(bucket1, "", clusterconfig.Username, clusterconfig.Password, kvaddress, "512")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete*/
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete*/
}
11 changes: 6 additions & 5 deletions secondary/tests/functionaltests/set02_mutations_test.go
@@ -1,15 +1,16 @@
package functionaltests

import (
"log"
"testing"
"time"

c "github.com/couchbase/indexing/secondary/common"
tc "github.com/couchbase/indexing/secondary/tests/framework/common"
"github.com/couchbase/indexing/secondary/tests/framework/datautility"
kv "github.com/couchbase/indexing/secondary/tests/framework/kvutility"
"github.com/couchbase/indexing/secondary/tests/framework/secondaryindex"
tv "github.com/couchbase/indexing/secondary/tests/framework/validation"
"log"
"testing"
"time"
)

func CreateDocs(num int) {
Expand Down Expand Up @@ -102,7 +103,7 @@ func TestRestartIndexer(t *testing.T) {
log.Printf("In TestRestartIndexer()")

tc.KillIndexer()
time.Sleep(30 * time.Second)
time.Sleep(20 * time.Second)

var indexName = "index_age"
var bucketName = "default"
Expand Down Expand Up @@ -148,7 +149,7 @@ func TestRestartProjector(t *testing.T) {
log.Printf("In TestRestartProjector()")

tc.KillProjector()
time.Sleep(30 * time.Second)
time.Sleep(20 * time.Second)

var indexName = "index_age"
var bucketName = "default"
Expand Down
13 changes: 6 additions & 7 deletions secondary/tests/functionaltests/set05_misc_test.go
Expand Up @@ -27,9 +27,9 @@ var proddir, bagdir string
func TestBucketDefaultDelete(t *testing.T) {
kvutility.DeleteBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, "default")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete
kvutility.CreateBucket("default", "none", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "11212")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete

tc.ClearMap(docs)
tc.ClearMap(mut_docs)
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestMultipleBuckets(t *testing.T) {
for i := 1; i < numOfBuckets; i++ {
kvutility.CreateBucket(bucketNames[i], "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", proxyPorts[i])
}
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Generating docs and Populating all the buckets")
for i := 0; i < numOfBuckets; i++ {
Expand Down Expand Up @@ -471,7 +471,7 @@ func TestMultipleBuckets(t *testing.T) {
kvutility.DeleteBucket(bucketNames[3], "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucketNames[3])
kvutility.EditBucket(bucketNames[0], "", clusterconfig.Username, clusterconfig.Password, kvaddress, "512")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete

tc.ClearMap(docs)
UpdateKVDocs(bucketDocs[0], docs)
Expand Down Expand Up @@ -501,7 +501,6 @@ func TestBucketFlush(t *testing.T) {
}

kvutility.FlushBucket(bucketName, "", clusterconfig.Username, clusterconfig.Password, kvaddress)
time.Sleep(5 * time.Second)
log.Printf("TestBucketFlush:: Flushed the bucket")

for i := 0; i < 3; i++ {
Expand All @@ -526,10 +525,10 @@ func SkipTestSaslBucket(t *testing.T) {

kvutility.DeleteBucket(bucketName, "sasl", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucketName)
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete

kvutility.CreateBucket(bucketName, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "300", "11212")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete
kvdocs := generateDocs(1000, "users.prod")
kvutility.SetKeyValues(kvdocs, bucketName, bucketPassword, clusterconfig.KVAddress)
err := secondaryindex.CreateSecondaryIndex(indexName, bucketName, indexManagementAddress, "", []string{field}, false, nil, true, defaultIndexActiveTimeout, nil)
Expand Down
8 changes: 2 additions & 6 deletions secondary/tests/functionaltests/set06_datashapes_test.go
Expand Up @@ -163,7 +163,7 @@ func TestSameIndexNameInTwoBuckets(t *testing.T) {
for i := 1; i < numOfBuckets; i++ {
kvutility.CreateBucket(bucketNames[i], "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", proxyPorts[i])
}
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Generating docs and Populating all the buckets")
for i := 0; i < numOfBuckets; i++ {
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestSameIndexNameInTwoBuckets(t *testing.T) {
kvutility.EditBucket(bucketNames[0], "", clusterconfig.Username, clusterconfig.Password, kvaddress, "512")
kvutility.DeleteBucket(bucketNames[1], "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucketNames[1])
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete

tc.ClearMap(docs)
UpdateKVDocs(bucketDocs[0], docs)
Expand Down Expand Up @@ -260,7 +260,6 @@ func TestVeryLargeIndexKey(t *testing.T) {
tc.ClearMap(docs)
kvutility.FlushBucket("default", "", clusterconfig.Username,
clusterconfig.Password, clusterconfig.KVAddress)
time.Sleep(5 * time.Second)

log.Printf("TestVeryLargeIndexKey:: Flushed the bucket")

Expand Down Expand Up @@ -313,7 +312,6 @@ func TestVeryLargeIndexKey(t *testing.T) {

kvutility.FlushBucket("default", "", clusterconfig.Username,
clusterconfig.Password, clusterconfig.KVAddress)
time.Sleep(5 * time.Second)
}

// Index key size = c.TEMP_BUF_SIZE +/- delta
Expand All @@ -335,7 +333,6 @@ func TestTempBufScanResult(t *testing.T) {
tc.ClearMap(docs)
kvutility.FlushBucket("default", "", clusterconfig.Username,
clusterconfig.Password, clusterconfig.KVAddress)
time.Sleep(5 * time.Second)

log.Printf("TestTempBufScanResult:: Flushed the bucket")

Expand Down Expand Up @@ -439,7 +436,6 @@ func TestTempBufScanResult(t *testing.T) {

kvutility.FlushBucket("default", "", clusterconfig.Username,
clusterconfig.Password, clusterconfig.KVAddress)
time.Sleep(5 * time.Second)
}

func recalcStrlen(strlen int, deltaPercent float64) int {
Expand Down
14 changes: 6 additions & 8 deletions secondary/tests/functionaltests/set07_system_test.go
Expand Up @@ -120,7 +120,7 @@ func TestMultipleBucketsDeferredBuild(t *testing.T) {
secondaryindex.RemoveClientForBucket(kvaddress, bucket2)
kvutility.CreateBucket(bucket2, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "11213")
tc.ClearMap(docs)
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Setting JSON docs in KV")
bucket1docs := generateDocs(50000, "users.prod")
Expand All @@ -147,7 +147,6 @@ func TestMultipleBucketsDeferredBuild(t *testing.T) {

err = secondaryindex.BuildIndexesAsync([]uint64{defn1}, indexManagementAddress, defaultIndexActiveTimeout)
FailTestIfError(err, "Error from BuildIndexesAsync of index1", t)
//time.Sleep(1 * time.Second)

err = secondaryindex.BuildIndexesAsync([]uint64{defn2, defn3}, indexManagementAddress, defaultIndexActiveTimeout)
//FailTestIfNoError(err, "Error from BuildIndexesAsync", t)
Expand Down Expand Up @@ -1034,7 +1033,7 @@ func TestCreateBucket_AnotherIndexBuilding(t *testing.T) {
kvutility.DeleteBucket(bucket2, "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucket2)
tc.ClearMap(docs)
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Setting JSON docs in KV")
bucket1docs := generateDocs(200000, "test.prod")
Expand All @@ -1045,7 +1044,7 @@ func TestCreateBucket_AnotherIndexBuilding(t *testing.T) {
FailTestIfError(err, "Error in creating the index1", t)

kvutility.CreateBucket(bucket2, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "11213")
time.Sleep(10 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)
kvutility.SetKeyValues(bucket2docs, bucket2, "", clusterconfig.KVAddress)
err = secondaryindex.CreateSecondaryIndexAsync(index2, bucket2, indexManagementAddress, "", []string{"age"}, false, nil, true, nil)
FailTestIfError(err, "Error in creating the index1", t)
Expand Down Expand Up @@ -1103,7 +1102,7 @@ func TestDropBucket2Index_Bucket1IndexBuilding(t *testing.T) {
secondaryindex.RemoveClientForBucket(kvaddress, bucket2)
kvutility.CreateBucket(bucket2, "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", "11213")
tc.ClearMap(docs)
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Setting JSON docs in KV")
bucket1docs := generateDocs(100000, "test.prod")
Expand Down Expand Up @@ -1174,10 +1173,9 @@ func TestDeleteBucketWhileInitialIndexBuild(t *testing.T) {
log.Printf("============== DBG: Create bucket %v", bucketNames[i])
kvutility.CreateBucket(bucketNames[i], "sasl", "", clusterconfig.Username, clusterconfig.Password, kvaddress, "256", proxyPorts[i])
kvutility.EnableBucketFlush(bucketNames[i], "", clusterconfig.Username, clusterconfig.Password, kvaddress)
time.Sleep(1 * time.Second)
kvutility.FlushBucket(bucketNames[i], "", clusterconfig.Username, clusterconfig.Password, kvaddress)
}
time.Sleep(30 * time.Second)
time.Sleep(bucketOpWaitDur * time.Second)

log.Printf("Generating docs and Populating all the buckets")
j := 0
Expand Down Expand Up @@ -1255,7 +1253,7 @@ func TestDeleteBucketWhileInitialIndexBuild(t *testing.T) {
kvutility.DeleteBucket(bucketNames[3], "", clusterconfig.Username, clusterconfig.Password, kvaddress)
secondaryindex.RemoveClientForBucket(kvaddress, bucketNames[3])
kvutility.EditBucket(bucketNames[0], "", clusterconfig.Username, clusterconfig.Password, kvaddress, "512")
time.Sleep(30 * time.Second) // Sleep after bucket create or delete
time.Sleep(bucketOpWaitDur * time.Second) // Sleep after bucket create or delete

tc.ClearMap(docs)
UpdateKVDocs(bucketDocs[0], docs)
Expand Down
Expand Up @@ -3,13 +3,14 @@ package functionaltests
import (
"errors"
"fmt"
tc "github.com/couchbase/indexing/secondary/tests/framework/common"
kv "github.com/couchbase/indexing/secondary/tests/framework/kvutility"
"github.com/couchbase/indexing/secondary/tests/framework/secondaryindex"
"log"
"path/filepath"
"testing"
"time"

tc "github.com/couchbase/indexing/secondary/tests/framework/common"
kv "github.com/couchbase/indexing/secondary/tests/framework/kvutility"
"github.com/couchbase/indexing/secondary/tests/framework/secondaryindex"
)

// =====================================================
Expand Down Expand Up @@ -76,7 +77,6 @@ func TestStat_ItemsCount(t *testing.T) {
kv.EnableBucketFlush("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
kv.FlushBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
tc.ClearMap(docs)
time.Sleep(5 * time.Second)

log.Printf("Generating JSON docs")
docs = GenerateJsons(10000, seed, filepath.Join(proddir, "test.prod"), bagdir)
Expand All @@ -93,7 +93,7 @@ func TestStat_ItemsCount(t *testing.T) {
err := secondaryindex.CreateSecondaryIndex(indexName, bucketName, indexManagementAddress, "", []string{indexField}, false, nil, true, defaultIndexActiveTimeout, nil)
FailTestIfError(err, "Error in creating the index", t)

time.Sleep(10 * time.Second)
time.Sleep(5 * time.Second)

prefix := bucketName + ":" + indexName
stats := secondaryindex.GetIndexStats(indexName, bucketName, clusterconfig.Username, clusterconfig.Password, kvaddress)
Expand Down Expand Up @@ -145,7 +145,6 @@ func SkipTestCompactionDiskMinSize(t *testing.T) {
kv.EnableBucketFlush("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
kv.FlushBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
tc.ClearMap(docs)
time.Sleep(5 * time.Second)

log.Printf("Generating JSON docs")
docs = GenerateJsons(10000, seed, filepath.Join(proddir, "test.prod"), bagdir)
Expand Down Expand Up @@ -201,7 +200,6 @@ func compactionFragmentationTest(fragmentationValue float64, updateFragmentation
kv.EnableBucketFlush("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
kv.FlushBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
tc.ClearMap(docs)
time.Sleep(5 * time.Second)

log.Printf("Generating JSON docs")
docs = GenerateJsons(10000, seed, filepath.Join(proddir, "test.prod"), bagdir)
Expand Down
1 change: 0 additions & 1 deletion secondary/tests/functionaltests/set10_n1qlclient_test.go
Expand Up @@ -33,7 +33,6 @@ func TestBufferedScan_BackfillDisabled(t *testing.T) {
e := secondaryindex.DropAllSecondaryIndexes(indexManagementAddress)
FailTestIfError(e, "Error in DropAllSecondaryIndexes", t)
kvutility.FlushBucket(bucketName, "", clusterconfig.Username, clusterconfig.Password, kvaddress)
time.Sleep(5 * time.Second)

kvdocs := generateDocs(50000, "users.prod")
kvutility.SetKeyValues(kvdocs, bucketName, "", clusterconfig.KVAddress)
Expand Down
9 changes: 4 additions & 5 deletions secondary/tests/functionaltests/set11_spock_test.go
Expand Up @@ -3,17 +3,17 @@ package functionaltests
import (
"errors"
"fmt"
"log"
"strconv"
"testing"

c "github.com/couchbase/indexing/secondary/common"
qc "github.com/couchbase/indexing/secondary/queryport/client"
tc "github.com/couchbase/indexing/secondary/tests/framework/common"
"github.com/couchbase/indexing/secondary/tests/framework/datautility"
"github.com/couchbase/indexing/secondary/tests/framework/kvutility"
"github.com/couchbase/indexing/secondary/tests/framework/secondaryindex"
tv "github.com/couchbase/indexing/secondary/tests/framework/validation"
"log"
"strconv"
"testing"
"time"
)

var offset int64
Expand All @@ -28,7 +28,6 @@ func TestMultiScanSetup(t *testing.T) {
log.Printf("Emptying the default bucket")
kvutility.EnableBucketFlush("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
kvutility.FlushBucket("default", "", clusterconfig.Username, clusterconfig.Password, kvaddress)
time.Sleep(5 * time.Second)

// Populate the bucket now
log.Printf("Populating the default bucket")
Expand Down

0 comments on commit cb540ce

Please sign in to comment.