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

Unit test enrol_database_testcase::test_sync_user_enrolments fails in MySQL when using a DB socket

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4, 2.5
    • Fix Version/s: 2.4.1
    • Component/s: Enrolments, Unit tests
    • Labels:
    • Environment:
      * Debian GNU/Linux
      * MySQL
      * Moodle using the DB socket connection
    • Database:
      MySQL
    • Testing Instructions:
      1. setup a Moodle site on MySQL using the DB socket connection option
      2. attempt to run the affected unit test: enrol_database_testcase enrol/database/tests/sync_test.php
      3. the test should complete correctly
    • Workaround:
      Hide

      I managed to get the test to run correctly after changing the value that the Moodle installer set in config.php from:

      • $CFG->dboptions = array (
          'dbpersist' => 0,
          'dbsocket' => 1
        );

        to:

      • $CFG->dboptions = array (
          'dbpersist' => 0,
          'dbsocket' => '/run/mysqld/mysqld.sock'
        );

      Show
      I managed to get the test to run correctly after changing the value that the Moodle installer set in config.php from: $CFG->dboptions = array ( 'dbpersist' => 0, 'dbsocket' => 1 ); to: $CFG->dboptions = array ( 'dbpersist' => 0, 'dbsocket' => '/run/mysqld/mysqld.sock' );
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w51_MDL-36807_m25_mysocket

      Description

      When running the unit tests on a 2.4 site configured to use a DB socket connection to a MySQL database, enrol_database_testcase::test_sync_user_enrolments test fails while attempting to connect to the DB.

      • $ vendor/bin/phpunit enrol_database_testcase enrol/database/tests/sync_test.php
        PHPUnit 3.7.9 by Sebastian Bergmann.
         
        Configuration read from /home/jfilip/code/moodle24/phpunit.xml
         
        ESS
         
        Time: 1 second, Memory: 63.75Mb
         
        There was 1 error:
         
        1) enrol_database_testcase::test_sync_user_enrolments
        mysqli_real_connect(): (HY000/2002): No such file or directory
         
        /home/jfilip/code/moodle24/lib/adodb/drivers/adodb-mysqli.inc.php:113
        /home/jfilip/code/moodle24/lib/adodb/adodb.inc.php:555
        /home/jfilip/code/moodle24/lib/adodb/adodb.inc.php:4354
        /home/jfilip/code/moodle24/enrol/database/lib.php:856
        /home/jfilip/code/moodle24/enrol/database/lib.php:146
        /home/jfilip/code/moodle24/enrol/database/tests/sync_test.php:224
        /home/jfilip/code/moodle24/lib/phpunit/classes/advanced_testcase.php:76
         
        To re-run:
         vendor/bin/phpunit enrol_database_testcase enrol/database/tests/sync_test.php
         
        FAILURES!
        Tests: 1, Assertions: 3, Errors: 1, Skipped: 2.

      If I change the Moodle config.php file to specify the path to the MySQL socket file, rather than the standard boolean value of 1, the test works:

      • $ vendor/bin/phpunit enrol_database_testcase enrol/database/tests/sync_test.php
        PHPUnit 3.7.9 by Sebastian Bergmann.
         
        Configuration read from /home/jfilip/code/moodle24/phpunit.xml
         
        ...
         
        Time: 5 seconds, Memory: 67.25Mb
         
        OK (3 tests, 280 assertions)

      The same result happened regardless of whether I was running my system-installed phpunit binary or the one installed via composer.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jan/13