Preparation:
Install tool/testtasks
git clone git@github.com:catalyst/moodle-tool_testtasks.git admin/tool/testtasks
|
The SQL steps below are for mysql, they may need double \ instead of single \ for testing in postgres.
Adhoc tasks
1. To test for adhoc tasks: Queue and run adhoc task, setting successrate to 0 so that it consistantly fails
php admin/tool/testtasks/cli/queue_adhoc_tasks.php -n=1 -s=0
|
php admin/cli/adhoc_task.php -e
|
2. Check task logs to confirm that the task failed and confirm that debugging is turned off. If debugging is turned off there will be no stack trace ("Backtrace: ...") showing in the task logs.
Check task log in cli or go to:
Site Administration > Server > Tasks > Task Logs
search for 'timed_adhoc_task'
3. Go into database and set fail delay for timed_adhoc_task to 120 (or greater);
UPDATE mdl_task_adhoc SET faildelay=120 WHERE classname='\tool_testtasks\task\timed_adhoc_task';
|
Repeat steps 2 and 3.
Confirm that debugging is turned on, check the stack trace ("Backtrace: ...") for the failed timed_adhoc_task is showing.
4. Go back to the database and clear the fail delay for timed_adhoc_task
UPDATE mdl_task_adhoc SET faildelay=0 WHERE classname='\tool_testtasks\task\timed_adhoc_task';
|
5. Repeat steps 2 and 3 one more time.
6. Confirm debugging is turned off again, confirm the stacktrace did not show.
Scheduled Tasks
1. In the database, reset the fail delay for the scheduled task which will be used for testing
UPDATE mdl_task_scheduled SET faildelay=0 WHERE classname='\tool_testtasks\task\failing_task';
|
2. Run the task
php admin/cli/scheduled_task.php --execute='\tool_testtasks\task\failing_task'
|
|
3. Check task logs to confirm that debugging is turned off. If it is turned off there will be no stack trace ("Backtrace: ...") shown for the failing task
Check in the cli or go to:
Site Administration > Server > Tasks > Task Logs
search for 'failing_task'
4. Go to database and set fail delay for failing_task
UPDATE mdl_task_scheduled SET faildelay=120 WHERE classname='\tool_testtasks\task\failing_task';
|
5. repeat steps 2 and 3. Confirm that debugging is turned on. If it is you will be able to see the stack trace ("Backtrace: ...") for the failed task
6. Go back to the database and reset the fail delay
UPDATE mdl_task_scheduled SET faildelay=0 WHERE classname='\tool_testtasks\task\failing_task';
|
7. Repeat steps 2 and 3 one more time. Confirm debugging is turned off again by seeing no stack trace ("Backtrace: ...") shown for the failing task.