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

Tasks: Max fail delay admin notification

XMLWordPrintable

    • MOODLE_404_STABLE
    • MDL-79131-main
    • Hide

      Test 3 and Test 4 - Covered by unittest

      Prerequisites

      Use "Mailpit" or any other mail server to check the notification emails.
       

      Initial setup 

      Login as admin.
      Set PHP cli path

      1. # Go to Site admin > Server > System path
      2. Set your PHP binary file path in "Path to PHP CLI"

      Use plugin moodle-tool_testtasks79131 for testing 

      It can be found attached to this issue, and it can be installed with the zip package from "site admin" / "Plugins" / "Install plugins"

      Test 1 - New hook and callback

      1. Navigate to Site Administration > Development > Hooks overview.
      2. Verify that you will see a Hook with the following information
        • Class: core\hook\task\after_failed_task_max_delay
        • Description: Allow plugins to get information when a task reaches its maximum failure delay.
        • Tag: task.
      3. Verify that you will see core\task\failed_task_callbacks::send_failed_task_max_delay_message (100) in the Callbacks column. 

      Testing 2 - New notification 

      1. Click on the Notification icon (Bell icon).
      2. Click on the Notification Preferences (Gear icon).
      3. Verify that you will see a new notification item called: Task reaches its maximum fail delay
      4. Verify that the default settings for Web and Email are turned on.

      Testing 3 - Scheduled task reach its max fail delay - Message

      1. As admin, access to Tasks / Scheduled tasks. 
      2. Search by "Fail scheduled task (\tool_testtasks79131\task\fail_scheduled_task)" and click on run now.
      3. Verify no notification or email has been send.
      4. Repeat step 3 until the column "Fail delay" is set to 86400.
      5. Verify the column "Next run" is tomorrow.
      6. Verify that you will see a new notification (Bell icon at the top).
      7. Click on "View full notification".
      8. Verify that the title of notification is:  "Task failed: Fail scheduled task"
      9. Verify that the content of the notification is: 

        Hi Admin,
         
        The task Fail scheduled task has failed multiple times and requires attention.
         
        See task 

      1. Switch to the Mailpit window.
      2. Verify that you will see a new email.
      3. Verify that the title is: 

        Task failed: Fail scheduled task

      1. Verify that the content of the email is: 

        Hi Admin,
         
        The task Fail scheduled task has failed multiple times and requires attention.
         
        See task 

      1. Click on the link "See task" and verify the that the link takes you to "System status / Tasks max fail delay" page. 

      Testing 4 - Adhoc task reach its max fail delay - Message

        # Queue up some failing test tasks: 

      php admin/tool/testtasks79131/cli/queue_adhoc_task.php
      

      # Access to the database and verify in the table "task_adhoc" that there is a task from the component "tool_testtasks79131" with the field "faildelay" set to "0"

      1. As admin go to "Site admin / Server / Tasks / Ad hoc tasks" and click on "Run now" in one of the failing tasks.
      2. Click on run again until in the table task_adhoc of the database you see  86400 in "faildelay" column
      3. Verify that you will see a new notification (Bell icon).
      4. Click on "View full notification".
      5. Verify that the title of notification is: 

        Task failed: Fail adhoc task

      1. Verify that the content of the notification is:  

        Hi Admin,
         
        The task Fail adhoc task has failed multiple times and requires attention.
         
        See task 

      1. Switch to the Mailpit window.
      2. Verify that you will see a new email.
      3. Verify that the title is: 

        Task failed: Fail adhoc task

      1. Verify that the content of the email is: 

        Hi Admin,
         
        The task Fail adhoc task has failed multiple times and requires attention.
         
        See task 

      1. Click on the link "See task" and verify the that the link takes you to "System status / Tasks max fail delay" page. 

       

      Show
      Test 3 and Test 4 - Covered by unittest Prerequisites Use "Mailpit" or any other mail server to check the notification emails.   Initial setup  Login as admin. Set PHP cli path # Go to Site admin > Server > System path Set your PHP binary file path in "Path to PHP CLI" Use plugin moodle-tool_testtasks79131 for testing   It can be found attached to this issue, and it can be installed with the zip package from "site admin" / "Plugins" / "Install plugins" Test 1 - New hook and callback Navigate to Site Administration > Development > Hooks overview. Verify  that you will see a Hook with the following information Class: core\hook\task\after_failed_task_max_delay Description: Allow plugins to get information when a task reaches its maximum failure delay. Tag: task. Verify that you will see core\task\failed_task_callbacks::send_failed_task_max_delay_message (100)  in the Callbacks column.  Testing 2 - New notification  Click on the Notification icon (Bell icon). Click on the Notification Preferences (Gear icon). Verify that you will see a new notification item called: Task reaches its maximum fail delay Verify  that the default settings for Web and Email are  turned on . Testing 3 - Scheduled task reach its max fail delay - Message As admin, access to Tasks / Scheduled tasks.  Search by "Fail scheduled task (\tool_testtasks79131\task\fail_scheduled_task)" and click on run now. Verify no notification or email has been send. Repeat step 3 until the column "Fail delay" is set to 86400. Verify the column "Next run" is tomorrow. Verify that you will see a new notification (Bell icon at the top). Click on "View full notification". Verify that the title of notification is:  "Task failed: Fail scheduled task" Verify that the content of the notification is:  Hi Admin,   The task Fail scheduled task has failed multiple times and requires attention.   See task Switch to the Mailpit window. Verify that you will see a new email. Verify that the title is:  Task failed: Fail scheduled task Verify that the content of the email is:  Hi Admin,   The task Fail scheduled task has failed multiple times and requires attention.   See task Click on the link "See task" and verify the that the link takes you to "System status / Tasks max fail delay" page.  Testing 4 - Adhoc task reach its max fail delay - Message   # Queue up some failing test tasks:  php admin/tool/testtasks79131/cli/queue_adhoc_task.php # Access to the database and verify in the table "task_adhoc" that there is a task from the component "tool_testtasks79131" with the field "faildelay" set to "0" As admin go to "Site admin / Server / Tasks / Ad hoc tasks" and click on "Run now" in one of the failing tasks. Click on run again until in the table task_adhoc of the database you see  86400 in "faildelay" column Verify that you will see a new notification (Bell icon). Click on "View full notification". Verify that the title of notification is:  Task failed: Fail adhoc task Verify that the content of the notification is:   Hi Admin,   The task Fail adhoc task has failed multiple times and requires attention.   See task Switch to the Mailpit window. Verify that you will see a new email. Verify that the title is:  Task failed: Fail adhoc task Verify that the content of the email is:  Hi Admin,   The task Fail adhoc task has failed multiple times and requires attention.   See task Click on the link "See task" and verify the that the link takes you to "System status / Tasks max fail delay" page.   
    • 6
    • Team Hedgehog 2023 Review 4, Team Hedgehog 2024 Sprint 1.1, Team Hedgehog 2024 Sprint 1.2, Team Hedgehog 2024 Sprint 1.3, Team Hedgehog 2024 Sprint 1.4

      If a task reaches its maximum fail delay (currently 86400 seconds), which means it has failed 9 consecutive times, something is wrong that is unlikely to resolve by itself. In this case we should be sending users notification of this via Moodle's notification system.

      This notification should be sent to the site admin, and default to both "web" and "email" modalities.

      This notification should apply to both scheduled tasks and ad-hoc tasks.

      We should make this "noisy" and trigger the notification every time the max fail delay is reached. This means sending a notification every 24 hours for a continuing failing task.

            raquel.ortega@moodle.com Raquel Ortega
            matt.porritt@moodle.com Matt Porritt
            Stevani Andolo Stevani Andolo
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week, 2 days, 1 hour, 37 minutes
                1w 2d 1h 37m

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