Skip to content

Commit

Permalink
pwd in settings.py for perftests.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Mar 28, 2011
1 parent f797060 commit d6c8b5e
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions dbtests/perftests.cpp
Expand Up @@ -135,22 +135,39 @@ namespace PerfTests {
/* if you want recording of the timings, place the password for the perf database
in a "pstats.login" text file in the current directory for the test binary
*/
if( exists("pstats.login") ) {
const char *fn = "../../settings.py";
static bool ok = true;
if( ok && exists(fn) ) {
try {
if( conn == 0 ) {
MemoryMappedFile f;
void *p = f.mapWithOptions("pstats.login", MongoFile::READONLY);
string pwd((const char *)p, (unsigned) f.length());
conn = new DBClientConnection(false, 0, 10);
string err;
if( conn->connect("mongo05.10gen.cust.cbici.net", err) ) {
if( !conn->auth("perf", "perf", pwd, err) ) {
cout << "info: authentication with stats before logging failed: " << err << endl;
assert(false);
const char *p = (const char *) f.mapWithOptions(fn, MongoFile::READONLY);
string pwd;

{
const char *q = str::after(p, "pstatspassword=\"");
if( *q == 0 ) {
cout << "info perftests.cpp: no pstatspassword= in settings.py" << endl;
ok = false;
}
else {
pwd = str::before(q, '\"');
}
}
else {
cout << err << " (to log pstats)" << endl;

if( ok ) {
conn = new DBClientConnection(false, 0, 10);
string err;
if( conn->connect("mongo05.10gen.cust.cbici.net", err) ) {
if( !conn->auth("perf", "perf", pwd, err) ) {
cout << "info: authentication with stats db failed: " << err << endl;
assert(false);
}
}
else {
cout << err << " (to log perfstats)" << endl;
ok = false;
}
}
}
if( conn && !conn->isFailed() ) {
Expand Down

0 comments on commit d6c8b5e

Please sign in to comment.