summaryrefslogtreecommitdiff
path: root/src/mongo/client/fetcher_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/client/fetcher_test.cpp')
-rw-r--r--src/mongo/client/fetcher_test.cpp160
1 files changed, 55 insertions, 105 deletions
diff --git a/src/mongo/client/fetcher_test.cpp b/src/mongo/client/fetcher_test.cpp
index 19713755b11..f0fa26cf7b3 100644
--- a/src/mongo/client/fetcher_test.cpp
+++ b/src/mongo/client/fetcher_test.cpp
@@ -405,8 +405,7 @@ TEST_F(FetcherTest, FindCommandFailed2) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("ok" << 0 << "errmsg"
<< "bad hint"
- << "code"
- << int(ErrorCodes::BadValue)),
+ << "code" << int(ErrorCodes::BadValue)),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::BadValue, status.code());
@@ -432,10 +431,8 @@ TEST_F(FetcherTest, CursorIdFieldMissing) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("ns"
<< "db.coll"
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
@@ -446,10 +443,8 @@ TEST_F(FetcherTest, CursorIdNotLongNumber) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 123.1 << "ns"
<< "db.coll"
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
@@ -469,11 +464,11 @@ TEST_F(FetcherTest, NamespaceFieldMissing) {
TEST_F(FetcherTest, NamespaceNotAString) {
ASSERT_OK(fetcher->schedule());
- processNetworkResponse(
- BSON("cursor" << BSON("id" << 123LL << "ns" << 123 << "firstBatch" << BSONArray()) << "ok"
- << 1),
- ReadyQueueState::kEmpty,
- FetcherState::kInactive);
+ processNetworkResponse(BSON("cursor"
+ << BSON("id" << 123LL << "ns" << 123 << "firstBatch" << BSONArray())
+ << "ok" << 1),
+ ReadyQueueState::kEmpty,
+ FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
ASSERT_STRING_CONTAINS(status.reason(), "'cursor.ns' field must be a string");
}
@@ -482,10 +477,8 @@ TEST_F(FetcherTest, NamespaceEmpty) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 123LL << "ns"
<< ""
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::BadValue, status.code());
@@ -496,10 +489,8 @@ TEST_F(FetcherTest, NamespaceMissingCollectionName) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 123LL << "ns"
<< "db."
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::BadValue, status.code());
@@ -510,8 +501,7 @@ TEST_F(FetcherTest, FirstBatchFieldMissing) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll")
- << "ok"
- << 1),
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
@@ -522,10 +512,8 @@ TEST_F(FetcherTest, FirstBatchNotAnArray) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << 123)
- << "ok"
- << 1),
+ << "firstBatch" << 123)
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
@@ -536,10 +524,8 @@ TEST_F(FetcherTest, FirstBatchArrayContainsNonObject) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(8))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(8))
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_EQUALS(ErrorCodes::FailedToParse, status.code());
@@ -551,10 +537,8 @@ TEST_F(FetcherTest, FirstBatchEmptyArray) {
ASSERT_OK(fetcher->schedule());
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_OK(status);
@@ -568,10 +552,8 @@ TEST_F(FetcherTest, FetchOneDocument) {
const BSONObj doc = BSON("_id" << 1);
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_OK(status);
@@ -596,10 +578,8 @@ TEST_F(FetcherTest, SetNextActionToContinueWhenNextBatchIsNotAvailable) {
};
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
ASSERT_OK(status);
@@ -629,10 +609,8 @@ TEST_F(FetcherTest, FetchMultipleBatches) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
Milliseconds(100),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -650,10 +628,8 @@ TEST_F(FetcherTest, FetchMultipleBatches) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc2))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc2))
+ << "ok" << 1),
Milliseconds(200),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -671,10 +647,8 @@ TEST_F(FetcherTest, FetchMultipleBatches) {
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc3))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc3))
+ << "ok" << 1),
Milliseconds(300),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
@@ -698,10 +672,8 @@ TEST_F(FetcherTest, ScheduleGetMoreAndCancel) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -715,10 +687,8 @@ TEST_F(FetcherTest, ScheduleGetMoreAndCancel) {
const BSONObj doc2 = BSON("_id" << 2);
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc2))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc2))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -761,10 +731,8 @@ TEST_F(FetcherTest, CancelDuringCallbackPutsFetcherInShutdown) {
const BSONObj doc = BSON("_id" << 1);
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kInactive);
@@ -782,10 +750,8 @@ TEST_F(FetcherTest, ScheduleGetMoreButShutdown) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -800,10 +766,8 @@ TEST_F(FetcherTest, ScheduleGetMoreButShutdown) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc2))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc2))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -839,10 +803,8 @@ TEST_F(FetcherTest, EmptyGetMoreRequestAfterFirstBatchMakesFetcherInactiveAndKil
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kInactive);
@@ -896,10 +858,8 @@ TEST_F(FetcherTest, UpdateNextActionAfterSecondBatch) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -916,10 +876,8 @@ TEST_F(FetcherTest, UpdateNextActionAfterSecondBatch) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc2))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc2))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kInactive);
@@ -993,10 +951,8 @@ TEST_F(FetcherTest, ShutdownDuringSecondBatch) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
@@ -1016,10 +972,8 @@ TEST_F(FetcherTest, ShutdownDuringSecondBatch) {
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "nextBatch"
- << BSON_ARRAY(doc2))
- << "ok"
- << 1),
+ << "nextBatch" << BSON_ARRAY(doc2))
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);
@@ -1059,10 +1013,8 @@ TEST_F(FetcherTest, FetcherAppliesRetryPolicyToFirstCommandButNotToGetMoreReques
processNetworkResponse(rs, ReadyQueueState::kHasReadyRequests, FetcherState::kActive);
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSON_ARRAY(doc))
- << "ok"
- << 1),
+ << "firstBatch" << BSON_ARRAY(doc))
+ << "ok" << 1),
ReadyQueueState::kHasReadyRequests,
FetcherState::kActive);
ASSERT_OK(status);
@@ -1110,10 +1062,8 @@ TEST_F(FetcherTest, FetcherResetsInternalFinishCallbackFunctionPointerAfterLastC
processNetworkResponse(BSON("cursor" << BSON("id" << 0LL << "ns"
<< "db.coll"
- << "firstBatch"
- << BSONArray())
- << "ok"
- << 1),
+ << "firstBatch" << BSONArray())
+ << "ok" << 1),
ReadyQueueState::kEmpty,
FetcherState::kInactive);