From faa32a72a6849132014bdcdabd075b56d7986c0a Mon Sep 17 00:00:00 2001 From: Mayank Agarwal Date: Fri, 5 Apr 2013 13:44:59 -0700 Subject: [PATCH] Invoke crash test from the Makefile Summary: make crash_test will now invoke the crash_test. Also some cleanup in the db_crashtest.py file Test Plan: make crash_test Reviewers: akushner, vamsi, sheki, dhruba Reviewed By: vamsi Differential Revision: https://reviews.facebook.net/D9987 --- Makefile | 3 +++ tools/db_crashtest.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e07f14a79..0aa488475 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,9 @@ check: all $(PROGRAMS) $(TESTS) $(TOOLS) ldb_tests ldb_tests: all $(PROGRAMS) $(TOOLS) python tools/ldb_test.py +crash_test: db_stress + python tools/db_crashtest.py + valgrind_check: all $(PROGRAMS) $(TESTS) echo TESTS THAT HAVE VALGRIND ERRORS > $(VALGRIND_DIR)/valgrind_failed_tests; \ echo TIMES in seconds TAKEN BY TESTS ON VALGRIND > $(VALGRIND_DIR)/valgrind_tests_times; \ diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 54f970c46..e065d3a35 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -1,9 +1,11 @@ +#! /usr/bin/env python import os import sys import time import shlex import getopt import logging +import tempfile import subprocess # This python script runs and kills db_stress multiple times with @@ -13,7 +15,6 @@ import subprocess # This checks consistency in case of unsafe crashes in Rocksdb def main(argv): - os.system("make -C ~/rocksdb db_stress") try: opts, args = getopt.getopt(argv, "hd:t:i:o:b:") except getopt.GetoptError: @@ -53,19 +54,21 @@ def main(argv): exit_time = time.time() + duration + dirpath = tempfile.mkdtemp() + while time.time() < exit_time: run_had_errors = False print "Running db_stress \n" - os.system("mkdir -p /tmp/rocksdb/crashtest") killtime = time.time() + interval - child = subprocess.Popen(['~/rocksdb/db_stress \ + child = subprocess.Popen(['./db_stress \ --test_batches_snapshots=1 \ --ops_per_thread=0' + str(ops_per_thread) + ' \ --threads=0' + str(threads) + ' \ --write_buffer_size=' + str(write_buf_size) + '\ + --destroy_db_initially=0 \ --reopen=0 \ --readpercent=50 \ - --db=/tmp/rocksdb/crashtest \ + --db=' + dirpath + '\ --max_key=1000'], stderr=subprocess.PIPE, shell=True) time.sleep(interval) while True: