Flaky tests due to relying on default result ordering

Bug #2049502 reported by Paul Mars
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
golang-entgo-ent (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

A test of the golang test suite of ent is sometimes failing because the results fetched from the database are not sorted as expected.

681s === RUN Example_M2M2Types
681s --- FAIL: Example_M2M2Types (0.00s)
681s got:
681s [Group(id=2, name=GitLab) Group(id=1, name=GitHub)]
681s [Group(id=1, name=GitHub)]
681s [User(id=1, age=30, name=a8m) User(id=2, age=28, name=nati)]
681s want:
681s [Group(id=1, name=GitHub) Group(id=2, name=GitLab)]
681s [Group(id=1, name=GitHub)]
681s [User(id=1, age=30, name=a8m) User(id=2, age=28, name=nati)]

By default sqlite does not guaranty results ordering but this can go unnoticed on simple cases. I suspect some race condition somewhere is triggering the bug and the 2 results are swapped.

To make it reliable we need to explicitly call .Order(ent.Asc("id")).

Tags: patch
Revision history for this message
Paul Mars (upils) wrote :
Revision history for this message
Paul Mars (upils) wrote :
Paul Mars (upils)
description: updated
description: updated
Revision history for this message
Paul Mars (upils) wrote :

I opened an issue upstream [0] to discuss this further with the maintainers

[0] https://github.com/ent/ent/issues/3903

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "golang-entgo-ent-0.11.3-4ubuntu1.diff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Revision history for this message
Simon Quigley (tsimonq2) wrote :

Sponsoring to Ubuntu with some minor nitpicks. Please ping me (on IRC) if you don't hear anything on the Debian bug in the next 7 days, I can NMU there.

Thanks!

Changed in golang-entgo-ent (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package golang-entgo-ent - 0.11.3-4ubuntu1

---------------
golang-entgo-ent (0.11.3-4ubuntu1) noble; urgency=medium

  * d/p/0005-0005-force-result-ordering-in-tests.patch: Fix flaky tests
    (LP: #2049502)

 -- Paul Mars <email address hidden> Tue, 16 Jan 2024 13:52:04 +0100

Changed in golang-entgo-ent (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.