Skip to content

test(integration): fix test for unordered golden files

Suleimi Ahmed requested to merge 835-fix-flaky-golden-files-import-test into master

Related to #835 (closed) and #819 (closed)

Problem 🚒

The values retrieved from the db table gc_blobs_layers for comparison with associated golden files (here) are ordered by digest due to https://gitlab.com/gitlab-org/container-registry/-/blob/master/registry/datastore/testutil/testutil.go#L153.

We see in #835 (closed) that some records in gc_blobs_layers table might have the exact same digest. Because of this postgres is allowed to determine how it would like to order the records that have similar digests when returning them by digest. This leads to a problem because our golden files need to match exactly the records returned by postgres (including the order) and leaves no room for postgres to decide ordering in cases where the digest are the same.

Solution 🚰

For the failing tests, Make sure we return records for gc_blobs_layers in a deterministic (e.g ordered on a unique id) manner from postgres. The associated golden files should also reflect the new deterministic order.

Edited by Jaime Martinez

Merge request reports