Skip to content

Commit 7b7d080

Browse files
committed
Update test_logzio_e2e.py
1 parent 2cf0f28 commit 7b7d080

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

tests/e2e/test_logzio_e2e.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import json
1313
import logging
1414
import os
15+
import re
1516
import time
1617
import requests
1718
import pytest
@@ -136,17 +137,28 @@ def test_log_content_matches(self):
136137
print("Waiting for log ingestion...")
137138
time.sleep(240)
138139

139-
query = f"env_id:{self.env_id} AND message:*Content*validation*"
140+
query = f"env_id:{self.env_id}"
140141
response = fetch_logs(self.api_key, query)
141142

142-
total = response.get("hits", {}).get("total", 0)
143-
if total == 0:
144-
pytest.fail("Test log not found")
143+
hits = response.get("hits", {}).get("hits", [])
144+
if not hits:
145+
pytest.fail("No logs found for env_id")
146+
147+
# Find the log with matching message using regex
148+
pattern = re.compile(r"Content\s+validation\s+test")
149+
matching_log = None
150+
for hit in hits:
151+
source = hit.get("_source", {})
152+
message = source.get("message", "")
153+
if pattern.search(message):
154+
matching_log = source
155+
break
156+
157+
if not matching_log:
158+
pytest.fail("Test log with 'Content validation test' not found in message field")
145159

146-
hit = response["hits"]["hits"][0]["_source"]
147-
assert "Content validation test" in hit.get("message", ""), "Message content mismatch"
148-
assert hit.get("env_id") == self.env_id, "env_id mismatch"
149-
assert hit.get("test_source") == "python-handler-e2e", "test_source mismatch"
160+
assert matching_log.get("env_id") == self.env_id, "env_id mismatch"
161+
assert matching_log.get("test_source") == "python-handler-e2e", "test_source mismatch"
150162

151163
print("✅ Log content matches expected values")
152164

0 commit comments

Comments
 (0)