func getCompactionStats(indexName, bucketName string) compactionStats {
	prefix := bucketName + ":" + indexName
	stats := secondaryindex.GetIndexStats(indexName, bucketName, clusterconfig.Username, clusterconfig.Password, kvaddress)
	//data_size := stats[prefix+":data_size"].(float64)
	disk_size := stats[prefix+":disk_size"].(float64)
	fragmentation := stats[prefix+":frag_percent"].(float64)
	num_compactions := stats[prefix+":num_compactions"].(float64)
	return compactionStats{fragmentation, num_compactions, disk_size}
}
// =====================================================
// Stats Tests
// =====================================================
func TestStat_ItemsCount(t *testing.T) {
	log.Printf("In TestStat_ItemsCount()")

	// Stat Name: items_count
	secondaryindex.DropAllSecondaryIndexes(indexManagementAddress)
	log.Printf("Emptying the default bucket")
	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)
	seed++

	log.Printf("Setting initial JSON docs in KV")
	kv.SetKeyValues(docs, "default", "", clusterconfig.KVAddress)

	indexName := "index_test1"
	bucketName := "default"
	indexField := "company"

	log.Printf("Creating a 2i")
	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)

	prefix := bucketName + ":" + indexName
	stats := secondaryindex.GetIndexStats(indexName, bucketName, clusterconfig.Username, clusterconfig.Password, kvaddress)
	itemsCount := stats[prefix+":items_count"].(float64)
	log.Printf("items_count stat is %v", itemsCount)

	if itemsCount != float64(len(docs)) {
		log.Printf("Expected number items count = %v, actual items_count stat returned = %v", len(docs), itemsCount)
		err = errors.New("items_count is incorrect for index " + prefix)
		FailTestIfError(err, "Error in TestStat_ItemsCount", t)
	}
}