From 1eb71d7b441c0cd31568350f3610a73a26f1778e Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Tue, 21 Apr 2026 15:49:02 +0100 Subject: [PATCH 1/2] Add tests for HorizonPrometheusExporter and our Custom Exporters Add some simple tests. These instantiate the existing exporters and check that their collection method works. Another test instantiates the exporter repository with our application config to check it is valid Bug: T423429 --- .../ExporterRepositoryTest.php | 16 +++++++++++++++ tests/Metrics/FailedQsBatchesTest.php | 20 +++++++++++++++++++ tests/Metrics/PendingQsBatchesTest.php | 19 ++++++++++++++++++ tests/Metrics/WikiEntityImportsTest.php | 19 ++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 tests/HorizonPrometheusExporter/ExporterRepositoryTest.php create mode 100644 tests/Metrics/FailedQsBatchesTest.php create mode 100644 tests/Metrics/PendingQsBatchesTest.php create mode 100644 tests/Metrics/WikiEntityImportsTest.php diff --git a/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php b/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php new file mode 100644 index 00000000..c5e6e4d4 --- /dev/null +++ b/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php @@ -0,0 +1,16 @@ +assertInstanceOf(CollectorRegistry::class, $registry); + } +} diff --git a/tests/Metrics/FailedQsBatchesTest.php b/tests/Metrics/FailedQsBatchesTest.php new file mode 100644 index 00000000..6a43bb46 --- /dev/null +++ b/tests/Metrics/FailedQsBatchesTest.php @@ -0,0 +1,20 @@ +getGauge(config('horizon-exporter.namespace'), 'qs_batches_failed_batches'); + + self::assertNotNull($gauge); + + } +} diff --git a/tests/Metrics/PendingQsBatchesTest.php b/tests/Metrics/PendingQsBatchesTest.php new file mode 100644 index 00000000..0dcf1653 --- /dev/null +++ b/tests/Metrics/PendingQsBatchesTest.php @@ -0,0 +1,19 @@ +getGauge(config('horizon-exporter.namespace'), 'qs_batches_pending_batches'); + + self::assertNotNull($gauge); + } +} diff --git a/tests/Metrics/WikiEntityImportsTest.php b/tests/Metrics/WikiEntityImportsTest.php new file mode 100644 index 00000000..7d7ded73 --- /dev/null +++ b/tests/Metrics/WikiEntityImportsTest.php @@ -0,0 +1,19 @@ +getGauge(config('horizon-exporter.namespace'), 'wiki_entity_imports_pending'); + + self::assertNotNull($gauge); + } +} From e95f5080174560b39c39e6ebe61f3405e05fbf42 Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Fri, 24 Apr 2026 14:04:58 +0100 Subject: [PATCH 2/2] Update tests/HorizonPrometheusExporter/ExporterRepositoryTest.php Co-authored-by: Ollie <43674967+outdooracorn@users.noreply.github.com> --- tests/HorizonPrometheusExporter/ExporterRepositoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php b/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php index c5e6e4d4..a419fd01 100644 --- a/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php +++ b/tests/HorizonPrometheusExporter/ExporterRepositoryTest.php @@ -8,7 +8,7 @@ class ExporterRepositoryTest extends TestCase { public function testCanBeCreated() { - // if nothing is passed to load it reads the config + // if nothing is passed to load(), exporters are read from the config at config/horizon-exporter.php ExporterRepository::load(); $registry = ExporterRepository::getRegistry(); $this->assertInstanceOf(CollectorRegistry::class, $registry);