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

Reset Content writer after simpledb unit test run

XMLWordPrintable

    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • master_MDL-66973
    • Hide

      1. Run unit test for search_simpledb_testsuite and tool_monitor_testsuite test suite in one go:

      ./vendor/bin/phpunit --testsuite search_simpledb_testsuite,tool_monitor_testsuite
      

      2. Confirm that there is no error:

      OK (56 tests, 369 assertions)

      Note: 57 tests and 374 assertions for master branch 3.8.

      Show
      1. Run unit test for search_simpledb_testsuite and tool_monitor_testsuite test suite in one go: ./vendor/bin/phpunit --testsuite search_simpledb_testsuite,tool_monitor_testsuite 2. Confirm that there is no error: OK ( 56 tests, 369 assertions) Note: 57 tests and 374 assertions for master branch 3.8.

      1. Overview

      • search_simpledb_testsuite testsuite has it's own declaration of tearDown() method, so parent's one is overwritten and therefore \core_privacy\local\request\writer::reset() can't be called;
      • search_simpledb_testsuite leaves data in Content writer singleton;
      • tool_monitor_privacy_testcase extends advanced_testcase and doesn't have tearDown() method;
      • tool_monitor_testsuite testsuite asserts that Content writer singleton has no data and fails.

      2. How to replicate 

        

      root@62c474b27a92:/siteroot#./vendor/bin/phpunit --testsuite search_simpledb_testsuite,tool_monitor_testsuite
      Moodle 3.7.2+
      (Build: 20191018), aac11a3c4beac3b24b5a769e83b0ced2a044e243
      Php:7.2.19.0.0.18.04.1, pgsql: 11.4 (Debian 11.4-1.pgdg90+1), OS: Linux 4.15.0-65-generic x86_64
      PHPUnit 7.5.15 by Sebastian Bergmann and contributors.
       
      ...............................F........................         56 / 56 (100%)
       
      Time: 17.61 seconds, Memory: 100.50 MB
       
      There was 1 failure:
       
      1) tool_monitor_privacy_testcase::test_export_user_data
      Failed asserting that true is false.
       
      /siteroot/admin/tool/monitor/tests/privacy_test.php:202
      /siteroot/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run: vendor/bin/phpunit "tool_monitor_privacy_testcase" admin/tool/monitor/tests/privacy_test.php
       
      FAILURES!
      Tests: 56, Assertions: 366, Failures: 1.
      

       

       3. Why it's been missed

      Normally PHPUnit sorts testsuits, so all of them are running in the same order all the time.

      It's been missed because between search_simpledb_testsuite and tool_monitor_testsuite there are other testsuits that reset Content writer singleton properly before tool_monitor_testsuite gets started.

       

       

       

            mikhailgolenkov Misha Golenkov
            mikhailgolenkov Misha Golenkov
            Matt Porritt Matt Porritt
            Jake Dallimore Jake Dallimore
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 50 minutes
                50m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.