Files
cacti/tests/Unit/Core/Rrd/RrdGraphArrayReuseTest.php
32467ddcab perf: reuse graph option arrays and document validation results (#8361)
* perf: reuse bootstrapped graph option arrays and document validation

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test: record the installed RRDtool version in profiles

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: record final validation scope and profiling runtime limits

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: clarify the scope of changed-code coverage

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* ci: repair relocated PHPUnit configs and the deletion-only coverage gate

- Point the five relocated configs that still carried a contributor's local
  autoload path (#8376) at ../include/vendor/autoload.php.
- Pass --configuration=tests/phpunit.xml to the CSV window workflow and the
  README example now that phpunit.xml no longer lives in the repository root.
- Let the changed-lines gate pass deletion-only PHP changes. Without added
  lines the generated config has no source filter, PHPUnit writes no clover
  report, and the gate failed on the missing file instead of reporting zero
  executable changed lines.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: TheWitness <thewitness@cacti.net>

* ci: keep the missing request-report check for deletion-only changes

Only short-circuit the changed-lines gate when there are no added PHP lines
and PHPUnit wrote no clover report, so an empty request-coverage directory
is still rejected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: TheWitness <thewitness@cacti.net>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: TheWitness <thewitness@cacti.net>
Co-authored-by: TheWitness <thewitness@cacti.net>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-14 22:45:42 -04:00

51 lines
2.3 KiB
PHP

<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
| |
| This program 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 2 |
| of the License, or (at your option) any later version. |
| |
| This program 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. |
+-------------------------------------------------------------------------+
*/
require_once dirname(__DIR__, 3) . '/Helpers/CactiStubs.php';
require_once dirname(__DIR__, 4) . '/include/global.php';
require_once CACTI_PATH_LIBRARY . '/rrd.php';
test('successive graph options reuse bootstrapped arrays without rebuilding menus', function () {
global $menu, $image_types, $datechar, $settings, $settings_user;
require CACTI_PATH_INCLUDE . '/global_arrays.php';
require CACTI_PATH_INCLUDE . '/global_settings.php';
$original = $menu;
$original_types = $image_types;
$menu = ['fixture' => 'retain bootstrapped menu'];
$image_types = [1 => 'PNG', 3 => 'SVG'];
try {
$graph = [
'auto_scale' => '', 'upper_limit' => '', 'lower_limit' => '',
'auto_scale_log' => '', 'scale_log_units' => '', 'auto_scale_rigid' => '',
'unit_value' => '', 'unit_exponent_value' => '', 'height' => '100', 'width' => '200',
'image_format_id' => 1,
];
foreach ([1, 3, 1] as $format) {
$graph['image_format_id'] = $format;
$data = [];
$options = rrd_function_process_graph_options(1700000000, 1700003600, $graph, $data);
expect($options)->toContain('--imgformat=' . $image_types[$format])
->and($menu)->toBe(['fixture' => 'retain bootstrapped menu']);
}
} finally {
$menu = $original;
$image_types = $original_types;
}
});