// keep client
keepClient = &keepclient.KeepClient{
Arvados: &arv,
- Want_replicas: 1,
+ Want_replicas: 2,
Using_proxy: true,
Client: &http.Client{},
}
return indexes
}
-func getBlockIndexes(t *testing.T) []string {
- var indexes []string
+func getBlockIndexes(t *testing.T) [][]string {
+ var indexes [][]string
for i := 0; i < len(keepServers); i++ {
- indexes = append(indexes, getBlockIndexesForServer(t, i)...)
+ indexes = append(indexes, getBlockIndexesForServer(t, i))
}
return indexes
}
func verifyBlocks(t *testing.T, notExpected []string, expected []string) {
blocks := getBlockIndexes(t)
for _, block := range notExpected {
- exists := valueInArray(block, blocks)
- if exists {
- t.Fatalf("Found unexpected block in index %s", block)
+ for i := 0; i < len(blocks); i++ {
+ exists := valueInArray(block, blocks[i])
+ if exists {
+ t.Fatalf("Found unexpected block in index %s", block)
+ }
}
}
+
+ // var blockExists [][]string
+ blockExists := make(map[string][]string)
for _, block := range expected {
- exists := valueInArray(block, blocks)
- if !exists {
- t.Fatalf("Did not find expected block in index %s", block)
+ var blockArray []string
+ for i := 0; i < len(blocks); i++ {
+ exists := valueInArray(block, blocks[i])
+ if exists {
+ blockArray = append(blockArray, block)
+ }
+ }
+ blockExists[block] = blockArray
+ }
+
+ for _, block := range expected {
+ if blockExists[block] == nil || len(blockExists[block]) != 2 {
+ t.Fatalf("Expected to find two replicas for block %s; found %d", block, len(blockExists[block]))
}
}
}
verifyBlocks(t, nil, expected)
- log.Print("Backdating blocks and deleting collection now")
-
// Backdate the to-be old blocks and delete the collections
backdateBlocks(t, oldUnusedBlockLocators)
deleteCollection(t, toBeDeletedCollectionUuid)