Skip to content

Commit

Permalink
Permit stdout "fail"/"error" in whitebox crash test (facebook#8272)
Browse files Browse the repository at this point in the history
Summary:
In facebook#8268, the `db_stress` stdout began containing both the strings
"fail" and "error" (case-insensitive). The whitebox crash test
failed upon seeing either of those strings.

I checked that all other occurrences of "fail" and "error"
(case-insensitive) that `db_stress` produces are printed to `stderr`. So
this PR separates the handling of `db_stress`'s stdout and stderr, and
only fails when one those bad strings are found in stderr.

The downside of this PR is `db_stress`'s original interleaving of stdout/stderr is not preserved in `db_crashtest.py`'s output.

Pull Request resolved: facebook#8272

Test Plan:
run it; see it succeeds for several runs until encountering a real error

```
$ python3 tools/db_crashtest.py whitebox --simple --random_kill_odd=8887 --max_key=1000000 --value_size_mult=33
...
db_stress: cache/clock_cache.cc:483: bool rocksdb::{anonymous}::ClockCacheShard::Unref(rocksdb::{anonymous}::CacheHandle*, bool, rocksdb::{anonymous}::CleanupContext*): Assertion `CountRefs(flags) > 0' failed.

TEST FAILED. Output has 'fail'!!!
```

Reviewed By: zhichao-cao

Differential Revision: D28239233

Pulled By: ajkr

fbshipit-source-id: 3b8602a0d570466a7e2c81bb9c49468f7716091e
  • Loading branch information
ajkr authored and facebook-github-bot committed May 6, 2021
1 parent 7f3a0f5 commit b71b459
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tools/db_crashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def whitebox_crash_main(args, unknown_args):
print("Running:" + ' '.join(cmd) + "\n") # noqa: E999 T25377293 Grandfathered in

popen = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stderr=subprocess.PIPE)
stdoutdata, stderrdata = popen.communicate()
if stdoutdata:
stdoutdata = stdoutdata.decode('utf-8')
Expand All @@ -624,8 +624,10 @@ def whitebox_crash_main(args, unknown_args):
retncode = popen.returncode
msg = ("check_mode={0}, kill option={1}, exitcode={2}\n".format(
check_mode, additional_opts['kill_random_test'], retncode))

print(msg)
print(stdoutdata)
print(stderrdata)

expected = False
if additional_opts['kill_random_test'] is None and (retncode == 0):
Expand All @@ -640,15 +642,16 @@ def whitebox_crash_main(args, unknown_args):
print("TEST FAILED. See kill option and exit code above!!!\n")
sys.exit(1)

stdoutdata = stdoutdata.lower()
errorcount = (stdoutdata.count('error') -
stdoutdata.count('got errors 0 times'))
print("#times error occurred in output is " + str(errorcount) + "\n")
stderrdata = stderrdata.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 (stdoutdata.find('fail') >= 0):
if (stderrdata.find('fail') >= 0):
print("TEST FAILED. Output has 'fail'!!!\n")
sys.exit(2)

Expand Down

0 comments on commit b71b459

Please sign in to comment.