Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mevdschee/symfony-session-tests
A test suite for the Symfony session save handlers (to test locking support)
https://github.com/mevdschee/symfony-session-tests
session-handler session-management sessions sessionstorage symfony
Last synced: 22 days ago
JSON representation
A test suite for the Symfony session save handlers (to test locking support)
- Host: GitHub
- URL: https://github.com/mevdschee/symfony-session-tests
- Owner: mevdschee
- License: mit
- Created: 2022-12-08T12:20:04.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-09T16:57:08.000Z (about 2 years ago)
- Last Synced: 2024-10-05T21:41:51.658Z (3 months ago)
- Topics: session-handler, session-management, sessions, sessionstorage, symfony
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Symfony session handler test suite
This repository contains a test suite for the Symfony session save handlers (to test locking support). Current handlers that can be tested (and their corresponding test mode) are:
- **standard**
- **default** ([NativeFileSessionHandler](https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php))
Uses the "files" session module.
- **strict** ([docs](https://www.php.net/manual/en/session.configuration.php#ini.session.use-strict-mode) / [rfc](https://wiki.php.net/rfc/strict_sessions))
- **pdo_mysql** ([PdoSessionHandler](https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php))
Stores data in MySQL using PDO.
- **memcached** ([MemcachedSessionHandler](https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php))
Stores data in Memcache (fails: no locking).
- **redis** ([RedisSessionHandler](https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php))
Stores data in Redis (fails: no locking).Note that the standard mode testable handlers implement strict mode as well, but can't be tested as strict handlers.
## Requirements
You can install the dependencies of this script using:
sudo apt install php-cli php-curl
Optional dependencies can be installed using:
sudo apt install memcached php-memcached redis php-redis php-mysql
You can install the Symfony dependencies of this script using:
wget getcomposer.org/composer.phar
php composer.phar installYou need PHP 7.4 or higher to run the code.
## Running the tests
You should prepare your MySQL database by running the SQL script:
cat create_mysql_symfony_session_test_db.sql | sudo mysql
You can run the tests from the command line using:
php run-tests.php
The code will execute in about 1 second per handler and test 104 HTTP calls for each handler. The following output would mean that the tests succeeded and locking is implemented correctly (which is not the case):
standard - default : OK
strict - pdo_mysql : OK
strict - memcached : OK
strict - redis : OKThe word "FAILED" appears on a failed test and "SKIPPED" is shown when the PHP module is not loaded for either Redis or Memcache.
## Stress testing
Use this for 100 runs:
for i in `seq 1 100`; do php run-tests.php silent; done
As shown, you may use the argument "silent" to suppress output on successful or skipped tests.
## Links
Below you find some more interesting information about Symony, Sessions and locking:
- https://github.com/mintyphp/session-handlers (Locking handler implementations)
- https://symfony.com/doc/current/session/database.html (Symfony Session documentation)Enjoy!