Spurious test failure: get_first_booter sorts lexicographically, test assumes numerically

Bug #1323307 reported by Jeroen T. Vermeulen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Jason Hobbs

Bug Description

I'm getting occasional test failures in provisioningserver.custom_hardware.tests.test_ucsm.TestGetFirstBooter.test_first_booter, like:

    MismatchError: 'Entry100' != u'Entry98'

It looks as if the test sets up a bunch of "Entry%d" strings and expects get_first_booter to sort them numerically. But get_first_booter gets strings, not numbers, and sorts them lexicographically. Thus, when the test sets its arbitrary starting number at 98 it expects to see "Entry98, Entry99, Entry100" but gets "Entry100, Entry98, Entry99."

There's not a lot of documentation for get_first_booter, and none at all for the test and its setup, so I can't easily tell who's wrong. Is the test uncovering a bug in get_first_booter when it hits this edge condition? Or is the lexicographical order just fine and the test scenario bogus? This needs 1: clear code documentation to set expectations so we don't get surprised by these things, 2: specific tests for any edge conditions, and 3: a fix. And I really would do it in that order.

Related branches

Raphaël Badin (rvb)
tags: added: tests
Raphaël Badin (rvb)
tags: removed: tests
Changed in maas:
status: Triaged → Fix Committed
Changed in maas:
milestone: none → 1.6.0
Raphaël Badin (rvb)
Changed in maas:
assignee: nobody → Jason Hobbs (jason-hobbs)
Changed in maas:
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.