summaryrefslogtreecommitdiff
path: root/dbtests
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2010-12-22 12:29:30 -0500
committerDwight <dwight@10gen.com>2010-12-22 12:30:46 -0500
commit8cf2e8f751518b7b2eaed173e3a7605e742b2131 (patch)
tree52634349d18becc74efdb8254990f0e3b0aa33b4 /dbtests
parent9a4661620538960f5ef0b6475655664c73ef1518 (diff)
downloadmongo-8cf2e8f751518b7b2eaed173e3a7605e742b2131.tar.gz
add test
Diffstat (limited to 'dbtests')
-rw-r--r--dbtests/directclienttests.cpp81
-rw-r--r--dbtests/perftests.cpp3
-rw-r--r--dbtests/test.vcxproj3
-rwxr-xr-xdbtests/test.vcxproj.filters3
4 files changed, 89 insertions, 1 deletions
diff --git a/dbtests/directclienttests.cpp b/dbtests/directclienttests.cpp
new file mode 100644
index 00000000000..894d4ac533c
--- /dev/null
+++ b/dbtests/directclienttests.cpp
@@ -0,0 +1,81 @@
+/** @file directclienttests.cpp
+*/
+
+/**
+ * Copyright (C) 2008 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "pch.h"
+#include "../db/query.h"
+#include "../db/db.h"
+#include "../db/instance.h"
+#include "../db/json.h"
+#include "../db/lasterror.h"
+#include "../db/update.h"
+#include "../db/deferredinvoker.h"
+#include "../util/timer.h"
+#include "dbtests.h"
+
+namespace DirectClientTests {
+
+ class ClientBase {
+ public:
+ // NOTE: Not bothering to backup the old error record.
+ ClientBase() { mongo::lastError.reset( new LastError() ); }
+ virtual ~ClientBase() { }
+ protected:
+ static bool error() {
+ return !_client.getPrevError().getField( "err" ).isNull();
+ }
+ DBDirectClient &client() const { return _client; }
+ private:
+ static DBDirectClient _client;
+ };
+ DBDirectClient ClientBase::_client;
+
+ const char *ns = "a.b";
+
+ class Capped : public ClientBase {
+ public:
+ virtual void run() {
+ for( int pass=0; pass < 3; pass++ ) {
+ client().createCollection(ns, 1024 * 1024, true, 999);
+ for( int j =0; j < pass*3; j++ )
+ client().insert(ns, BSON("x" << j));
+
+ // test truncation of a capped collection
+ if( pass ) {
+ BSONObj info;
+ BSONObj cmd = BSON( "captrunc" << "b" << "n" << 1 << "inc" << true );
+ cout << cmd.toString() << endl;
+ bool ok = client().runCommand("a", cmd, info);
+ cout << info.toString() << endl;
+ assert(ok);
+ }
+
+ assert( client().dropCollection(ns) );
+ }
+ }
+ };
+
+ class All : public Suite {
+ public:
+ All() : Suite( "directclient" ) {
+ }
+ void setupTests(){
+ add< Capped >();
+ }
+ } myall;
+}
diff --git a/dbtests/perftests.cpp b/dbtests/perftests.cpp
index 6560d4d552a..65f38397139 100644
--- a/dbtests/perftests.cpp
+++ b/dbtests/perftests.cpp
@@ -91,6 +91,9 @@ namespace PerfTests {
};
int DefInvoke::tot;
+ class CappedTest : public ClientBase {
+ };
+
class B : public ClientBase
{
string _ns;
diff --git a/dbtests/test.vcxproj b/dbtests/test.vcxproj
index 811490fa701..2f5470031a7 100644
--- a/dbtests/test.vcxproj
+++ b/dbtests/test.vcxproj
@@ -97,7 +97,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\js\src;..\pcre-7.4;C:\boost;\boost;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_UNICODE;UNICODE;SUPPORT_UCP;SUPPORT_UTF8;MONGO_EXPOSE_MACROS;OLDJS;STATIC_JS_API;XP_WIN;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_TESTINTENT;_UNICODE;UNICODE;SUPPORT_UCP;SUPPORT_UTF8;MONGO_EXPOSE_MACROS;OLDJS;STATIC_JS_API;XP_WIN;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;PCRE_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>No</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -648,6 +648,7 @@
<ClCompile Include="clienttests.cpp" />
<ClCompile Include="cursortests.cpp" />
<ClCompile Include="dbtests.cpp" />
+ <ClCompile Include="directclienttests.cpp" />
<ClCompile Include="framework.cpp" />
<ClCompile Include="jsobjtests.cpp" />
<ClCompile Include="jsontests.cpp" />
diff --git a/dbtests/test.vcxproj.filters b/dbtests/test.vcxproj.filters
index 34d2908ecb6..b84316c901a 100755
--- a/dbtests/test.vcxproj.filters
+++ b/dbtests/test.vcxproj.filters
@@ -758,6 +758,9 @@
<ClCompile Include="perftests.cpp">
<Filter>dbtests</Filter>
</ClCompile>
+ <ClCompile Include="directclienttests.cpp">
+ <Filter>dbtests</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\SConstruct">