Preparations
- in IDE:
- go to Languages & Frameworks → PHP → Debug section of the PhpStorm settings dialog
- set Max simultaneous connections setting to 3
- save changes
- in Admin Console:
- go to Configuration → Website → Advanced section
- enable Use Cron to run Scheduled Tasks setting
- save changes
- go to Configuration → Website → Scheduled Tasks section
- disable all scheduled tasks
- pick several tasks that are executed each minute (update Run Schedule of any other task to make it usable in the test)
- enable picked tasks (Cancel them if they're marked as running currently)
- in IDE:
- replace the body of the above-chosen scheduled tasks with echo #' . getmypid() . ' - ' . $event . PHP_EOL;
- place breakpoint on if ( !$this->claim($event_data, $start_time) ) { line in \kScheduledTaskManager::runAll method
- in Terminal (start 2 windows in parallel):
- enable debugging from CLI
- run php tools/cron.php in the folder of the project
Test Plan
NOTE: The goal is to test that even if both tools/cron.php started with the same available scheduled task list, they won't execute scheduled tasks processed from the parallel process.
- in the 1st process use Step Over in PhpStorm
- confirm that claiming succeeded and you're able to execute the $this->run($event_data, $start_time); line
- in the 2nd process use Step Over in PhpStorm
- confirm that claiming failed and you're redirect to the next scheduled task execution (if any)