From fa29780e87a86cc4623b92847a9a6188c9d4ec12 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 12 Mar 2024 22:14:30 +0100 Subject: [PATCH] Fix tests --- src/Orchestration/Adapter/DockerCLI.php | 20 ++++++++++++++++++++ tests/Orchestration/Base.php | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Orchestration/Adapter/DockerCLI.php b/src/Orchestration/Adapter/DockerCLI.php index cfdadc9..6df4090 100644 --- a/src/Orchestration/Adapter/DockerCLI.php +++ b/src/Orchestration/Adapter/DockerCLI.php @@ -116,6 +116,12 @@ public function getStats(string $container = null, array $filters = []): array if ($result !== 0) { throw new Orchestration("Docker Error: {$output}"); } + $dump = function($value) { + $p = var_export($value, true); + $b = debug_backtrace(); + print($b[0]['file'] . ':' . $b[0]['line'] . ' - ' . $p . "\n"); + }; + $dump($output); $lines = \explode("\n", $output); @@ -344,6 +350,13 @@ public function run(string $image, $vars = $parsedVariables; + $dump = function($value) { + $p = var_export($value, true); + $b = debug_backtrace(); + print($b[0]['file'] . ':' . $b[0]['line'] . ' - ' . $p . "\n"); + }; + $dump(implode(' ', $command)); + $time = time(); $result = Console::execute('docker run'. @@ -401,6 +414,13 @@ public function execute( $vars = $parsedVariables; + $dump = function($value) { + $p = var_export($value, true); + $b = debug_backtrace(); + print($b[0]['file'] . ':' . $b[0]['line'] . ' - ' . $p . "\n"); + }; + $dump(implode(' ', $command)); + $result = Console::execute('docker exec '.\implode(' ', $vars)." {$name} ".implode(' ', $command), '', $output, $timeout); if ($result !== 0) { diff --git a/tests/Orchestration/Base.php b/tests/Orchestration/Base.php index 2f8e1dd..9d83b02 100644 --- a/tests/Orchestration/Base.php +++ b/tests/Orchestration/Base.php @@ -493,8 +493,8 @@ public function testUsageStats(): void // This allows CPU-heavy load check $output = ''; - static::getOrchestration()->execute($containerId1, ['screen', '-d', '-m', "'stress --cpu 1 --timeout 5'"], $output); // Run in screen so it's background task - static::getOrchestration()->execute($containerId2, ['screen', '-d', '-m', "'stress --cpu 1 --timeout 5'"], $output); + static::getOrchestration()->execute($containerId1, ['screen', '-d', '-m', 'stress --cpu 1 --timeout 10'], $output); // Run in screen so it's background task + static::getOrchestration()->execute($containerId2, ['screen', '-d', '-m', 'stress --cpu 1 --timeout 10'], $output); // Set CPU stress-test start \sleep(1);