func TestLargeDocumentSize(t *testing.T) { log.Printf("In TestLargeDocumentSize()") u, _ := user.Current() datapath := filepath.Join(u.HomeDir, "testdata/TwitterFeed1.txt.gz") tc.DownloadDataFile(tc.IndexTypesTwitterFeed1JSONDataS3, datapath, true) largeDocs := datautility.LoadJSONFromCompressedFile(datapath, "id_str") UpdateKVDocs(largeDocs, docs) log.Printf("Length of docs and largeDocs = %d and %d", len(docs), len(largeDocs)) bucketName := "default" index1 := "index_userscreenname" kvutility.SetKeyValues(largeDocs, bucketName, "", clusterconfig.KVAddress) err := secondaryindex.CreateSecondaryIndex(index1, bucketName, indexManagementAddress, "", []string{"`user`.screen_name"}, false, nil, true, defaultIndexActiveTimeout, nil) FailTestIfError(err, "Error in creating the index", t) docScanResults := datautility.ExpectedScanAllResponse(docs, "user.screen_name") scanResults, err := secondaryindex.ScanAll(index1, bucketName, indexScanAddress, defaultlimit, c.SessionConsistency, nil) FailTestIfError(err, "Error in scan 1: ", t) err = tv.Validate(docScanResults, scanResults) FailTestIfError(err, "Error in scan 1: result validation", t) }
func init() { log.Printf("In init()") logging.SetLogLevel(logging.Warn) var configpath string flag.StringVar(&configpath, "cbconfig", "../config/clusterrun_conf.json", "Path of the configuration file with data about Couchbase Cluster") flag.Parse() clusterconfig = tc.GetClusterConfFromFile(configpath) kvaddress = clusterconfig.KVAddress indexManagementAddress = clusterconfig.KVAddress indexScanAddress = clusterconfig.KVAddress seed = 1 proddir, bagdir = tc.FetchMonsterToolPath() // setup cbauth if _, err := cbauth.InternalRetryDefaultInit(kvaddress, clusterconfig.Username, clusterconfig.Password); err != nil { log.Fatalf("Failed to initialize cbauth: %s", err) } secondaryindex.CheckCollation = true e := secondaryindex.DropAllSecondaryIndexes(indexManagementAddress) tc.HandleError(e, "Error in DropAllSecondaryIndexes") time.Sleep(5 * time.Second) // Working with Users10k and Users_mut dataset. u, _ := user.Current() dataFilePath = filepath.Join(u.HomeDir, "testdata/Users10k.txt.gz") mutationFilePath = filepath.Join(u.HomeDir, "testdata/Users_mut.txt.gz") tc.DownloadDataFile(tc.IndexTypesStaticJSONDataS3, dataFilePath, true) tc.DownloadDataFile(tc.IndexTypesMutationJSONDataS3, mutationFilePath, true) docs = datautility.LoadJSONFromCompressedFile(dataFilePath, "docid") mut_docs = datautility.LoadJSONFromCompressedFile(mutationFilePath, "docid") 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" var bucketName = "default" err := secondaryindex.CreateSecondaryIndex(indexName, bucketName, indexManagementAddress, "", []string{"eyeColor"}, false, nil, true, defaultIndexActiveTimeout, nil) tc.HandleError(err, "Error in creating the index") // Populate the bucket now log.Printf("Populating the default bucket") kvutility.SetKeyValues(docs, "default", "", clusterconfig.KVAddress) }