Merge pull request 'test(artist-dir): fix flaky uq_image_record_sha256 collision' (#115) from dev into main
Build images / sign-extension (push) Successful in 3s
CI / lint (push) Successful in 3s
Build images / build-ml (push) Successful in 7s
Build images / build-web (push) Successful in 6s
CI / frontend-build (push) Successful in 22s
CI / backend-lint-and-test (push) Successful in 31s
CI / integration (push) Successful in 3m17s
Build images / sign-extension (push) Successful in 3s
CI / lint (push) Successful in 3s
Build images / build-ml (push) Successful in 7s
Build images / build-web (push) Successful in 6s
CI / frontend-build (push) Successful in 22s
CI / backend-lint-and-test (push) Successful in 31s
CI / integration (push) Successful in 3m17s
This commit was merged in pull request #115.
This commit is contained in:
@@ -5,6 +5,8 @@ ordering by (name ASC, id ASC), substring q filter, platform EXISTS
|
||||
filter (with the row-duplication trap), pagination, image_count via
|
||||
LEFT JOIN, and the window-function preview helper.
|
||||
"""
|
||||
import hashlib
|
||||
|
||||
import pytest
|
||||
|
||||
from backend.app.models import Artist, ImageRecord, Source
|
||||
@@ -58,9 +60,13 @@ async def _seed_source(db, artist_id: int, platform: str, url: str):
|
||||
|
||||
|
||||
async def _seed_image(db, artist_id: int, suffix: str):
|
||||
# Derive a stable, collision-free digest from the suffix. The old
|
||||
# `abs(hash(suffix)) % 10000` used PYTHONHASHSEED-randomized hash() over only
|
||||
# 10k buckets, so two suffixes in one test could birthday-collide and violate
|
||||
# uq_image_record_sha256 — flaky per process seed (CI run 1182).
|
||||
db.add(ImageRecord(
|
||||
path=f"/images/{suffix}.jpg",
|
||||
sha256=("0" * 60) + f"{abs(hash(suffix)) % 10000:04d}",
|
||||
sha256=hashlib.sha256(suffix.encode()).hexdigest(),
|
||||
size_bytes=10, mime="image/jpeg", width=10, height=10,
|
||||
origin="downloaded", artist_id=artist_id,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user