Skip to content

Prevent floating number precision issue#418

Open
puck wants to merge 1 commit into
bestpractical:5.0-trunkfrom
puck:api_attribute-test_runid
Open

Prevent floating number precision issue#418
puck wants to merge 1 commit into
bestpractical:5.0-trunkfrom
puck:api_attribute-test_runid

Conversation

@puck

@puck puck commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Some test runs would cause runid to end up with a slightly differing values which caused the tests to fail.

An example of failing test is when $runid was observed to be 153.425536363056, but in the database it is stored as '153.42553636305601'. This caused the Attribute to not be found causing some of the tests to fail.

I see no need for a long fraction to be used, so truncate it.

I haven't seen this issue on the Intel i7 I normally test on, but was reproducible about 50% of the time on an AMD EPYC that a fellow Debian Developer runs package tests on.

I added debugging to lib/RT/Record.pm to see what was happening and got this:

ok 15
AddAtribute: RT::User=HASH(0x562dbdb480f0) at /home/puck/request-tracker5/lib/RT/Record.pm line 179, <DATA> line 2112.
$VAR1 = {
          'Name' => '153.425536363056',
          'Content' => 'First',
          'Description' => undef
        };
ok 16 - Object created
# AttrID: 2 - Object created
# runid: 153.425536363056
not ok 17 - got some sort of attribute

#   Failed test 'got some sort of attribute'
#   at t/api/attribute-tests.t line 54.
not ok 18 - undef isa 'RT::Attribute'

Check database file:

sqlite> select name from Attributes where Content='First';
╭──────────────────────╮
│         Name         │
╞══════════════════════╡
│ '153.42553636305601' │
╰──────────────────────╯
sqlite>

@puck puck force-pushed the api_attribute-test_runid branch 2 times, most recently from 05a7d93 to a11b7e8 Compare June 19, 2026 11:30
Some test runs would cause runid to end up with a slightly differing values
in the database which caused the tests to fail.

An example of a failing test is when $runid was observed to be
153.425536363056, but in the database it is stored as '153.42553636305601'.
This caused the Attribute to not be found causing some of the tests to fail.

I see no need for a long fraction to be used, so truncate it.
@puck puck force-pushed the api_attribute-test_runid branch from a11b7e8 to 2fd5484 Compare June 21, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant