-
Functional Test
-
Minor
-
Moodle 3.7
Prerequisites
- Memcache server (localhost is fine, otherwise replace 127.0.0.1 below)
- Redis server (again localhost if fine)
- php-memcached and php-redis extensions
- $CFG->autologinguests = 0; (setting disabled)
- Two additional language packs installed
- Two different browsers
Setup
We need to test each of them so we need repeat the steps below after setting each of the session handlers in our config.php:
- memcached session handler
- Log out if you are logged in
- Remove any config.php $CFG->session_handler_* stuff you previously added
- Paste this in your config.php before require_once...lib/setup.php
$CFG->session_handler_class = '\core\session\memcached';
$CFG->session_memcached_save_path = '127.0.0.1:11211';
$CFG->session_memcached_prefix = 'memc.sess.key.';
$CFG->session_memcached_acquire_lock_timeout = 120;
$CFG->session_memcached_lock_expire = 7200;
- redis session handler
- Log out if you are logged in
- Remove any config.php $CFG->session_handler_* stuff you previously added
- Paste this in your config.php before require_once...lib/setup.php
$CFG->session_handler_class = '\core\session\redis';
$CFG->session_redis_host = '127.0.0.1';
$CFG->session_redis_port = 6379; // Optional.
$CFG->session_redis_database = 0; // Optional, default is db 0.
$CFG->session_redis_prefix = 'qa.sess.'; // Optional, default is don't set one.
$CFG->session_redis_acquire_lock_timeout = 120;
$CFG->session_redis_lock_expire = 7200;
Test
- Use the CLI to run php admin/cli/purge_caches.php
- Set up the session handling according to config-dist.php instructions (you can also check Session_handling moodle docs page)
- Log in and switch the language to a non-default one. Browser through some site-level pages (such as calendar, notes, tags) and make sure the manually selected language is still the current one.
- Open a session with the same user in another browser, leave the previous browser session opened
- Log in. Check that you end up with the default language and switch the language to yet another one.
- Return to the previous session and check the language selected here is still the same, unaffected by the language selected in the other session.
- Log out from the last opened session
- Open another session with a different user and again check you end up with the default language
- Log out from all opened sessions
- Set http://YOURSITE/admin/index.php url in your browser, you should be redirected to the login page
- Log in as admin and check that you are redirected to where you wanted to be -
admin/index.php
Notes:
- To make sure the memcached server is really used, you can do
$ echo "flush_all" | nc localhost 11211
which should force all users to be logged out.
- With Redis, the same test can be done via
$ redis-cli flushall
- The config-dist.php recommends to use igbinary as the serializer for redis store. At the time of writing this (May 2017) there are reported issues with igbinary and php7 so you may want to use the default serializer.