-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
T&A: add metric to collect inconsistencies for #37759 (#7426)
- Loading branch information
1 parent
061438c
commit 8f2e851
Showing
2 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
Modules/Test/classes/Setup/class.ilTestDatabaseInconsistencyMetricsCollectedObjective.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
use ILIAS\Setup; | ||
use ILIAS\Setup\Metrics\Metric; | ||
use ILIAS\DI; | ||
|
||
class ilTestDatabaseInconsistencyMetricsCollectedObjective extends Setup\Metrics\CollectedObjective | ||
{ | ||
/** | ||
* @return array<\ilDatabaseInitializedObjective|\ilIniFilesLoadedObjective> | ||
*/ | ||
protected function getTentativePreconditions(Setup\Environment $environment): array | ||
{ | ||
return [ | ||
new \ilDatabaseInitializedObjective() | ||
]; | ||
} | ||
|
||
protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage): void | ||
{ | ||
$db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE); | ||
$metrics = [ | ||
"database_available" => new Metric( | ||
Metric::STABILITY_VOLATILE, | ||
Metric::TYPE_BOOL, | ||
!is_null($db), | ||
"This metric is a canary to check for the general existence of this collection." | ||
) | ||
]; | ||
|
||
if ($db) { | ||
$this->collectMantis37759($metrics, $db); | ||
} | ||
|
||
$storage->store("database_inconsistencies", new Metric( | ||
Metric::STABILITY_MIXED, | ||
Metric::TYPE_COLLECTION, | ||
$metrics, | ||
"These metrics collect information about inconsistencies in the database of the T&A." | ||
)); | ||
} | ||
|
||
protected function collectMantis37759(array &$metrics, \ilDBInterface $db) | ||
{ | ||
$result = $db->query(" | ||
SELECT COUNT(*) as cnt | ||
FROM tst_active | ||
LEFT JOIN object_data ON tst_active.test_fi = object_data.obj_id | ||
WHERE object_data.obj_id IS NULL | ||
"); | ||
|
||
$metrics["mantis_37759"] = new Metric( | ||
Metric::STABILITY_VOLATILE, | ||
Metric::TYPE_GAUGE, | ||
$db->fetchAssoc($result)["cnt"], | ||
"Measures active tests runs where the corresponding Test object does not exist anymore." | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters