summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-10-11 21:23:32 -0400
committerEliot Horowitz <eliot@10gen.com>2014-10-11 23:26:50 -0400
commit81c227fe23f5487bd8c54bbb918e82c4aa3ac147 (patch)
tree8ebb311cb5e734d333aa0297e5697312c8f6479c /src
parent00e695acb824bcf047b671c6649678056873804b (diff)
downloadmongo-81c227fe23f5487bd8c54bbb918e82c4aa3ac147.tar.gz
SERVER-13635: make capped dbtests more generic
Diffstat (limited to 'src')
-rw-r--r--src/mongo/dbtests/executor_registry.cpp5
-rw-r--r--src/mongo/dbtests/querytests.cpp39
2 files changed, 42 insertions, 2 deletions
diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp
index f018119f149..6ad15d20cbb 100644
--- a/src/mongo/dbtests/executor_registry.cpp
+++ b/src/mongo/dbtests/executor_registry.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/collection_scan.h"
#include "mongo/db/exec/plan_stage.h"
+#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
@@ -111,6 +112,10 @@ namespace ExecutorRegistry {
class ExecutorRegistryDiskLocInvalid : public ExecutorRegistryBase {
public:
void run() {
+ if ( supportsDocLocking() ) {
+ return;
+ }
+
auto_ptr<PlanExecutor> run(getCollscan());
BSONObj obj;
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index cd1c5171fbc..04626db82d2 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -472,7 +472,14 @@ namespace QueryTests {
ASSERT( !c->more() );
insert( ns, BSON( "a" << 2 ) );
insert( ns, BSON( "a" << 3 ) );
- ASSERT( !c->more() );
+
+ // This can either have been killed, or jumped to the right thing.
+ // Key is that it can't skip.
+ if ( c->more() ) {
+ BSONObj x = c->next();
+ ASSERT_EQUALS( 2, x["a"].numberInt() );
+ }
+
// Inserting a document into a capped collection can force another document out.
// In this case, the capped collection has 2 documents, so inserting two more clobbers
// whatever DiskLoc that the underlying cursor had as its state.
@@ -488,6 +495,34 @@ namespace QueryTests {
}
};
+ class TailableDelete2 : public ClientBase {
+ public:
+ ~TailableDelete2() {
+ _client.dropCollection( "unittests.querytests.TailableDelete" );
+ }
+ void run() {
+ const char *ns = "unittests.querytests.TailableDelete";
+ _client.createCollection( ns, 8192, true, 2 );
+ insert( ns, BSON( "a" << 0 ) );
+ insert( ns, BSON( "a" << 1 ) );
+ auto_ptr< DBClientCursor > c = _client.query( ns, Query().hint( BSON( "$natural" << 1 ) ), 2, 0, 0, QueryOption_CursorTailable );
+ c->next();
+ c->next();
+ ASSERT( !c->more() );
+ insert( ns, BSON( "a" << 2 ) );
+ insert( ns, BSON( "a" << 3 ) );
+ insert( ns, BSON( "a" << 4 ) );
+
+ // This can either have been killed, or jumped to the right thing.
+ // Key is that it can't skip.
+ if ( c->more() ) {
+ BSONObj x = c->next();
+ ASSERT_EQUALS( 2, x["a"].numberInt() );
+ }
+ }
+ };
+
+
class TailableInsertDelete : public ClientBase {
public:
~TailableInsertDelete() {
@@ -1193,7 +1228,6 @@ namespace QueryTests {
ctx.commit();
while ( c->more() ) { c->next(); }
- ASSERT( c->isDead() );
}
void insertNext() {
@@ -1559,6 +1593,7 @@ namespace QueryTests {
add< TailNotAtEnd >();
add< EmptyTail >();
add< TailableDelete >();
+ add< TailableDelete2 >();
add< TailableInsertDelete >();
add< TailCappedOnly >();
add< TailableQueryOnId >();