fix(pipeline): prevent event loop blocking in local collector and increase CI pipeline timeouts
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 2m15s
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 2m15s
This commit is contained in:
+11
-10
@@ -28,6 +28,7 @@ TCP_HOST = "127.0.0.1"
|
||||
TCP_PORT = 9443
|
||||
HERMES_HOST = "127.0.0.1"
|
||||
HERMES_PORT = 8443
|
||||
HTTP_TIMEOUT = 30
|
||||
|
||||
|
||||
def run_tests():
|
||||
@@ -69,7 +70,7 @@ def run_tests():
|
||||
|
||||
# 1. Check current license status
|
||||
req_status_init = urllib.request.Request(f"http://{HERMES_HOST}:{HERMES_PORT}/api/license/status")
|
||||
with urllib.request.urlopen(req_status_init, timeout=15) as resp:
|
||||
with urllib.request.urlopen(req_status_init, timeout=HTTP_TIMEOUT) as resp:
|
||||
init_lic_stat = json.loads(resp.read().decode("utf-8"))
|
||||
|
||||
if init_lic_stat.get("status") == "UNLICENSED":
|
||||
@@ -85,7 +86,7 @@ def run_tests():
|
||||
headers={"Content-Type": "application/json"}
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req_unlicensed, timeout=15):
|
||||
with urllib.request.urlopen(req_unlicensed, timeout=HTTP_TIMEOUT):
|
||||
assert False, "Expected HTTP 403 on unlicensed server enrollment"
|
||||
except urllib.error.HTTPError as e:
|
||||
assert e.code == 403, f"Expected HTTP 403 on unlicensed server, got {e.code}"
|
||||
@@ -96,7 +97,7 @@ def run_tests():
|
||||
f"http://{HERMES_HOST}:{HERMES_PORT}/api/license/csr",
|
||||
headers={"Authorization": f"Bearer {auth_token}"}
|
||||
)
|
||||
with urllib.request.urlopen(req_csr, timeout=15) as resp:
|
||||
with urllib.request.urlopen(req_csr, timeout=HTTP_TIMEOUT) as resp:
|
||||
assert resp.status == 200
|
||||
csr_data = json.loads(resp.read().decode("utf-8"))
|
||||
csr_pem = csr_data["csr"]
|
||||
@@ -104,7 +105,7 @@ def run_tests():
|
||||
|
||||
# 3. Generate test master CA and sign subordinate CA with 10 seats
|
||||
master_ca_dir = os.path.join(ROOT_DIR, "test_pipeline_master_ca")
|
||||
master_cert, master_key, master_pem, master_key_pem = server_enrollment.generate_ca_if_needed(cert_dir=master_ca_dir, common_name="LOGAR-Master-Root-CA")
|
||||
master_cert, master_key, master_pem, master_key_pem = server_enrollment.generate_ca_if_needed(cert_dir=master_ca_dir, common_name="LOGAR-Master-Root-CA", key_size=2048)
|
||||
sub_pem = server_enrollment.sign_ca_csr_with_seats(
|
||||
csr_pem=csr_pem,
|
||||
master_ca_cert_pem=master_pem,
|
||||
@@ -121,7 +122,7 @@ def run_tests():
|
||||
data=json.dumps(import_payload).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json", "Authorization": f"Bearer {auth_token}"}
|
||||
)
|
||||
with urllib.request.urlopen(req_import, timeout=15) as resp:
|
||||
with urllib.request.urlopen(req_import, timeout=HTTP_TIMEOUT) as resp:
|
||||
assert resp.status == 200
|
||||
import_res = json.loads(resp.read().decode("utf-8"))
|
||||
assert import_res["status"] == "success"
|
||||
@@ -130,7 +131,7 @@ def run_tests():
|
||||
|
||||
# 5. Verify license status
|
||||
req_status = urllib.request.Request(f"http://{HERMES_HOST}:{HERMES_PORT}/api/license/status")
|
||||
with urllib.request.urlopen(req_status, timeout=15) as resp:
|
||||
with urllib.request.urlopen(req_status, timeout=HTTP_TIMEOUT) as resp:
|
||||
assert resp.status == 200
|
||||
lic_stat = json.loads(resp.read().decode("utf-8"))
|
||||
assert lic_stat["status"] == "ACTIVE"
|
||||
@@ -153,7 +154,7 @@ def run_tests():
|
||||
headers={"Content-Type": "application/json"}
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req_bad, timeout=15):
|
||||
with urllib.request.urlopen(req_bad, timeout=HTTP_TIMEOUT):
|
||||
assert False, "Expected HTTP 403 on invalid secret"
|
||||
except urllib.error.HTTPError as e:
|
||||
assert e.code == 403, f"Expected HTTP 403, got {e.code}"
|
||||
@@ -171,7 +172,7 @@ def run_tests():
|
||||
data=json.dumps(valid_enroll_payload).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json"}
|
||||
)
|
||||
with urllib.request.urlopen(req_valid, timeout=15) as resp:
|
||||
with urllib.request.urlopen(req_valid, timeout=HTTP_TIMEOUT) as resp:
|
||||
assert resp.status == 200, f"Expected 200, got {resp.status}"
|
||||
enroll_data = json.loads(resp.read().decode("utf-8"))
|
||||
assert "ca_cert" in enroll_data
|
||||
@@ -194,7 +195,7 @@ def run_tests():
|
||||
auth_tok = server_conf.get("auth_token") or client_conf.get("auth_token")
|
||||
client_headers = {"Authorization": f"Bearer {auth_tok}"} if auth_tok else {}
|
||||
clients_req = urllib.request.Request(f"http://{HERMES_HOST}:{HERMES_PORT}/api/clients", headers=client_headers)
|
||||
with urllib.request.urlopen(clients_req, timeout=15) as resp:
|
||||
with urllib.request.urlopen(clients_req, timeout=HTTP_TIMEOUT) as resp:
|
||||
clients_data = json.loads(resp.read().decode("utf-8"))
|
||||
assert clients_data["active_seats"] >= 1
|
||||
found_c = any(c["client_id"] == client_id for c in clients_data["clients"])
|
||||
@@ -294,7 +295,7 @@ def run_tests():
|
||||
token = server_conf.get("auth_token") or client_conf.get("auth_token")
|
||||
headers = {"Authorization": f"Bearer {token}"} if token else {}
|
||||
req = urllib.request.Request(f"http://{HERMES_HOST}:{HERMES_PORT}/api/hermes/report", headers=headers)
|
||||
with urllib.request.urlopen(req, timeout=15) as response:
|
||||
with urllib.request.urlopen(req, timeout=HTTP_TIMEOUT) as response:
|
||||
assert response.status == 200, f"Expected 200, got {response.status}"
|
||||
hermes_data = json.loads(response.read().decode("utf-8"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user