Skip to content

Commit

Permalink
GH-1176 Add --keep-logs option and do not clean logs on test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jun 27, 2023
1 parent 3bea733 commit e4aeee1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/plugin_http_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import socket
import re
import shlex
import argparse
import sys
import signal
from pathlib import Path

from TestHarness import Account, Node, TestHelper, Utils, WalletMgr, ReturnType
Expand Down Expand Up @@ -68,7 +71,11 @@ def createConfigDir(self):
shutil.rmtree(self.config_dir)
self.config_dir.mkdir()

# kill nodeos and keosd and clean up dirs
# kill nodeos. keosd shuts down automatically
def killNodes(self):
self.nodeos.kill(signal.SIGTERM)

# clean up dirs
def cleanEnv(self) :
if self.data_dir.exists():
shutil.rmtree(Utils.DataPath)
Expand Down Expand Up @@ -1536,11 +1543,24 @@ def setUpClass(self):

@classmethod
def tearDownClass(self):
self.cleanEnv(self)
global keepLogs
self.killNodes(self)
if unittest.TestResult().wasSuccessful() and not keepLogs:
self.cleanEnv(self)


if __name__ == "__main__":
test_category = True if os.environ.get("PLUGIN_HTTP_TEST_CATEGORY") == "ON" else False
category_config = HttpCategoryConfig(test_category)

parser = argparse.ArgumentParser()
parser.add_argument('--keep-logs', action='store_true')
parser.add_argument('unittest_args', nargs=argparse.REMAINDER)

args = parser.parse_args()
global keepLogs
keepLogs = args.keep_logs;

# Now set the sys.argv to the unittest_args (leaving sys.argv[0] alone)
sys.argv[1:] = args.unittest_args
unittest.main()

0 comments on commit e4aeee1

Please sign in to comment.