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

Allow unit tests to be executed against custom cache stores

    Details

    • Testing Instructions:
      Hide

      Common prep

      You need to do this before running the following suites.

      1. Install memcached on your server.
      2. Install mongodb on your server.
      3. Install the memcache php extension.
      4. install the memcached php extension.
      5. Install the mongodb php extension.
      6. Ensure memcached and mongo are running.
      7. Start a second memcached instance on another port. We'll need this for testing "sudo -u memcache /usr/bin/memcached -d -m 128 -p 11212 -u memcache -l 127.0.0.1"
      8. Edit your config.php and add the following:
        <?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');
        
      9. Run full unit tests and record time taken (all must pass). You'll refer to this in both tests.

      Test altcacheconfigpath

      1. Edit your config.php and set $CFG->altcacheconfigpath = '/tmp/';
      2. Browse to your site and configure a memcached store instance in the cache config screen (Settings > Plugins > Caching > Cache configuration)
      3. Map it as the default application cache
      4. Save your changes
      5. In your console run `sudo cp /tmp/cacheconfig.php /tmp/cacheconfig.php.bak`
      6. Run full unit tests again and wait for it to finish
      7. Ensure that everything passes
      8. Hopefully it is quicker
      9. Run `sdiff -s /tmp/cacheconfig.php /tmp/cacheconfig.php.bak | wc -l` and check it shows 0.
      10. In your browser inspect the cache configuration and check it hasn't changed.

      Test TEST_CACHE_USING_APPLICATION_STORE define.

      1. Make sure a memcached instance is running on your server.
      2. Edit your config.php and remove $CFG->altcacheconfigpath
      3. Add:
        define('TEST_CACHE_USING_APPLICATION_STORE', 'memcache');
        
      4. Run full unit tests again and wait for it to finish
      5. Ensure that everything passes
      6. Hopefully it is quicker than the very first run.
      Show
      Common prep You need to do this before running the following suites. Install memcached on your server. Install mongodb on your server. Install the memcache php extension. install the memcached php extension. Install the mongodb php extension. Ensure memcached and mongo are running. Start a second memcached instance on another port. We'll need this for testing "sudo -u memcache /usr/bin/memcached -d -m 128 -p 11212 -u memcache -l 127.0.0.1" Edit your config.php and add the following: <?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'); Run full unit tests and record time taken (all must pass). You'll refer to this in both tests. Test altcacheconfigpath Edit your config.php and set $CFG->altcacheconfigpath = '/tmp/'; Browse to your site and configure a memcached store instance in the cache config screen (Settings > Plugins > Caching > Cache configuration) Map it as the default application cache Save your changes In your console run `sudo cp /tmp/cacheconfig.php /tmp/cacheconfig.php.bak` Run full unit tests again and wait for it to finish Ensure that everything passes Hopefully it is quicker Run `sdiff -s /tmp/cacheconfig.php /tmp/cacheconfig.php.bak | wc -l` and check it shows 0. In your browser inspect the cache configuration and check it hasn't changed. Test TEST_CACHE_USING_APPLICATION_STORE define. Make sure a memcached instance is running on your server. Edit your config.php and remove $CFG->altcacheconfigpath Add: define('TEST_CACHE_USING_APPLICATION_STORE', 'memcache'); Run full unit tests again and wait for it to finish Ensure that everything passes Hopefully it is quicker than the very first run.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull Master Branch:
      45513-28-defines

      Description

      It'd be great to be able to run unit tests against custom cache stores rather than just the default stores.
      I suppose the biggest advantage to this is that it would allow for faster unit test runs by using faster cache backends (memcache, apc etc).

      We'd have to ensure that the unit tests stay as they are when running against the default and that by default the default stores would be used.
      Really we'd have to have some tests marked as skipped to ensure that the dev knew that there was things being avoided.
      We have a file test that manually checks cached filed existence which could not be tested against anything but the default.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Nov/14