test.py: add new test type "Run"

This patch adds a new test type, "Run". A test subdirectory of type "Run"
has a script called "run" which is expected to run all the tests in that
directory.

This will be used, in the next patch, by the Alternator functional tests.
These tests indeed have a "run" script, which runs Scylla and then runs
*all* of Alternator's tests, finishing fairly quickly (in less than a
minute). All of that will become one test.py test.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
(cherry picked from commit 0ae3136900)
This commit is contained in:
Nadav Har'El
2020-03-26 23:27:00 +02:00
parent bb1554f09e
commit 32cd3a070a

28
test.py
View File

@@ -203,6 +203,17 @@ class CqlTestSuite(TestSuite):
def pattern(self):
return "*_test.cql"
class RunTestSuite(TestSuite):
"""TestSuite for test directory with a 'run' script """
def add_test(self, shortname, mode, options):
test = RunTest(self.next_id, shortname, self, mode, options)
self.tests.append(test)
@property
def pattern(self):
return "run"
class Test:
"""Base class for CQL, Unit and Boost tests"""
@@ -332,6 +343,23 @@ class CqlTest(Test):
if self.is_equal_result is False:
print_unidiff(self.result, self.reject)
class RunTest(Test):
"""Run tests in a directory started by a run script"""
def __init__(self, test_no, shortname, suite, mode, options):
super().__init__(test_no, shortname, suite, mode, options)
self.path = os.path.join(suite.path, shortname)
self.args = ""
def print_summary(self):
print("Output of {} {}:".format(self.path, " ".join(self.args)))
print(read_log(self.log_filename))
async def run(self, options):
# This test can and should be killed gently, with SIGTERM, not with SIGKILL
self.success = await run_test(self, options, gentle_kill=True)
logging.info("Test #%d %s", self.id, "succeeded" if self.success else "failed ")
return self
class TabularConsoleOutput:
"""Print test progress to the console"""