summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
authoroxpa <iippolitov@gmail.com>2024-09-17 14:21:10 +0100
committeroxpa <iippolitov@gmail.com>2024-09-17 14:21:10 +0100
commit2417826d8bebf921ee1be102ef8ce702f0683d66 (patch)
tree76d29a1705415ed7368870826dbb2f04942ee794 /test/unit
parent0e79d961bb1ea68674961da1703ffedb1ddf6e43 (diff)
parent24ed91f40634372d99f67f0e4e3c2ac0abde81bd (diff)
downloadunit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.gz
unit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.bz2
Merge tag '1.33.0' into packaging.
Unit 1.33.0 release.
Diffstat (limited to '')
-rw-r--r--test/unit/applications/lang/java.py2
-rw-r--r--test/unit/applications/lang/wasm_component.py63
-rw-r--r--test/unit/applications/tls.py6
-rw-r--r--test/unit/check/cargo_component.py4
-rw-r--r--test/unit/check/discover_available.py4
-rw-r--r--test/unit/http.py2
-rw-r--r--test/unit/status.py13
7 files changed, 85 insertions, 9 deletions
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index 351d04ce..2b3194ae 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -53,7 +53,7 @@ class ApplicationJava(ApplicationProto):
os.makedirs(classes_path)
classpath = (
- f'{option.current_dir}/build/tomcat-servlet-api-9.0.86.jar'
+ f'{option.current_dir}/build/tomcat-servlet-api-9.0.93.jar'
)
ws_jars = glob.glob(
diff --git a/test/unit/applications/lang/wasm_component.py b/test/unit/applications/lang/wasm_component.py
new file mode 100644
index 00000000..a6c8dd14
--- /dev/null
+++ b/test/unit/applications/lang/wasm_component.py
@@ -0,0 +1,63 @@
+from pathlib import Path
+import shutil
+import subprocess
+from urllib.parse import quote
+
+from unit.applications.proto import ApplicationProto
+from unit.option import option
+
+
+class ApplicationWasmComponent(ApplicationProto):
+ @staticmethod
+ def prepare_env(script):
+ try:
+ subprocess.check_output(
+ ['cargo', 'component', '--help'],
+ stderr=subprocess.STDOUT,
+ )
+ except (subprocess.CalledProcessError, FileNotFoundError):
+ return None
+
+ temp_dir = Path(f'{option.temp_dir}/wasm_component/')
+
+ if not temp_dir.exists():
+ temp_dir.mkdir()
+
+ app_path = f'{temp_dir}/{script}'
+
+ shutil.copytree(f'{option.test_dir}/wasm_component/{script}', app_path)
+
+ try:
+ output = subprocess.check_output(
+ ['cargo', 'component', 'build', '--release'],
+ cwd=app_path,
+ stderr=subprocess.STDOUT,
+ )
+ except KeyboardInterrupt:
+ raise
+
+ except subprocess.CalledProcessError:
+ return None
+
+ return output
+
+ def load(self, script, **kwargs):
+ self.prepare_env(script)
+
+ component_path = f'{option.temp_dir}/wasm_component/{script}/target/wasm32-wasip1/release/test_wasi_component.wasm'
+
+ self._load_conf(
+ {
+ "listeners": {
+ "*:8080": {"pass": f"applications/{quote(script, '')}"}
+ },
+ "applications": {
+ script: {
+ "type": "wasm-wasi-component",
+ "processes": {"spare": 0},
+ "component": component_path,
+ }
+ },
+ },
+ **kwargs,
+ )
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py
index 75354dd9..b48293be 100644
--- a/test/unit/applications/tls.py
+++ b/test/unit/applications/tls.py
@@ -85,9 +85,13 @@ subjectAltName = @alt_names
default_bits = 2048
encrypt_key = no
distinguished_name = req_distinguished_name
+x509_extensions = myca_extensions
{a_sec if alt_names else ""}
-[ req_distinguished_name ]'''
+[ req_distinguished_name ]
+
+[ myca_extensions ]
+basicConstraints = critical,CA:TRUE'''
)
def load(self, script, name=None):
diff --git a/test/unit/check/cargo_component.py b/test/unit/check/cargo_component.py
new file mode 100644
index 00000000..1c194bfc
--- /dev/null
+++ b/test/unit/check/cargo_component.py
@@ -0,0 +1,4 @@
+from unit.applications.lang.wasm_component import ApplicationWasmComponent
+
+def check_cargo_component():
+ return ApplicationWasmComponent.prepare_env('hello_world') is not None
diff --git a/test/unit/check/discover_available.py b/test/unit/check/discover_available.py
index 1383a0c3..99e63604 100644
--- a/test/unit/check/discover_available.py
+++ b/test/unit/check/discover_available.py
@@ -1,6 +1,7 @@
import subprocess
import sys
+from unit.check.cargo_component import check_cargo_component
from unit.check.chroot import check_chroot
from unit.check.go import check_go
from unit.check.isolation import check_isolation
@@ -28,7 +29,7 @@ def discover_available(unit):
# discover modules from log file
- for module in Log.findall(r'module: ([a-zA-Z]+) (.*) ".*"$'):
+ for module in Log.findall(r'module: ([a-zA-Z\-]+) (.*) ".*"$'):
versions = option.available['modules'].setdefault(module[0], [])
if module[1] not in versions:
versions.append(module[1])
@@ -44,6 +45,7 @@ def discover_available(unit):
# Discover features using check. Features should be discovered after
# modules since some features can require modules.
+ option.available['features']['cargo_component'] = check_cargo_component()
option.available['features']['chroot'] = check_chroot()
option.available['features']['isolation'] = check_isolation()
option.available['features']['unix_abstract'] = check_unix_abstract()
diff --git a/test/unit/http.py b/test/unit/http.py
index 9401501b..e449c8b5 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -67,7 +67,7 @@ class HTTP1:
headers['Content-Type'] = content_type
- if 'Content-Length' not in headers:
+ if 'Content-Length' not in headers and 'Transfer-Encoding' not in headers:
headers['Content-Length'] = len(body)
for header, value in headers.items():
diff --git a/test/unit/status.py b/test/unit/status.py
index 95096a96..679008d0 100644
--- a/test/unit/status.py
+++ b/test/unit/status.py
@@ -6,16 +6,16 @@ class Status:
control = Control()
def _check_zeros():
- assert Status.control.conf_get('/status') == {
- 'connections': {
+ status = Status.control.conf_get('/status')
+
+ assert status['connections'] == {
'accepted': 0,
'active': 0,
'idle': 0,
'closed': 0,
- },
- 'requests': {'total': 0},
- 'applications': {},
}
+ assert status['requests'] == {'total': 0}
+ assert status['applications'] == {}
def init(status=None):
Status._status = (
@@ -31,6 +31,9 @@ class Status:
if k in d2
}
+ if isinstance(d1, str) or isinstance(d1, list):
+ return d1 == d2
+
return d1 - d2
return find_diffs(Status.control.conf_get('/status'), Status._status)