ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DatabaseInconsistencyMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Setup;
22
27
29{
33 protected function getTentativePreconditions(Environment $environment): array
34 {
35 return [
36 new \ilDatabaseInitializedObjective()
37 ];
38 }
39
40 protected function collectFrom(Environment $environment, Storage $storage): void
41 {
43 $metrics = [
44 'database_available' => new Metric(
47 !is_null($db),
48 'This metric is a canary to check for the general existence of this collection.'
49 )
50 ];
51
52 if ($db) {
53 $this->collectMantis37759($metrics, $db);
54 }
55
56 $storage->store('database_inconsistencies', new Metric(
59 $metrics,
60 'These metrics collect information about inconsistencies in the database of the T&A.'
61 ));
62 }
63
64 protected function collectMantis37759(array &$metrics, \ilDBInterface $db)
65 {
66 $result = $db->query('
67 SELECT COUNT(*) as cnt
68 FROM tst_active
69 LEFT JOIN object_data ON tst_active.test_fi = object_data.obj_id
70 WHERE object_data.obj_id IS NULL
71 ');
72
73 $metrics["mantis_37759"] = new Metric(
76 $db->fetchAssoc($result)['cnt'],
77 'Measures active tests runs where the corresponding Test object does not exist anymore.'
78 );
79 }
80}
Base class to simplify collection of metrics.
A metric is something we can measure about the system.
Definition: Metric.php:34
const TYPE_BOOL
The type of the metric tells what to expect of the values.
Definition: Metric.php:53
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
store(string $key, Metric $metric)
Store some metric in the storage.
Interface ilDBInterface.