first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Behat step definitions for scheduled task administration.
*
* @package tool_task
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
/**
* Behat step definitions for scheduled task administration.
*
* @package tool_task
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_tool_task extends behat_base {
/**
* Set a fake fail delay for a scheduled task.
*
* @Given /^the scheduled task "(?P<task_name>[^"]+)" has a fail delay of "(?P<seconds_number>\d+)" seconds$/
* @param string $task Task classname
* @param int $seconds Fail delay time in seconds
*/
public function scheduled_task_has_fail_delay_seconds($task, $seconds) {
global $DB;
$id = $DB->get_field('task_scheduled', 'id', ['classname' => $task], IGNORE_MISSING);
if (!$id) {
throw new Exception('Unknown scheduled task: ' . $task);
}
$DB->set_field('task_scheduled', 'faildelay', $seconds, ['id' => $id]);
}
}
@@ -0,0 +1,32 @@
@tool @tool_task
Feature: Clear scheduled task fail delay
In order to stop failures from delaying a scheduled task run
As an admin
I need to be able to clear the fail delay on a task
Background:
Given the scheduled task "\core\task\send_new_user_passwords_task" has a fail delay of "60" seconds
And I log in as "admin"
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Scenario: Any fail delay is highlighted
Then I should see "60" in the "Send new user passwords" "table_row"
And I should see "Clear" in the "Send new user passwords" "table_row"
And I should see "60" in the "td.table-danger" "css_element"
Scenario: Clear fail delay
When I click on "Clear" "text" in the "Send new user passwords" "table_row"
And I should see "Are you sure you want to clear the fail delay"
And I press "Clear"
Then I should not see "60" in the "Send new user passwords" "table_row"
And I should not see "Clear" in the "Send new user passwords" "table_row"
And I should see "Send new user passwords" in the "tr.table-primary" "css_element"
Scenario: Cancel clearing the fail delay
When I click on "Clear" "text" in the "Send new user passwords" "table_row"
And I press "Cancel"
Then I should see "60" in the "Send new user passwords" "table_row"
And I should see "Clear" in the "Send new user passwords" "table_row"
And I should see "Send new user passwords" in the "tr.table-primary" "css_element"
@@ -0,0 +1,20 @@
@tool @tool_task
Feature: See warning message if cron is disabled
In order to manage scheduled tasks
As a Moodle Administrator
I need to be able to view a warning message if cron is disabled
Background:
Given I log in as "admin"
Scenario: If cron is disabled, I should see the message
When the following config values are set as admin:
| cron_enabled | 0 |
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Then I should see "Cron is disabled"
Scenario: If cron is enabled, I should not see the message
When the following config values are set as admin:
| cron_enabled | 1 |
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Then I should not see "Cron is disabled"
@@ -0,0 +1,73 @@
@tool @tool_task @javascript
Feature: Manage scheduled tasks
In order to configure scheduled tasks
As an admin
I need to be able to disable, enable, edit and reset to default scheduled tasks
Background:
Given I log in as "admin"
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Scenario: Disable scheduled task
When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row"
Then I should see "Edit task schedule: Log table cleanup"
And I set the following fields to these values:
| disabled | 1 |
And I press "Save changes"
Then I should see "Changes saved"
And I should see "Task disabled" in the "Log table cleanup" "table_row"
And I should see "Log table cleanup" in the "tr.table-primary" "css_element"
Scenario: Enable scheduled task
When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row"
Then I should see "Edit task schedule: Log table cleanup"
And I set the following fields to these values:
| disabled | 0 |
And I press "Save changes"
Then I should see "Changes saved"
And I should not see "Task disabled" in the "Log table cleanup" "table_row"
And I should see "Log table cleanup" in the "tr.table-primary" "css_element"
Scenario: Edit scheduled task
When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row"
Then I should see "Edit task schedule: Log table cleanup"
And I should see "\logstore_standard\task\cleanup_task"
And I should see "From component: Standard log"
And I should see "logstore_standard"
And I should see "Default: R" in the "Minute" "fieldset"
And I should see "Default: *" in the "Day" "fieldset"
And I set the following fields to these values:
| minute | frog |
And I press "Save changes"
And I should see "Data submitted is invalid"
And I set the following fields to these values:
| minute | */5 |
| hour | 1 |
| day | 2 |
| month | 3 |
| dayofweek | 4 |
And I press "Save changes"
And I should see "Changes saved"
And the following should exist in the "admintable" table:
| Component | Minute | Hour | Day | Day of week | Month |
| Standard log logstore_standard | */5 Default: R | 1 Default: 4 | 2 Default: * | 4 Default: * | 3 Default: * |
And I should see "Log table cleanup" in the "tr.table-primary" "css_element"
And I should see "*/5 Default: R" in the "td.table-warning" "css_element"
Scenario: Reset scheduled task to default
When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row"
Then I should see "Edit task schedule: Log table cleanup"
And I set the following fields to these values:
| resettodefaults | 1 |
And I press "Save changes"
Then I should see "Changes saved"
And the following should not exist in the "admintable" table:
| Name | Minute | Hour | Day | Day of week | Month |
| Log table cleanup | */5 | 1 | 2 | 4 | 3 |
And I should see "Log table cleanup" in the "tr.table-primary" "css_element"
Scenario: Disabled plugin's tasks are labelled as disabled too
When "CAS users sync job \auth_cas\task\sync_task" row "Next run" column of "Scheduled tasks" table should contain "Plugin disabled"
Then "CAS users sync job \auth_cas\task\sync_task" row "Component" column of "Scheduled tasks" table should contain "Disabled"
And "Background processing for scheduled allocation \workshopallocation_scheduled\task\cron_task" row "Next run" column of "Scheduled tasks" table should not contain "Plugin disabled"
And "Background processing for scheduled allocation \workshopallocation_scheduled\task\cron_task" row "Component" column of "Scheduled tasks" table should not contain "Disabled"
@@ -0,0 +1,40 @@
@tool @tool_task
Feature: See running scheduled tasks
In order to configure scheduled tasks
As an admin
I need to see if tasks are running
Background:
Given I log in as "admin"
Scenario: If no task is running, I should see the corresponding message
Given I navigate to "Server > Tasks > Tasks running now" in site administration
Then I should see "Nothing to display"
Scenario: If tasks are running, I should see task details
Given the following "tool_task > scheduled tasks" exist:
| classname | seconds | hostname | pid |
| \core\task\automated_backup_task | 121 | c69335460f7f | 1914 |
And the following "tool_task > adhoc tasks" exist:
| classname | seconds | hostname | pid |
| \core\task\asynchronous_backup_task | 7201 | c69335460f7f | 1915 |
| \core\task\asynchronous_restore_task | 172800 | c69335460f7f | 1916 |
And I navigate to "Server > Tasks > Tasks running now" in site administration
# Check the scheduled task details.
Then I should see "Scheduled" in the "\core\task\automated_backup_task" "table_row"
And I should see "2 mins" in the "Automated backups" "table_row"
And I should see "c69335460f7f" in the "Automated backups" "table_row"
And I should see "1914" in the "Automated backups" "table_row"
# Check the "asynchronous_backup_task" adhoc task details.
And I should see "Ad hoc" in the "\core\task\asynchronous_backup_task" "table_row"
And I should see "2 hours" in the "core\task\asynchronous_backup_task" "table_row"
And I should see "c69335460f7f" in the "core\task\asynchronous_backup_task" "table_row"
And I should see "1915" in the "core\task\asynchronous_backup_task" "table_row"
# Check the "asynchronous_restore_task" adhoc task details.
And I should see "Ad hoc" in the "\core\task\asynchronous_restore_task" "table_row"
And I should see "2 days" in the "core\task\asynchronous_restore_task" "table_row"
And I should see "c69335460f7f" in the "core\task\asynchronous_restore_task" "table_row"
And I should see "1916" in the "core\task\asynchronous_restore_task" "table_row"