Tests: rerun tests for each module version.

Rerun supported for Python, PHP, Perl, Ruby, and Java modules.
This commit is contained in:
Andrey Zelenkov
2019-08-06 18:25:13 +03:00
parent 274260bd28
commit c8c259b972
6 changed files with 40 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ from unit.applications.proto import TestApplicationProto
class TestApplicationJava(TestApplicationProto):
application_type = "java"
def load(self, script, name='app'):
app_path = self.testdir + '/java'
@@ -64,7 +66,7 @@ class TestApplicationJava(TestApplicationProto):
"applications": {
script: {
"unit_jars": self.pardir + '/build',
"type": "java",
"type": self.application_type,
"processes": {"spare": 0},
"working_directory": script_path,
"webapp": app_path,

View File

@@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto
class TestApplicationPerl(TestApplicationProto):
application_type = "perl"
def load(self, script, name='psgi.pl'):
script_path = self.current_dir + '/perl/' + script
@@ -10,7 +12,7 @@ class TestApplicationPerl(TestApplicationProto):
"listeners": {"*:7080": {"pass": "applications/" + script}},
"applications": {
script: {
"type": "perl",
"type": self.application_type,
"processes": {"spare": 0},
"working_directory": script_path,
"script": script_path + '/' + name,

View File

@@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto
class TestApplicationPHP(TestApplicationProto):
application_type = "php"
def load(self, script, name='index.php'):
script_path = self.current_dir + '/php/' + script
@@ -10,7 +12,7 @@ class TestApplicationPHP(TestApplicationProto):
"listeners": {"*:7080": {"pass": "applications/" + script}},
"applications": {
script: {
"type": "php",
"type": self.application_type,
"processes": {"spare": 0},
"root": script_path,
"working_directory": script_path,

View File

@@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto
class TestApplicationPython(TestApplicationProto):
application_type = "python"
def load(self, script, name=None):
if name is None:
name = script
@@ -13,7 +15,7 @@ class TestApplicationPython(TestApplicationProto):
"listeners": {"*:7080": {"pass": "applications/" + name}},
"applications": {
name: {
"type": "python",
"type": self.application_type,
"processes": {"spare": 0},
"path": script_path,
"working_directory": script_path,

View File

@@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto
class TestApplicationRuby(TestApplicationProto):
application_type = "ruby"
def load(self, script, name='config.ru'):
script_path = self.current_dir + '/ruby/' + script
@@ -10,7 +12,7 @@ class TestApplicationRuby(TestApplicationProto):
"listeners": {"*:7080": {"pass": "applications/" + script}},
"applications": {
script: {
"type": "ruby",
"type": self.application_type,
"processes": {"spare": 0},
"working_directory": script_path,
"script": script_path + '/' + name,

View File

@@ -12,6 +12,8 @@ import subprocess
from multiprocessing import Process
available_modules = {}
class TestUnit(unittest.TestCase):
current_dir = os.path.abspath(
@@ -34,6 +36,17 @@ class TestUnit(unittest.TestCase):
TestUnit._set_args(args)
def run(self, result=None):
if not hasattr(self, 'application_type'):
return super().run(result)
type = self.application_type
for prerequisite in self.prerequisites:
if prerequisite in available_modules:
for version in available_modules[prerequisite]:
self.application_type = type + ' ' + version
super().run(result)
@classmethod
def main(cls):
args, rest = TestUnit._parse_args()
@@ -108,6 +121,16 @@ class TestUnit(unittest.TestCase):
self.stop()
exit("Unit is writing log too long")
# discover all available modules
global available_modules
available_modules = {}
for module in re.findall(r'module: ([a-zA-Z]+) ([\d\.]*) ', log):
if module[0] not in available_modules:
available_modules[module[0]] = [module[1]]
else:
available_modules[module[0]].append(module[1])
missed_module = ''
for module in modules:
if module == 'go':
@@ -153,7 +176,8 @@ class TestUnit(unittest.TestCase):
m = None
else:
m = re.search('module: ' + module, log)
if module not in available_modules:
m = None
if m is None:
missed_module = module