Moodle
  1. Moodle
  2. MDL-34309

Fix core_adodb_testcase::test_read_table for postgresql sockets connection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide

      1/ break your pg setup in config.php by giving invalid socket
      2/ run unittests

      Show
      1/ break your pg setup in config.php by giving invalid socket 2/ run unittests
    • Workaround:
      Hide

      Workaround is to fix broken legacy postgresql socket value in config.php.

      Show
      Workaround is to fix broken legacy postgresql socket value in config.php.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Rank:
      42677

      Description

      The core_adodb_testcase::test_read_table attempts to configure the external database enrolment plugin with the database details from $CFG->db* settings. However, it fails to replicate the settings properly when Moodle is configured with $CFG->dbhost = 'localhost' and $CFG->dboptions['dbsocket'] = 1 with postgres. This is because it sets enrol_database.dbhost to '1' rather than blank. To properly mirror the settings, it should leave dbhost blank if sockets are on and the dbhost doesn't contain a slash (see code in pgsql_native_moodle_database::connect()).

      Here is the failed test output:

      $ phpunit core_adodb_testcase enrol/database/tests/adodb_test.php
      PHPUnit 3.6.11 by Sebastian Bergmann.
      
      Configuration read from /git/hosted/phpunit.xml
      
      E
      
      Time: 3 seconds, Memory: 51.25Mb
      
      There was 1 error:
      
      1) core_adodb_testcase::test_read_table
      pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Invalid argument
      	Is the server running on host "1" (0.0.0.1) and accepting
      	TCP/IP connections on port 5432?
      

      I've linked a patch which fixes this.

        Activity

        Hide
        Petr Škoda added a comment -

        Thanks for the report.

        Show
        Petr Škoda added a comment - Thanks for the report.
        Hide
        Sam Hemelryk added a comment -

        Thanks Ashley, this has been integrated now.

        Show
        Sam Hemelryk added a comment - Thanks Ashley, this has been integrated now.
        Hide
        Ankit Agarwal added a comment -

        After breaking the setup am getting the following error on both moodle install and during phpunit tests

        
        
        Error: Database connection failed
        
        It is possible that the database is overloaded or otherwise not running properly.
        
        The site administrator should also check that the database details have been correctly specified in config.php
        
        

        As Sam suggested, that is how it is supposed to behave.
        So passing the test.
        Cheers

        Show
        Ankit Agarwal added a comment - After breaking the setup am getting the following error on both moodle install and during phpunit tests Error: Database connection failed It is possible that the database is overloaded or otherwise not running properly. The site administrator should also check that the database details have been correctly specified in config.php As Sam suggested, that is how it is supposed to behave. So passing the test. Cheers
        Hide
        Dan Poltawski added a comment -

        *Notice*: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26

        Congratulations

        {tracker.user.name}

        !

        You've made into Moodle

        {tracker.fixversion-1}

        +

        I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world.

        cheers!

        {tracker.friendlyintegrator}
        Show
        Dan Poltawski added a comment - * Notice *: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26 Congratulations {tracker.user.name} ! You've made into Moodle {tracker.fixversion-1} + I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world. cheers! {tracker.friendlyintegrator}
        Hide
        Ashley Holman added a comment -

        Thanks Dan.. for your buggy automated congratulations.. LOL

        Show
        Ashley Holman added a comment - Thanks Dan.. for your buggy automated congratulations.. LOL

          People

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

            Dates

            • Created:
              Updated:
              Resolved: