From 48c5d828a3771a8a2622cce648bc3decaab3c295 Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Tue, 6 Aug 2024 09:56:15 -0700 Subject: [PATCH 1/4] fix undefined command summary --- src/Commands/Remote/SSHBaseCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/Remote/SSHBaseCommand.php b/src/Commands/Remote/SSHBaseCommand.php index b3659a604..129bc44a5 100755 --- a/src/Commands/Remote/SSHBaseCommand.php +++ b/src/Commands/Remote/SSHBaseCommand.php @@ -100,13 +100,14 @@ protected function executeCommand(array $command_args, int $retries = 0) // Send the combined command line via SSH $ssh_data = $this->sendCommandViaSsh($command_line, $env_vars); + $command_summary = $this->getCommandSummary($command_args); // Log the command execution $this->log()->notice( 'Command: {site}.{env} -- {command} [Exit: {exit}] (Attempt {attempt}/{max_attempts})', [ 'site' => $this->site->getName(), 'env' => $this->environment->id, - 'command' => $this->getCommandSummary($command_args), + 'command' => $command_summary, 'exit' => $ssh_data['exit_code'], 'attempt' => $attempt + 1, 'max_attempts' => $max_attempts, From 8d093460fd58eb9276d9006ee57c0d143f66c84e Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 7 Aug 2024 12:19:02 -0700 Subject: [PATCH 2/4] test for error exit --- .../Commands/Remote/SSHBaseCommandTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php index ba948b285..1d356c07e 100644 --- a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php +++ b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php @@ -139,6 +139,19 @@ public function testExecuteCommandNonzeroStatus() $out = $this->command->dummyCommand("$site_name.{$this->environment->id}", $options); $this->assertNull($out); + $this->logger->expects($this->once()) + ->method('log') + ->with( + $this->equalTo('error'), + $this->equalTo('Command: {site}.{env} -- {command} [Exit: {exit}] (All attempts failed)'), + $this->equalTo([ + 'site' => $site_name, + 'env' => $this->environment->id, + 'command' => "$expectedLoggedCommand", + 'exit' => $status_code, + ]) + ); + } /** From 0d4d285f63a1dc9cfebb1f146af0ed0b85272668 Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 7 Aug 2024 12:21:26 -0700 Subject: [PATCH 3/4] fixup --- tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php index 1d356c07e..4e0a8f4ae 100644 --- a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php +++ b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php @@ -151,7 +151,6 @@ public function testExecuteCommandNonzeroStatus() 'exit' => $status_code, ]) ); - } /** From f8f7df3f31984a4553f371a2e97bf42df75a39de Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 7 Aug 2024 13:04:47 -0700 Subject: [PATCH 4/4] Revert "fix undefined command summary" This reverts commit 48c5d828a3771a8a2622cce648bc3decaab3c295. --- src/Commands/Remote/SSHBaseCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Commands/Remote/SSHBaseCommand.php b/src/Commands/Remote/SSHBaseCommand.php index 129bc44a5..b3659a604 100755 --- a/src/Commands/Remote/SSHBaseCommand.php +++ b/src/Commands/Remote/SSHBaseCommand.php @@ -100,14 +100,13 @@ protected function executeCommand(array $command_args, int $retries = 0) // Send the combined command line via SSH $ssh_data = $this->sendCommandViaSsh($command_line, $env_vars); - $command_summary = $this->getCommandSummary($command_args); // Log the command execution $this->log()->notice( 'Command: {site}.{env} -- {command} [Exit: {exit}] (Attempt {attempt}/{max_attempts})', [ 'site' => $this->site->getName(), 'env' => $this->environment->id, - 'command' => $command_summary, + 'command' => $this->getCommandSummary($command_args), 'exit' => $ssh_data['exit_code'], 'attempt' => $attempt + 1, 'max_attempts' => $max_attempts,