Skip to content

Commit ddedfde

Browse files
committed
Fix flaky test for oplog restore
1 parent 5cc0026 commit ddedfde

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pbm/oplog/restore_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ func TestApply(t *testing.T) {
214214
oplogFile string
215215
db string
216216
coll string
217-
idxs bson.D
217+
idxs bson.M
218218
}{
219219
{
220220
desc: "index: dropIndexes-createIndexes",
221221
oplogFile: "ops_cmd_createIndexes_dropIndexes",
222222
db: "mydb",
223223
coll: "c1",
224-
idxs: bson.D{{"fieldX", -1}, {"fieldZ", -1}},
224+
idxs: bson.M{"fieldX": -1, "fieldZ": -1},
225225
},
226226
// todo: add more cases
227227
}
@@ -237,13 +237,13 @@ func TestApply(t *testing.T) {
237237
t.Fatalf("error while applying oplog: %v", err)
238238
}
239239

240-
idxs := oRestore.indexCatalog.GetIndexes(tC.db, tC.coll)
241-
if len(idxs) != len(tC.idxs) {
242-
t.Errorf("wrong number of indexes: want=%d, got=%d", len(tC.idxs), len(idxs))
240+
idxDocs := oRestore.indexCatalog.GetIndexes(tC.db, tC.coll)
241+
if len(idxDocs) != len(tC.idxs) {
242+
t.Errorf("wrong number of indexes: want=%d, got=%d", len(tC.idxs), len(idxDocs))
243243
}
244-
for i, idx := range idxs {
245-
if idx.Key[0].Key != tC.idxs[i].Key {
246-
t.Errorf("wrong key: want=%v, got=%v", tC.idxs[i], idx.Key[0])
244+
for _, idxDoc := range idxDocs {
245+
if _, ok := tC.idxs[idxDoc.Key[0].Key]; !ok {
246+
t.Errorf("wrong key: %v", idxDoc.Key[0])
247247
}
248248
}
249249
})

0 commit comments

Comments
 (0)