Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ All notable changes to this plugin are recorded here. The format follows [Keep a
- Graphs made from earlier templates are brought to the installed ones by the main poller, 200 per cycle, or all at once with `cli/smokeping.php upgrade-graphs`. Each keeps its title and upper limit (#81).
- The SmokePing targets page shows whether each target's device is in a Maint maintenance window, from Maint's `is_device_in_maintenance` hook (#31).
- The health page lists targets that alert in both SmokePing and Thold, where one problem may notify twice. The inventory now records each target's SmokePing `alerts`; schema 6 stores them (#32).
- Smoke graph templates with SmokePing 2.7's loss colors, which match 2.7.3's graphs (Ubuntu 22.04). The Loss Colors setting picks them; Automatic, the default, follows the SmokePing version the reader finds in `Smokeping.pm`, which schema 7 records. The main poller moves smoke graphs to the configured colors, 200 per cycle, and `upgrade-graphs` moves them all. The health page shows the colors in use and why (#34).
- Smoke graph templates with SmokePing 2.7's loss colors, which match 2.7.3's graphs (Ubuntu 22.04). The Loss Colors setting picks them; Automatic, the default, follows the SmokePing version the reader finds in `Smokeping.pm`, which schema 7 records. The main poller moves smoke graphs to the configured colors, 200 per cycle, and `upgrade-graphs` moves them all. The health page shows the colors in use and why, and how many graphs are still to move or failed to move (#34).

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The loss column reads `lost/pings` of the last round, and the median is in milli
| `visibility` | The files the inventory lists are visible through the mount | Warning, naming how many are missing |
| `templates` | The SmokePing templates are imported | Error with the cause; fix it and use **Retry Template Import** |
| `device_pollers` | Every device with summary data sources is polled by the reader's poller | Error naming the devices: their summary values and alerts have no data until they are polled by that poller |
| `loss_colors` | Which loss colors the Loss Colors setting selects: those of the SmokePing the reader found, or the ones it names. After a change the main poller moves existing graphs over the next cycles, 200 per cycle; `upgrade-graphs` moves them at once | Unknown when the reader found no SmokePing version and the setting is Automatic: the graphs use 2.8 and later colors. Warning when the setting differs from the version found. See [loss colors](provisioning.md#loss-colors) |
| `loss_colors` | Which loss colors the Loss Colors setting selects: those of the SmokePing the reader found, or the ones it names. After a change the main poller moves existing graphs over the next cycles, 200 per cycle; `upgrade-graphs` moves them at once. The row counts the graphs still on the other colors, and warns about those whose move failed | Unknown when the reader found no SmokePing version and the setting is Automatic: the graphs use 2.8 and later colors. Warning when the setting differs from the version found. See [loss colors](provisioning.md#loss-colors) |
| `dual_alerting` | No target has both a SmokePing `alerts` value and an enabled Thold threshold on its summary data source | Warning naming up to 10 targets: a problem that meets both alerts' conditions notifies twice. The check does not compare the conditions; a Thold `age` threshold, for example, can fire when no SmokePing loss alert does. Compare them before removing the target's SmokePing alert or disabling its threshold. OK when Thold is not installed |

## Typical situations
Expand Down
32 changes: 32 additions & 0 deletions lib/CactiObjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,38 @@
return array_values(array_map(fn (array $row) => Row::string($row, 'description'), $rows));
}

/**
* How many live or archived smoke graphs are still on the templates of
* the loss colors other than $selected, split into those the main poller
* has yet to move and those whose last template change failed
* (template_failed), for the health page.
*
* @return array{pending: int, failed: int}
*/
public function graphsOnOtherLossColors(LossColors $selected): array {

Check warning on line 125 in lib/CactiObjectRepository.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1b-MioAmihIewCV&open=AaHiT1b-MioAmihIewCV&pullRequest=107
$templateIds = [];

foreach (TemplateInstaller::PINGS as $pings) {
$id = $this->graphTemplateId(TemplateInstaller::graphTemplateName($pings, $selected->other()));

if ($id > 0) {
$templateIds[] = $id;
}
}

if ($templateIds === []) {
return ['pending' => 0, 'failed' => 0];
}

$row = db_fetch_row_prepared('SELECT SUM(o.template_failed = 0) AS pending, SUM(o.template_failed > 0) AS failed
FROM plugin_smokeping_object AS o
INNER JOIN graph_local AS gl ON gl.id = o.local_graph_id
WHERE gl.graph_template_id IN (' . implode(', ', array_fill(0, count($templateIds), '?')) . ')
AND o.state IN (?, ?)', array_merge($templateIds, [ObjectRepository::ACTIVE, ObjectRepository::ARCHIVED]), true, $this->connection);

Check warning on line 144 in lib/CactiObjectRepository.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 136 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1b-MioAmihIewCU&open=AaHiT1b-MioAmihIewCU&pullRequest=107

Check warning on line 144 in lib/CactiObjectRepository.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either split this list into multiple lines, aligned at column "6" or put all arguments on line "140".

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1b-MioAmihIewCW&open=AaHiT1b-MioAmihIewCW&pullRequest=107

Check warning on line 144 in lib/CactiObjectRepository.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move the closing parenthesis on the next line.

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1b-MioAmihIewCX&open=AaHiT1b-MioAmihIewCX&pullRequest=107

return ['pending' => (int) ($row['pending'] ?? 0), 'failed' => (int) ($row['failed'] ?? 0)];
}

/**
* Paths of the poller's targets that alert in SmokePing (an alerts value
* in its configuration) and have an enabled Thold threshold on one of
Expand Down
27 changes: 24 additions & 3 deletions lib/HealthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,34 @@
}

/**
* Which loss colors the Loss Colors setting selects, and why
* (LossColors). Graphs still on the other colors move later.
* Which loss colors the Loss Colors setting selects and why (LossColors),
* then how many smoke graphs still draw the other colors: those the main
* poller has yet to move, and those whose move failed, which wait for
* upgrade-graphs (SmokeProvisioner::restyleDue()).
*
* @param string $setting the Loss Colors setting
* @param string $version the SmokePing version the reader found, '' for none
* @param int $pending graphs on the other colors' templates, not failed
* @param int $failed graphs on the other colors' templates whose move failed
*/
public static function lossColors(string $setting, string $version): Finding {
public static function lossColors(string $setting, string $version, int $pending = 0, int $failed = 0): Finding {

Check warning on line 51 in lib/HealthCheck.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1bEMioAmihIewCR&open=AaHiT1bEMioAmihIewCR&pullRequest=107
$selected = self::lossColorsSelected($setting, $version);
$message = $selected->message;
$level = $selected->level;

if ($pending > 0) {
$message .= ' ' . __('%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle.', $pending, 'smokeping');

Check warning on line 57 in lib/HealthCheck.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 138 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1bEMioAmihIewCP&open=AaHiT1bEMioAmihIewCP&pullRequest=107
}

if ($failed > 0) {
$message .= ' ' . __('%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause.', $failed, 'smokeping');

Check warning on line 61 in lib/HealthCheck.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 160 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1bEMioAmihIewCQ&open=AaHiT1bEMioAmihIewCQ&pullRequest=107
$level = $level === HealthLevel::Ok || $level === HealthLevel::Unknown ? HealthLevel::Warning : $level;
}

return new Finding('loss_colors', $level, $message);
}

private static function lossColorsSelected(string $setting, string $version): Finding {

Check warning on line 68 in lib/HealthCheck.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1bEMioAmihIewCS&open=AaHiT1bEMioAmihIewCS&pullRequest=107
$colors = LossColors::resolve($setting, $version);
$detected = LossColors::ofVersion($version);
$shown = LossColors::displayVersion($version);
Expand Down
12 changes: 11 additions & 1 deletion lib/HealthPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
) {
}

/**
* The loss_colors row, with the smoke graphs still on the other colors.
*/
private function lossColors(string $smokepingVersion): Finding {

Check warning on line 36 in lib/HealthPage.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this open curly brace to the beginning of the next line.

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1bYMioAmihIewCT&open=AaHiT1bYMioAmihIewCT&pullRequest=107
$setting = (string) read_config_option(LossColors::SETTING);
$left = $this->cacti->graphsOnOtherLossColors(LossColors::resolve($setting, $smokepingVersion));

return HealthCheck::lossColors($setting, $smokepingVersion, $left['pending'], $left['failed']);
}

public function render(Settings $settings, string $rraPath, string $phpBinary, bool $readerHost): void {
$health = $this->health->forPoller($settings->pollerId);
$expected = [];
Expand All @@ -46,7 +56,7 @@
[HealthCheck::templates($this->templates->present(), $this->templates->failure())],
[HealthCheck::devicePollers($this->cacti->summaryDevicesOffPoller($settings->pollerId), $settings->pollerId)],
[HealthCheck::dualAlerting($this->cacti->dualAlerting($settings->pollerId))],
[HealthCheck::lossColors((string) read_config_option(LossColors::SETTING), $health->smokepingVersion)],
[$this->lossColors($health->smokepingVersion)],
$this->mount->check($settings->mountPath, $rraPath, $expected)
);

Expand Down
Binary file modified locales/LC_MESSAGES/de-DE.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-419.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-ES.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/fr-FR.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/ja-JP.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/zh-CN.mo
Binary file not shown.
10 changes: 10 additions & 0 deletions locales/po/cacti.pot
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ msgstr ""
msgid "SmokePing Targets of this Device"
msgstr ""

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr ""

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr ""

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/de-DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ msgstr "Dieses Zielsystem hat SmokePing-Ziele, aber der Reader, der deren Zusamm
msgid "SmokePing Targets of this Device"
msgstr "SmokePing-Ziele dieses Zielsystems"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d Smoke-Graphen zeichnen noch die anderen Farben; der Hauptpoller stellt bis zu 200 pro Zyklus um."

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "%d Smoke-Graphen konnten nicht umgestellt werden; führen Sie upgrade-graphs aus, um es erneut zu versuchen, und sehen Sie die Ursache im Cacti-Protokoll."

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/es-419.po
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ msgstr "Este dispositivo tiene destinos de SmokePing, pero el lector que complet
msgid "SmokePing Targets of this Device"
msgstr "Destinos de SmokePing de este dispositivo"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d gráficas de humo aún dibujan los otros colores; el sondeador principal cambia hasta 200 por ciclo."

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "No se pudieron cambiar %d gráficas de humo; ejecute upgrade-graphs para intentarlo de nuevo y consulte la causa en el registro de Cacti."

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/es-ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ msgstr "Este dispositivo tiene destinos de SmokePing, pero el lector que rellena
msgid "SmokePing Targets of this Device"
msgstr "Destinos de SmokePing de este dispositivo"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d gráficas de humo aún dibujan los otros colores; el sondeador principal cambia hasta 200 por ciclo."

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "No se pudieron cambiar %d gráficas de humo; ejecute upgrade-graphs para intentarlo de nuevo y consulte la causa en el registro de Cacti."

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/fr-FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ msgstr "Cet équipement possède des cibles SmokePing, mais le lecteur qui rense
msgid "SmokePing Targets of this Device"
msgstr "Cibles SmokePing de cet équipement"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d graphes de fumée dessinent encore les autres couleurs ; l'agent de collecte principal en change jusqu'à 200 par cycle."

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "%d graphes de fumée n'ont pas pu être changés ; lancez upgrade-graphs pour réessayer, et consultez la cause dans le journal de Cacti."

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/ja-JP.po
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ msgstr "このデバイスには SmokePing ターゲットがありますが、
msgid "SmokePing Targets of this Device"
msgstr "このデバイスの SmokePing ターゲット"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d 個のスモークグラフはまだ別の色で描画されています。メインポーラーは 1 サイクルあたり最大 200 個を切り替えます。"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "%d 個のスモークグラフを切り替えられませんでした。upgrade-graphs を実行して再試行し、原因は Cacti ログで確認してください。"

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
10 changes: 10 additions & 0 deletions locales/po/zh-CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ msgstr "此设备有 SmokePing 目标,但填充其汇总值的读取器运行
msgid "SmokePing Targets of this Device"
msgstr "此设备的 SmokePing 目标"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs still draw the other colors; the main poller moves up to 200 per cycle."
msgstr "%d 个烟雾图仍使用另一组颜色;主轮询器每个周期最多切换 200 个。"

#: lib/HealthCheck.php
#, php-format
msgid "%d smoke graphs could not be moved; run upgrade-graphs to try them again, and see the Cacti log for the cause."
msgstr "%d 个烟雾图无法切换;请运行 upgrade-graphs 重试,并在 Cacti 日志中查看原因。"

#: lib/HealthCheck.php
#, php-format
msgid "The Loss Colors setting asks for SmokePing %s loss colors, but the reader found SmokePing %s. Set it to Automatic unless the graphs should differ from SmokePing's."
Expand Down
54 changes: 54 additions & 0 deletions tests/Unit/LossColorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* more details.
*/

use Somethingwithproof\Smokeping\CactiObjectRepository;
use Somethingwithproof\Smokeping\HealthCheck;
use Somethingwithproof\Smokeping\HealthRepository;
use Somethingwithproof\Smokeping\InventoryStatus;
Expand Down Expand Up @@ -216,3 +217,56 @@
->and($query['params'])->toBe([110, 120, 'active', 'archived', 3]);
});
});

describe('restyle progress on the loss_colors row', function () {
beforeEach(function () {
$GLOBALS['__smokeping_db_queries'] = [];
$GLOBALS['__smokeping_db_row'] = [];
$GLOBALS['__smokeping_db_cell'] = 0;
});

it('names graphs still to move without changing the level', function () {
$row = HealthCheck::lossColors('2.7', '', 3, 0);

expect($row->level)->toBe(HealthLevel::Ok)
->and($row->message)->toContain('3 smoke graphs still draw the other colors')
->not->toContain('could not be moved');
});

it('warns about graphs whose move failed, even when no version was found', function () {
$failed = HealthCheck::lossColors('2.7', '', 0, 2);
$unknown = HealthCheck::lossColors(LossColors::AUTO, '', 1, 1);
$warned = HealthCheck::lossColors('2.7', '2.009000', 0, 1);

expect($failed->level)->toBe(HealthLevel::Warning)
->and($failed->message)->toContain('2 smoke graphs could not be moved')->toContain('upgrade-graphs')
->and($unknown->level)->toBe(HealthLevel::Warning)
->and($unknown->message)->toContain('1 smoke graphs still draw')->toContain('1 smoke graphs could not be moved')
->and($warned->level)->toBe(HealthLevel::Warning)
->and($warned->message)->toContain('2.9.0');
});

it('says nothing more once every graph has moved', function () {
expect(HealthCheck::lossColors('2.7', '', 0, 0)->message)->not->toContain('smoke graphs still')->not->toContain('could not be moved');

Check warning on line 250 in tests/Unit/LossColorsTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 136 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1akMioAmihIewCL&open=AaHiT1akMioAmihIewCL&pullRequest=107
});

it('counts graphs on the other colors\' templates, split by failure', function () {
// Templates 110, 120 and 130 exist for the other (2.8) colors.
$GLOBALS['__smokeping_db_cell'] = fn (string $sql, array $params) => str_contains($sql, 'FROM graph_templates WHERE name')

Check warning on line 255 in tests/Unit/LossColorsTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 124 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1akMioAmihIewCM&open=AaHiT1akMioAmihIewCM&pullRequest=107
? (preg_match('/^SmokePing Smoke \((\d+) pings\)$/', (string) $params[0], $m) === 1 ? 100 + (int) $m[1] : 0)
: 0;
$GLOBALS['__smokeping_db_row'] = ['pending' => '4', 'failed' => '1'];

expect((new CactiObjectRepository(false))->graphsOnOtherLossColors(LossColors::Legacy))->toBe(['pending' => 4, 'failed' => 1]);

Check warning on line 260 in tests/Unit/LossColorsTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 129 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1akMioAmihIewCN&open=AaHiT1akMioAmihIewCN&pullRequest=107

$query = end($GLOBALS['__smokeping_db_queries']);

expect($query['sql'])->toContain('gl.graph_template_id IN (?, ?, ?)')
->and($query['params'])->toBe([110, 120, 130, 'active', 'archived']);
});

it('counts nothing when the other templates are not imported', function () {
expect((new CactiObjectRepository(false))->graphsOnOtherLossColors(LossColors::Current))->toBe(['pending' => 0, 'failed' => 0])

Check warning on line 269 in tests/Unit/LossColorsTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 129 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1akMioAmihIewCO&open=AaHiT1akMioAmihIewCO&pullRequest=107
->and($GLOBALS['__smokeping_db_queries'])->toBe([]);
});
});
9 changes: 9 additions & 0 deletions tests/bin/lifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@
list($graph, $version) = explode(':', $argument);
db_execute_prepared('UPDATE plugin_smokeping_object SET template_version = ? WHERE local_graph_id = ?', array((int) $version, (int) $graph));

break;
case 'loss_colors_row':
// The health page's loss_colors row, from the same calls the page makes.
$setting = (string) read_config_option(\Somethingwithproof\Smokeping\LossColors::SETTING);
$version = (new \Somethingwithproof\Smokeping\HealthRepository(false))->forPoller(1)->smokepingVersion;
$left = (new \Somethingwithproof\Smokeping\CactiObjectRepository(false))->graphsOnOtherLossColors(\Somethingwithproof\Smokeping\LossColors::resolve($setting, $version));

Check warning on line 315 in tests/bin/lifecycle.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 174 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1WNMioAmihIewCJ&open=AaHiT1WNMioAmihIewCJ&pullRequest=107
$finding = \Somethingwithproof\Smokeping\HealthCheck::lossColors($setting, $version, $left['pending'], $left['failed']);

Check warning on line 316 in tests/bin/lifecycle.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 122 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_smokeping&issues=AaHiT1WNMioAmihIewCK&open=AaHiT1WNMioAmihIewCK&pullRequest=107
$result = $finding->level->value . ' ' . $finding->message;

break;
case 'query':
// Read-only inspection for the shell-driven checks.
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ function db_table_exists($table, $log = true, $db_conn = false) {

if (!function_exists('db_fetch_row_prepared')) {
function db_fetch_row_prepared($sql, $params = [], $log = true, $db_conn = false, $log_function = null) {
$GLOBALS['__smokeping_db_queries'][] = ['sql' => $sql, 'params' => $params];

return $GLOBALS['__smokeping_db_row'];
}
}
Expand Down
Loading
Loading