diff --git a/docs/adr/0031-referential-integrity-is-declared-in-the-database.md b/docs/adr/0031-referential-integrity-is-declared-in-the-database.md index f3724faf4d..4fecccde74 100644 --- a/docs/adr/0031-referential-integrity-is-declared-in-the-database.md +++ b/docs/adr/0031-referential-integrity-is-declared-in-the-database.md @@ -15,9 +15,9 @@ windowskey 2, ldap 6, oidc 8, capone 2, subnetgroup 1 -- are declared in core's map and applied by a step in each plugin's own `schema()` in `FOGProject/fog-plugins`. -**126 of the map's 141 relationships are declared.** The other 15 are not +**127 of the map's 143 relationships are declared.** The other 16 are not pending work: they carry action `none`, which the map's docblock defines as a -decision rather than an omission. Nine are audit rows, which MUST NOT +decision rather than an omission. Ten are audit rows, which MUST NOT constrain the thing they record (ADR 0021, `schema.php` step 341); six are polymorphic columns whose target table is chosen by a sibling column, where no constraint is expressible at all. Nothing in the map is waiting on a diff --git a/docs/development/foreign-keys.md b/docs/development/foreign-keys.md index 633b130f10..7715be8354 100644 --- a/docs/development/foreign-keys.md +++ b/docs/development/foreign-keys.md @@ -603,7 +603,7 @@ half-converted column. ## Phase D — plugins, and the direction rule 18 plugin tables ship in `FOGProject/fog-plugins`. All 18 clone cleanly into -the survey and 29 of the map's 141 relationships live in them. +the survey and 29 of the map's 143 relationships live in them. ### Direction is the whole rule diff --git a/packages/web/commons/schema-constraints.php b/packages/web/commons/schema-constraints.php index 06dd31173d..dc8f7807c8 100644 --- a/packages/web/commons/schema-constraints.php +++ b/packages/web/commons/schema-constraints.php @@ -357,6 +357,11 @@ ['child' => 'hostSoftware', 'column' => 'hsHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], ['child' => 'hostUserSession', 'column' => 'husHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], ['child' => 'hostFactState', 'column' => 'hfsHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], + // Performance Test results (fos#55). A satellite of the host: CASCADE. + // The task id is audit, like taskLog.taskID: a result records something + // that happened and must not constrain the task row. + ['child' => 'hostPerfTests', 'column' => 'hptHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], + ['child' => 'hostPerfTests', 'column' => 'hptTaskID', 'parent' => 'tasks', 'pcolumn' => 'taskID', 'class' => 'audit', 'action' => 'none'], ['child' => 'hostDirectory', 'column' => 'hdHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], ['child' => 'hostPrinter', 'column' => 'hpHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], ['child' => 'hostSpooler', 'column' => 'hspHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14], diff --git a/packages/web/commons/schema-expected.php b/packages/web/commons/schema-expected.php index a63ab7752c..b41032c73a 100644 --- a/packages/web/commons/schema-expected.php +++ b/packages/web/commons/schema-expected.php @@ -472,6 +472,25 @@ 'hnObservedAt' => 'datetime DEFAULT NULL', ], ], + 'hostPerfTests' => [ + 'create' => 'CREATE TABLE IF NOT EXISTS `hostPerfTests` ( `hptID` int(11) NOT NULL AUTO_INCREMENT, `hptHostID` int(11) NOT NULL, `hptTaskID` int(11) NOT NULL DEFAULT 0, `hptDateTime` datetime DEFAULT NULL, `hptDisk` varchar(64) NOT NULL DEFAULT \'\', `hptDiskMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptNetMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptCpuMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptRatio` int(10) unsigned NOT NULL DEFAULT 0, `hptFormat` varchar(8) NOT NULL DEFAULT \'\', `hptSample` varchar(255) NOT NULL DEFAULT \'\', `hptBottleneck` varchar(16) NOT NULL DEFAULT \'\', `hptKernel` varchar(64) NOT NULL DEFAULT \'\', `hptInit` varchar(32) NOT NULL DEFAULT \'\', PRIMARY KEY (`hptID`), KEY `hptHostID` (`hptHostID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC', + 'columns' => [ + 'hptID' => 'int(11) NOT NULL', + 'hptHostID' => 'int(11) NOT NULL', + 'hptTaskID' => 'int(11) NOT NULL DEFAULT 0', + 'hptDateTime' => 'datetime DEFAULT NULL', + 'hptDisk' => 'varchar(64) NOT NULL DEFAULT \'\'', + 'hptDiskMBps' => 'int(10) unsigned NOT NULL DEFAULT 0', + 'hptNetMBps' => 'int(10) unsigned NOT NULL DEFAULT 0', + 'hptCpuMBps' => 'int(10) unsigned NOT NULL DEFAULT 0', + 'hptRatio' => 'int(10) unsigned NOT NULL DEFAULT 0', + 'hptFormat' => 'varchar(8) NOT NULL DEFAULT \'\'', + 'hptSample' => 'varchar(255) NOT NULL DEFAULT \'\'', + 'hptBottleneck' => 'varchar(16) NOT NULL DEFAULT \'\'', + 'hptKernel' => 'varchar(64) NOT NULL DEFAULT \'\'', + 'hptInit' => 'varchar(32) NOT NULL DEFAULT \'\'', + ], + ], 'hostPrinter' => [ 'create' => 'CREATE TABLE IF NOT EXISTS `hostPrinter` ( `hpID` int(11) NOT NULL AUTO_INCREMENT, `hpHostID` int(11) NOT NULL, `hpName` varchar(255) NOT NULL DEFAULT \'\', `hpURI` varchar(1024) NOT NULL DEFAULT \'\', `hpDriver` varchar(255) NOT NULL DEFAULT \'\', `hpDefault` tinyint(1) NOT NULL DEFAULT 0, `hpShared` tinyint(1) NOT NULL DEFAULT 0, `hpObservedAt` datetime DEFAULT NULL, PRIMARY KEY (`hpID`), UNIQUE KEY `hpHostName` (`hpHostID`,`hpName`), KEY `hpName` (`hpName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC', 'columns' => [ diff --git a/packages/web/commons/schema.php b/packages/web/commons/schema.php index 89a2063b92..144cb1d085 100644 --- a/packages/web/commons/schema.php +++ b/packages/web/commons/schema.php @@ -11998,3 +11998,51 @@ function () { . "JOIN `groupModuleAssoc` g ON g.`gmaGroupID` = gm.`gmGroupID` " . "WHERE gm.`gmHostID` = h.`hostID` AND g.`gmaModuleID` = m.`id`)", ]; + +// 444 +$this->schema[] = [ + // The Performance Test task type (fos#55). FOS boots with + // mode=perftest, times the disk, the network and decompression, and + // reports the result to service/perftest.php. The task changes + // nothing on the disk. + // + // ttID 27 is the next free id (26 is the Secure Boot test task). + // Deleted ids are not reused. ttIsAdvanced '1': a diagnostic, not a + // fleet operation, so it sits behind the Advanced toggle. It needs no + // image, so getTasking() treats it like the wipes. + "INSERT IGNORE INTO `taskTypes` " + . "(`ttID`,`ttName`,`ttDescription`,`ttIcon`,`ttKernel`," + . "`ttKernelArgs`,`ttType`,`ttIsAdvanced`,`ttIsAccess`) " + . "VALUES " + . "(27,'Performance Test','Times the disk, network and decompression " + . "speed of the client to find what limits imaging. It changes nothing " + . "on the disk.','gauge-high','','mode=perftest','fog','1','both')", + // One row per reported run, newest first on the host page. + // + // hptHostID is a satellite of the host: the rows go with the host + // (CASCADE in commons/schema-constraints.php, group 14, like + // hostUserSession). hptTaskID is an audit reference: a result records + // something that happened and must not constrain the task row, the + // same as taskLog.taskID. + // + // A rate of 0 means FOS did not measure it. hptRatio is the + // compression ratio times 100, so 250 is 2.50:1. + "CREATE TABLE IF NOT EXISTS `hostPerfTests` ( " + . "`hptID` int(11) NOT NULL AUTO_INCREMENT, " + . "`hptHostID` int(11) NOT NULL, " + . "`hptTaskID` int(11) NOT NULL DEFAULT 0, " + . "`hptDateTime` datetime DEFAULT NULL, " + . "`hptDisk` varchar(64) NOT NULL DEFAULT '', " + . "`hptDiskMBps` int(10) unsigned NOT NULL DEFAULT 0, " + . "`hptNetMBps` int(10) unsigned NOT NULL DEFAULT 0, " + . "`hptCpuMBps` int(10) unsigned NOT NULL DEFAULT 0, " + . "`hptRatio` int(10) unsigned NOT NULL DEFAULT 0, " + . "`hptFormat` varchar(8) NOT NULL DEFAULT '', " + . "`hptSample` varchar(255) NOT NULL DEFAULT '', " + . "`hptBottleneck` varchar(16) NOT NULL DEFAULT '', " + . "`hptKernel` varchar(64) NOT NULL DEFAULT '', " + . "`hptInit` varchar(32) NOT NULL DEFAULT '', " + . "PRIMARY KEY (`hptID`), " + . "KEY `hptHostID` (`hptHostID`) " + . ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC", +]; diff --git a/packages/web/management/js/fog/host/fog.host.edit.js b/packages/web/management/js/fog/host/fog.host.edit.js index cf319a6658..7fa6695900 100644 --- a/packages/web/management/js/fog/host/fog.host.edit.js +++ b/packages/web/management/js/fog/host/fog.host.edit.js @@ -1032,6 +1032,45 @@ } }); + // --------------------------------------------------------------- + // PERFORMANCE TAB (read only) + // + // One row per Performance Test run, newest first. The server formats the + // rates and the ratio (getPerfTests), so every column only escapes. The + // empty-state sentence is translated server side and handed over in a + // hidden element. + var hostPerfTestTable = $('#host-perftest-table').registerTable(null, { + columns: [ + $.escapedColumn('date'), + $.escapedColumn('disk'), + $.escapedColumn('diskMBps'), + $.escapedColumn('netMBps'), + $.escapedColumn('cpuMBps'), + $.escapedColumn('ratio'), + $.escapedColumn('format'), + $.escapedColumn('bottleneck'), + $.escapedColumn('kernel'), + $.escapedColumn('init') + ], + order: [ + [0, 'desc'] + ], + rowId: 'id', + processing: true, + serverSide: true, + select: false, + language: { + emptyTable: $('#host-perftest-empty').text() + }, + ajax: { + url: '../management/index.php?node=' + + Common.node + + '&sub=getPerfTests&id=' + + Common.id, + type: 'post' + } + }); + // FOG CLIENT AREA // --------------------------------------------------------------- // CLIENT SETTINGS TAB diff --git a/packages/web/management/languages/de_DE.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/de_DE.UTF-8/LC_MESSAGES/messages.po index 71dcb3b024..93188802fa 100644 --- a/packages/web/management/languages/de_DE.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/de_DE.UTF-8/LC_MESSAGES/messages.po @@ -2746,6 +2746,9 @@ msgstr "Debug" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Standard" @@ -2950,6 +2953,12 @@ msgstr "Ausgewählte löschen" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Anzeige" @@ -3908,6 +3917,9 @@ msgstr "Ausgewählte löschen" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG-Forum" @@ -4482,6 +4494,10 @@ msgstr "Host Aktualisierung erfolgreich!" msgid "Host OU Updated!" msgstr "Host aktualisiert!" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Host-Produkt-Schlüssel" + msgid "Host Primary Disk" msgstr "Primäre Festplatte Host" @@ -5820,6 +5836,10 @@ msgstr "Lizenz" msgid "Light" msgstr "Mitternacht" +#, fuzzy +msgid "Limited by" +msgstr "Erstellt von" + msgid "Line" msgstr "Zeile" @@ -6586,6 +6606,9 @@ msgstr "Netzwerkinformationen" msgid "Network Interface" msgstr "Netzwerk-Installer" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "Netzwerk-Drucker" @@ -6838,6 +6861,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "Keinen aktiven Task gefunden für Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "Keinen aktiven Task gefunden für Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "Keine gültigen Tasks gefunden" @@ -7540,6 +7567,10 @@ msgstr "Ausstehend..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "Versuche, anzupingen" + #, fuzzy msgid "Permission" msgstr "Version" @@ -8158,6 +8189,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Dauer" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12894,6 +12929,9 @@ msgstr "auf diesem Knoten nicht gefunden" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Nicht verfügbar" @@ -14005,10 +14043,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "Ausstehende MACs" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "Versuche, anzupingen" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "Bitte geben Sie einen Namen für einen Admin oder einen mobilen Lookup ein." diff --git a/packages/web/management/languages/en_US.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/en_US.UTF-8/LC_MESSAGES/messages.po index 5fb1e7a8ee..d1414e7800 100644 --- a/packages/web/management/languages/en_US.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/en_US.UTF-8/LC_MESSAGES/messages.po @@ -2748,6 +2748,9 @@ msgstr "Debug" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Default" @@ -2952,6 +2955,12 @@ msgstr "Delete Selected" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Display" @@ -3909,6 +3918,9 @@ msgstr "Delete Selected" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG Forums" @@ -4483,6 +4495,10 @@ msgstr "Install / Update Successful!" msgid "Host OU Updated!" msgstr "User updated" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Host Product Key" + msgid "Host Primary Disk" msgstr "Host Primary Disk" @@ -5819,6 +5835,10 @@ msgstr "License" msgid "Light" msgstr "Midnight" +#, fuzzy +msgid "Limited by" +msgstr "Created By" + msgid "Line" msgstr "Line" @@ -6597,6 +6617,9 @@ msgstr "Network Information" msgid "Network Interface" msgstr "Network Printer" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "Network Printer" @@ -6849,6 +6872,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "No Active Task found for Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "No Active Task found for Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "No valid class sent" @@ -7549,6 +7576,10 @@ msgstr "Pending..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "Attempting to ping" + #, fuzzy msgid "Permission" msgstr "Version" @@ -8167,6 +8198,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Duration" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12896,6 +12931,9 @@ msgstr "Image not found on node" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Not Available" @@ -13982,10 +14020,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "Pending macs" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "Attempting to ping" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "Please enter a name for this location." diff --git a/packages/web/management/languages/es_ES.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/es_ES.UTF-8/LC_MESSAGES/messages.po index 32fbfcf5b6..4acc905508 100644 --- a/packages/web/management/languages/es_ES.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/es_ES.UTF-8/LC_MESSAGES/messages.po @@ -2771,6 +2771,9 @@ msgstr "Opciones de arranque:" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + #, fuzzy msgid "Default" msgstr "Defecto" @@ -2980,6 +2983,12 @@ msgstr "Eliminar seleccionado" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + #, fuzzy msgid "Display" msgstr "Diariamente" @@ -3955,6 +3964,9 @@ msgstr "Eliminar seleccionado" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "Foros FOG" @@ -4541,6 +4553,10 @@ msgstr "actualización Valoración falló" msgid "Host OU Updated!" msgstr "el usuario actualiza" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Clave del producto Grupo" + #, fuzzy msgid "Host Primary Disk" msgstr "Disco de grupo primario" @@ -5913,6 +5929,10 @@ msgstr "Línea" msgid "Light" msgstr "Medianoche" +#, fuzzy +msgid "Limited by" +msgstr "Creado" + msgid "Line" msgstr "Línea" @@ -6696,6 +6716,9 @@ msgstr "Información de la red" msgid "Network Interface" msgstr "impresora de red" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "impresora de red" @@ -6952,6 +6975,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "No se encontró Clase FOGPage para este nodo" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "No se encontró Clase FOGPage para este nodo" + #, fuzzy msgid "No plugin tasks to run" msgstr "Ninguna clase válida enviado" @@ -7659,6 +7686,9 @@ msgstr "macs pendientes" msgid "People" msgstr "" +msgid "Performance" +msgstr "" + #, fuzzy msgid "Permission" msgstr "Versión" @@ -8284,6 +8314,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Configuración" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -13055,6 +13089,9 @@ msgstr "No se encontró Clase FOGPage para este nodo" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "No disponible" diff --git a/packages/web/management/languages/eu_ES.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/eu_ES.UTF-8/LC_MESSAGES/messages.po index a927ed0c78..6e5a42bf42 100644 --- a/packages/web/management/languages/eu_ES.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/eu_ES.UTF-8/LC_MESSAGES/messages.po @@ -2746,6 +2746,9 @@ msgstr "Debug" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Standard" @@ -2950,6 +2953,12 @@ msgstr "Ausgewählte löschen" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Anzeige" @@ -3908,6 +3917,9 @@ msgstr "Ausgewählte löschen" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG-Forum" @@ -4482,6 +4494,10 @@ msgstr "Host Aktualisierung erfolgreich!" msgid "Host OU Updated!" msgstr "Host aktualisiert!" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Host-Produkt-Schlüssel" + msgid "Host Primary Disk" msgstr "Primäre Festplatte Host" @@ -5821,6 +5837,10 @@ msgstr "Lizenz" msgid "Light" msgstr "Mitternacht" +#, fuzzy +msgid "Limited by" +msgstr "Erstellt von" + msgid "Line" msgstr "Zeile" @@ -6587,6 +6607,9 @@ msgstr "Netzwerkinformationen" msgid "Network Interface" msgstr "Netzwerk-Installer" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "Netzwerk-Drucker" @@ -6839,6 +6862,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "Keinen aktiven Task gefunden für Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "Keinen aktiven Task gefunden für Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "Keine gültigen Tasks gefunden" @@ -7541,6 +7568,10 @@ msgstr "Ausstehend..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "Versuche, anzupingen" + #, fuzzy msgid "Permission" msgstr "Version" @@ -8159,6 +8190,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Dauer" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12895,6 +12930,9 @@ msgstr "auf diesem Knoten nicht gefunden" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Nicht verfügbar" @@ -14006,10 +14044,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "Ausstehende MACs" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "Versuche, anzupingen" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "Bitte geben Sie einen Namen für einen Admin oder einen mobilen Lookup ein." diff --git a/packages/web/management/languages/fr_FR.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/fr_FR.UTF-8/LC_MESSAGES/messages.po index 47dbbb77e6..cf49efa1cf 100644 --- a/packages/web/management/languages/fr_FR.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/fr_FR.UTF-8/LC_MESSAGES/messages.po @@ -2748,6 +2748,9 @@ msgstr "Déboguer" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Défaut" @@ -2952,6 +2955,12 @@ msgstr "Supprimer sélectionnée" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Afficher" @@ -3909,6 +3918,9 @@ msgstr "Supprimer sélectionnée" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "BROUILLARD Forums" @@ -4483,6 +4495,10 @@ msgstr "Installation / Mise à jour réussie!" msgid "Host OU Updated!" msgstr "mis à jour l'utilisateur" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Hôte clé de produit" + msgid "Host Primary Disk" msgstr "Hôte disque primaire" @@ -5819,6 +5835,10 @@ msgstr "Licence" msgid "Light" msgstr "Minuit" +#, fuzzy +msgid "Limited by" +msgstr "Créé par" + msgid "Line" msgstr "Ligne" @@ -6582,6 +6602,9 @@ msgstr "Réseau d'information" msgid "Network Interface" msgstr "Imprimante réseau" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "Imprimante réseau" @@ -6834,6 +6857,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "Aucune tâche active trouvée pour Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "Aucune tâche active trouvée pour Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "Aucune classe valide envoyé" @@ -7534,6 +7561,10 @@ msgstr "En attendant..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "Tenter de faire un ping" + #, fuzzy msgid "Permission" msgstr "Version" @@ -8152,6 +8183,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Durée" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12881,6 +12916,9 @@ msgstr "Image not found sur le noeud" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Indisponible" @@ -13971,10 +14009,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "macs en attente" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "Tenter de faire un ping" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "S'il vous plaît entrer un nom pour cet emplacement." diff --git a/packages/web/management/languages/it_IT.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/it_IT.UTF-8/LC_MESSAGES/messages.po index 6b03f678e3..c891ea23d9 100644 --- a/packages/web/management/languages/it_IT.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/it_IT.UTF-8/LC_MESSAGES/messages.po @@ -2690,6 +2690,9 @@ msgstr "mettere a punto" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Predefinito" @@ -2888,6 +2891,12 @@ msgstr "Cancella selezionato" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Display" @@ -3830,6 +3839,9 @@ msgstr "Cancella selezionato" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG Forum" @@ -4388,6 +4400,10 @@ msgstr "Aggiornamento host completato!" msgid "Host OU Updated!" msgstr "Host aggiornato!" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Tasti del prodotto host" + msgid "Host Primary Disk" msgstr "Host disco principale" @@ -5671,6 +5687,10 @@ msgstr "Licenza" msgid "Light" msgstr "Mezzanotte" +#, fuzzy +msgid "Limited by" +msgstr "Creato da" + msgid "Line" msgstr "linea" @@ -6416,6 +6436,9 @@ msgstr "Informationi di rete" msgid "Network Interface" msgstr "Installazione via rete" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "stampante di rete" @@ -6661,6 +6684,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "Nessun compito attivo trovato per Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "Nessun compito attivo trovato per Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "Non sono stati trovati compiti validi" @@ -7346,6 +7373,10 @@ msgstr "In attesa di..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "Il tentativo di ping" + #, fuzzy msgid "Permission" msgstr "Versione" @@ -7951,6 +7982,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Durata" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12542,6 +12577,9 @@ msgstr "Non trovato su questo nodo" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Non disponibile" @@ -13623,10 +13661,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "Mac in attesa" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "Il tentativo di ping" - #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "Inserisci un nome di amministratore o di ricerca per cellulari" diff --git a/packages/web/management/languages/ja_JP.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/ja_JP.UTF-8/LC_MESSAGES/messages.po index fad050822b..201edd812b 100644 --- a/packages/web/management/languages/ja_JP.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/ja_JP.UTF-8/LC_MESSAGES/messages.po @@ -2386,6 +2386,9 @@ msgstr "デバッグタスク" msgid "Decided." msgstr "判定済み。" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "既定" @@ -2556,6 +2559,12 @@ msgstr "選択した項目を無効化" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "無効な項目は表示されません。従来の項目は削除されます。" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "表示" @@ -3380,6 +3389,10 @@ msgstr "選択した項目の登録情報を削除" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "登録情報を削除しました。ただし、プラグインが作成したデータベーステーブルは残っています。削除すべきテーブルの情報は、既にアンインストールされたコードに記述されているためです。" +#, fuzzy +msgid "Format" +msgstr "フォーム" + msgid "Forums" msgstr "フォーラム" @@ -3863,6 +3876,10 @@ msgstr "ホストの OU を更新しました" msgid "Host OU Updated!" msgstr "ホストの OU を更新しました!" +#, fuzzy +msgid "Host Performance Tests" +msgstr "ホストプロダクトキー" + msgid "Host Primary Disk" msgstr "ホストプライマリディスク" @@ -4990,6 +5007,10 @@ msgstr "ライセンス" msgid "Light" msgstr "ライト" +#, fuzzy +msgid "Limited by" +msgstr "無制限" + msgid "Line" msgstr "行" @@ -5643,6 +5664,9 @@ msgstr "ネットワーク情報" msgid "Network Interface" msgstr "ネットワークインターフェイス" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "ネットワークプリンター" @@ -5866,6 +5890,10 @@ msgstr "パスワードは不要です。アカウント作成後、そのアカ msgid "No payloads for the capability, or not a live row of this host." msgstr "この機能に対応するペイロードがないか、対象ホストの有効なレコードではありません。" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "このホストに実行中のタスクが見つかりません" + msgid "No plugin tasks to run" msgstr "実行するプラグインタスクがありません" @@ -6485,6 +6513,10 @@ msgstr "保留中..." msgid "People" msgstr "利用者" +#, fuzzy +msgid "Performance" +msgstr "検索を実行" + msgid "Permission" msgstr "権限" @@ -7004,6 +7036,10 @@ msgstr "REST API リファレンス" msgid "RX" msgstr "受信(RX)" +#, fuzzy +msgid "Ratio" +msgstr "所要時間" + msgid "Re-Transmit Hello Interval" msgstr "Hello 再送信間隔" @@ -11135,6 +11171,9 @@ msgstr "このノード上に見つかりません" msgid "not joined" msgstr "未参加" +msgid "not measured" +msgstr "" + msgid "not reachable" msgstr "到達できません" @@ -12201,9 +12240,6 @@ msgstr "{node}" #~ msgid "Force task to start" #~ msgstr "タスクを強制開始" -#~ msgid "Form" -#~ msgstr "フォーム" - #~ msgid "Found login information" #~ msgstr "ログイン情報が見つかりました" @@ -13037,9 +13073,6 @@ msgstr "{node}" #~ msgid "Perform Immediately?" #~ msgstr "すぐに実行しますか?" -#~ msgid "Perform search" -#~ msgstr "検索を実行" - #~ msgid "Performing ping" #~ msgstr "Ping を実行しています" diff --git a/packages/web/management/languages/messages.pot b/packages/web/management/languages/messages.pot index 685dcc69d8..24a4535229 100644 --- a/packages/web/management/languages/messages.pot +++ b/packages/web/management/languages/messages.pot @@ -2376,6 +2376,9 @@ msgstr "" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "" @@ -2546,6 +2549,12 @@ msgstr "" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "" @@ -3370,6 +3379,9 @@ msgstr "" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + msgid "Forums" msgstr "" @@ -3853,6 +3865,9 @@ msgstr "" msgid "Host OU Updated!" msgstr "" +msgid "Host Performance Tests" +msgstr "" + msgid "Host Primary Disk" msgstr "" @@ -4980,6 +4995,9 @@ msgstr "" msgid "Light" msgstr "" +msgid "Limited by" +msgstr "" + msgid "Line" msgstr "" @@ -5631,6 +5649,9 @@ msgstr "" msgid "Network Interface" msgstr "" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "" @@ -5853,6 +5874,9 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "" +msgid "No performance tests have run for this host." +msgstr "" + msgid "No plugin tasks to run" msgstr "" @@ -6467,6 +6491,9 @@ msgstr "" msgid "People" msgstr "" +msgid "Performance" +msgstr "" + msgid "Permission" msgstr "" @@ -6986,6 +7013,9 @@ msgstr "" msgid "RX" msgstr "" +msgid "Ratio" +msgstr "" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -11117,6 +11147,9 @@ msgstr "" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + msgid "not reachable" msgstr "" diff --git a/packages/web/management/languages/pt_BR.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/pt_BR.UTF-8/LC_MESSAGES/messages.po index decc3665fd..bad00b4766 100644 --- a/packages/web/management/languages/pt_BR.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/pt_BR.UTF-8/LC_MESSAGES/messages.po @@ -2748,6 +2748,9 @@ msgstr "Depurar" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "Padrão" @@ -2952,6 +2955,12 @@ msgstr "Delete Selected" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "Exibição" @@ -3909,6 +3918,9 @@ msgstr "Delete Selected" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG Fóruns" @@ -4483,6 +4495,10 @@ msgstr "Instalar / Atualizar sucesso!" msgid "Host OU Updated!" msgstr "usuário atualizada" +#, fuzzy +msgid "Host Performance Tests" +msgstr "Hospedar de Chave de Produto" + msgid "Host Primary Disk" msgstr "Hospedar rígido primário" @@ -5819,6 +5835,10 @@ msgstr "Licença" msgid "Light" msgstr "meia-noite" +#, fuzzy +msgid "Limited by" +msgstr "Criado por" + msgid "Line" msgstr "Linha" @@ -6584,6 +6604,9 @@ msgstr "Informações de rede" msgid "Network Interface" msgstr "impressora de rede" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "impressora de rede" @@ -6836,6 +6859,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "Nenhuma tarefa ativa encontrada para o Host" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "Nenhuma tarefa ativa encontrada para o Host" + #, fuzzy msgid "No plugin tasks to run" msgstr "Nenhuma classe válida enviada" @@ -7536,6 +7563,10 @@ msgstr "Pendente..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "A tentativa de executar ping" + #, fuzzy msgid "Permission" msgstr "Versão" @@ -8154,6 +8185,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "Duração" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12884,6 +12919,9 @@ msgstr "Imagem não encontrada no nó" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "Não disponível" @@ -13974,10 +14012,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "macs pendentes" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "A tentativa de executar ping" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "Por favor, indique um nome para este local." diff --git a/packages/web/management/languages/zh_CN.UTF-8/LC_MESSAGES/messages.po b/packages/web/management/languages/zh_CN.UTF-8/LC_MESSAGES/messages.po index 10edea971a..ea317ea7f8 100644 --- a/packages/web/management/languages/zh_CN.UTF-8/LC_MESSAGES/messages.po +++ b/packages/web/management/languages/zh_CN.UTF-8/LC_MESSAGES/messages.po @@ -2748,6 +2748,9 @@ msgstr "调试" msgid "Decided." msgstr "" +msgid "Decompress MB/s" +msgstr "" + msgid "Default" msgstr "默认" @@ -2952,6 +2955,12 @@ msgstr "删除所选" msgid "Disabled items are not displayed. Legacy items are removed." msgstr "" +msgid "Disk" +msgstr "" + +msgid "Disk MB/s" +msgstr "" + msgid "Display" msgstr "显示" @@ -3909,6 +3918,9 @@ msgstr "删除所选" msgid "Forgotten. Any database tables the plugin created are still there -- what to drop is described by code that is no longer installed." msgstr "" +msgid "Format" +msgstr "" + #, fuzzy msgid "Forums" msgstr "FOG论坛" @@ -4483,6 +4495,10 @@ msgstr "安装/升级成功!" msgid "Host OU Updated!" msgstr "用户更新" +#, fuzzy +msgid "Host Performance Tests" +msgstr "主机产品密钥" + msgid "Host Primary Disk" msgstr "主机主磁盘" @@ -5819,6 +5835,10 @@ msgstr "执照" msgid "Light" msgstr "午夜" +#, fuzzy +msgid "Limited by" +msgstr "由...制作" + msgid "Line" msgstr "线" @@ -6584,6 +6604,9 @@ msgstr "网络信息" msgid "Network Interface" msgstr "网络打印机" +msgid "Network MB/s" +msgstr "" + msgid "Network Printer" msgstr "网络打印机" @@ -6836,6 +6859,10 @@ msgstr "" msgid "No payloads for the capability, or not a live row of this host." msgstr "发现主机没有活动任务" +#, fuzzy +msgid "No performance tests have run for this host." +msgstr "发现主机没有活动任务" + #, fuzzy msgid "No plugin tasks to run" msgstr "发送无有效类" @@ -7536,6 +7563,10 @@ msgstr "待..." msgid "People" msgstr "" +#, fuzzy +msgid "Performance" +msgstr "尝试ping" + #, fuzzy msgid "Permission" msgstr "版" @@ -8154,6 +8185,10 @@ msgstr "" msgid "RX" msgstr "RX" +#, fuzzy +msgid "Ratio" +msgstr "为期" + msgid "Re-Transmit Hello Interval" msgstr "" @@ -12884,6 +12919,9 @@ msgstr "图片没有节点发现" msgid "not joined" msgstr "" +msgid "not measured" +msgstr "" + #, fuzzy msgid "not reachable" msgstr "不可用" @@ -13974,10 +14012,6 @@ msgstr "" #~ msgid "Pending Mac List" #~ msgstr "待淅淅沥沥" -#, fuzzy -#~ msgid "Performing ping" -#~ msgstr "尝试ping" - #, fuzzy #~ msgid "Please Enter an admin or mobile lookup name" #~ msgstr "这个位置输入名称。" diff --git a/packages/web/service/perftest.php b/packages/web/service/perftest.php new file mode 100644 index 0000000000..8218a38f6c --- /dev/null +++ b/packages/web/service/perftest.php @@ -0,0 +1,92 @@ + + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ + +use FOG\Base\FOGBase; +use FOG\Base\FOGCore; +use FOG\Items\HostPerfTest; + +/** + * FOS reports what a Performance Test measured. + * + * FOS boots with mode=perftest, times the disk, the network and + * decompression, and posts the result here before it completes the task. + * Each run adds one row to hostPerfTests. The host page shows them. + * + * ADVISORY, like every other machine entry point. Nothing reads a row as a + * security control. It is still narrowed: the host must have a Performance + * Test task in flight, and every field is checked. The rules are in + * HostPerfTest::refusal(), so a test can drive them without a database. + * + * FOS treats a body of exactly `##` as success. Any other body is shown on + * the client screen as the reason for the failure. So a refusal answers 200 + * with the reason as plain text. A non-2xx is invisible to the caller and + * reads as a transport failure. + * + * @category Performance_Test_Report + * @package FOGProject + * @author Tom Elliott + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ +/* + * A machine entry point: the caller is FOS, which cannot present a + * credential. Declared per file -- see Authorization::_hasNoPrincipal(). + */ +define('FOG_MACHINE_REQUEST', true); + +require '../commons/base.inc.php'; + +header('Content-type: text/plain'); + +/** + * Say what happened and stop. + * + * @param string $msg the body to send + * + * @return void + */ +$done = function ($msg) { + echo $msg . "\n"; + exit; +}; + +$in = []; +foreach ( + [ + 'mac', 'disk', 'diskmbps', 'netmbps', 'cpumbps', 'ratio', 'format', + 'sample', 'bottleneck', 'kernel', 'initversion' + ] as $key +) { + $in[$key] = (string)filter_input(INPUT_POST, $key); +} + +FOGCore::getHostItem(false, false, true, false, false, $in['mac']); +$Host = FOGBase::$Host; + +$row = []; +$reason = HostPerfTest::refusal($Host, $in, $row); +if ('' !== $reason) { + $done($reason); +} + +$row['dateTime'] = FOGBase::niceDate()->format('Y-m-d H:i:s'); +$Result = new HostPerfTest(); +foreach ($row as $field => $value) { + $Result->set($field, $value); +} +if (!$Result->save()) { + $done('The result could not be stored'); +} + +// FOS looks for exactly this and nothing else. +echo '##'; diff --git a/packages/web/src/Base/System.php b/packages/web/src/Base/System.php index 64fd2f42f8..8a6124a4b3 100644 --- a/packages/web/src/Base/System.php +++ b/packages/web/src/Base/System.php @@ -130,7 +130,7 @@ public function __construct() // 1.5.x carried count does, see SchemaReconciler's docstring -- is // permanently "up to date" from the updater's point of view and will // never run another indexed step, whatever this constant says. - define('FOG_SCHEMA', 443); + define('FOG_SCHEMA', 444); define('FOG_BCACHE_VER', 370); define('FOG_CLIENT_VERSION', '0.13.0'); // GH-959: iPXE lives in FOGProject/fog-ipxe and its binaries arrive as diff --git a/packages/web/src/Items/HostPerfTest.php b/packages/web/src/Items/HostPerfTest.php new file mode 100644 index 0000000000..2d1c8acbac --- /dev/null +++ b/packages/web/src/Items/HostPerfTest.php @@ -0,0 +1,251 @@ + + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ + +namespace FOG\Items; + +use FOG\Base\FOGController; + +/** + * One reported Performance Test run on a host (fos#55). + * + * FOS boots with mode=perftest, times the disk, the network and + * decompression, and POSTs the result to service/perftest.php. That + * endpoint has no credential, so this class holds the rules that decide + * what it accepts. They are static and take plain values, so a test can + * drive the real code without a database. + * + * @category PerfTest + * @package FOGProject + * @author Tom Elliott + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ +class HostPerfTest extends FOGController +{ + /** + * The largest rate FOS may report, in MB/s. + */ + const MAX_RATE = 1000000; + /** + * The largest compression ratio FOS may report (ratio times 100). + */ + const MAX_RATIO = 100000; + /** + * The largest decoded sample path, in bytes. + */ + const MAX_SAMPLE = 255; + /** + * The compression formats FOS may report. + */ + const FORMATS = ['zstd', 'gzip', 'unknown', '']; + /** + * The limiting resources FOS may report. + */ + const BOTTLENECKS = ['disk', 'network', 'cpu', '']; + /** + * The hostPerfTests table. + * + * @var string + */ + protected $databaseTable = 'hostPerfTests'; + /** + * The hostPerfTests fields and common names. + * + * @var array + */ + protected $databaseFields = [ + 'id' => 'hptID', + 'hostID' => 'hptHostID', + 'taskID' => 'hptTaskID', + 'dateTime' => 'hptDateTime', + 'disk' => 'hptDisk', + 'diskMBps' => 'hptDiskMBps', + 'netMBps' => 'hptNetMBps', + 'cpuMBps' => 'hptCpuMBps', + 'ratio' => 'hptRatio', + 'format' => 'hptFormat', + 'sample' => 'hptSample', + 'bottleneck' => 'hptBottleneck', + 'kernel' => 'hptKernel', + 'init' => 'hptInit' + ]; + /** + * The required fields. + * + * @var array + */ + protected $databaseFieldsRequired = [ + 'hostID', + 'taskID' + ]; + /** + * Whether a posted value is a plain run of digits within a cap. + * + * Digits only: no sign, no decimal point, no space. A value that FOS + * could not have produced is refused rather than cleaned up. + * + * @param mixed $value the posted value + * @param int $max the largest value accepted + * + * @return bool + */ + public static function isCappedInt($value, $max) + { + if (!is_string($value) || !preg_match('/^[0-9]{1,9}$/', $value)) { + return false; + } + return (int)$value <= $max; + } + /** + * Check a posted report and build the row to store. + * + * Returns the name of the first field that is not acceptable, or an + * empty string with the row in $row. Nothing is stored here. + * + * @param array $in the posted fields, as strings + * @param array $row the cleaned values, keyed by common name + * + * @return string the name of the bad field, or '' when all are good + */ + public static function validate(array $in, array &$row = []) + { + $row = []; + $get = function ($key) use ($in) { + return isset($in[$key]) ? $in[$key] : ''; + }; + foreach (['diskmbps', 'netmbps', 'cpumbps'] as $key) { + if (!self::isCappedInt($get($key), self::MAX_RATE)) { + return $key; + } + } + if (!self::isCappedInt($get('ratio'), self::MAX_RATIO)) { + return 'ratio'; + } + if (!in_array($get('format'), self::FORMATS, true)) { + return 'format'; + } + if (!in_array($get('bottleneck'), self::BOTTLENECKS, true)) { + return 'bottleneck'; + } + $disk = $get('disk'); + if ('' !== $disk + && !preg_match('#^/dev/[A-Za-z0-9/_.-]{1,58}$#D', $disk) + ) { + return 'disk'; + } + $kernel = $get('kernel'); + if (!preg_match('/^[A-Za-z0-9._+-]{0,64}$/D', $kernel)) { + return 'kernel'; + } + $init = $get('initversion'); + if (!preg_match('/^[A-Za-z0-9._+-]{0,32}$/D', $init)) { + return 'initversion'; + } + // The sample path arrives base64 encoded, so a file name with odd + // bytes cannot break the form. Strict decoding refuses stray + // characters, and the re-encode check refuses missing padding, which + // PHP's strict mode allows. The result must be printable UTF-8 with + // no control character, and short enough for the column. + $sample = ''; + if ('' !== $get('sample')) { + $sample = base64_decode($get('sample'), true); + if (false === $sample + || base64_encode($sample) !== $get('sample') + || strlen($sample) > self::MAX_SAMPLE + || !preg_match('/^[^\x00-\x1F\x7F]*$/Du', $sample) + ) { + return 'sample'; + } + } + $row = [ + 'disk' => $disk, + 'diskMBps' => (int)$get('diskmbps'), + 'netMBps' => (int)$get('netmbps'), + 'cpuMBps' => (int)$get('cpumbps'), + 'ratio' => (int)$get('ratio'), + 'format' => $get('format'), + 'sample' => $sample, + 'bottleneck' => $get('bottleneck'), + 'kernel' => $kernel, + 'init' => $init + ]; + return ''; + } + /** + * Decide whether a report is accepted, and build the row to store. + * + * The endpoint has no credential. The host must have a Performance + * Test task in flight, which is true when FOS calls it because the task + * is what booted FOS. Without that rule any caller that knows a MAC + * could add rows to a host that was never tested. + * + * @param object|null $Host the host found for the posted MAC + * @param array $in the posted fields, as strings + * @param array $row the row to store, keyed by common name + * + * @return string the reason for a refusal, or '' when accepted + */ + public static function refusal($Host, array $in, array &$row = []) + { + $row = []; + if (!$Host || !$Host->isValid()) { + return 'Unknown host'; + } + $Task = $Host->get('task'); + if (!$Task + || !$Task->isValid() + || TaskType::PERF_TEST != $Task->get('typeID') + ) { + return 'No active Performance Test task for this host'; + } + $bad = self::validate($in, $row); + if ('' !== $bad) { + $row = []; + return 'Invalid field: ' . $bad; + } + $row['hostID'] = (int)$Host->get('id'); + $row['taskID'] = (int)$Task->get('id'); + return ''; + } + /** + * Format a stored ratio (times 100) for display. + * + * 250 is 2.50:1. A ratio of 0 was not measured. + * + * @param mixed $ratio the stored ratio + * + * @return string + */ + public static function formatRatio($ratio) + { + $ratio = (int)$ratio; + if ($ratio < 1) { + return '-'; + } + return sprintf('%d.%02d:1', intdiv($ratio, 100), $ratio % 100); + } + /** + * Format a stored rate for display. + * + * A rate of 0 means FOS did not measure it. + * + * @param mixed $rate the stored rate, in MB/s + * + * @return string + */ + public static function formatRate($rate) + { + $rate = (int)$rate; + return $rate < 1 ? _('not measured') : (string)$rate; + } +} diff --git a/packages/web/src/Items/TaskType.php b/packages/web/src/Items/TaskType.php index 99f1fd6124..d3f1bdb7c8 100644 --- a/packages/web/src/Items/TaskType.php +++ b/packages/web/src/Items/TaskType.php @@ -46,6 +46,7 @@ class TaskType extends FOGController const NORMAL_WIPE = 19; const FULL_WIPE = 20; const ENROLL_SECUREBOOT = 25; + const PERF_TEST = 27; const DEBUGTASKS = [ self::DEBUG, self::MULTICAST, diff --git a/packages/web/src/Managers/HostPerfTestManager.php b/packages/web/src/Managers/HostPerfTestManager.php new file mode 100644 index 0000000000..cdcfaebc46 --- /dev/null +++ b/packages/web/src/Managers/HostPerfTestManager.php @@ -0,0 +1,35 @@ + + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ + +namespace FOG\Managers; + +use FOG\Base\FOGManagerController; + +/** + * The hostPerfTests manager. + * + * @category PerfTest + * @package FOGProject + * @author Tom Elliott + * @license http://opensource.org/licenses/gpl-3.0 GPLv3 + * @link https://fogproject.org + */ +class HostPerfTestManager extends FOGManagerController +{ + /** + * The base table name. + * + * @var string + */ + public $tablename = 'hostPerfTests'; +} diff --git a/packages/web/src/Pages/HostManagement.php b/packages/web/src/Pages/HostManagement.php index a8709d104d..ad3bf3f670 100644 --- a/packages/web/src/Pages/HostManagement.php +++ b/packages/web/src/Pages/HostManagement.php @@ -25,6 +25,7 @@ use FOG\Items\Group; use FOG\Items\Host; use FOG\Items\HostAutoLogout; +use FOG\Items\HostPerfTest; use FOG\Items\MACAddress; use FOG\Items\PowerManagement; use FOG\Items\ScheduledTask; @@ -4630,6 +4631,43 @@ public function hostInstalledSoftware() 'host-installed-software-table' ); } + /** + * Display the host's Performance Test results. + * + * Read only. Each row is one run of the Performance Test task type + * (fos#55), newest first. The grid is filled by getPerfTests(). + * + * The empty-state text is translated here and handed to the grid + * through a hidden element, because the script cannot call _(). + * + * @return void + */ + public function hostPerfTests() + { + printf( + '%s', + \Initiator::e(_('No performance tests have run for this host.')) + ); + $this->renderHistoryTab( + [ + _('Date'), + _('Disk'), + _('Disk MB/s'), + _('Network MB/s'), + _('Decompress MB/s'), + _('Ratio'), + _('Format'), + _('Limited by'), + _('Kernel'), + _('Init') + ], + [ + [], [], [], [], [], [], [], [], [], [] + ], + _('Host Performance Tests'), + 'host-perftest-table' + ); + } /** * Edits an existing item. * @@ -4888,6 +4926,15 @@ public function edit() $this->hostInstalledSoftware(); } ], + [ + // What the Performance Test task type measured on + // this host (fos#55). Read only. + 'name' => _('Performance'), + 'id' => 'host-perftest', + 'generator' => function () { + $this->hostPerfTests(); + } + ], [ // The agent's own trail for THIS host. The rows have // always been in auditLog tagged with the host id; @@ -8053,6 +8100,69 @@ public function getInstalledSoftware() json_encode($data, JSON_UNESCAPED_UNICODE) ); } + /** + * Serves the host's Performance Test grid. + * + * Newest first. The rates and the ratio are formatted here, by the same + * functions the tests pin, so the grid script only escapes and shows. + * + * @return void + */ + public function getPerfTests() + { + header('Content-type: application/json'); + parse_str( + file_get_contents('php://input'), + $request + ); + $hostID = (int)$this->obj->get('id'); + $columns = [ + ['db' => 'hptID', 'dt' => 'id'], + ['db' => 'hptDateTime', 'dt' => 'date'], + ['db' => 'hptDisk', 'dt' => 'disk'], + ['db' => 'hptDiskMBps', 'dt' => 'diskMBps'], + ['db' => 'hptNetMBps', 'dt' => 'netMBps'], + ['db' => 'hptCpuMBps', 'dt' => 'cpuMBps'], + ['db' => 'hptRatio', 'dt' => 'ratio'], + ['db' => 'hptFormat', 'dt' => 'format'], + ['db' => 'hptBottleneck', 'dt' => 'bottleneck'], + ['db' => 'hptKernel', 'dt' => 'kernel'], + ['db' => 'hptInit', 'dt' => 'init'] + ]; + $sqlstr = "SELECT `%s` + FROM `%s` + %s + %s + %s"; + $fltrstr = "SELECT COUNT(`%s`) + FROM `%s` + %s"; + $ttlstr = "SELECT COUNT(`%s`) + FROM `%s`"; + $data = FOGManagerController::complex( + $request, + 'hostPerfTests', + 'hptID', + $columns, + $sqlstr, + $fltrstr, + $ttlstr, + null, + sprintf('`hostPerfTests`.`hptHostID` = %d', $hostID), + 'date' + ); + foreach ($data['data'] as &$row) { + $row['diskMBps'] = HostPerfTest::formatRate($row['diskMBps']); + $row['netMBps'] = HostPerfTest::formatRate($row['netMBps']); + $row['cpuMBps'] = HostPerfTest::formatRate($row['cpuMBps']); + $row['ratio'] = HostPerfTest::formatRatio($row['ratio']); + } + unset($row); + $this->jsonSend( + HTTPResponseCodes::HTTP_SUCCESS, + json_encode($data, JSON_UNESCAPED_UNICODE) + ); + } /** * Get the hosts display man values * diff --git a/packages/web/vendor/composer/autoload_classmap.php b/packages/web/vendor/composer/autoload_classmap.php index 3e4c4ecd06..27b6aa926c 100644 --- a/packages/web/vendor/composer/autoload_classmap.php +++ b/packages/web/vendor/composer/autoload_classmap.php @@ -121,6 +121,7 @@ 'FOG\\Items\\HostDirectory' => $baseDir . '/src/Items/HostDirectory.php', 'FOG\\Items\\HostFactState' => $baseDir . '/src/Items/HostFactState.php', 'FOG\\Items\\HostNetwork' => $baseDir . '/src/Items/HostNetwork.php', + 'FOG\\Items\\HostPerfTest' => $baseDir . '/src/Items/HostPerfTest.php', 'FOG\\Items\\HostPrinter' => $baseDir . '/src/Items/HostPrinter.php', 'FOG\\Items\\HostSoftware' => $baseDir . '/src/Items/HostSoftware.php', 'FOG\\Items\\HostSpooler' => $baseDir . '/src/Items/HostSpooler.php', @@ -206,6 +207,7 @@ 'FOG\\Managers\\HostFactStateManager' => $baseDir . '/src/Managers/HostFactStateManager.php', 'FOG\\Managers\\HostManager' => $baseDir . '/src/Managers/HostManager.php', 'FOG\\Managers\\HostNetworkManager' => $baseDir . '/src/Managers/HostNetworkManager.php', + 'FOG\\Managers\\HostPerfTestManager' => $baseDir . '/src/Managers/HostPerfTestManager.php', 'FOG\\Managers\\HostPrinterManager' => $baseDir . '/src/Managers/HostPrinterManager.php', 'FOG\\Managers\\HostSoftwareManager' => $baseDir . '/src/Managers/HostSoftwareManager.php', 'FOG\\Managers\\HostSpoolerManager' => $baseDir . '/src/Managers/HostSpoolerManager.php', diff --git a/packages/web/vendor/composer/autoload_static.php b/packages/web/vendor/composer/autoload_static.php index 75869a919b..35cc14c43d 100644 --- a/packages/web/vendor/composer/autoload_static.php +++ b/packages/web/vendor/composer/autoload_static.php @@ -158,6 +158,7 @@ class ComposerStaticInitf1e42438574b3ce50c0c9ee957f57472 'FOG\\Items\\HostDirectory' => __DIR__ . '/../..' . '/src/Items/HostDirectory.php', 'FOG\\Items\\HostFactState' => __DIR__ . '/../..' . '/src/Items/HostFactState.php', 'FOG\\Items\\HostNetwork' => __DIR__ . '/../..' . '/src/Items/HostNetwork.php', + 'FOG\\Items\\HostPerfTest' => __DIR__ . '/../..' . '/src/Items/HostPerfTest.php', 'FOG\\Items\\HostPrinter' => __DIR__ . '/../..' . '/src/Items/HostPrinter.php', 'FOG\\Items\\HostSoftware' => __DIR__ . '/../..' . '/src/Items/HostSoftware.php', 'FOG\\Items\\HostSpooler' => __DIR__ . '/../..' . '/src/Items/HostSpooler.php', @@ -243,6 +244,7 @@ class ComposerStaticInitf1e42438574b3ce50c0c9ee957f57472 'FOG\\Managers\\HostFactStateManager' => __DIR__ . '/../..' . '/src/Managers/HostFactStateManager.php', 'FOG\\Managers\\HostManager' => __DIR__ . '/../..' . '/src/Managers/HostManager.php', 'FOG\\Managers\\HostNetworkManager' => __DIR__ . '/../..' . '/src/Managers/HostNetworkManager.php', + 'FOG\\Managers\\HostPerfTestManager' => __DIR__ . '/../..' . '/src/Managers/HostPerfTestManager.php', 'FOG\\Managers\\HostPrinterManager' => __DIR__ . '/../..' . '/src/Managers/HostPrinterManager.php', 'FOG\\Managers\\HostSoftwareManager' => __DIR__ . '/../..' . '/src/Managers/HostSoftwareManager.php', 'FOG\\Managers\\HostSpoolerManager' => __DIR__ . '/../..' . '/src/Managers/HostSpoolerManager.php', diff --git a/tests/fixtures/upgrade-rehearsal-baseline.txt b/tests/fixtures/upgrade-rehearsal-baseline.txt index b85e18c7e5..41d3b8b233 100644 --- a/tests/fixtures/upgrade-rehearsal-baseline.txt +++ b/tests/fixtures/upgrade-rehearsal-baseline.txt @@ -1,5 +1,5 @@ - constraints declared and applicable here: 97 - constraints actually present: 95 + constraints declared and applicable here: 98 + constraints actually present: 96 MISSING: 2 fk_hostMAC_hmHostID CASCADE orphan rows: 0 fk_nfsGroupMembers_ngmGroupID RESTRICT orphan rows: 1 diff --git a/tests/foreign-key-map.test.php b/tests/foreign-key-map.test.php index 157afdacd1..a6d6756ef6 100644 --- a/tests/foreign-key-map.test.php +++ b/tests/foreign-key-map.test.php @@ -373,6 +373,7 @@ 'agentWake.awTargetID', 'agentWake.awSenderID', 'hostFactState.hfsHostID', + 'hostPerfTests.hptHostID', // Plugin groups, named for the plugin rather than numbered. Each // lands in that plugin's own repo, in an appended step of its // manager's schema(); see fog-plugins tests/foreign-keys.test.php, diff --git a/tests/module-not-set-follows-default.test.php b/tests/module-not-set-follows-default.test.php index b6d53229f5..4c29d858a8 100644 --- a/tests/module-not-set-follows-default.test.php +++ b/tests/module-not-set-follows-default.test.php @@ -16,7 +16,7 @@ * - schema step 443 only inserts, inserts msState 0, and keeps every host * whose missing row meant OFF on an install upgraded from 1.5 (it skips * a host with a row and a host whose group grants the module); - * - FOG_SCHEMA is 443; + * - FOG_SCHEMA has reached 443, so the step ships; * - host creation no longer copies the default modules into host rows. * * Usage: php tests/module-not-set-follows-default.test.php @@ -104,14 +104,16 @@ // Schema step 443 is array index 442: the array is keyed from 0. $systemSrc = file_get_contents(dirname(__DIR__) . '/packages/web/src/Base/System.php'); -$t->check('FOG_SCHEMA is 443', 1 === preg_match("/define\(\s*'FOG_SCHEMA'\s*,\s*443\s*\)/", $systemSrc)); +// At least 443, not exactly: a later step raises the constant and must not +// fail a test about step 443. +$t->check('FOG_SCHEMA has reached 443', 1 === preg_match("/define\(\s*'FOG_SCHEMA'\s*,\s*(\d+)\s*\)/", $systemSrc, $schemaVer) && (int)$schemaVer[1] >= 443); $steps = fogCollectSchemaSteps( dirname(__DIR__) . '/packages/web/commons/schema.php', 'module_not_set_follows_default', - 443 + (int)$schemaVer[1] ); $sql = isset($steps[442]) ? implode("\n", (array)$steps[442]) : ''; -$t->check('step 443 is the last step', 443 === count($steps)); +$t->check('step 443 exists', count($steps) >= 443); $t->check('step 443 inserts msState 0', 1 === preg_match('/INSERT IGNORE INTO `moduleStatusByHost`.*SELECT h\.`hostID`, m\.`id`, 0 FROM/s', $sql)); $t->check('step 443 has no DELETE or UPDATE', 0 === preg_match('/\b(DELETE|UPDATE)\b/i', $sql)); $t->check('step 443 skips hosts with a row', false !== strpos($sql, 'FROM `moduleStatusByHost` s')); diff --git a/tests/perftest-report.test.php b/tests/perftest-report.test.php new file mode 100644 index 0000000000..5099fc6012 --- /dev/null +++ b/tests/perftest-report.test.php @@ -0,0 +1,264 @@ +_valid = $valid; + $this->_data = $data; + } + + public function isValid() + { + return $this->_valid; + } + + public function get($key) + { + return $this->_data[$key] ?? null; + } +} + +/** + * A host with the given task in flight. + * + * @param int|null $typeID the task type, or null for no task + * + * @return PerfStub + */ +function perfHost($typeID) +{ + $task = null === $typeID + ? new PerfStub(false) + : new PerfStub(true, ['id' => 77, 'typeID' => $typeID]); + return new PerfStub(true, ['id' => 12, 'task' => $task]); +} + +/** + * A report FOS could have sent, with some fields replaced. + * + * @param array $over the fields to replace + * + * @return array + */ +function perfReport(array $over = []) +{ + return array_merge( + [ + 'mac' => '00:11:22:33:44:55', + 'disk' => '/dev/nvme0n1', + 'diskmbps' => '1800', + 'netmbps' => '110', + 'cpumbps' => '650', + 'ratio' => '250', + 'format' => 'zstd', + 'sample' => base64_encode('win11/d1p2.img'), + 'bottleneck' => 'network', + 'kernel' => '6.18.59', + 'initversion' => '20261027', + ], + $over + ); +} + +$t = new FogChecks(); +$good = perfHost(TaskType::PERF_TEST); + +// --- who may report --------------------------------------------------------- +$row = []; +$t->check( + 'an unknown host is refused', + 'Unknown host' === HostPerfTest::refusal( + new PerfStub(false), + perfReport(), + $row + ) && [] === $row +); +$t->check( + 'a null host is refused', + 'Unknown host' === HostPerfTest::refusal(null, perfReport(), $row) +); +$msg = HostPerfTest::refusal(perfHost(null), perfReport(), $row); +$t->check( + 'a host with no active task is refused', + 'No active Performance Test task for this host' === $msg && [] === $row +); +foreach ([TaskType::DEPLOY, TaskType::CAPTURE, TaskType::ENROLL_SECUREBOOT, 26] + as $other) { + $msg = HostPerfTest::refusal(perfHost($other), perfReport(), $row); + $t->check( + "a host whose active task is type $other is refused", + 'No active Performance Test task for this host' === $msg + && [] === $row + ); +} + +// --- every field class is checked ------------------------------------------- +$bad = [ + ['diskmbps', 'abc', 'a non-digit rate'], + ['netmbps', '-5', 'a negative rate'], + ['cpumbps', '12.5', 'a decimal rate'], + ['diskmbps', '', 'an empty rate'], + ['diskmbps', '1000001', 'an over-cap rate'], + ['ratio', '100001', 'an over-cap ratio'], + ['ratio', '2.5', 'a decimal ratio'], + ['format', 'lz4', 'a format outside the list'], + ['format', 'ZSTD', 'a format in the wrong case'], + ['bottleneck', 'memory', 'a bottleneck outside the list'], + ['disk', 'nvme0n1', 'a disk with no /dev/ prefix'], + ['disk', '/dev/sda; rm -rf /', 'a disk with shell characters'], + ['disk', '/dev/' . str_repeat('a', 59), 'a disk name over the cap'], + ['kernel', "6.18\n", 'a kernel with a newline'], + ['kernel', str_repeat('1', 65), 'a kernel over the cap'], + ['initversion', str_repeat('1', 33), 'an initversion over the cap'], + ['initversion', '2026 1027', 'an initversion with a space'], + ['sample', 'not base64!', 'a sample that is not strict base64'], + ['sample', 'aGVsbG8', 'a sample with missing padding'], + ['sample', base64_encode("a\x01b"), 'a sample with a control character'], + ['sample', base64_encode("a\nb"), 'a sample with a newline'], + ['sample', base64_encode("\xff\xfe"), 'a sample that is not UTF-8'], + ['sample', base64_encode(str_repeat('a', 256)), 'a sample over the cap'], +]; +foreach ($bad as list($field, $value, $what)) { + $msg = HostPerfTest::refusal( + $good, + perfReport([$field => $value]), + $row + ); + $t->check( + "$what is refused, naming $field, and builds no row", + 'Invalid field: ' . $field === $msg && [] === $row + ); +} + +// --- what is accepted ------------------------------------------------------- +$msg = HostPerfTest::refusal($good, perfReport(), $row); +$t->check('a valid report is accepted', '' === $msg); +$t->check( + 'the row carries the posted values', + isset($row['diskMBps']) + && 1800 === $row['diskMBps'] + && 110 === $row['netMBps'] + && 650 === $row['cpuMBps'] + && 250 === $row['ratio'] + && 'zstd' === $row['format'] + && 'network' === $row['bottleneck'] + && '/dev/nvme0n1' === $row['disk'] + && '6.18.59' === $row['kernel'] + && '20261027' === $row['init'] +); +$t->check( + 'the sample is stored decoded', + isset($row['sample']) && 'win11/d1p2.img' === $row['sample'] +); +$t->check( + 'the row carries the host id and the active task id', + isset($row['hostID'], $row['taskID']) + && 12 === $row['hostID'] + && 77 === $row['taskID'] +); +$msg = HostPerfTest::refusal( + $good, + perfReport( + [ + 'disk' => '', + 'diskmbps' => '0', + 'netmbps' => '0', + 'cpumbps' => '0', + 'ratio' => '0', + 'format' => '', + 'sample' => '', + 'bottleneck' => '', + 'kernel' => '', + 'initversion' => '', + ] + ), + $row +); +$t->check( + 'an all-empty, all-zero report (nothing measured) is accepted', + '' === $msg && '' === $row['sample'] && 0 === $row['ratio'] +); +$msg = HostPerfTest::refusal( + $good, + perfReport( + [ + 'diskmbps' => '1000000', + 'ratio' => '100000', + 'sample' => base64_encode(str_repeat('a', 255)), + ] + ), + $row +); +$t->check('values exactly at the caps are accepted', '' === $msg); + +// --- the tab's formatting --------------------------------------------------- +$t->check('ratio 250 shows as 2.50:1', '2.50:1' === HostPerfTest::formatRatio(250)); +$t->check('ratio 100 shows as 1.00:1', '1.00:1' === HostPerfTest::formatRatio('100')); +$t->check('ratio 105 shows as 1.05:1', '1.05:1' === HostPerfTest::formatRatio(105)); +$t->check('ratio 99 shows as 0.99:1', '0.99:1' === HostPerfTest::formatRatio(99)); +$t->check('ratio 0 shows as a dash', '-' === HostPerfTest::formatRatio(0)); +$t->check('rate 1800 shows as 1800', '1800' === HostPerfTest::formatRate('1800')); +$t->check( + 'rate 0 shows as not measured', + 'not measured' === HostPerfTest::formatRate(0) +); + +// --- the endpoint's wiring -------------------------------------------------- +$src = file_get_contents($web . '/service/perftest.php'); +$refusalAt = strpos($src, 'HostPerfTest::refusal('); +$saveAt = strpos($src, '->save()'); +$t->check( + 'the endpoint checks the report before it stores anything', + false !== $refusalAt && false !== $saveAt && $refusalAt < $saveAt +); +$t->check( + 'the endpoint declares itself a machine request', + false !== strpos($src, "define('FOG_MACHINE_REQUEST', true);") +); +$t->check( + 'the endpoint answers exactly ## on success', + (bool)preg_match("/echo '##';\s*$/", $src) +); + +$t->finish();