From 32cd3a070a4f00a171018607ea71ffc5b78ee7fa Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Thu, 26 Mar 2020 23:27:00 +0200 Subject: [PATCH] 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 (cherry picked from commit 0ae31369002c8ff9ef95ac04868fcb6de3fcc805) --- test.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test.py b/test.py index d88785aae1..568f03cd96 100755 --- a/test.py +++ b/test.py @@ -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"""