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

Setting alternative stores for testing lead to unit test failure

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8.1, 2.9
    • Fix Version/s: 2.8.2
    • Component/s: Caching
    • Labels:
    • Testing Instructions:
      Hide

      Make sure you have the following services installed on your machine:

      • MongoDB
      • Memcache

      Make sure you have the following PHP extensions installed on your machine:

      • MongoDB
      • Memcache
      • Memcached

      Testing the 1st way of specifying alternative stores for testing

      • Ensure that both the TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH define and $CFG->altcacheconfigpath are commented/not specified in your config.php.
      • Add the following defines to your config.php
        • define('TEST_CACHESTORE_MONGODB_TESTSERVER', 'mongodb://127.0.0.1:27017');
        • define('TEST_CACHESTORE_MEMCACHE_TESTSERVERS', '127.0.0.1:11211');
        • define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', '127.0.0.1:11212'."\n".'127.0.0.1:11211');

      Testing (cibot can't do this for you sorry):

      1. Run full unit tests
      2. Add to your config.php define('TEST_CACHE_USING_APPLICATION_STORE', 'mongodb');
      3. Run full unit tests
      4. Change TEST_CACHE_USING_APPLICATION_STORE to memcache
      5. Run full unit tests
      6. Change TEST_CACHE_USING_APPLICATION_STORE to memcached
      7. Run full unit tests

      Testing the 2st way of specifying alternative stores for testing

      • Ensure TEST_CACHE_USING_APPLICATION_STORE define in config.php is commented/not specified in your config.php.
      • Add the following to your config.php:
        • define('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH', true);
        • $CFG->altcacheconfigpath = '/tmp/MDL-48568.cache.config.php';

      Testing:

      1. init behat site, visit it and set the default application cache pointing to a mongodb store. Verify it's shown in the perf information @ page footer.
      2. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath
      3. Run full unit tests.
      4. change, in the behat site, the application cache to point to a memcache store. Verify it's shown in the perf information @ page footer.
      5. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath
      6. Run full unit tests.
      7. change, in the behat site, the application cache to point to a memcached store. Verify it's shown in the perf information @ page footer.
      8. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath
      9. Run full unit tests.
      Show
      Make sure you have the following services installed on your machine: MongoDB Memcache Make sure you have the following PHP extensions installed on your machine: MongoDB Memcache Memcached Testing the 1st way of specifying alternative stores for testing Ensure that both the TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH define and $CFG->altcacheconfigpath are commented/not specified in your config.php. Add the following defines to your config.php define('TEST_CACHESTORE_MONGODB_TESTSERVER', 'mongodb://127.0.0.1:27017'); define('TEST_CACHESTORE_MEMCACHE_TESTSERVERS', '127.0.0.1:11211'); define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', '127.0.0.1:11212'."\n".'127.0.0.1:11211'); Testing (cibot can't do this for you sorry): Run full unit tests Add to your config.php define('TEST_CACHE_USING_APPLICATION_STORE', 'mongodb'); Run full unit tests Change TEST_CACHE_USING_APPLICATION_STORE to memcache Run full unit tests Change TEST_CACHE_USING_APPLICATION_STORE to memcached Run full unit tests Testing the 2st way of specifying alternative stores for testing Ensure TEST_CACHE_USING_APPLICATION_STORE define in config.php is commented/not specified in your config.php. Add the following to your config.php: define('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH', true); $CFG->altcacheconfigpath = '/tmp/ MDL-48568 .cache.config.php'; Testing: init behat site, visit it and set the default application cache pointing to a mongodb store. Verify it's shown in the perf information @ page footer. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath Run full unit tests. change, in the behat site, the application cache to point to a memcache store. Verify it's shown in the perf information @ page footer. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath Run full unit tests. change, in the behat site, the application cache to point to a memcached store. Verify it's shown in the perf information @ page footer. copy the moodledata/muc/config.php to $CFG->altcacheconfigpath Run full unit tests.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull Master Branch:
      48568-29
    • Pull Master Diff URL:

      Description

      While testing MDL-37072 different combinations, I came to:

      1) Setting this into config.php:

      define('TEST_CACHESTORE_MONGODB_TESTSERVER', 'mongodb://localhost:27017');
      define('TEST_CACHE_USING_APPLICATION_STORE', 'mongodb');
      

      Leads to failure:

      vendor/bin/phpunit core_cache_testcase cache/tests/cache_test.php
      Moodle 2.9dev (Build: 20141205), pgsql, c9d507886984ca85a3024d3f680d118445789836
      PHPUnit 3.7.38 by Sebastian Bergmann.
       
      Configuration read from /Users/stronk7/git_moodle/integration/phpunit.xml
       
      S.......F............................
       
      Time: 2.45 seconds, Memory: 58.25Mb
       
      There was 1 failure:
       
      1) core_cache_testcase::test_definition_mappings_only
      Failed asserting that two strings are equal.
      --- Expected
      +++ Actual
      @@ @@
      -'cachestore_mongodb'
      +'cachestore_file'
       
      /Users/stronk7/git_moodle/integration/cache/tests/cache_test.php:526
      /Users/stronk7/git_moodle/integration/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit core_cache_testcase cache/tests/cache_test.php
       
      FAILURES!
      Tests: 37, Assertions: 1120, Failures: 1, Skipped: 1.
      

      Tracing down the problem, it seems that, for MONGODB we are using a singular define (TEST_CACHESTORE_MONGODB_TESTSERVER) but in cache/tests/fixtures/lib.php we are assuming (concatenating) to a plural "_TESTSERVERS" define.

      Hence it does not find the expected singular define, and default file store is used, leading to the unit test above failing.

      To confirm it, I've run the tests with both (singular and plural) defines and they passed.

      So this should be as simple as replacing all singular occurrences of TEST_CACHESTORE_MONGODB_TESTSERVER to plural. Code base and docs.

      Ciao

        Attachments

          Activity

            People

            Assignee:
            samhemelryk Sam Hemelryk
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Peer reviewer:
            Eloy Lafuente (stronk7)
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Eloy Lafuente (stronk7)
            Participants:
            Component watchers:
            Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              12/Jan/15