0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
Dwight 2010-12-22 12:29:30 -05:00
parent 9a46616205
commit 8cf2e8f751
8 changed files with 95 additions and 5 deletions

View File

@ -281,7 +281,7 @@ namespace mongo {
cout << "dl[1]: " << deletedList[1].toString() << endl;
}
/* everything from end on, eliminate from the capped collection.
/* truncate everything from 'end' onward from the capped collection.
@param inclusive if true, deletes end (i.e. closed or open range)
*/
void NamespaceDetails::cappedTruncateAfter(const char *ns, DiskLoc end, bool inclusive) {

View File

@ -98,7 +98,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\js\src;..\pcre-7.4;c:\boost;\boost</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>

View File

@ -1624,10 +1624,12 @@ namespace mongo {
uassert( 13416, "captrunc must specify a collection", !coll.empty() );
string ns = dbname + "." + coll;
int n = cmdObj.getIntField( "n" );
// inclusive range?
bool inc = cmdObj.getBoolField( "inc" );
NamespaceDetails *nsd = nsdetails( ns.c_str() );
ReverseCappedCursor c( nsd );
massert( 13417, "captrunc invalid collection", c.ok() );
massert( 13417, "captrunc collection not found or empty", c.ok() );
for( int i = 0; i < n; ++i ) {
massert( 13418, "captrunc invalid n", c.advance() );
}

View File

@ -85,7 +85,7 @@ namespace mongo {
LocalDbBit = 0x80000000 // assuming "local" db instead of using the JDbContext
};
int _fileNo; // high bit is set to indicate it should be the <dbpath>/local database
// char data[] follows
// char data[len] follows
const char * srcData() const {
const int *i = &_fileNo;

View File

@ -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;
}

View File

@ -91,6 +91,9 @@ namespace PerfTests {
};
int DefInvoke::tot;
class CappedTest : public ClientBase {
};
class B : public ClientBase
{
string _ns;

View File

@ -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" />

View File

@ -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">