diff options
author | Matt Kangas <matt.kangas@mongodb.com> | 2014-05-06 23:54:47 -0400 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-05-08 09:05:19 -0400 |
commit | 71534242a3dbf802bfb3728c1d0f74848509cca6 (patch) | |
tree | 21954a3fe9d8ade91a938857516559f2866c5fdf | |
parent | b267b2824ea6043cd27c14cfef6ff8af6f93b861 (diff) | |
download | mongo-71534242a3dbf802bfb3728c1d0f74848509cca6.tar.gz |
SERVER-13712 cleanbb should clean entire /data/db dir
Invoke cleanbb via function call, not subprocess.
clean_dbroot() now cleans entire /data/db if --with-cleanbb specified,
including periodic cleanups.
(cherry picked from commit ab47b0b217ab40971a928bbe3d98bd315bbba716)
-rwxr-xr-x | buildscripts/smoke.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/buildscripts/smoke.py b/buildscripts/smoke.py index 9adda8ee52a..c54cb8618ed 100755 --- a/buildscripts/smoke.py +++ b/buildscripts/smoke.py @@ -38,20 +38,19 @@ from itertools import izip import glob from optparse import OptionParser import os -import parser import pprint import re -import shutil import shlex import socket import stat -from subprocess import (call, PIPE, Popen, STDOUT) +from subprocess import (PIPE, Popen, STDOUT) import sys import time from pymongo import Connection from pymongo.errors import OperationFailure +import cleanbb import utils try: @@ -85,6 +84,7 @@ file_of_commands_mode = False start_mongod = True temp_path = None clean_every_n_tests = 1 +clean_whole_dbroot = False tests = [] winners = [] @@ -124,6 +124,16 @@ def buildlogger(cmd, is_global=False): return [utils.find_python(), 'buildscripts/buildlogger.py'] + cmd return cmd + +def clean_dbroot(dbroot="", nokill=False): + # Clean entire /data/db dir if --with-cleanbb, else clean specific database path. + if clean_whole_dbroot and not small_oplog: + dbroot = os.path.normpath(smoke_db_prefix + "/data/db") + if os.path.exists(dbroot): + print("clean_dbroot: %s" % dbroot) + cleanbb.cleanup(dbroot, nokill) + + class mongod(object): def __init__(self, **kwargs): self.kwargs = kwargs @@ -187,13 +197,10 @@ class mongod(object): srcport = mongod_port self.port += 1 self.slave = True - if os.path.exists(dir_name): - if 'slave' in self.kwargs: - argv = [utils.find_python(), "buildscripts/cleanbb.py", '--nokill', dir_name] - else: - argv = [utils.find_python(), "buildscripts/cleanbb.py", dir_name] - call(argv) + + clean_dbroot(dbroot=dir_name, nokill=self.slave) utils.ensureDir(dir_name) + argv = [mongod_executable, "--port", str(self.port), "--dbpath", dir_name] # These parameters are alwas set for tests # SERVER-9137 Added httpinterface parameter to keep previous behavior @@ -705,8 +712,9 @@ def run_tests(tests): check_and_report_replication_dbhashes() elif use_db: # reach inside test and see if "usedb" is true - if (tests_run % clean_every_n_tests) == 0: - # restart mongo every 'clean_every_n_tests' times + if clean_every_n_tests and (tests_run % clean_every_n_tests) == 0: + # Restart mongod periodically to clean accumulated test data + # clean_dbroot() is invoked by mongod.start() master.__exit__(None, None, None) master = mongod(small_oplog_rs=small_oplog_rs, small_oplog=small_oplog, @@ -981,6 +989,7 @@ def set_globals(options, tests): global report_file, shell_write_mode, use_write_commands global temp_path global clean_every_n_tests + global clean_whole_dbroot start_mongod = options.start_mongod if hasattr(options, 'use_ssl'): @@ -1013,7 +1022,9 @@ def set_globals(options, tests): auth = options.auth authMechanism = options.authMechanism keyFile = options.keyFile + clean_every_n_tests = options.clean_every_n_tests + clean_whole_dbroot = options.with_cleanbb if auth and not keyFile: # if only --auth was given to smoke.py, load the @@ -1271,8 +1282,7 @@ def main(): return if options.with_cleanbb: - dbroot = os.path.join(options.smoke_db_prefix, 'data', 'db') - call([utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot]) + clean_dbroot(nokill=True) test_report["start"] = time.time() test_report["mongod_running_at_start"] = mongod().is_mongod_up(mongod_port) |