mirror of
https://github.com/Cacti/cacti.git
synced 2026-12-01 04:36:05 +09:00
* fix: Make boost_redirect the default boost behavior
Port of the 1.2.x change (issue#8470) to develop. Boost redirection is now
permanent whenever boost is enabled, so the boost_redirect setting is removed
and the collector always stages poller output directly into
poller_output_boost.
- cmd.php: drop the boost_redirect guard; stage whenever boost_rrd_update_enable
is on.
- include/global_settings.php, settings.php: remove the boost_redirect setting
and its UI toggles.
- lib/snmpagent.php: always report the redirect object as enabled.
- poller.php, settings.php: stop force-setting boost_redirect for multi-poller
installs (boost_rrd_update_enable alone now implies redirection).
- lib/boost.php: boost_poller_on_demand() no longer stages inline; cmd.php owns
staging, so it only reports rows as already staged and never re-inserts.
Tests are updated to match the single, permanent-redirect pipeline: the
hand-off acknowledgement and consolidation contracts point at the surviving
cmd.php/poller_recovery.php call sites, and the PollerOutput probe drops the
now-dead redirect-off staging scenarios.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test(coverage): cover the permanent Boost redirect in snmpagent
Add a request-coverage probe that exercises the permanent
boostApplRrdUpdateRedirect assignment in snmpagent_global_settings_update().
The statement lives in a MibCache-driven function that cannot run under the
unit/integration coverage driver without a live SNMP agent cache, so the
single changed line is compiled at its original line number and executed
against a minimal MibCache stand-in, with Xdebug coverage remapped to
lib/snmpagent.php. Register the probe so the changed-PHP coverage gate runs
it whenever lib/snmpagent.php changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* i18n:
* tests: Cover the cmd.php Boost flush guards for the changed-line gate
Making boost_redirect the default removed the boost_redirect half of the three poller flush conditions in cmd.php, leaving bare read_config_option(boost_rrd_update_enable) guards at lines 392, 501, and 537. Those statements live in cmd.php top-level poller loop, so the unit/integration driver includes them in the denominator but never executes them, dropping changed-line coverage to 3 of 6 (50 percent).
Adds a request-coverage probe that compiles each changed guard at its original line number and executes it against minimal read_config_option/boost_flush_output_batch stand-ins, mirroring the existing snmpagent redirect probe. Xdebug hits are remapped to cmd.php, raising changed-line coverage to 6 of 6 (100 percent). Registers the probe in run_request_coverage.sh so it runs whenever cmd.php changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(boost): keep the boost_redirect compatibility flag enabled
Port the poller.php compatibility assignment from the 1.2.x change
(#8559, commit ba2ab827) that this develop port dropped. Supported
Spine versions still read the hidden boost_redirect flag to stage
poller output into poller_output_boost; without it a compatible
collector never stages, yet boost_poller_on_demand() still reports
the rows as staged and poller_acknowledge_output() deletes them,
losing samples. Set the flag unconditionally before launching
collectors so redirection stays permanent whenever Boost is enabled.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: TheWitness <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
87 lines
4.4 KiB
PHP
87 lines
4.4 KiB
PHP
<?php
|
|
// Copyright (C) 2026 The Cacti Group. Licensed under GPL-2.0-or-later.
|
|
require_once dirname(__DIR__, 3) . '/Helpers/IsolatedProbe.php';
|
|
|
|
function poller_output_probe(string $scenario) : array {
|
|
return cacti_test_isolated_probe(dirname(__DIR__, 3) . '/fixtures/PollerOutputProbe.php', [$scenario]);
|
|
}
|
|
|
|
test('completed timestamps do not delete incomplete timestamps for the same source', function () {
|
|
$r = poller_output_probe('partial');
|
|
expect($r['first'])->toBe(1)->and($r['remaining'])->toBe(1);
|
|
expect($r['rows'][0]['unix_time'])->toBe(1700000060);
|
|
});
|
|
test('samples arriving after the fetch are not acknowledged by the previous update', function () {
|
|
$r = poller_output_probe('arrival');
|
|
expect($r['first'])->toBe(1)->and($r['remaining'])->toBe(1);
|
|
});
|
|
test('failed RRDtool writes retain their queue rows', function () {
|
|
$r = poller_output_probe('failed');
|
|
expect($r['first'])->toBe(0)->and($r['remaining'])->toBe(1)->and($r['delete_calls'])->toBe(0);
|
|
});
|
|
test('one failing file stops before later timestamps while other files can succeed', function () {
|
|
$r = poller_output_probe('mixed');
|
|
expect($r['first'])->toBe(1)->and($r['remaining'])->toBe(2)->and($r['rrd_calls'])->toBe(2);
|
|
});
|
|
test('template mappings expand into individual RRD fields', function () {
|
|
$r = poller_output_probe('fanout');
|
|
expect($r['first'])->toBe(1)->and($r['remaining'])->toBe(0);
|
|
expect($r['commands'][0])->toContain('--template in:out')->toContain('1700000000:42:42');
|
|
});
|
|
test('mapping expansion applies orphan exclusions to each field', function () {
|
|
$r = poller_output_probe('fanout-orphan');
|
|
expect($r['first'])->toBe(1)->and($r['commands'][0])->toContain('--template in ')->not->toContain('in:out');
|
|
});
|
|
test('batch boundaries defer a whole timestamp group', function () {
|
|
$r = poller_output_probe('boundary');
|
|
expect($r['first'])->toBe(39999)->and($r['second'])->toBe(1)->and($r['remaining'])->toBe(0)->and($r['queries'])->toBe(2);
|
|
});
|
|
test('large incomplete backlogs return without recursion and advance past the first batch', function () {
|
|
$r = poller_output_probe('backlog');
|
|
expect($r['first'])->toBe(0)->and($r['second'])->toBe(0)->and($r['remaining'])->toBe(40001)->and($r['queries'])->toBe(2);
|
|
});
|
|
test('boost polling acknowledges collector-staged samples without re-inserting or inline RRD writes', function () {
|
|
$r = poller_output_probe('boost-redirect');
|
|
expect($r['remaining'])->toBe(0)->and($r['boost_calls'])->toBe(0)->and($r['rrd_calls'])->toBe(0);
|
|
});
|
|
test('failed acknowledgement leaves stored samples available for a safe retry', function () {
|
|
$r = poller_output_probe('delete-failure');
|
|
expect($r['first'])->toBe(1)->and($r['remaining'])->toBe(1);
|
|
});
|
|
test('failed template metadata reads retain samples and retry on the next pass', function () {
|
|
$r = poller_output_probe('metadata');
|
|
expect($r['first'])->toBe(0)->and($r['second'])->toBe(1)->and($r['mapping_queries'])->toBe(2)->and($r['remaining'])->toBe(0);
|
|
});
|
|
|
|
test('later timestamps cannot advance an RRD past an incomplete earlier timestamp', function () {
|
|
$r = poller_output_probe('early-partial');
|
|
expect($r['first'])->toBe(0)->and($r['remaining'])->toBe(3)->and($r['rrd_calls'])->toBe(0);
|
|
});
|
|
|
|
test('incomplete timestamps block later timestamps across batch boundaries', function () {
|
|
$r = poller_output_probe('boundary-partial');
|
|
expect($r['first'])->toBe(39999)->and($r['second'])->toBe(0)->and($r['remaining'])->toBe(3);
|
|
});
|
|
|
|
test('failed timestamps block later timestamps across batch boundaries', function () {
|
|
$r = poller_output_probe('boundary-failure');
|
|
expect($r['first'])->toBe(39999)->and($r['second'])->toBe(0)->and($r['remaining'])->toBe(2);
|
|
});
|
|
|
|
test('a failed delete never leaves only part of a stored timestamp group queued', function () {
|
|
$r = poller_output_probe('delete-group');
|
|
expect($r['first'])->toBe(1001)->and($r['remaining'])->toBe(1);
|
|
expect($r['rows'][0]['local_data_id'])->toBe(1001);
|
|
});
|
|
|
|
test('a failed sample succeeds on a later pass without being lost or duplicated', function () {
|
|
$r = poller_output_probe('retry-failed');
|
|
expect($r['first'])->toBe(0)->and($r['second'])->toBe(1)->and($r['remaining'])->toBe(0);
|
|
});
|
|
|
|
test('failed source-specific metadata reads retry without losing samples', function (string $scenario) {
|
|
$r = poller_output_probe($scenario);
|
|
expect($r['first'])->toBe(0)->and($r['second'])->toBe(1)->and($r['remaining'])->toBe(0)
|
|
->and($r['source_queries'])->toBe(2);
|
|
})->with(['manual-query-failure', 'orphan-query-failure']);
|