Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing Test: Lucene.Net.Search.TestSimpleExplanations::TestDMQ8() #546

Closed
NightOwl888 opened this issue Nov 18, 2021 · 0 comments · Fixed by #557
Closed

Failing Test: Lucene.Net.Search.TestSimpleExplanations::TestDMQ8() #546

NightOwl888 opened this issue Nov 18, 2021 · 0 comments · Fixed by #557

Comments

@NightOwl888
Copy link
Contributor

NightOwl888 commented Nov 18, 2021

For information about how to help us debug tests, see #269.

This test only started failing after fixing the test framework to randomize the codecs, culture and time zone (NUnit's Randomizer was always initialized with a seed of 0, so none of these were actually random).

It only fails on .NET Framework under x86 on Windows, and only when optimizations are enabled (Release mode). I have confirmed that the test is 100% repeatable with the below seed and culture.

So far, all similar failures have been due to one of two things:

  1. Floating point numbers are compared directly using ==, >=, <=, >, or <. To fix these, converting the float data type to an int for both sides of the comparison has worked using Lucene.Net.Util.NumericUtils.SingleToSortableInt32().
  2. A float is being assigned to a double, which makes it change in precision. A place to watch out for are the Math functions that accept double as a parameter but are passed a float. For score values which can only be between 0 and 1, doing an intermediate cast to a decimal works (double x = (double)(decimal)theFloat). However, we haven't found a solution that works in more general cases because this could overflow the decimal for large numbers.
query assigned doc 2 a score of <243969.1> but skipTo(1) has <243969.1>!
Expected: 243969.09375d +/- 0.0010000000474974513d
But was:  243969.078125d
Off by:   0.015625d

To reproduce this test result:

Option 1:

Apply the following assembly-level attributes:

[assembly: Lucene.Net.Util.RandomSeed(0x88c92f3536160e0L)]
[assembly: NUnit.Framework.SetCulture("en-IN")]

Option 2:

Use the following .runsettings file:

<RunSettings>
  <TestRunParameters>
    <Parameter name="tests:seed" value="0x88c92f3536160e0" />
    <Parameter name="tests:culture" value="en-IN" />
  </TestRunParameters>
</RunSettings>

See the .runsettings documentation at: https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file.
at Lucene.Net.Search.QueryUtils.CollectorAnonymousClass2.Collect(Int32 doc) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\QueryUtils.cs:line 585
at Lucene.Net.Search.Weight.DefaultBulkScorer.ScoreAll(ICollector collector, Scorer scorer) in D:\a\1\s\src\Lucene.Net\Search\Weight.cs:line 196
at Lucene.Net.Search.Weight.DefaultBulkScorer.Score(ICollector collector, Int32 max) in D:\a\1\s\src\Lucene.Net\Search\Weight.cs:line 167
at Lucene.Net.Search.BulkScorer.Score(ICollector collector) in D:\a\1\s\src\Lucene.Net\Search\BulkScorer.cs:line 36
at Lucene.Net.Search.AssertingBulkScorer.Score(ICollector collector) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\AssertingBulkScorer.cs:line 74
at Lucene.Net.Search.IndexSearcher.Search(IList`1 leaves, Weight weight, ICollector collector) in D:\a\1\s\src\Lucene.Net\Search\IndexSearcher.cs:line 633
at Lucene.Net.Search.AssertingIndexSearcher.Search(IList`1 leaves, Weight weight, ICollector collector) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\AssertingIndexSearcher.cs:line 106
at Lucene.Net.Search.IndexSearcher.Search(Query query, ICollector results) in D:\a\1\s\src\Lucene.Net\Search\IndexSearcher.cs:line 304
at Lucene.Net.Search.QueryUtils.CheckFirstSkipTo(Query q, IndexSearcher s) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\QueryUtils.cs:line 518
at Lucene.Net.Search.QueryUtils.Check(Random random, Query q1, IndexSearcher s, Boolean wrap) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\QueryUtils.cs:line 146
at Lucene.Net.Search.CheckHits.CheckHitCollector(Random random, Query query, String defaultFieldName, IndexSearcher searcher, Int32[] results) in D:\a\1\s\src\Lucene.Net.TestFramework\Search\CheckHits.cs:line 114
at Lucene.Net.Search.TestExplanations.Qtest(Query q, Int32[] expDocNrs) in D:\a\1\s\src\Lucene.Net.Tests\Search\TestExplanations.cs:line 109
at Lucene.Net.Search.TestSimpleExplanations.TestDMQ8() in D:\a\1\s\src\Lucene.Net.Tests\Search\TestSimpleExplanations.cs:line 293

See: https://dev.azure.com/lucene-net-temp3/Lucene.NET/_build/results?buildId=590&view=ms.vss-test-web.build-test-results-tab&runId=429610&resultId=100341&paneView=debug](https://dev.azure.com/lucene-net-temp3/Lucene.NET/_build/results?buildId=590&view=ms.vss-test-web.build-test-results-tab&runId=429610&resultId=100341&paneView=debug) to download the test artifacts, but do note that the build will be cleaned up after 30 days.

NOTE: I am working on a PR to fix the random seed functionality #288 now, and the settings in the error message don't exist in master yet.

@NightOwl888 NightOwl888 added up-for-grabs This issue is open to be worked on by anyone help-wanted Extra attention is needed is:bug test-failure pri:normal labels Nov 18, 2021
@NightOwl888 NightOwl888 added this to the 4.8.0 milestone Nov 18, 2021
@NightOwl888 NightOwl888 self-assigned this Nov 23, 2021
@NightOwl888 NightOwl888 removed up-for-grabs This issue is open to be worked on by anyone help-wanted Extra attention is needed labels Nov 23, 2021
NightOwl888 added a commit to NightOwl888/lucenenet that referenced this issue Nov 23, 2021
…res an explicit cast to float to prevent it from losing precision. Fixes apache#546.
NightOwl888 added a commit that referenced this issue Nov 23, 2021
…res an explicit cast to float to prevent it from losing precision. Fixes #546.
@NightOwl888 NightOwl888 modified the milestones: 4.8.0, 4.8.0-beta00016 Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment