Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60705

core_search: Unit tests get time wrong by factor of a million




      Adam Olley points out that code in the mock search engine for faking time (introduced in MDL-60555) is incorrect by a factor of a million; the code used to call usleep which is measured in microseconds, and has now been changed to add to a numeric variable that is stored in seconds.

      This did not cause the unit tests to fail, which indicated somewhat of an inadequacy in the unit tests. Code in the tests was basically along the lines of:

      • Set a time limit so that only 2 items will be processed
      • Check that only 2 items were processed

      However, because of the way that search time limits work, there is usually a minimum of 2 items that need to be processed before it really even checks the time limit. (This is because it guarantees to make some progress each time, which means it has to get onto the next second; it does this by, roughly, requiring to process items with different time values, which means it must process at least 2.)

      I have changed one of the unit tests so that 3 items will be processed. This now fails as expected with the old code (that was out by a factor of a million) and passes again once that code is corrected.


          Issue Links



              • Assignee:
                quen Sam Marshall
                quen Sam Marshall
                Peer reviewer:
                Adam Olley
                Jake Dallimore
                Adrian Greeve
                Component watchers:
                Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created:
                  Fix Release Date: