diff options
author | Oisin Canty <o.canty@f5.com> | 2021-07-02 13:00:57 +0000 |
---|---|---|
committer | Oisin Canty <o.canty@f5.com> | 2021-07-02 13:00:57 +0000 |
commit | 8c83652c2a0ad7386e27a9ea595c996d3dce018c (patch) | |
tree | 154281c0fc0216f5588f6a9c7f96a79c500737a5 /test/unit | |
parent | 6c14d5d7b1921bd78f2d1b7458eae7d97eee0fcd (diff) | |
download | unit-8c83652c2a0ad7386e27a9ea595c996d3dce018c.tar.gz unit-8c83652c2a0ad7386e27a9ea595c996d3dce018c.tar.bz2 |
Tests: Ruby hooks.
Diffstat (limited to '')
-rw-r--r-- | test/unit/applications/lang/ruby.py | 24 | ||||
-rw-r--r-- | test/unit/applications/proto.py | 16 | ||||
-rw-r--r-- | test/unit/utils.py | 28 |
3 files changed, 46 insertions, 22 deletions
diff --git a/test/unit/applications/lang/ruby.py b/test/unit/applications/lang/ruby.py index d95d62b4..61d50558 100644 --- a/test/unit/applications/lang/ruby.py +++ b/test/unit/applications/lang/ruby.py @@ -12,7 +12,7 @@ class TestApplicationRuby(TestApplicationProto): def prepare_env(self, script): shutil.copytree( option.test_dir + '/ruby/' + script, - option.temp_dir + '/ruby/' + script + option.temp_dir + '/ruby/' + script, ) public_dir(option.temp_dir + '/ruby/' + script) @@ -22,17 +22,23 @@ class TestApplicationRuby(TestApplicationProto): script_path = option.temp_dir + '/ruby/' + script + app = { + "type": self.get_application_type(), + "processes": {"spare": 0}, + "working_directory": script_path, + "script": script_path + '/' + name, + } + + for key in [ + 'hooks', + ]: + if key in kwargs: + app[key] = kwargs[key] + self._load_conf( { "listeners": {"*:7080": {"pass": "applications/" + script}}, - "applications": { - script: { - "type": self.get_application_type(), - "processes": {"spare": 0}, - "working_directory": script_path, - "script": script_path + '/' + name, - } - }, + "applications": {script: app}, }, **kwargs ) diff --git a/test/unit/applications/proto.py b/test/unit/applications/proto.py index 92754c03..e30d21ff 100644 --- a/test/unit/applications/proto.py +++ b/test/unit/applications/proto.py @@ -47,13 +47,15 @@ class TestApplicationProto(TestControl): if 'applications' in conf: for app in conf['applications'].keys(): app_conf = conf['applications'][app] - if 'user' in kwargs: - app_conf['user'] = kwargs['user'] - if 'group' in kwargs: - app_conf['group'] = kwargs['group'] - - if 'isolation' in kwargs: - app_conf['isolation'] = kwargs['isolation'] + for key in [ + 'user', + 'group', + 'isolation', + 'processes', + 'threads', + ]: + if key in kwargs: + app_conf[key] = kwargs[key] assert 'success' in self.conf(conf), 'load application configuration' diff --git a/test/unit/utils.py b/test/unit/utils.py index a627e9f5..43aaa81b 100644 --- a/test/unit/utils.py +++ b/test/unit/utils.py @@ -1,3 +1,4 @@ +import glob import os import socket import subprocess @@ -16,8 +17,8 @@ def public_dir(path): os.chmod(os.path.join(root, f), 0o777) -def waitforfiles(*files): - for i in range(50): +def waitforfiles(*files, timeout=50): + for i in range(timeout): wait = False for f in files: @@ -33,6 +34,21 @@ def waitforfiles(*files): return False +def waitforglob(pattern, count=1, timeout=50): + for i in range(timeout): + n = 0 + + for f in glob.glob(pattern): + n += 1 + + if n == count: + return True + + time.sleep(0.1) + + return False + + def waitforsocket(port): for i in range(50): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: @@ -72,8 +88,8 @@ def sysctl(): return out -def waitformount(template, wait=50): - for i in range(wait): +def waitformount(template, timeout=50): + for i in range(timeout): if findmnt().find(template) != -1: return True @@ -82,8 +98,8 @@ def waitformount(template, wait=50): return False -def waitforunmount(template, wait=50): - for i in range(wait): +def waitforunmount(template, timeout=50): + for i in range(timeout): if findmnt().find(template) == -1: return True |