From 17f9a7293c50c4f369f74bc44b605546cac0e276 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 3 Mar 2025 16:39:34 +0100 Subject: [PATCH] update tests and included php modules in binary --- TODO.md | 20 ++++++++++---- inc_vars.php | 4 ++- tests/00_start.php | 3 +++ ..._set_metadata.php => 100_set_metadata.php} | 0 tests/200_mysqlconnect.php | 7 +++++ tests/200_pdoconnect.php | 7 +++++ tests/configs/mysqlconnect.ini | 26 +++++++++++++++++++ tests/configs/pdoconnect.ini | 24 +++++++++++++++++ 8 files changed, 85 insertions(+), 6 deletions(-) rename tests/{110_set_metadata.php => 100_set_metadata.php} (100%) create mode 100644 tests/200_mysqlconnect.php create mode 100644 tests/200_pdoconnect.php create mode 100644 tests/configs/mysqlconnect.ini create mode 100644 tests/configs/pdoconnect.ini diff --git a/TODO.md b/TODO.md index eaa02fb..4937271 100644 --- a/TODO.md +++ b/TODO.md @@ -3,35 +3,45 @@ was ich so sehe ... ✅ Slack-Notifikation: statt Parsing-mechanismus eines Strings --> JSON in der INI schreiben + ✅ `--ini=<FILE>` bei relativem Pfad ist relativ zum Binary --> nicht ins eigene Verzeichnis wechseln + ⬜ Dokumentation + ⬜ Code aufräumen ## Tests schreiben ✅ Test auf gesetzte Metadaten + ⬜ für alle Checks einen Test schreiben ⬜ ApacheProcesses - ✅ Cert - ✅ Diskfree + ✅ Cert --> Hostname bei Wildcard-Zertifikat wird nicht erkannt + ✅ Diskfree --> preg_replace hat den Integer Wert noch geholt ✅ Exec - ⬜ File --> "exists": false meldet bei Test einer nicht existierenden Datei fälschlicherweise einen Fehler + ✅ File --> "exists": false meldet bei Test einer nicht existierenden Datei fälschlicherweise einen Fehler ✅ Hello ✅ HttpContent ✅ Loadmeter - ⬜ MysqlConnect - ⬜ PdoConnect + ✅ MysqlConnect -> mysqli->real_connect() Fatal error: Uncaught mysqli_sql_exception: No such file or directory + ✅ PdoConnect ⬜ Phpmodules ⬜ Ping ⬜ PortTcp ⬜ Simple ⬜ SqliteConnect +⬜ parent Option testen + +⬜ group testen + ## Done ✅ PHP compiliert zum Binary + ✅ Binary startet in einem fremden Verzichnis + ✅ Binary startet auf einen Nicht-PHP-System --- diff --git a/inc_vars.php b/inc_vars.php index 2fdeb03..498f5b2 100644 --- a/inc_vars.php +++ b/inc_vars.php @@ -1,7 +1,9 @@ <?php $php_version="8.3"; -$php_libs="zlib"; + +// extensions - see https://static-php.dev/en/guide/extensions.html +$php_libs="mysqli,openssl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,zlib"; $myos=strtolower(PHP_OS); $myarchitecture="x86_64"; diff --git a/tests/00_start.php b/tests/00_start.php index bb0df25..416a2bd 100755 --- a/tests/00_start.php +++ b/tests/00_start.php @@ -5,6 +5,9 @@ require_once __DIR__.'/../inc_functions.php'; require_once __DIR__.'/../inc_vars.php'; $AMCLI??=__DIR__.'/../src/amcli.php'; +$AMCLI=__DIR__.'/../built_packages/amcli'; + +_chdir(__DIR__); echo "\n\nSTART TESTS\n\n"; foreach(glob("*.php") as $sFile){ diff --git a/tests/110_set_metadata.php b/tests/100_set_metadata.php similarity index 100% rename from tests/110_set_metadata.php rename to tests/100_set_metadata.php diff --git a/tests/200_mysqlconnect.php b/tests/200_mysqlconnect.php new file mode 100644 index 0000000..1fe4dc9 --- /dev/null +++ b/tests/200_mysqlconnect.php @@ -0,0 +1,7 @@ +#!/usr/bin/env php +<?php + +echo " +WHAT: Run check mysqlconnect +"; +_exec("$AMCLI --ini='".__DIR__."/configs/mysqlconnect.ini'"); diff --git a/tests/200_pdoconnect.php b/tests/200_pdoconnect.php new file mode 100644 index 0000000..30e4bcd --- /dev/null +++ b/tests/200_pdoconnect.php @@ -0,0 +1,7 @@ +#!/usr/bin/env php +<?php + +echo " +WHAT: Run check pdoconnect +"; +_exec("$AMCLI --ini='".__DIR__."/configs/pdoconnect.ini'"); diff --git a/tests/configs/mysqlconnect.ini b/tests/configs/mysqlconnect.ini new file mode 100644 index 0000000..c2cab2d --- /dev/null +++ b/tests/configs/mysqlconnect.ini @@ -0,0 +1,26 @@ +; ======================================================================= +; +; APPMONITOR CLI CLIENT +; +; for the checks see its parameters +; <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/Plugins/Checks/index.html> +; +; ======================================================================= + + +; ----------------------------------------------------------------------- +; CHECKS +; ----------------------------------------------------------------------- + +["Mysqlconnect"] +description="Test Mysql database connection" +function="Mysqlconnect" +params='{ + "server": "127.0.0.1", + "user": "root", + "password": "12345678", + "db": "ahcrawler", + "port": "13306" +}' + +; ----------------------------------------------------------------------- diff --git a/tests/configs/pdoconnect.ini b/tests/configs/pdoconnect.ini new file mode 100644 index 0000000..b97be28 --- /dev/null +++ b/tests/configs/pdoconnect.ini @@ -0,0 +1,24 @@ +; ======================================================================= +; +; APPMONITOR CLI CLIENT +; +; for the checks see its parameters +; <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/Plugins/Checks/index.html> +; +; ======================================================================= + + +; ----------------------------------------------------------------------- +; CHECKS +; ----------------------------------------------------------------------- + +["PDO connect mysql"] +description="PDO - Test Mysql database connection" +function="Pdoconnect" +params='{ + "connect": "mysql:host=127.0.0.1;port=13306;dbname=ahcrawler;", + "user": "root", + "password": "12345678" +}' + +; ----------------------------------------------------------------------- -- GitLab