liip / liip/LiipTestFixturesBundle

Configurable cached fixtures directory

Open
#118 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
178
Forks
48
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
We've switched from custom implementation to this library to leverage fixtures caching (thanks for extraction from `liip/LiipFunctionalTestBundle`!). Also we use paratest to speed up our sqlite tests execution. To guarantee that the used database is different for each thread, we use `TEST_TOKEN` provided by paratest and connection factory similar to the one provided in https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Factory/ConnectionFactory.php (btw it looks broken now as `getDbNameFromEnv` is not used)

Unfortunately, we still end up in concurrency problems but in fixtures backup usage, being it loading or restoring from fixtures. In our custom implementation we solved it with similar to connection factory - use different folders for different threads. It's possible to maintain this behavior by overwriting service definition of `\Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup` but will appreciate if configurability of cache folder makes it to upstream

**Describe the solution you'd like**
`\Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup::getBackupFilePath` cache folder (for other providers it's the same) should be configurable and instead of using `$this->container->getParameter('kernel.cache_dir')` allow configuration to come from bundle configuration.

For backwards-compatibility this parameter can be `%kernel.cache_dir%` by default.

**Describe alternatives you've considered**
Alternatives are to keep overwritten service definition on our side, but it's prone to future breaking changes.

**Additional context**
I've tried to add more configuration to `liip_test_fixtures.cache_db` but it accepts only service id, so I don't see clear non-breaking change here. Looking for alternatives and up to implement it f it satisfies both maintainers and my use case.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Services/DatabaseBackup/SqliteDatabaseBackup.php at getBackupFilePath, then inspect the bundle configuration around liip_test_fixtures.cache_db and the corresponding database-backup services. Make the cache directory configurable while preserving the current kernel.cache_dir default, and verify that separate configured directories can prevent concurrent fixture backup and restore conflicts.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sqlite, symfony
Domain
database, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.