Skip to content

Commit 2e834cd

Browse files
committed
Update integration tests to account for new explain command reply format
Needs additional updates to account for sharded clusters JAVA-4169
1 parent 5aac839 commit 2e834cd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

driver-core/src/test/functional/com/mongodb/internal/operation/QueryOperationHelper.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class QueryOperationHelper {
4040
} else if (winningPlan.containsKey('inputStage')) {
4141
return winningPlan.getDocument('inputStage').getDocument('keyPattern')
4242
} else if (winningPlan.containsKey('shards')) {
43-
return winningPlan.getArray('shards')[0].asDocument().getDocument('winningPlan')
44-
.getDocument('inputStage').getDocument('keyPattern')
43+
// recurse on shards[0] to get its query plan
44+
return getKeyPattern(new BsonDocument('queryPlanner', winningPlan.getArray('shards')[0].asDocument()))
4545
}
4646
}
4747
}

driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,12 @@ class DBCursorFunctionalSpecification extends FunctionalSpecification {
274274
} else if (explainPlan.queryPlanner.winningPlan.inputStage != null) {
275275
return explainPlan.queryPlanner.winningPlan.inputStage.keyPattern
276276
} else if (explainPlan.queryPlanner.winningPlan.shards != null) {
277-
return explainPlan.queryPlanner.winningPlan.shards[0].winningPlan.inputStage.keyPattern
277+
def winningPlan = explainPlan.queryPlanner.winningPlan.shards[0].winningPlan
278+
if (winningPlan.queryPlan?.inputStage != null) {
279+
return winningPlan.queryPlan.inputStage.keyPattern
280+
} else if (winningPlan.inputStage != null) {
281+
return winningPlan.inputStage.keyPattern
282+
}
278283
}
279284
}
280285
}

0 commit comments

Comments
 (0)