Show
1. Setup Requirements
To test the Redis cluster with other features that have been provided by the existing system, such as TLS/SSL, Auth Password, please follow the instructions on Usage section at https://github.com/meirzamoodle/middleware-tutorials-redis-cluster-tls/tree/main#usage
To the single Redis unit testing, we need to install a single Redis on local machine and ensure it's running at 127.0.0.1:6379. Refer to this page on how to install Redis https://redis.io/docs/install/install-redis/ .
Ensure your machine has the PHP-Redis extension by checking on the Info PHP page. There are a lot of ways to check the PHP Info Page. Moodle has provided it on the Site Admin > Server > PHP info.
If it has not been installed, you can install it by running the below command:
pecl install redis
Please visit https://developer.redis.com/develop/php/ for detailed information on how to do the installation.
During the unit testing, if enabled, please disable the Xdebug on your PHP CLI config.
2. Steps to run the PHPUnit for single Redis session
Open config.php and add the below codes:
define(
'TEST_SESSION_REDIS_HOST' ,
'127.0.0.1'
);
Make sure all the tests in lib/tests/session_redis_test.php are passed.
3. Steps to run the PHPUnit for Redis cluster session
Open config.php and add the below codes:
define(
'TEST_SESSION_REDIS_HOSTCLUSTER' ,
'172.23.0.11,172.23.0.12,172.23.0.13,172.23.0.14,172.23.0.15,172.23.0.16'
);
define(
'TEST_SESSION_REDIS_ENCRYPTCLUSTER' ,
[ 'verify_peer' => false , 'verify_peer_name' => false ],
);
define(
'TEST_SESSION_REDIS_AUTHCLUSTER' ,
'foobared'
);
Make sure all the tests in lib/tests/session_redis_cluster_test.php are passed.
4. Steps to run the PHPUnit for single Redis cache store
Open config.php and add the below codes:
define(
'TEST_CACHESTORE_REDIS_TESTSERVERS' ,
'127.0.0.1'
);
Make sure all the tests in cache/stores/redis/tests/cachestore_redis_test.php are passed.
5. Steps to run the PHPUnit for Redis cluster cache store
Open config.php and add the below codes:
define(
'TEST_CACHESTORE_REDIS_SERVERSCLUSTER' ,
'172.23.0.11,172.23.0.12,172.23.0.13,172.23.0.14,172.23.0.15,172.23.0.16'
);
define(
'TEST_CACHESTORE_REDIS_ENCRYPTCLUSTER' ,
true
);
define(
'TEST_CACHESTORE_REDIS_AUTHCLUSTER' ,
'foobared'
);
Make sure all the tests in cache/stores/redis/tests/cachestore_cluster_redis_test.php are passed.