Ejemplo n.º 1
0
func RangeScanForDuration_ltr(header string, wg *sync.WaitGroup, seconds float64, t *testing.T, indexName, bucketName, server string) {
	log.Printf("In Range Scan")
	defer wg.Done()

	client, e := secondaryindex.CreateClient(clusterconfig.KVAddress, "RangeForDuration")
	if e != nil {
		FailTestIfError(e, "RangeScanForDuration Thread:: Error in gsi client creation", t)
	}
	defer client.Close()

	start := time.Now()
	i := 1
	for {
		elapsed := time.Since(start)
		if elapsed.Seconds() >= seconds {
			break
		}
		low := random_letter()
		high := random_letter()

		rangeStart := time.Now()
		_, err := secondaryindex.RangeWithClient(indexName, bucketName, server, []interface{}{low}, []interface{}{high}, 3, true, defaultlimit, c.AnyConsistency, nil, client)
		rangeElapsed := time.Since(rangeStart)
		FailTestIfError(err, "RangeScanForDuration Thread:: Error in scan", t)
		log.Printf("Range Scan of %d user documents took %s\n", len(kvdocs), rangeElapsed)
		i++
	}
}
Ejemplo n.º 2
0
func CreateDropIndexesForDuration(wg *sync.WaitGroup, seconds float64, t *testing.T) {
	log.Printf("Create and Drop index operations")
	defer wg.Done()

	client, e := secondaryindex.CreateClient(clusterconfig.KVAddress, "CDIndex")
	if e != nil {
		FailTestIfError(e, "CreateDropIndexesForDuration Thread:: Error in gsi client creation", t)
	}
	defer client.Close()

	start := time.Now()
	for {
		elapsed := time.Since(start)
		if elapsed.Seconds() >= seconds {
			break
		}

		var index1 = "index_age"
		var bucketName = "default"
		err := secondaryindex.CreateSecondaryIndex(index1, bucketName, indexManagementAddress, "", []string{"age"}, false, nil, true, defaultIndexActiveTimeout, client)
		FailTestIfError(err, "Error in creating the index", t)
		time.Sleep(1 * time.Second)
		_, err = secondaryindex.RangeWithClient(index1, bucketName, indexScanAddress, []interface{}{random_num(15, 80)}, []interface{}{random_num(15, 80)}, 3, true, defaultlimit, c.AnyConsistency, nil, client)
		FailTestIfError(err, "CreateDropIndexesForDuration:: Error in scan", t)

		var index2 = "index_firstname"
		err = secondaryindex.CreateSecondaryIndex(index2, bucketName, indexManagementAddress, "", []string{"`first-name`"}, false, nil, true, defaultIndexActiveTimeout, client)
		FailTestIfError(err, "Error in creating the index", t)
		time.Sleep(1 * time.Second)
		_, err = secondaryindex.RangeWithClient(index2, bucketName, indexScanAddress, []interface{}{"M"}, []interface{}{"Z"}, 3, true, defaultlimit, c.AnyConsistency, nil, client)
		FailTestIfError(err, "CreateDropIndexesForDuration:: Error in scan", t)

		err = secondaryindex.DropSecondaryIndexWithClient(index1, bucketName, indexManagementAddress, client)
		FailTestIfError(err, "Error in drop index", t)
		time.Sleep(1 * time.Second)
		err = secondaryindex.DropSecondaryIndexWithClient(index2, bucketName, indexManagementAddress, client)
		FailTestIfError(err, "Error in drop index", t)
		time.Sleep(1 * time.Second)
	}
}
Ejemplo n.º 3
0
func SequentialRangeScanForDuration(indexName, bucketName string, seconds float64, t *testing.T) error {
	log.Printf("In Range Scan")
	start := time.Now()
	i := 1
	for {
		elapsed := time.Since(start)
		if elapsed.Seconds() >= seconds {
			break
		}
		client, e := secondaryindex.CreateClient(clusterconfig.KVAddress, "SeqTest")
		if e != nil {
			return e
		}

		_, err := secondaryindex.RangeWithClient(indexName, bucketName, indexScanAddress, []interface{}{"a"}, []interface{}{"z"}, 3, true, defaultlimit, c.AnyConsistency, nil, client)
		// log.Printf("%d  RangeScan:: Len of scanResults is: %d", i, len(scanResults))
		i++
		FailTestIfError(err, "Error in scan", t)
		client.Close()
	}

	return nil
}