Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47067

Behat Cron task does not work if run repeatedly

XMLWordPrintable

    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • Easy

      The Behat task 'And I trigger cron' seems to work just by going to admin/cron.php. This is fine but if you are testing something that uses cron, a common pattern is:

      • Set something up
      • Trigger cron
      • Check that a result happened
      • Change a setting
      • Trigger cron
      • Check that a result happened

      The problem is, when Moodle runs tasks (e.g. legacy cron) there are limits to stop them happening too frequently. As a result, the second time Moodle does not run cron tasks e.g. the legacy cron task (it only runs once per minute).

      In the Behat run we are probably not really trying to simulate 'what happens if a user runs cron twice within 10 seconds' but 'over a period of time, cron runs twice, each time taking full effect'.

      I'm not sure what is the best solution for this - possibly 'And I trigger cron' should automatically reset the next runtime for everything in task_scheduled, before going to the page?

      I searched for 'behat cron' and didn't find this issue mentioned already, apologies if this is a duplicate.

            Unassigned Unassigned
            quen Sam Marshall
            Votes:
            8 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.