22"""
33Upload pytest results to MySQL.
44Tables:
5- - ci_runs_dup : one row per run
6- - ci_tests_dup : one row per unique test
7- - ci_results_dup : one row per test per run
5+ - ci_runs : one row per run
6+ - ci_tests : one row per unique test
7+ - ci_results : one row per test per run
88"""
99
1010from __future__ import annotations
@@ -78,6 +78,7 @@ def find_single_report_json(logs_dir: Path) -> Path:
7878 for p in logs_dir .iterdir ()
7979 if p .is_file ()
8080 and p .suffix .lower () == ".json"
81+ and p .name not in {"metadata.json" }
8182 and not p .name .endswith ("last_running.json" )
8283 ]
8384 if not jsons :
@@ -267,10 +268,10 @@ def connect():
267268
268269
269270def insert_run (cur , created_at : datetime , meta : dict ) -> int :
270- """Insert one row into ci_runs_dup and return run_id. Idempotence is not enforced here."""
271+ """Insert one row into ci_runs and return run_id. Idempotence is not enforced here."""
271272 cur .execute (
272273 """
273- INSERT INTO ci_runs_dup (
274+ INSERT INTO ci_runs (
274275 created_at, commit_sha, runner_label, ubuntu_version,
275276 rocm_version, build_num, github_run_id, run_tag, logs_path
276277 ) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)
@@ -291,11 +292,11 @@ def insert_run(cur, created_at: datetime, meta: dict) -> int:
291292
292293
293294def sync_tests_and_get_ids (cur , tests : List [dict ]) -> Dict [Tuple [str , str , str ], int ]:
294- """Ensure all tests exist in ci_tests_dup and return an ID mapping.
295+ """Ensure all tests exist in ci_tests and return an ID mapping.
295296
296297 Uses a TEMPORARY TABLE for efficiency with large runs:
297298 1) Bulk insert unique (filename, classname, test_name) into a temp table.
298- 2) INSERT any missing rows into ci_tests_dup in one set operation.
299+ 2) INSERT any missing rows into ci_tests in one set operation.
299300 3) SELECT back (file, class, test) -> id mapping in one query.
300301 """
301302 uniq = {nodeid_parts (t ["nodeid" ]) for t in tests }
@@ -319,10 +320,10 @@ def sync_tests_and_get_ids(cur, tests: List[dict]) -> Dict[Tuple[str, str, str],
319320
320321 cur .execute (
321322 """
322- INSERT INTO ci_tests_dup (filename, classname, test_name)
323+ INSERT INTO ci_tests (filename, classname, test_name)
323324 SELECT s.filename, s.classname, s.test_name
324325 FROM tmp_tests s
325- LEFT JOIN ci_tests_dup t
326+ LEFT JOIN ci_tests t
326327 ON t.filename = s.filename
327328 AND t.classname = s.classname
328329 AND t.test_name = s.test_name
@@ -334,7 +335,7 @@ def sync_tests_and_get_ids(cur, tests: List[dict]) -> Dict[Tuple[str, str, str],
334335 """
335336 SELECT t.id, s.filename, s.classname, s.test_name
336337 FROM tmp_tests s
337- JOIN ci_tests_dup t
338+ JOIN ci_tests t
338339 ON t.filename = s.filename
339340 AND t.classname = s.classname
340341 AND t.test_name = s.test_name
@@ -360,7 +361,7 @@ def batch_insert_results(
360361 return
361362
362363 sql = """
363- INSERT INTO ci_results_dup
364+ INSERT INTO ci_results
364365 (run_id, test_id, outcome, duration, longrepr, message, skip_label)
365366 VALUES (%s,%s,%s,%s,%s,%s,%s)
366367 ON DUPLICATE KEY UPDATE
@@ -392,9 +393,9 @@ def upload_pytest_results( # pylint: disable=too-many-arguments, too-many-local
392393
393394 Flow:
394395 1) Parse JSONs and gather tests.
395- 2) Insert a ci_runs_dup row and get run_id.
396+ 2) Insert a ci_runs row and get run_id.
396397 3) Ensure all tests exist; get (file,class,test) -> test_id map.
397- 4) Bulk insert/update ci_results_dup for this run.
398+ 4) Bulk insert/update ci_results for this run.
398399 """
399400 report = find_single_report_json (logs_dir )
400401 created_at , tests = load_from_single_json (report )
0 commit comments