Skip to content

Commit a03a9b9

Browse files
fix test analytics (#1016)
1 parent 089f5c6 commit a03a9b9

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

ta_storage/pg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def save_tests(db_session: Session, tests_to_write: dict[str, dict[str, Any]]):
222222

223223
test_insert = insert(Test.__table__).values(test_data)
224224
insert_on_conflict_do_update = test_insert.on_conflict_do_update(
225-
index_elements=["repoid", "name", "testsuite", "flags_hash"],
225+
index_elements=["id"],
226226
set_={
227227
"framework": test_insert.excluded.framework,
228228
"computed_name": test_insert.excluded.computed_name,

tasks/ta_finisher.py

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from helpers.string import EscapeEnum, Replacement, StringEscaper, shorten_file_paths
2525
from services.activation import activate_user
2626
from services.lock_manager import LockManager, LockRetry, LockType
27+
from services.redis import get_redis_connection
2728
from services.repository import (
2829
EnrichedPull,
2930
TorngitBaseAdapter,
@@ -84,8 +85,11 @@ def queue_optional_tasks(
8485
commit_yaml: UserYaml,
8586
branch: str | None,
8687
):
88+
redis_client = get_redis_connection()
89+
8790
if should_do_flaky_detection(repo, commit_yaml):
8891
if commit.merged is True or branch == repo.branch:
92+
redis_client.set(f"flake_uploads:{repo.repoid}", 0)
8993
process_flakes_task_sig = process_flakes_task.s(
9094
repo_id=repo.repoid,
9195
commit_id=commit.commitid,

tasks/test_results_processor.py

+5-22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import annotations
22

3-
import base64
43
import logging
5-
import zlib
64
from dataclasses import dataclass
75
from datetime import date, datetime
86
from typing import Literal, TypedDict
@@ -380,10 +378,6 @@ def save_test_flag_bridges(
380378
db_session.execute(insert_on_conflict_do_nothing_flags)
381379
db_session.commit()
382380

383-
def decode_raw_file(self, file: bytes) -> bytes:
384-
file_bytes = zlib.decompress(base64.b64decode(file))
385-
return file_bytes
386-
387381
def parse_file(
388382
self,
389383
file_bytes: bytes,
@@ -438,8 +432,6 @@ def process_individual_upload(
438432

439433
parsing_results, readable_files = result
440434

441-
upload.state = "processed"
442-
443435
if all(len(result["testruns"]) == 0 for result in parsing_results):
444436
successful = False
445437
log.error(
@@ -460,6 +452,7 @@ def process_individual_upload(
460452
upload.flag_names,
461453
)
462454

455+
upload.state = "processed"
463456
db_session.commit()
464457

465458
log.info(
@@ -469,24 +462,14 @@ def process_individual_upload(
469462
if should_delete_archive:
470463
self.delete_archive(archive_service, upload)
471464
else:
465+
log.info(
466+
"Writing readable files to archive",
467+
extra=dict(upload_id=upload_id, readable_files=readable_files),
468+
)
472469
archive_service.write_file(upload.storage_path, readable_files)
473470

474471
return {"successful": successful}
475472

476-
def rewrite_readable(
477-
self, network: list[str] | None, report_contents: list[ReadableFile]
478-
) -> bytes:
479-
buffer = b""
480-
if network is not None:
481-
for file in network:
482-
buffer += f"{file}\n".encode("utf-8")
483-
buffer += b"<<<<<< network\n\n"
484-
for report_content in report_contents:
485-
buffer += f"# path={report_content.path}\n".encode("utf-8")
486-
buffer += report_content.contents
487-
buffer += b"\n<<<<<< EOF\n\n"
488-
return buffer
489-
490473
def should_delete_archive(self, commit_yaml):
491474
if get_config("services", "minio", "expire_raw_after_n_days"):
492475
return True

0 commit comments

Comments
 (0)