summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkanksha Mahajan <akankshamahajan@meta.com>2023-10-24 11:46:18 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2023-10-24 11:46:18 -0700
commit917fd87513545aadfc3cf4091afd9c36b0464567 (patch)
tree49f9eaaebb5c00628c85c59362a368f8d07f065f
parent99b371b417bb76aaf8f1da56dc361e22e0c51182 (diff)
Error out in case of std errors in blackbox test and export file in TARGETS
Summary: - Right now in blackbox test we don't exit if there are std::error as we do in whitebox crash tests. As result those errors are swallowed. It only errors out if state is unexpected. One example that was noticed in blackbox crash test - ``` stderr has error message: ***Error restoring historical expected values: Corruption: DB is older than any restorable expected state*** Running db_stress with pid=30454: /packages/rocksdb_db_stress_internal_repo/rocks_db_stress .... ``` - This diff also provided support to export files - db_crashtest.py file to be used by different repo. Reviewed By: ajkr Differential Revision: D50564889 fbshipit-source-id: 7bafbbc6179dc79467ca2b680fe83afc7850616a
-rw-r--r--TARGETS2
-rwxr-xr-xbuckifier/buckify_rocksdb.py1
-rw-r--r--buckifier/targets_builder.py6
-rw-r--r--buckifier/targets_cfg.py4
-rw-r--r--tools/db_crashtest.py22
5 files changed, 35 insertions, 0 deletions
diff --git a/TARGETS b/TARGETS
index c53ed156e..6f0efa400 100644
--- a/TARGETS
+++ b/TARGETS
@@ -5620,3 +5620,5 @@ cpp_unittest_wrapper(name="write_unprepared_transaction_test",
deps=[":rocksdb_test_lib"],
extra_compiler_flags=[])
+
+export_file(name = "tools/db_crashtest.py")
diff --git a/buckifier/buckify_rocksdb.py b/buckifier/buckify_rocksdb.py
index 0172acf9b..b56e1a82d 100755
--- a/buckifier/buckify_rocksdb.py
+++ b/buckifier/buckify_rocksdb.py
@@ -303,6 +303,7 @@ def generate_targets(repo_path, deps_map):
deps=json.dumps(deps["extra_deps"] + [":rocksdb_test_lib"]),
extra_compiler_flags=json.dumps(deps["extra_compiler_flags"]),
)
+ TARGETS.export_file("tools/db_crashtest.py")
print(ColorString.info("Generated TARGETS Summary:"))
print(ColorString.info("- %d libs" % TARGETS.total_lib))
diff --git a/buckifier/targets_builder.py b/buckifier/targets_builder.py
index 94dbd3653..f5d727469 100644
--- a/buckifier/targets_builder.py
+++ b/buckifier/targets_builder.py
@@ -148,3 +148,9 @@ add_c_test_wrapper()
).encode("utf-8")
)
self.total_test = self.total_test + 1
+
+ def export_file(self, name):
+ with open(self.path, "a") as targets_file:
+ targets_file.write(
+ targets_cfg.export_file_template.format(name=name)
+ )
diff --git a/buckifier/targets_cfg.py b/buckifier/targets_cfg.py
index 66dd173c2..ead6ac51a 100644
--- a/buckifier/targets_cfg.py
+++ b/buckifier/targets_cfg.py
@@ -37,3 +37,7 @@ fancy_bench_template = """
fancy_bench_wrapper(suite_name="{name}", binary_to_bench_to_metric_list_map={bench_config}, slow={slow}, expected_runtime={expected_runtime}, sl_iterations={sl_iterations}, regression_threshold={regression_threshold})
"""
+
+export_file_template = """
+export_file(name = "{name}")
+"""
diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py
index c9374f59c..c09bc4d65 100644
--- a/tools/db_crashtest.py
+++ b/tools/db_crashtest.py
@@ -846,6 +846,17 @@ def blackbox_crash_main(args, unknown_args):
print("stderr has error message:")
print("***" + line + "***")
+ stderrdata = errs.lower()
+ errorcount = stderrdata.count("error") - stderrdata.count("got errors 0 times")
+ print("#times error occurred in output is " + str(errorcount) + "\n")
+
+ if errorcount > 0:
+ print("TEST FAILED. Output has 'error'!!!\n")
+ sys.exit(2)
+ if stderrdata.find("fail") >= 0:
+ print("TEST FAILED. Output has 'fail'!!!\n")
+ sys.exit(2)
+
time.sleep(1) # time to stabilize before the next run
time.sleep(1) # time to stabilize before the next run
@@ -869,6 +880,17 @@ def blackbox_crash_main(args, unknown_args):
print("stderr has error message:")
print("***" + line + "***")
+ stderrdata = errs.lower()
+ errorcount = stderrdata.count("error") - stderrdata.count("got errors 0 times")
+ print("#times error occurred in output is " + str(errorcount) + "\n")
+
+ if errorcount > 0:
+ print("TEST FAILED. Output has 'error'!!!\n")
+ sys.exit(2)
+ if stderrdata.find("fail") >= 0:
+ print("TEST FAILED. Output has 'fail'!!!\n")
+ sys.exit(2)
+
# we need to clean up after ourselves -- only do this on test success
shutil.rmtree(dbname, True)