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

Many windows phpunit errors introduced in 3.1 (unclosed files)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1) Run phpunit tests under linux and windows. No warnings related to open/permission/unlink should happen and no failures related with backup/restore.

      2) Reset the QAs related with:

      • backup and restore operations (individual and scheduled).
      • recyclebin operations (deleting and recovering course and categories).

      3) Behat, partially covering 2), also should pass (I've not been able to complete this, but I'm optimist).

      Show
      1) Run phpunit tests under linux and windows. No warnings related to open/permission/unlink should happen and no failures related with backup/restore. 2) Reset the QAs related with: backup and restore operations (individual and scheduled). recyclebin operations (deleting and recovering course and categories). 3) Behat, partially covering 2), also should pass (I've not been able to complete this, but I'm optimist).
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Running unit tests under windows there are a lot of failures, all them of the type:

      Warning: rmdir(C:\Users\stronk7\moodledata\integration\master\mssql_phpunit/temp): Directory not empty in C:\Users\stronk7\git_moodle\integration\lib\moodlelib.php on line 9064
      

      Curiously this does not happen in previous versions, where we have (in an not-ideal way) mitigated it by adding calls to gc_collect_cycles() in tests (MDL-47675).

      Then MDL-50063 was created to review all those calls and fix the real problem: we leaving unclosed resources in tests. But it has not been fixed at the time of creating this.

      Back to Moodle 3.1... it seems that the new tool_recyclebin is enabled by default and that causes every delete (course or category) operation in tests, to perform a silent backup of the affected courses.

      And those backup operations, happening behind the scenes are the ultimate culprit for the windows failures, because every operation leaves at least a .log file opened.

      I've confirmed that tool_recyclebin is the cause of the problem because, the same unit tests, running with the tool disabled via cfg end without error.

      So this issue is about to ensure that, in core, we always close all files correctly. And we should achieve that by always destroying the controller when a backup/restore operation happens.

      Note that such a destroy() destroy operation is optional, and people using custom backup & restore scripts may not be using it. They shouldn't be affected much and, at least, with this solved... they'll have a way to close logger resources properly.

      So that's it. Working on this right now...

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16