From 0b71a936923e1e38cb6ed2cee2f26470d80b60f0 Mon Sep 17 00:00:00 2001 From: ashvini22326 Date: Fri, 22 Aug 2025 16:13:52 +0530 Subject: [PATCH 01/66] MCLOUD-13771 : Add support of Active MQ in cloud-docker --- config/services.xml | 1 + src/Compose/BuilderInterface.php | 1 + .../Service/ActiveMqArtemis.php | 78 +++++++++++++++++++ src/Config/Relationship.php | 9 +++ src/Config/Source/CloudSource.php | 3 +- src/Service/ServiceFactory.php | 15 ++++ src/Service/ServiceInterface.php | 1 + 7 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php diff --git a/config/services.xml b/config/services.xml index 319f8350..b3eea275 100644 --- a/config/services.xml +++ b/config/services.xml @@ -38,6 +38,7 @@ + diff --git a/src/Compose/BuilderInterface.php b/src/Compose/BuilderInterface.php index a31a394b..1e527d9c 100644 --- a/src/Compose/BuilderInterface.php +++ b/src/Compose/BuilderInterface.php @@ -28,6 +28,7 @@ interface BuilderInterface public const SERVICE_SELENIUM = ServiceInterface::SERVICE_SELENIUM; public const SERVICE_TLS = ServiceInterface::SERVICE_TLS; public const SERVICE_RABBITMQ = ServiceInterface::SERVICE_RABBITMQ; + public const SERVICE_ACTIVEMQ_ARTEMIS = ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS; public const SERVICE_REDIS = ServiceInterface::SERVICE_REDIS; public const SERVICE_VALKEY = ServiceInterface::SERVICE_VALKEY; public const SERVICE_ELASTICSEARCH = ServiceInterface::SERVICE_ELASTICSEARCH; diff --git a/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php b/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php new file mode 100644 index 00000000..676f8441 --- /dev/null +++ b/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php @@ -0,0 +1,78 @@ +serviceFactory = $serviceFactory; + } + + /** + * @inheritDoc + */ + public function getName(): string + { + return BuilderInterface::SERVICE_ACTIVEMQ_ARTEMIS; + } + + /** + * @inheritDoc + */ + public function getServiceName(): string + { + return $this->getName(); + } + + /** + * @inheritDoc + */ + public function getConfig(Config $config): array + { + return $this->serviceFactory->create( + $this->getServiceName(), + $config->getServiceVersion($this->getServiceName()), + [], + $config->getServiceImage($this->getServiceName()), + $config->getCustomRegistry() + ); + } + + /** + * @inheritDoc + */ + public function getNetworks(): array + { + return [BuilderInterface::NETWORK_MAGENTO]; + } + + /** + * @inheritDoc + */ + public function getDependsOn(Config $config): array + { + return []; + } +} diff --git a/src/Config/Relationship.php b/src/Config/Relationship.php index c22e4c3e..eb8ed363 100644 --- a/src/Config/Relationship.php +++ b/src/Config/Relationship.php @@ -81,6 +81,15 @@ class Relationship 'password' => 'guest', ] ], + 'activemq-artemis' => [ + [ + 'host' => 'activemq-artemis', + 'port' => '61616', + 'username' => 'admin', + 'password' => 'admin', + 'web_console_port' => '8161', + ] + ], 'zookeeper' => [ [ 'host' => 'zookeeper', diff --git a/src/Config/Source/CloudSource.php b/src/Config/Source/CloudSource.php index 2e9e3712..84802ba8 100644 --- a/src/Config/Source/CloudSource.php +++ b/src/Config/Source/CloudSource.php @@ -48,7 +48,8 @@ class CloudSource implements SourceInterface ServiceInterface::SERVICE_OPENSEARCH => ['opensearch', 'os'], ServiceInterface::SERVICE_REDIS => ['redis'], ServiceInterface::SERVICE_VALKEY => ['cache','valkey'], - ServiceInterface::SERVICE_RABBITMQ => ['rmq', 'rabbitmq'] + ServiceInterface::SERVICE_RABBITMQ => ['rmq', 'rabbitmq'], + ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS => ['activemq', 'artemis', 'activemq-artemis'] ]; /** diff --git a/src/Service/ServiceFactory.php b/src/Service/ServiceFactory.php index 119fcc51..6d5d1e7c 100644 --- a/src/Service/ServiceFactory.php +++ b/src/Service/ServiceFactory.php @@ -153,6 +153,21 @@ class ServiceFactory 'image' => 'rabbitmq', 'pattern' => self::PATTERN_STD, ], + ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS => [ + 'image' => 'apache/activemq-artemis', + 'pattern' => self::PATTERN_STD, + 'config' => [ + 'ports' => [61616, 8161], + 'environment' => [ + 'ARTEMIS_USER' => 'admin', + 'ARTEMIS_PASSWORD' => 'admin', + ], + 'volumes' => [ + '/var/lib/artemis/data', + '/var/log/artemis', + ] + ], + ], ServiceInterface::SERVICE_NODE => [ 'image' => 'node', 'pattern' => self::PATTERN_STD diff --git a/src/Service/ServiceInterface.php b/src/Service/ServiceInterface.php index 54936094..7ae08bbd 100644 --- a/src/Service/ServiceInterface.php +++ b/src/Service/ServiceInterface.php @@ -27,6 +27,7 @@ interface ServiceInterface public const SERVICE_ELASTICSEARCH = 'elasticsearch'; public const SERVICE_OPENSEARCH = 'opensearch'; public const SERVICE_RABBITMQ = 'rabbitmq'; + public const SERVICE_ACTIVEMQ_ARTEMIS = 'activemq-artemis'; public const SERVICE_NODE = 'node'; public const SERVICE_VARNISH = 'varnish'; public const SERVICE_SELENIUM = 'selenium'; From 95f72e1deeabec494ce5c0e8d39ce92c1902c7f2 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Fri, 29 Aug 2025 19:27:57 +0530 Subject: [PATCH 02/66] MCLOUD-14015:Debug the docker commands --- tests/functional/Codeception/Docker.php | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index ac65e51d..978db1cb 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -176,6 +176,23 @@ static function ($val) use ($magentoRoot) { */ public function downloadFromContainer(string $source, string $destination, string $container): bool { + // Validate inputs + if (empty($source)) { + throw new \RuntimeException("Source path is empty."); + } + if (empty($destination)) { + throw new \RuntimeException("Destination path is empty."); + } + if (empty($container)) { + throw new \RuntimeException("Container name is empty."); + } + + // Construct the full source path + $fullSourcePath = $this->_getConfig('system_magento_dir') . $source; + if (empty($fullSourcePath)) { + throw new \RuntimeException("Failed to construct full source path. Check 'system_magento_dir' configuration."); + } + /** @var Result $result */ $result = $this->taskCopyFromDocker($container) ->printOutput($this->_getConfig('printOutput')) @@ -253,8 +270,17 @@ public function uploadToContainer(string $source, string $destination, string $c public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) { $tmpFile = tempnam(sys_get_temp_dir(), md5($source)); - $this->downloadFromContainer($source, $tmpFile, $container); - + if (!file_exists($tmpFile) || filesize($tmpFile) === 0) { + throw new \RuntimeException("Temporary file is empty or not created: $tmpFile"); + } + if (!$this->downloadFromContainer($source, $tmpFile, $container)) { + throw new \RuntimeException("Failed to download file from container: $source"); + } + // static::$output = $this->downloadFromContainer($source, $tmpFile, $container); + $content = file_get_contents($tmpFile); + if ($content === false || $content === '') { + throw new \RuntimeException("File is empty: $source"); + } return file_get_contents($tmpFile); } } From 2c0168da1ee647fce833de8e8f2cce80462bcf7e Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Fri, 29 Aug 2025 20:25:59 +0530 Subject: [PATCH 03/66] MCLOUD-14015:small fix --- tests/functional/Codeception/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 978db1cb..671338cf 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -270,7 +270,7 @@ public function uploadToContainer(string $source, string $destination, string $c public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) { $tmpFile = tempnam(sys_get_temp_dir(), md5($source)); - if (!file_exists($tmpFile) || filesize($tmpFile) === 0) { + if (!file_exists($tmpFile)) { throw new \RuntimeException("Temporary file is empty or not created: $tmpFile"); } if (!$this->downloadFromContainer($source, $tmpFile, $container)) { From d15a6c37b7a16be4fb93d6b1e863d54783294b64 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 1 Sep 2025 13:01:32 +0530 Subject: [PATCH 04/66] MCLOUD-14015: small fix --- tests/functional/Codeception/Docker.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 671338cf..75774be7 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -273,8 +273,13 @@ public function grabFileContent(string $source, string $container = self::DEPLOY if (!file_exists($tmpFile)) { throw new \RuntimeException("Temporary file is empty or not created: $tmpFile"); } + + if (!$this->downloadFromContainer($source, $tmpFile, $container)) { - throw new \RuntimeException("Failed to download file from container: $source"); + $errorMessage = sprintf( + "Failed to download file from container. Source: %s, Container: %s, Temporary File: %s",$source, $container,$tmpFile + ); + throw new \RuntimeException($errorMessage); } // static::$output = $this->downloadFromContainer($source, $tmpFile, $container); $content = file_get_contents($tmpFile); From e7bbdd868cd440e168698f2a39c1f8b137c23620 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 4 Sep 2025 19:10:06 +0530 Subject: [PATCH 05/66] MCLOUD-14015:Checking file permissions --- tests/functional/Codeception/Docker.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 75774be7..fb4e9feb 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -269,12 +269,19 @@ public function uploadToContainer(string $source, string $destination, string $c */ public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) { + // Check if the system has write permissions for the temporary directory + $tempDir = sys_get_temp_dir(); + if (!is_writable($tempDir)) { + throw new \RuntimeException("Temporary directory is not writable: $tempDir"); + } + $tmpFile = tempnam(sys_get_temp_dir(), md5($source)); if (!file_exists($tmpFile)) { throw new \RuntimeException("Temporary file is empty or not created: $tmpFile"); } - - + if (!is_writable($tmpFile)) { + throw new \RuntimeException("Temporary file is not writable: $tmpFile"); + } if (!$this->downloadFromContainer($source, $tmpFile, $container)) { $errorMessage = sprintf( "Failed to download file from container. Source: %s, Container: %s, Temporary File: %s",$source, $container,$tmpFile From bb0634fc42ce92e1a74f74b09e763491454d7b24 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 4 Sep 2025 19:28:52 +0530 Subject: [PATCH 06/66] MCLOUD-14015:small change --- tests/functional/Codeception/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index fb4e9feb..474fddff 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -267,7 +267,7 @@ public function uploadToContainer(string $source, string $destination, string $c * @param string $container * @return string|false */ - public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) + public function grabFileContent(string $source, string $container = self::BUILD_CONTAINER) { // Check if the system has write permissions for the temporary directory $tempDir = sys_get_temp_dir(); From 378d805fb8f0cc3d6a89fa1cd6e31f994155fb2a Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 8 Sep 2025 18:25:38 +0530 Subject: [PATCH 07/66] Small fix --- tests/functional/Codeception/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 474fddff..fb4e9feb 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -267,7 +267,7 @@ public function uploadToContainer(string $source, string $destination, string $c * @param string $container * @return string|false */ - public function grabFileContent(string $source, string $container = self::BUILD_CONTAINER) + public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) { // Check if the system has write permissions for the temporary directory $tempDir = sys_get_temp_dir(); From e0bdc6a6ac1562cf53649e7e8360648280b0e73d Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 13:07:34 +0530 Subject: [PATCH 08/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index fb4e9feb..52ce9457 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -201,7 +201,10 @@ public function downloadFromContainer(string $source, string $destination, strin ->destination($destination) ->dir($this->getWorkDirPath()) ->run(); - + if (!$result->wasSuccessful()) { + throw new \RuntimeException("Task failed: " . $result); + } + static::$output = $result->getMessage(); return $result->wasSuccessful(); From f779922de026c7a1f737a954553d3d92449a9276 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 13:19:36 +0530 Subject: [PATCH 09/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 52ce9457..3aeb80aa 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -201,9 +201,10 @@ public function downloadFromContainer(string $source, string $destination, strin ->destination($destination) ->dir($this->getWorkDirPath()) ->run(); - if (!$result->wasSuccessful()) { - throw new \RuntimeException("Task failed: " . $result); - } + if (!$result->wasSuccessful()) { + $message = is_string($result->getMessage()) ? $result->getMessage() : json_encode($result->getMessage()); + throw new \RuntimeException("Task failed: " . $message); + } static::$output = $result->getMessage(); From 28209d360e1d42b7b0922c2b1ff75388e99ea767 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 13:29:26 +0530 Subject: [PATCH 10/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 3aeb80aa..6f265c70 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -202,7 +202,12 @@ public function downloadFromContainer(string $source, string $destination, strin ->dir($this->getWorkDirPath()) ->run(); if (!$result->wasSuccessful()) { - $message = is_string($result->getMessage()) ? $result->getMessage() : json_encode($result->getMessage()); + $message = $result->getMessage(); + if (empty($message)) { + $message = 'Unknown error occurred during task execution.'; + } elseif (!is_string($message)) { + $message = json_encode($message); + } throw new \RuntimeException("Task failed: " . $message); } From d55a13396beb40d10ea51962b3696126a4276e79 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 13:43:57 +0530 Subject: [PATCH 11/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 6f265c70..408846e4 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -186,6 +186,23 @@ public function downloadFromContainer(string $source, string $destination, strin if (empty($container)) { throw new \RuntimeException("Container name is empty."); } + $printOutput = $this->_getConfig('printOutput'); + if (!is_bool($printOutput)) { + throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); + } + + // Validate 'system_magento_dir' configuration + $systemMagentoDir = $this->_getConfig('system_magento_dir'); + if (empty($systemMagentoDir)) { + throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); + } + + // Validate source path + $fullSourcePath = $systemMagentoDir . $source; + if (!is_string($fullSourcePath) || empty($fullSourcePath)) { + throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); + } + // Construct the full source path $fullSourcePath = $this->_getConfig('system_magento_dir') . $source; From f97bd3a2aa7826f342c8056a325caa32b4f48550 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 13:56:10 +0530 Subject: [PATCH 12/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 123 ++++++++++++++---------- 1 file changed, 73 insertions(+), 50 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 408846e4..93bc2ca1 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -175,64 +175,87 @@ static function ($val) use ($magentoRoot) { * @return bool */ public function downloadFromContainer(string $source, string $destination, string $container): bool - { - // Validate inputs - if (empty($source)) { - throw new \RuntimeException("Source path is empty."); - } - if (empty($destination)) { - throw new \RuntimeException("Destination path is empty."); - } - if (empty($container)) { - throw new \RuntimeException("Container name is empty."); - } - $printOutput = $this->_getConfig('printOutput'); - if (!is_bool($printOutput)) { - throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); - } +{ + // Validate inputs + if (empty($source)) { + throw new \RuntimeException("Source path is empty."); + } + if (empty($destination)) { + throw new \RuntimeException("Destination path is empty."); + } + if (empty($container)) { + throw new \RuntimeException("Container name is empty."); + } - // Validate 'system_magento_dir' configuration - $systemMagentoDir = $this->_getConfig('system_magento_dir'); - if (empty($systemMagentoDir)) { - throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); - } + // Log inputs + error_log("Starting downloadFromContainer..."); + error_log("Source: $source"); + error_log("Destination: $destination"); + error_log("Container: $container"); - // Validate source path - $fullSourcePath = $systemMagentoDir . $source; - if (!is_string($fullSourcePath) || empty($fullSourcePath)) { - throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); - } + $printOutput = $this->_getConfig('printOutput'); + if (!is_bool($printOutput)) { + throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); + } + // Validate 'system_magento_dir' configuration + $systemMagentoDir = $this->_getConfig('system_magento_dir'); + if (empty($systemMagentoDir)) { + throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); + } - // Construct the full source path - $fullSourcePath = $this->_getConfig('system_magento_dir') . $source; - if (empty($fullSourcePath)) { - throw new \RuntimeException("Failed to construct full source path. Check 'system_magento_dir' configuration."); - } + // Log configuration + error_log("System Magento Directory: $systemMagentoDir"); - /** @var Result $result */ - $result = $this->taskCopyFromDocker($container) - ->printOutput($this->_getConfig('printOutput')) - ->interactive(false) - ->source($this->_getConfig('system_magento_dir') . $source) - ->destination($destination) - ->dir($this->getWorkDirPath()) - ->run(); - if (!$result->wasSuccessful()) { - $message = $result->getMessage(); - if (empty($message)) { - $message = 'Unknown error occurred during task execution.'; - } elseif (!is_string($message)) { - $message = json_encode($message); - } - throw new \RuntimeException("Task failed: " . $message); - } - - static::$output = $result->getMessage(); + // Validate source path + $fullSourcePath = $systemMagentoDir . $source; + if (!is_string($fullSourcePath) || empty($fullSourcePath)) { + throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); + } - return $result->wasSuccessful(); + // Log full source path + error_log("Full Source Path: $fullSourcePath"); + + // Construct the full source path + $fullSourcePath = $this->_getConfig('system_magento_dir') . $source; + if (empty($fullSourcePath)) { + throw new \RuntimeException("Failed to construct full source path. Check 'system_magento_dir' configuration."); } + // Log task execution + error_log("Executing taskCopyFromDocker..."); + + /** @var Result $result */ + $result = $this->taskCopyFromDocker($container) + ->printOutput($this->_getConfig('printOutput')) + ->interactive(false) + ->source($this->_getConfig('system_magento_dir') . $source) + ->destination($destination) + ->dir($this->getWorkDirPath()) + ->run(); + + // Log result status + if ($result->wasSuccessful()) { + error_log("taskCopyFromDocker completed successfully."); + } else { + $message = $result->getMessage(); + if (empty($message)) { + $message = 'Unknown error occurred during task execution.'; + } elseif (!is_string($message)) { + $message = json_encode($message); + } + error_log("taskCopyFromDocker failed. Message: $message"); + throw new \RuntimeException("Task failed: " . $message); + } + + static::$output = $result->getMessage(); + + // Log final output + error_log("Task output: " . static::$output); + + return $result->wasSuccessful(); +} + /** * Creates folder on Docker * From 6f223088d1b6768bdd117eee42aab31a2951bb90 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 14:07:38 +0530 Subject: [PATCH 13/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 152 ++++++++++++------------ 1 file changed, 74 insertions(+), 78 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 93bc2ca1..1e80a1e7 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -175,87 +175,83 @@ static function ($val) use ($magentoRoot) { * @return bool */ public function downloadFromContainer(string $source, string $destination, string $container): bool -{ - // Validate inputs - if (empty($source)) { - throw new \RuntimeException("Source path is empty."); - } - if (empty($destination)) { - throw new \RuntimeException("Destination path is empty."); - } - if (empty($container)) { - throw new \RuntimeException("Container name is empty."); - } - - // Log inputs - error_log("Starting downloadFromContainer..."); - error_log("Source: $source"); - error_log("Destination: $destination"); - error_log("Container: $container"); - - $printOutput = $this->_getConfig('printOutput'); - if (!is_bool($printOutput)) { - throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); - } - - // Validate 'system_magento_dir' configuration - $systemMagentoDir = $this->_getConfig('system_magento_dir'); - if (empty($systemMagentoDir)) { - throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); - } - - // Log configuration - error_log("System Magento Directory: $systemMagentoDir"); - - // Validate source path - $fullSourcePath = $systemMagentoDir . $source; - if (!is_string($fullSourcePath) || empty($fullSourcePath)) { - throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); - } - - // Log full source path - error_log("Full Source Path: $fullSourcePath"); - - // Construct the full source path - $fullSourcePath = $this->_getConfig('system_magento_dir') . $source; - if (empty($fullSourcePath)) { - throw new \RuntimeException("Failed to construct full source path. Check 'system_magento_dir' configuration."); - } - - // Log task execution - error_log("Executing taskCopyFromDocker..."); - - /** @var Result $result */ - $result = $this->taskCopyFromDocker($container) - ->printOutput($this->_getConfig('printOutput')) - ->interactive(false) - ->source($this->_getConfig('system_magento_dir') . $source) - ->destination($destination) - ->dir($this->getWorkDirPath()) - ->run(); - - // Log result status - if ($result->wasSuccessful()) { - error_log("taskCopyFromDocker completed successfully."); - } else { - $message = $result->getMessage(); - if (empty($message)) { - $message = 'Unknown error occurred during task execution.'; - } elseif (!is_string($message)) { - $message = json_encode($message); + { + // Validate inputs + if (empty($source)) { + throw new \RuntimeException("Source path is empty."); } - error_log("taskCopyFromDocker failed. Message: $message"); - throw new \RuntimeException("Task failed: " . $message); + if (empty($destination)) { + throw new \RuntimeException("Destination path is empty."); + } + if (empty($container)) { + throw new \RuntimeException("Container name is empty."); + } + + // Log inputs + error_log("Starting downloadFromContainer..."); + error_log("Source: $source"); + error_log("Destination: $destination"); + error_log("Container: $container"); + + $printOutput = $this->_getConfig('printOutput'); + if (!is_bool($printOutput)) { + throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); + } + + // Validate 'system_magento_dir' configuration + $systemMagentoDir = $this->_getConfig('system_magento_dir'); + if (empty($systemMagentoDir)) { + throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); + } + + // Log configuration + error_log("System Magento Directory: $systemMagentoDir"); + + // Validate source path + $fullSourcePath = $systemMagentoDir . $source; + if (!is_string($fullSourcePath) || empty($fullSourcePath)) { + throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); + } + + // Log full source path + error_log("Full Source Path: $fullSourcePath"); + + // Log task execution + error_log("Executing taskCopyFromDocker..."); + + /** @var Result $result */ + $result = $this->taskCopyFromDocker($container) + ->printOutput($this->_getConfig('printOutput')) + ->interactive(false) + ->source($fullSourcePath) + ->destination($destination) + ->dir($this->getWorkDirPath()) + ->run(); + + // Log result status + if ($result->wasSuccessful()) { + error_log("taskCopyFromDocker completed successfully."); + } else { + error_log("Inspecting Result object..."); + var_dump($result); // Inspect the full Result object + $message = $result->getMessage(); + if (empty($message)) { + $message = 'Unknown error occurred during task execution.'; + } elseif (!is_string($message)) { + $message = json_encode($message); + } + error_log("taskCopyFromDocker failed. Message: $message"); + throw new \RuntimeException("Task failed: " . $message); + } + + static::$output = $result->getMessage(); + + // Log final output + error_log("Task output: " . static::$output); + + return $result->wasSuccessful(); } - static::$output = $result->getMessage(); - - // Log final output - error_log("Task output: " . static::$output); - - return $result->wasSuccessful(); -} - /** * Creates folder on Docker * From 54eeaffcdd017761438e131d6ec3f6727a1e97ae Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 9 Sep 2025 14:24:10 +0530 Subject: [PATCH 14/66] MCLOUD-14015:Adding debugging statements --- tests/functional/Codeception/Docker.php | 133 +++++++++++++----------- 1 file changed, 72 insertions(+), 61 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 1e80a1e7..1c3c8202 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -175,50 +175,50 @@ static function ($val) use ($magentoRoot) { * @return bool */ public function downloadFromContainer(string $source, string $destination, string $container): bool - { - // Validate inputs - if (empty($source)) { - throw new \RuntimeException("Source path is empty."); - } - if (empty($destination)) { - throw new \RuntimeException("Destination path is empty."); - } - if (empty($container)) { - throw new \RuntimeException("Container name is empty."); - } - - // Log inputs - error_log("Starting downloadFromContainer..."); - error_log("Source: $source"); - error_log("Destination: $destination"); - error_log("Container: $container"); - - $printOutput = $this->_getConfig('printOutput'); - if (!is_bool($printOutput)) { - throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); - } - - // Validate 'system_magento_dir' configuration - $systemMagentoDir = $this->_getConfig('system_magento_dir'); - if (empty($systemMagentoDir)) { - throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); - } - - // Log configuration - error_log("System Magento Directory: $systemMagentoDir"); - - // Validate source path - $fullSourcePath = $systemMagentoDir . $source; - if (!is_string($fullSourcePath) || empty($fullSourcePath)) { - throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); - } - - // Log full source path - error_log("Full Source Path: $fullSourcePath"); - - // Log task execution +{ + // Validate inputs + if (empty($source)) { + throw new \RuntimeException("Source path is empty."); + } + if (empty($destination)) { + throw new \RuntimeException("Destination path is empty."); + } + if (empty($container)) { + throw new \RuntimeException("Container name is empty."); + } + + // Log inputs + error_log("Starting downloadFromContainer..."); + error_log("Source: $source"); + error_log("Destination: $destination"); + error_log("Container: $container"); + + $printOutput = $this->_getConfig('printOutput'); + if (!is_bool($printOutput)) { + throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); + } + + // Validate 'system_magento_dir' configuration + $systemMagentoDir = $this->_getConfig('system_magento_dir'); + if (empty($systemMagentoDir)) { + throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); + } + + // Log configuration + error_log("System Magento Directory: $systemMagentoDir"); + + // Validate source path + $fullSourcePath = $systemMagentoDir . $source; + if (!is_string($fullSourcePath) || empty($fullSourcePath)) { + throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); + } + + // Log full source path + error_log("Full Source Path: $fullSourcePath"); + + // Attempt to use taskCopyFromDocker + try { error_log("Executing taskCopyFromDocker..."); - /** @var Result $result */ $result = $this->taskCopyFromDocker($container) ->printOutput($this->_getConfig('printOutput')) @@ -227,31 +227,42 @@ public function downloadFromContainer(string $source, string $destination, strin ->destination($destination) ->dir($this->getWorkDirPath()) ->run(); - + // Log result status if ($result->wasSuccessful()) { error_log("taskCopyFromDocker completed successfully."); + static::$output = $result->getMessage(); + error_log("Task output: " . static::$output); + return true; } else { - error_log("Inspecting Result object..."); - var_dump($result); // Inspect the full Result object - $message = $result->getMessage(); - if (empty($message)) { - $message = 'Unknown error occurred during task execution.'; - } elseif (!is_string($message)) { - $message = json_encode($message); - } - error_log("taskCopyFromDocker failed. Message: $message"); - throw new \RuntimeException("Task failed: " . $message); + error_log("taskCopyFromDocker failed. Falling back to docker cp..."); } - - static::$output = $result->getMessage(); - - // Log final output - error_log("Task output: " . static::$output); - - return $result->wasSuccessful(); + } catch (\Exception $e) { + error_log("taskCopyFromDocker threw an exception: " . $e->getMessage()); + error_log("Falling back to docker cp..."); } + // Fallback to docker cp command + $command = sprintf( + 'docker cp %s:%s %s', + escapeshellarg($container), + escapeshellarg($fullSourcePath), + escapeshellarg($destination) + ); + + exec($command, $output, $returnVar); + + if ($returnVar !== 0) { + throw new \RuntimeException("Failed to execute docker cp command: " . implode("\n", $output)); + } + else { + error_log("docker cp command executed: $command"); + } + + error_log("docker cp command executed successfully."); + return true; +} + /** * Creates folder on Docker * From c1be76565f32574f5db9168f742a271c32a2ae38 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 10 Sep 2025 15:37:14 +0530 Subject: [PATCH 15/66] Small change --- tests/functional/Codeception/Docker.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 1c3c8202..64cf3f49 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -212,7 +212,9 @@ public function downloadFromContainer(string $source, string $destination, strin if (!is_string($fullSourcePath) || empty($fullSourcePath)) { throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); } - + error_log("Constructed Full Source Path: $fullSourcePath"); + $fullSourcePath2= rtrim($systemMagentoDir, '/') . '/' . ltrim($source, '/'); + error_log("Constructed Full Source Path2: $fullSourcePath2"); // Log full source path error_log("Full Source Path: $fullSourcePath"); From 28c936b9170c28f056f7e402012defd72937f765 Mon Sep 17 00:00:00 2001 From: Prateek Karanpuria Date: Wed, 10 Sep 2025 19:51:23 +0530 Subject: [PATCH 16/66] MCLOUD-14063: Fixed broken mailhog docker image --- images/mailhog/1.0/Dockerfile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/images/mailhog/1.0/Dockerfile b/images/mailhog/1.0/Dockerfile index f7d70d66..7249b32c 100644 --- a/images/mailhog/1.0/Dockerfile +++ b/images/mailhog/1.0/Dockerfile @@ -2,17 +2,14 @@ # MailHog Dockerfile # -FROM golang:1.17.9-alpine - -# Install MailHog: -RUN apk --no-cache add --virtual build-dependencies \ - git \ - && mkdir -p /root/gocode \ - && export GOPATH=/root/gocode \ - && go get github.com/mailhog/MailHog@v1.0.1 \ - && mv /root/gocode/bin/MailHog /usr/local/bin \ - && rm -rf /root/gocode \ - && apk del --purge build-dependencies + +FROM golang:1.22-alpine + +# Install MailHog +RUN apk --no-cache add git \ + && go install github.com/mailhog/MailHog@v1.0.1 \ + && mv /go/bin/MailHog /usr/local/bin/MailHog \ + && apk del git # Add mailhog user/group with uid/gid 1000. # This is a workaround for boot2docker issue #581, see From 165bee1916b69c2be26245d48098a204a733c3af Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 12:14:30 +0530 Subject: [PATCH 17/66] MCLOUD-14015:Change in docker cp command --- tests/functional/Robo/Tasks/CopyFromDocker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 2dd862d4..39ab9651 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -80,7 +80,7 @@ public function destination(string $destination): self public function getCommand(): string { return sprintf( - 'docker cp "$(docker-compose ps -q %s)":%s %s', + 'docker-compose cp %s:%s %s', $this->container, $this->source, $this->destination @@ -108,4 +108,4 @@ public function run(): Result return $this->executeCommand($this->getCommand()); } -} +} \ No newline at end of file From 7272ba7087ad7e329d901a9985902fae83bf4e34 Mon Sep 17 00:00:00 2001 From: Prateek Karanpuria Date: Thu, 11 Sep 2025 17:10:19 +0530 Subject: [PATCH 18/66] MCLOUD-14063: Fixed broken mailhog docker image when tested image build locally --- images/mailhog/1.0/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/images/mailhog/1.0/Dockerfile b/images/mailhog/1.0/Dockerfile index 7249b32c..87b64951 100644 --- a/images/mailhog/1.0/Dockerfile +++ b/images/mailhog/1.0/Dockerfile @@ -2,8 +2,7 @@ # MailHog Dockerfile # - -FROM golang:1.22-alpine +FROM golang:1.24-alpine # Install MailHog RUN apk --no-cache add git \ From 1089fd3aca130b5604c789775558c8fd9f73afe8 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 17:38:39 +0530 Subject: [PATCH 19/66] MCLOUD-14015:Added the small fix for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 39ab9651..68cbcb35 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,9 +79,13 @@ public function destination(string $destination): self */ public function getCommand(): string { + $processId=sprintf( + 'docker-compose ps -q %s', + $this->container + ); return sprintf( 'docker-compose cp %s:%s %s', - $this->container, + $processId, $this->source, $this->destination ); From 49f8ba558553bee094f194b2e3866783bda1552e Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 18:00:03 +0530 Subject: [PATCH 20/66] MCLOUD-14015:Added the small fix for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 68cbcb35..f3a27b8e 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,10 +79,13 @@ public function destination(string $destination): self */ public function getCommand(): string { + error_log("Container content: " . print_r($this->container, true)); $processId=sprintf( 'docker-compose ps -q %s', $this->container ); + error_log("Process ID: " . print_r($processId, true)); + error_log(print_r($processId)); return sprintf( 'docker-compose cp %s:%s %s', $processId, From c6533975cfaa34e7aeb4d9591385af1481af00b8 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 18:16:47 +0530 Subject: [PATCH 21/66] MCLOUD-14015:Added the small fix for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index f3a27b8e..5fa4a5ba 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,12 +79,12 @@ public function destination(string $destination): self */ public function getCommand(): string { - error_log("Container content: " . print_r($this->container, true)); + error_log("Container content: " . print_r($this->container)); $processId=sprintf( 'docker-compose ps -q %s', $this->container ); - error_log("Process ID: " . print_r($processId, true)); + error_log("Process ID: " . print_r($processId)); error_log(print_r($processId)); return sprintf( 'docker-compose cp %s:%s %s', From fd760e1003cc964ea0589906a8f5c00df7e2f401 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 18:26:13 +0530 Subject: [PATCH 22/66] MCLOUD-14015:Added the small fix for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 5fa4a5ba..2e58be6e 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,7 +79,7 @@ public function destination(string $destination): self */ public function getCommand(): string { - error_log("Container content: " . print_r($this->container)); + error_log("Container content: " . print_r($this->container,true)); $processId=sprintf( 'docker-compose ps -q %s', $this->container From deb360e4b7abd1b4b50f7ea0bea7b9861e898ff5 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 18:36:14 +0530 Subject: [PATCH 23/66] MCLOUD-14015:Added the small fix for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 2e58be6e..abd3113e 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,16 +79,9 @@ public function destination(string $destination): self */ public function getCommand(): string { - error_log("Container content: " . print_r($this->container,true)); - $processId=sprintf( - 'docker-compose ps -q %s', - $this->container - ); - error_log("Process ID: " . print_r($processId)); - error_log(print_r($processId)); return sprintf( - 'docker-compose cp %s:%s %s', - $processId, + 'docker cp "$(docker-compose ps -q %s)":%s %s', + $this->container, $this->source, $this->destination ); From 6520b6681af41ea0e534fa3c82460721cbd4eef1 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 18:45:58 +0530 Subject: [PATCH 24/66] MCLOUD-14015:Removed all logs from Docker.php --- tests/functional/Codeception/Docker.php | 108 ++---------------------- 1 file changed, 6 insertions(+), 102 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 64cf3f49..ac65e51d 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -175,96 +175,21 @@ static function ($val) use ($magentoRoot) { * @return bool */ public function downloadFromContainer(string $source, string $destination, string $container): bool -{ - // Validate inputs - if (empty($source)) { - throw new \RuntimeException("Source path is empty."); - } - if (empty($destination)) { - throw new \RuntimeException("Destination path is empty."); - } - if (empty($container)) { - throw new \RuntimeException("Container name is empty."); - } - - // Log inputs - error_log("Starting downloadFromContainer..."); - error_log("Source: $source"); - error_log("Destination: $destination"); - error_log("Container: $container"); - - $printOutput = $this->_getConfig('printOutput'); - if (!is_bool($printOutput)) { - throw new \RuntimeException("Invalid 'printOutput' configuration. Expected a boolean value."); - } - - // Validate 'system_magento_dir' configuration - $systemMagentoDir = $this->_getConfig('system_magento_dir'); - if (empty($systemMagentoDir)) { - throw new \RuntimeException("Invalid 'system_magento_dir' configuration. It cannot be empty."); - } - - // Log configuration - error_log("System Magento Directory: $systemMagentoDir"); - - // Validate source path - $fullSourcePath = $systemMagentoDir . $source; - if (!is_string($fullSourcePath) || empty($fullSourcePath)) { - throw new \RuntimeException("Invalid source path. Constructed path: $fullSourcePath"); - } - error_log("Constructed Full Source Path: $fullSourcePath"); - $fullSourcePath2= rtrim($systemMagentoDir, '/') . '/' . ltrim($source, '/'); - error_log("Constructed Full Source Path2: $fullSourcePath2"); - // Log full source path - error_log("Full Source Path: $fullSourcePath"); - - // Attempt to use taskCopyFromDocker - try { - error_log("Executing taskCopyFromDocker..."); + { /** @var Result $result */ $result = $this->taskCopyFromDocker($container) ->printOutput($this->_getConfig('printOutput')) ->interactive(false) - ->source($fullSourcePath) + ->source($this->_getConfig('system_magento_dir') . $source) ->destination($destination) ->dir($this->getWorkDirPath()) ->run(); - // Log result status - if ($result->wasSuccessful()) { - error_log("taskCopyFromDocker completed successfully."); - static::$output = $result->getMessage(); - error_log("Task output: " . static::$output); - return true; - } else { - error_log("taskCopyFromDocker failed. Falling back to docker cp..."); - } - } catch (\Exception $e) { - error_log("taskCopyFromDocker threw an exception: " . $e->getMessage()); - error_log("Falling back to docker cp..."); - } - - // Fallback to docker cp command - $command = sprintf( - 'docker cp %s:%s %s', - escapeshellarg($container), - escapeshellarg($fullSourcePath), - escapeshellarg($destination) - ); - - exec($command, $output, $returnVar); + static::$output = $result->getMessage(); - if ($returnVar !== 0) { - throw new \RuntimeException("Failed to execute docker cp command: " . implode("\n", $output)); - } - else { - error_log("docker cp command executed: $command"); + return $result->wasSuccessful(); } - error_log("docker cp command executed successfully."); - return true; -} - /** * Creates folder on Docker * @@ -327,30 +252,9 @@ public function uploadToContainer(string $source, string $destination, string $c */ public function grabFileContent(string $source, string $container = self::DEPLOY_CONTAINER) { - // Check if the system has write permissions for the temporary directory - $tempDir = sys_get_temp_dir(); - if (!is_writable($tempDir)) { - throw new \RuntimeException("Temporary directory is not writable: $tempDir"); - } - $tmpFile = tempnam(sys_get_temp_dir(), md5($source)); - if (!file_exists($tmpFile)) { - throw new \RuntimeException("Temporary file is empty or not created: $tmpFile"); - } - if (!is_writable($tmpFile)) { - throw new \RuntimeException("Temporary file is not writable: $tmpFile"); - } - if (!$this->downloadFromContainer($source, $tmpFile, $container)) { - $errorMessage = sprintf( - "Failed to download file from container. Source: %s, Container: %s, Temporary File: %s",$source, $container,$tmpFile - ); - throw new \RuntimeException($errorMessage); - } - // static::$output = $this->downloadFromContainer($source, $tmpFile, $container); - $content = file_get_contents($tmpFile); - if ($content === false || $content === '') { - throw new \RuntimeException("File is empty: $source"); - } + $this->downloadFromContainer($source, $tmpFile, $container); + return file_get_contents($tmpFile); } } From 2a1adf13ec272c02e049af19b755fdf6f0a20d11 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 19:02:04 +0530 Subject: [PATCH 25/66] MCLOUD-14015:Adding logs --- tests/functional/Robo/Tasks/CopyFromDocker.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index abd3113e..d22b470a 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,12 +79,21 @@ public function destination(string $destination): self */ public function getCommand(): string { - return sprintf( - 'docker cp "$(docker-compose ps -q %s)":%s %s', + // Log individual parts + error_log("Container: " . $this->container); + error_log("Source path: " . $this->source); + error_log("Destination path: " . $this->destination); + + // Compose the command + $command = sprintf( + 'docker-compose cp %s:%s %s', $this->container, $this->source, $this->destination ); + + // Log the final command + error_log("Final docker command: " . $command); } /** From bfbf6d9fcfee5a19ff7556fe03641ee728f585d8 Mon Sep 17 00:00:00 2001 From: Prateek Karanpuria Date: Thu, 11 Sep 2025 19:03:11 +0530 Subject: [PATCH 26/66] MCLOUD-14063: Fixed broken PHP8 images --- images/php/8.1-cli/Dockerfile | 3 +-- images/php/8.1-fpm/Dockerfile | 3 +-- images/php/8.2-cli/Dockerfile | 3 +-- images/php/8.2-fpm/Dockerfile | 3 +-- images/php/8.3-cli/Dockerfile | 3 +-- images/php/8.3-fpm/Dockerfile | 3 +-- images/php/8.4-cli/Dockerfile | 3 +-- images/php/8.4-fpm/Dockerfile | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile index d810cd61..407263db 100644 --- a/images/php/8.1-cli/Dockerfile +++ b/images/php/8.1-cli/Dockerfile @@ -56,7 +56,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -65,7 +64,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.1-fpm/Dockerfile b/images/php/8.1-fpm/Dockerfile index f9f544dd..4da8e6e2 100644 --- a/images/php/8.1-fpm/Dockerfile +++ b/images/php/8.1-fpm/Dockerfile @@ -37,7 +37,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -46,7 +45,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.2-cli/Dockerfile b/images/php/8.2-cli/Dockerfile index 54e8f1a6..f8f3114c 100644 --- a/images/php/8.2-cli/Dockerfile +++ b/images/php/8.2-cli/Dockerfile @@ -56,7 +56,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -65,7 +64,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.2-fpm/Dockerfile b/images/php/8.2-fpm/Dockerfile index 9a3a83da..9fc37b02 100644 --- a/images/php/8.2-fpm/Dockerfile +++ b/images/php/8.2-fpm/Dockerfile @@ -37,7 +37,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -46,7 +45,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.3-cli/Dockerfile b/images/php/8.3-cli/Dockerfile index d4154a5f..e5d0addc 100644 --- a/images/php/8.3-cli/Dockerfile +++ b/images/php/8.3-cli/Dockerfile @@ -56,7 +56,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -65,7 +64,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.3-fpm/Dockerfile b/images/php/8.3-fpm/Dockerfile index d1342ab1..5872837e 100644 --- a/images/php/8.3-fpm/Dockerfile +++ b/images/php/8.3-fpm/Dockerfile @@ -37,7 +37,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -46,7 +45,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.4-cli/Dockerfile b/images/php/8.4-cli/Dockerfile index d04d9411..5235cc19 100644 --- a/images/php/8.4-cli/Dockerfile +++ b/images/php/8.4-cli/Dockerfile @@ -77,7 +77,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -86,7 +85,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ diff --git a/images/php/8.4-fpm/Dockerfile b/images/php/8.4-fpm/Dockerfile index 1e610bef..e377d59d 100644 --- a/images/php/8.4-fpm/Dockerfile +++ b/images/php/8.4-fpm/Dockerfile @@ -58,7 +58,6 @@ RUN apt-get update \ gnupg2 \ ca-certificates \ lsb-release \ - software-properties-common \ libbz2-dev \ libjpeg62-turbo-dev \ libpng-dev \ @@ -67,7 +66,7 @@ RUN apt-get update \ libgpgme11-dev \ libicu-dev \ libldap2-dev \ - libpcre3-dev \ + libpcre2-dev \ libpspell-dev \ libtidy-dev \ libxslt1-dev \ From 794a4dfbb8e90568716de1e289632a47a21e2946 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 11 Sep 2025 19:11:11 +0530 Subject: [PATCH 27/66] MCLOUD-14015:Adding logs --- tests/functional/Robo/Tasks/CopyFromDocker.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index d22b470a..39ab9651 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,21 +79,12 @@ public function destination(string $destination): self */ public function getCommand(): string { - // Log individual parts - error_log("Container: " . $this->container); - error_log("Source path: " . $this->source); - error_log("Destination path: " . $this->destination); - - // Compose the command - $command = sprintf( + return sprintf( 'docker-compose cp %s:%s %s', $this->container, $this->source, $this->destination ); - - // Log the final command - error_log("Final docker command: " . $command); } /** From 7ab39eb517aea39bf59b774d7d61fdb239672ed3 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Fri, 12 Sep 2025 11:27:51 +0530 Subject: [PATCH 28/66] MCLOUD-14015:Making changes in docker cp command --- tests/functional/Robo/Tasks/CopyFromDocker.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 39ab9651..b36c7965 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,12 +79,15 @@ public function destination(string $destination): self */ public function getCommand(): string { - return sprintf( - 'docker-compose cp %s:%s %s', - $this->container, - $this->source, - $this->destination - ); + //code for test purpose only + $dockerComposeCmd = 'docker-compose ps -q %s'; + $dockerCpCmd = 'docker cp "$(%s)":%s %s'; + $container = $this->container; + $source = $this->source; + $destination = $this->destination; + $innerCmd = sprintf($dockerComposeCmd, $container); + return sprintf($dockerCpCmd, $innerCmd, $source, $destination); + } /** From 285808af49e850cd5946fe7622cd5fd9c1f48f97 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Fri, 12 Sep 2025 11:40:01 +0530 Subject: [PATCH 29/66] MCLOUD-14015:Making changes in docker cp command --- .../functional/Robo/Tasks/CopyFromDocker.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index b36c7965..6b8e7a6d 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,15 +79,18 @@ public function destination(string $destination): self */ public function getCommand(): string { - //code for test purpose only - $dockerComposeCmd = 'docker-compose ps -q %s'; - $dockerCpCmd = 'docker cp "$(%s)":%s %s'; - $container = $this->container; - $source = $this->source; - $destination = $this->destination; - $innerCmd = sprintf($dockerComposeCmd, $container); - return sprintf($dockerCpCmd, $innerCmd, $source, $destination); - + return sprintf( + 'docker-compose cp %s:%s %s', + $this->container, + $this->source, + $this->destination + ); + // return sprintf( + // 'docker cp "$(docker-compose ps -q %s)":%s %s', + // $this->container, + // $this->source, + // $this->destination + // ); } /** From 799f2c1bdb0a839eac811b93b1b65d3244d52f44 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Fri, 12 Sep 2025 18:30:09 +0530 Subject: [PATCH 30/66] MCLOUD-14015:Changes in docker command --- tests/functional/Robo/Tasks/CopyFromDocker.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 6b8e7a6d..f9a28c68 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,18 +79,18 @@ public function destination(string $destination): self */ public function getCommand(): string { - return sprintf( - 'docker-compose cp %s:%s %s', - $this->container, - $this->source, - $this->destination - ); // return sprintf( - // 'docker cp "$(docker-compose ps -q %s)":%s %s', + // 'docker-compose cp %s:%s %s', // $this->container, // $this->source, // $this->destination // ); + return sprintf( + 'docker cp "$(docker compose ps -q %s)":%s %s', + $this->container, + $this->source, + $this->destination + ); } /** From bf10de75a9b9cb62737d0190e59c6e12d2cd0950 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 11:29:51 +0530 Subject: [PATCH 31/66] MCLOUD-14015:Format change for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index f9a28c68..c1d456b7 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -86,7 +86,7 @@ public function getCommand(): string // $this->destination // ); return sprintf( - 'docker cp "$(docker compose ps -q %s)":%s %s', + 'docker cp "$(docker compose ps -q %s)":"%s" "%s"', $this->container, $this->source, $this->destination From c656a597041adb6631bc522ffb8ca49b2bc7a671 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 13:00:11 +0530 Subject: [PATCH 32/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 2 +- .../functional/Robo/Tasks/CopyFromDocker.php | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index ac65e51d..f734cc01 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -108,7 +108,7 @@ public function runDockerComposeCommand(string $command): bool public function resetFilesOwner(): bool { return $this->runDockerComposeCommand( - 'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' + 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' ); } diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index c1d456b7..55849d84 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,18 +79,19 @@ public function destination(string $destination): self */ public function getCommand(): string { - // return sprintf( - // 'docker-compose cp %s:%s %s', - // $this->container, - // $this->source, - // $this->destination - // ); - return sprintf( - 'docker cp "$(docker compose ps -q %s)":"%s" "%s"', - $this->container, - $this->source, - $this->destination - ); + + // Log the values before using them + error_log('Container for cp: ' . $this->container); + error_log('Source: ' . $this->source); + error_log('Destination: ' . $this->destination); + + return sprintf( + 'docker-compose cp %s:%s %s', + $this->container, + $this->source, + $this->destination + ); + } /** From 0229fafcd5921b218e453506540feee38b9c11d1 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 14:27:16 +0530 Subject: [PATCH 33/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index f734cc01..63eb2b9c 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,8 +107,11 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { + // return $this->runDockerComposeCommand( + // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + // ); return $this->runDockerComposeCommand( - 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + 'run build bash -c "sudo chown -R $(id -u):$(id -g) . /composer/cache"' ); } From 45432a8ea86865ed22bfd03586018e42e8752a11 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 14:40:46 +0530 Subject: [PATCH 34/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 8 ++++---- tests/functional/Robo/Tasks/CopyFromDocker.php | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 63eb2b9c..9aee4c39 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,12 +107,12 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { - // return $this->runDockerComposeCommand( - // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' - // ); return $this->runDockerComposeCommand( - 'run build bash -c "sudo chown -R $(id -u):$(id -g) . /composer/cache"' + 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' ); + // return $this->runDockerComposeCommand( + // 'run build bash -c "sudo chown -R $(id -u):$(id -g) . /composer/cache"' + // ); } /** diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 55849d84..ecb9841d 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -85,8 +85,14 @@ public function getCommand(): string error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); + // return sprintf( + // 'docker-compose cp %s:%s %s', + // $this->container, + // $this->source, + // $this->destination + // ); return sprintf( - 'docker-compose cp %s:%s %s', + 'docker cp "$(docker-compose ps -q %s)":%s %s', $this->container, $this->source, $this->destination From 4a57ff22c6aecbf3c90a120fab8231ee362a3f3f Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 14:59:01 +0530 Subject: [PATCH 35/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 9aee4c39..6a135444 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,12 +107,15 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { - return $this->runDockerComposeCommand( - 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' - ); + // return $this->runDockerComposeCommand( + // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + // ); // return $this->runDockerComposeCommand( // 'run build bash -c "sudo chown -R $(id -u):$(id -g) . /composer/cache"' // ); + $this->runDockerComposeCommand( + 'run --user root build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' + ); } /** From efb02b4b9336484d1fa5c449bc7714fbafe606b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAshvin?= <“cod”44867@adobe.com> Date: Mon, 15 Sep 2025 15:19:54 +0530 Subject: [PATCH 36/66] MCLOUD-13771 : Add support of Active MQ in cloud-docker --- src/Service/ServiceFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/ServiceFactory.php b/src/Service/ServiceFactory.php index 6d5d1e7c..290f35a3 100644 --- a/src/Service/ServiceFactory.php +++ b/src/Service/ServiceFactory.php @@ -157,7 +157,7 @@ class ServiceFactory 'image' => 'apache/activemq-artemis', 'pattern' => self::PATTERN_STD, 'config' => [ - 'ports' => [61616, 8161], + 'ports' => [61616, 61613, 8161], 'environment' => [ 'ARTEMIS_USER' => 'admin', 'ARTEMIS_PASSWORD' => 'admin', From ae091a2b7785aa44ddc115ed19ac231c3bf07fce Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 15:20:22 +0530 Subject: [PATCH 37/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 6a135444..fefd10df 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -110,12 +110,10 @@ public function resetFilesOwner(): bool // return $this->runDockerComposeCommand( // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' // ); - // return $this->runDockerComposeCommand( - // 'run build bash -c "sudo chown -R $(id -u):$(id -g) . /composer/cache"' - // ); - $this->runDockerComposeCommand( - 'run --user root build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' + return $this->runDockerComposeCommand( + 'run build bash -c "chmod -R u+rwX . /composer/cache"' ); + } /** From 87a47a1ea9cfb742ecb29718f571e3091579efcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAshvin?= <“cod”44867@adobe.com> Date: Mon, 15 Sep 2025 18:05:51 +0530 Subject: [PATCH 38/66] MCLOUD-13771: Add support of Active MQ in cloud-docker - PHPUnit fixes --- src/Service/ServiceFactory.php | 52 +++++++++++++---------- src/Test/Unit/Config/RelationshipTest.php | 19 ++++++++- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/src/Service/ServiceFactory.php b/src/Service/ServiceFactory.php index 290f35a3..1e782713 100644 --- a/src/Service/ServiceFactory.php +++ b/src/Service/ServiceFactory.php @@ -161,11 +161,11 @@ class ServiceFactory 'environment' => [ 'ARTEMIS_USER' => 'admin', 'ARTEMIS_PASSWORD' => 'admin', - ], - 'volumes' => [ + ], + 'volumes' => [ '/var/lib/artemis/data', '/var/log/artemis', - ] + ] ], ], ServiceInterface::SERVICE_NODE => [ @@ -223,12 +223,12 @@ public function __construct(FileList $fileList) } /** - * @param string $name - * @param string $version - * @param array $config - * @param string|null $image - * @param string|null $customRegistry - * @param string|null $imagePattern + * @param string $name + * @param string $version + * @param array $config + * @param string|null $image + * @param string|null $customRegistry + * @param string|null $imagePattern * @return array * @throws ConfigurationMismatchException */ @@ -241,10 +241,12 @@ public function create( ?string $imagePattern = null ): array { if (!array_key_exists($name, self::$config)) { - throw new ConfigurationMismatchException(sprintf( - 'Service "%s" is not supported', - $name - )); + throw new ConfigurationMismatchException( + sprintf( + 'Service "%s" is not supported', + $name + ) + ); } $metaConfig = self::$config[$name]; @@ -261,7 +263,7 @@ public function create( } /** - * @param string $name + * @param string $name * @return string * @throws ConfigurationMismatchException */ @@ -271,14 +273,16 @@ public function getDefaultImage(string $name): string return self::$config[$name]['image']; } - throw new ConfigurationMismatchException(sprintf( - 'Default image for %s cannot be resolved', - $name - )); + throw new ConfigurationMismatchException( + sprintf( + 'Default image for %s cannot be resolved', + $name + ) + ); } /** - * @param string $name + * @param string $name * @return string * @throws ConfigurationMismatchException */ @@ -288,10 +292,12 @@ public function getDefaultVersion(string $name): string return self::$config[$name]['version']; } - throw new ConfigurationMismatchException(sprintf( - 'Default version for %s cannot be resolved', - $name - )); + throw new ConfigurationMismatchException( + sprintf( + 'Default version for %s cannot be resolved', + $name + ) + ); } /** diff --git a/src/Test/Unit/Config/RelationshipTest.php b/src/Test/Unit/Config/RelationshipTest.php index 7def0faf..4ff6387f 100644 --- a/src/Test/Unit/Config/RelationshipTest.php +++ b/src/Test/Unit/Config/RelationshipTest.php @@ -72,6 +72,15 @@ class RelationshipTest extends TestCase 'password' => 'guest', ] ], + 'activemq-artemis' => [ + [ + 'host' => 'activemq-artemis', + 'port' => '61616', + 'username' => 'admin', + 'password' => 'admin', + 'web_console_port' => '8161', + ] + ], 'zookeeper' => [ [ 'host' => 'zookeeper', @@ -100,6 +109,7 @@ public function testGet() $esVersion = '7.7'; $osVersion = '1.1'; $rmqVersion = '3.5'; + $activemqArtemisVersion = '2.17'; $zookeeperVersion = 'latest'; $configWithType = $this->defaultConfigs; $configWithType['database'][0]['type'] = "mysql:$mysqlVersion"; @@ -108,9 +118,10 @@ public function testGet() $configWithType['elasticsearch'][0]['type'] = "elasticsearch:$esVersion"; $configWithType['opensearch'][0]['type'] = "opensearch:$osVersion"; $configWithType['rabbitmq'][0]['type'] = "rabbitmq:$rmqVersion"; + $configWithType['activemq-artemis'][0]['type'] = "activemq-artemis:$activemqArtemisVersion"; $configWithType['zookeeper'][0]['type'] = "zookeeper:$zookeeperVersion"; - $this->configMock->expects($this->exactly(9)) + $this->configMock->expects($this->exactly(10)) ->method('hasServiceEnabled') ->willReturnCallback(function ($service) { static $services = [ @@ -122,6 +133,7 @@ public function testGet() 'elasticsearch', 'opensearch', 'rabbitmq', + 'activemq-artemis', 'zookeeper' ]; @@ -134,6 +146,7 @@ public function testGet() true, true, true, + true, true ]; @@ -152,6 +165,7 @@ public function testGet() 'elasticsearch', 'opensearch', 'rabbitmq', + 'activemq-artemis', 'zookeeper' ]; @@ -162,10 +176,11 @@ public function testGet() $esVersion, $osVersion, $rmqVersion, + $activemqArtemisVersion, $zookeeperVersion ]; - $this->configMock->expects($this->exactly(7)) + $this->configMock->expects($this->exactly(8)) ->method('getServiceVersion') ->willReturnCallback(function ($service) use ( &$services, From cd43855e7f33383d1cf1657dfaa0d86287b37525 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 19:26:16 +0530 Subject: [PATCH 39/66] MCLOUD-14015:Debug for git permissions --- tests/functional/Codeception/Docker.php | 8 ++------ tests/functional/Robo/Tasks/CopyFromDocker.php | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index fefd10df..955cb2c3 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,13 +107,9 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { - // return $this->runDockerComposeCommand( - // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' - // ); return $this->runDockerComposeCommand( - 'run build bash -c "chmod -R u+rwX . /composer/cache"' - ); - + 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + ); } /** diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index ecb9841d..235c9f56 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -92,7 +92,7 @@ public function getCommand(): string // $this->destination // ); return sprintf( - 'docker cp "$(docker-compose ps -q %s)":%s %s', + 'docker-compose cp %s %s:%s', $this->container, $this->source, $this->destination From 62df8002e27ab9570b93d080e6b5c25b4915aaf3 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 15 Sep 2025 19:35:56 +0530 Subject: [PATCH 40/66] MCLOUD-14015:Debug for docker cp --- tests/functional/Robo/Tasks/CopyFromDocker.php | 9 +-------- tests/functional/Robo/Tasks/CopyToDocker.php | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 235c9f56..74808ca8 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -85,19 +85,12 @@ public function getCommand(): string error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - // return sprintf( - // 'docker-compose cp %s:%s %s', - // $this->container, - // $this->source, - // $this->destination - // ); return sprintf( - 'docker-compose cp %s %s:%s', + 'docker-compose cp %s:%s %s', $this->container, $this->source, $this->destination ); - } /** diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index a1d6d8b3..22cecf6e 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -80,7 +80,7 @@ public function destination(string $destination): self public function getCommand(): string { return sprintf( - 'docker cp "$(docker-compose ps -q %s)":%s %s', + 'docker-compose cp %s %s:%s', $this->source, $this->container, $this->destination From 3309b84870668d91bc19626a2a196ad749bfe726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAshvin?= <“cod”44867@adobe.com> Date: Wed, 17 Sep 2025 13:33:55 +0530 Subject: [PATCH 41/66] code refactor and funcational test added --- .../Service/ActiveMqArtemis.php | 2 +- src/Config/Source/CloudSource.php | 15 +- src/Service/ServiceFactory.php | 4 +- .../Acceptance/ActivemqArtemis84Cest.php | 19 +++ .../Acceptance/ActivemqArtemisCest.php | 137 ++++++++++++++++++ 5 files changed, 167 insertions(+), 10 deletions(-) create mode 100644 src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php create mode 100644 src/Test/Functional/Acceptance/ActivemqArtemisCest.php diff --git a/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php b/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php index 676f8441..0126f33b 100644 --- a/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php +++ b/src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php @@ -20,7 +20,7 @@ class ActiveMqArtemis implements ServiceBuilderInterface /** * @var ServiceFactory */ - private $serviceFactory; + private ServiceFactory $serviceFactory; /** * @param ServiceFactory $serviceFactory diff --git a/src/Config/Source/CloudSource.php b/src/Config/Source/CloudSource.php index 84802ba8..9b272026 100644 --- a/src/Config/Source/CloudSource.php +++ b/src/Config/Source/CloudSource.php @@ -25,22 +25,22 @@ class CloudSource implements SourceInterface /** * @var FileList */ - private $fileList; + private FileList $fileList; /** * @var Filesystem */ - private $filesystem; + private Filesystem $filesystem; /** * @var ServiceFactory */ - private $serviceFactory; + private ServiceFactory $serviceFactory; /** * @var array */ - private static $map = [ + private static array $map = [ ServiceInterface::SERVICE_DB => ['db', 'database', 'mysql'], ServiceInterface::SERVICE_DB_QUOTE => ['mysql-quote'], ServiceInterface::SERVICE_DB_SALES => ['mysql-sales'], @@ -67,9 +67,10 @@ public function __construct( $this->serviceFactory = $serviceFactory; } - /** - * @inheritDoc - */ + /** + * @inheritDoc + * @throws ConfigurationMismatchException + */ public function read(): Repository { $appConfigFile = $this->fileList->getAppConfig(); diff --git a/src/Service/ServiceFactory.php b/src/Service/ServiceFactory.php index 1e782713..d53d27d7 100644 --- a/src/Service/ServiceFactory.php +++ b/src/Service/ServiceFactory.php @@ -52,7 +52,7 @@ class ServiceFactory /** * @var array */ - private static $config = [ + private static array $config = [ ServiceInterface::SERVICE_PHP_CLI => [ 'image' => 'magento/magento-cloud-docker-php', 'pattern' => '%s:%s-cli-%s', @@ -207,7 +207,7 @@ class ServiceFactory /** * @var FileList */ - private $fileList; + private FileList $fileList; /** * @var string diff --git a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php new file mode 100644 index 00000000..4b459d51 --- /dev/null +++ b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php @@ -0,0 +1,19 @@ + [ + 'type' => 'activemq-artemis:' . $data['version'] + ] + ]; + $I->writeServicesYaml($servicesConfig); + + $I->generateDockerCompose($this->buildCommand($data)); + $I->replaceImagesWithCustom(); + $I->startEnvironment(); + + // Test that ActiveMQ Artemis container is running and healthy + $I->runDockerComposeCommand('ps'); + $I->seeInOutput('activemq-artemis'); + $I->seeInOutput('(healthy)'); + + // Test ActiveMQ Artemis web console accessibility (port 8161) + $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 8161'); + $I->seeInOutput(''); // nc returns empty output on success + + // Test ActiveMQ Artemis broker port accessibility (port 61616) + $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61616'); + $I->seeInOutput(''); + + // Test ActiveMQ Artemis STOMP port accessibility (port 61613) + $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61613'); + $I->seeInOutput(''); + + // Test that ActiveMQ Artemis is accessible through direct host name + $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis 61616'); + $I->seeInOutput(''); + + // Test ActiveMQ Artemis broker status using artemis CLI + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' + ); + $I->seeInOutput('Connection brokerURL'); + + // Test creating a queue using artemis CLI + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue create ' . + '--name test.queue --address test.address --routing-type anycast --user admin --password admin' + ); + $I->seeInOutput('successfully'); + + // Test listing queues to verify our test queue was created + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' + ); + $I->seeInOutput('test.queue'); + + // Test sending a message to the queue + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis producer ' . + '--destination queue://test.queue --message-count 1 --message "Hello ActiveMQ Artemis" ' . + '--user admin --password admin' + ); + $I->seeInOutput('Produced: 1 messages'); + + // Test consuming the message from the queue + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis consumer ' . + '--destination queue://test.queue --message-count 1 --user admin --password admin' + ); + $I->seeInOutput('Hello ActiveMQ Artemis'); + + // Test broker memory and connection info + $I->runDockerComposeCommand( + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' + ); + $I->seeInOutput('CONNECTION_COUNT'); + + // Test that environment variables are properly set + $I->runDockerComposeCommand('exec -T activemq-artemis env | grep ARTEMIS'); + $I->seeInOutput('ARTEMIS_USER=admin'); + $I->seeInOutput('ARTEMIS_PASSWORD=admin'); + } + + /** + * Builds build:compose command from given test data + * + * @param Example $data + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + private function buildCommand(Example $data): string + { + // Note: $data is not used as ActiveMQ Artemis is configured via services.yaml + // rather than CLI options, but parameter is kept for consistency with other tests + return '--mode=production --no-es --no-os --no-redis --no-valkey'; + } + + /** + * @return array + */ + protected function dataProvider(): array + { + return [ + [ + 'version' => '2.17', + ], + ]; + } +} From 94c3628ed6bc38f928cd934ef7879ffa66fafe7a Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 17 Sep 2025 17:01:14 +0530 Subject: [PATCH 42/66] MCLOUD-14015:Docker cp alternative --- tests/functional/Robo/Tasks/CopyFromDocker.php | 16 ++++++++++------ tests/functional/Robo/Tasks/CopyToDocker.php | 6 +++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 74808ca8..967ae8f3 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -85,12 +85,16 @@ public function getCommand(): string error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - return sprintf( - 'docker-compose cp %s:%s %s', - $this->container, - $this->source, - $this->destination - ); + $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container)))); + if (!$containerId) { + throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); + } + return sprintf( + 'docker cp %s:%s %s', + $containerId, + $this->source, + $this->destination + ); } /** diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index 22cecf6e..fcd5a12a 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -79,9 +79,13 @@ public function destination(string $destination): self */ public function getCommand(): string { + $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container)))); + if (!$containerId) { + throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); + } return sprintf( 'docker-compose cp %s %s:%s', - $this->source, + $containerId, $this->container, $this->destination ); From 9816f5e04da519121f5647fcba57eb1912091e88 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 17 Sep 2025 17:28:52 +0530 Subject: [PATCH 43/66] MCLOUD-14015:Docker cp alternative --- tests/functional/Robo/Tasks/CopyFromDocker.php | 16 ++++++++++++---- tests/functional/Robo/Tasks/CopyToDocker.php | 10 +++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 967ae8f3..69961e4e 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -85,10 +85,18 @@ public function getCommand(): string error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container)))); - if (!$containerId) { - throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); - } + $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); + + if ($rawOutput === null) { + throw new \RuntimeException('Failed to execute shell command.'); + } + + $containerId = trim($rawOutput); + + if (!$containerId) { + throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); + } + return sprintf( 'docker cp %s:%s %s', $containerId, diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index fcd5a12a..c2805a92 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -79,10 +79,18 @@ public function destination(string $destination): self */ public function getCommand(): string { - $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container)))); + $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); + + if ($rawOutput === null) { + throw new \RuntimeException('Failed to execute shell command.'); + } + + $containerId = trim($rawOutput); + if (!$containerId) { throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); } + return sprintf( 'docker-compose cp %s %s:%s', $containerId, From 873c3fc0bc88df1954f4da244f4f5b608c3c4ac4 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 17 Sep 2025 17:56:21 +0530 Subject: [PATCH 44/66] MCLOUD-14015:Docker cp alternative --- .../functional/Robo/Tasks/CopyFromDocker.php | 60 +++++++++++++------ 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 69961e4e..167dc8f4 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -77,26 +77,52 @@ public function destination(string $destination): self /** * @inheritdoc */ - public function getCommand(): string + private function runShell(string $command): string { - - // Log the values before using them - error_log('Container for cp: ' . $this->container); - error_log('Source: ' . $this->source); - error_log('Destination: ' . $this->destination); - - $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); - - if ($rawOutput === null) { - throw new \RuntimeException('Failed to execute shell command.'); + // Capture stdout and stderr + $output = shell_exec($command . ' 2>&1'); + + if ($output === null) { + throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); + } + + return trim((string)$output); } - - $containerId = trim($rawOutput); - - if (!$containerId) { - throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); + + private function getContainerId(): string + { + // First try docker-compose + $cmdCompose = sprintf( + 'docker-compose ps -q %s', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdCompose); + if ($output !== '') { + return $output; + } + + // Fallback to plain docker ps + $cmdDocker = sprintf( + 'docker ps -q --filter "name=%s$"', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdDocker); + if ($output !== '') { + return $output; + } + + throw new \RuntimeException(sprintf( + 'Container "%s" not found or not running.', + $this->container + )); } - + + public function getDockerCpCommand(): string + { + $containerId = $this->getContainerId(); + return sprintf( 'docker cp %s:%s %s', $containerId, From 247907c34627757ca82da0a973baa64d18ac9867 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 17 Sep 2025 18:10:58 +0530 Subject: [PATCH 45/66] MCLOUD-14015:Docker cp alternative --- .../functional/Robo/Tasks/CopyFromDocker.php | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 167dc8f4..d35275c1 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -77,59 +77,59 @@ public function destination(string $destination): self /** * @inheritdoc */ - private function runShell(string $command): string - { - // Capture stdout and stderr - $output = shell_exec($command . ' 2>&1'); - - if ($output === null) { - throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); - } - - return trim((string)$output); +private function runShell(string $command): string +{ + // Capture stdout and stderr + $output = shell_exec($command . ' 2>&1'); + + if ($output === null) { + throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); } - - private function getContainerId(): string - { - // First try docker-compose - $cmdCompose = sprintf( - 'docker-compose ps -q %s', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdCompose); - if ($output !== '') { - return $output; - } - - // Fallback to plain docker ps - $cmdDocker = sprintf( - 'docker ps -q --filter "name=%s$"', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdDocker); - if ($output !== '') { - return $output; - } - - throw new \RuntimeException(sprintf( - 'Container "%s" not found or not running.', - $this->container - )); + + return trim((string)$output); +} + +private function getContainerId(): string +{ + // First try docker-compose + $cmdCompose = sprintf( + 'docker-compose ps -q %s', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdCompose); + if ($output !== '') { + return $output; } - - public function getDockerCpCommand(): string - { - $containerId = $this->getContainerId(); - - return sprintf( - 'docker cp %s:%s %s', - $containerId, - $this->source, - $this->destination - ); + + // Fallback to plain docker ps + $cmdDocker = sprintf( + 'docker ps -q --filter "name=%s$"', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdDocker); + if ($output !== '') { + return $output; } + + throw new \RuntimeException(sprintf( + 'Container "%s" not found or not running.', + $this->container + )); +} + +public function getCommand(): string +{ + $containerId = $this->getContainerId(); + + return sprintf( + 'docker cp %s:%s %s', + $containerId, + $this->source, + $this->destination + ); +} /** * @inheritdoc From 809c5d94aedf41485bc8ef6f1369627036e2b478 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 17 Sep 2025 18:31:23 +0530 Subject: [PATCH 46/66] MCLOUD-14015:Docker cp alternative --- tests/functional/Robo/Tasks/CopyToDocker.php | 53 ++++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index c2805a92..0ac674f3 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -77,19 +77,52 @@ public function destination(string $destination): self /** * @inheritdoc */ - public function getCommand(): string + private function runShell(string $command): string { - $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); - - if ($rawOutput === null) { - throw new \RuntimeException('Failed to execute shell command.'); + // Capture stdout and stderr + $output = shell_exec($command . ' 2>&1'); + + if ($output === null) { + throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); } - - $containerId = trim($rawOutput); - - if (!$containerId) { - throw new \RuntimeException(sprintf('Container "%s" not found or not running.', $this->container)); + + return trim((string)$output); + } + + private function getContainerId(): string + { + // First try docker-compose + $cmdCompose = sprintf( + 'docker-compose ps -q %s', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdCompose); + if ($output !== '') { + return $output; } + + // Fallback to plain docker ps + $cmdDocker = sprintf( + 'docker ps -q --filter "name=%s$"', + escapeshellarg($this->container) + ); + + $output = $this->runShell($cmdDocker); + if ($output !== '') { + return $output; + } + + throw new \RuntimeException(sprintf( + 'Container "%s" not found or not running.', + $this->container + )); + } + + + public function getCommand(): string + { + $containerId = $this->getContainerId(); return sprintf( 'docker-compose cp %s %s:%s', From 82f558fc0c5f486d4c840643b8e62d085d796a76 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 18 Sep 2025 17:16:22 +0530 Subject: [PATCH 47/66] MCLOUD-14015:Working changes --- .../functional/Robo/Tasks/CopyFromDocker.php | 60 ++++--------------- tests/functional/Robo/Tasks/CopyToDocker.php | 49 +-------------- 2 files changed, 13 insertions(+), 96 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index d35275c1..74808ca8 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -77,59 +77,21 @@ public function destination(string $destination): self /** * @inheritdoc */ -private function runShell(string $command): string -{ - // Capture stdout and stderr - $output = shell_exec($command . ' 2>&1'); - - if ($output === null) { - throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); - } - - return trim((string)$output); -} - -private function getContainerId(): string -{ - // First try docker-compose - $cmdCompose = sprintf( - 'docker-compose ps -q %s', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdCompose); - if ($output !== '') { - return $output; - } - - // Fallback to plain docker ps - $cmdDocker = sprintf( - 'docker ps -q --filter "name=%s$"', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdDocker); - if ($output !== '') { - return $output; - } - - throw new \RuntimeException(sprintf( - 'Container "%s" not found or not running.', - $this->container - )); -} - -public function getCommand(): string -{ - $containerId = $this->getContainerId(); - + public function getCommand(): string + { + + // Log the values before using them + error_log('Container for cp: ' . $this->container); + error_log('Source: ' . $this->source); + error_log('Destination: ' . $this->destination); + return sprintf( - 'docker cp %s:%s %s', - $containerId, + 'docker-compose cp %s:%s %s', + $this->container, $this->source, $this->destination ); -} + } /** * @inheritdoc diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index 0ac674f3..d4631f43 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -77,56 +77,11 @@ public function destination(string $destination): self /** * @inheritdoc */ - private function runShell(string $command): string - { - // Capture stdout and stderr - $output = shell_exec($command . ' 2>&1'); - - if ($output === null) { - throw new \RuntimeException(sprintf('Shell command failed to execute: %s', $command)); - } - - return trim((string)$output); - } - - private function getContainerId(): string - { - // First try docker-compose - $cmdCompose = sprintf( - 'docker-compose ps -q %s', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdCompose); - if ($output !== '') { - return $output; - } - - // Fallback to plain docker ps - $cmdDocker = sprintf( - 'docker ps -q --filter "name=%s$"', - escapeshellarg($this->container) - ); - - $output = $this->runShell($cmdDocker); - if ($output !== '') { - return $output; - } - - throw new \RuntimeException(sprintf( - 'Container "%s" not found or not running.', - $this->container - )); - } - - public function getCommand(): string { - $containerId = $this->getContainerId(); - return sprintf( 'docker-compose cp %s %s:%s', - $containerId, + $this->source, $this->container, $this->destination ); @@ -147,4 +102,4 @@ public function run(): Result return $this->executeCommand($this->getCommand()); } -} +} \ No newline at end of file From 1edc7441d5c87f59956b8101c98650f049c66ab2 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 17:32:39 +0530 Subject: [PATCH 48/66] Small change --- tests/functional/Robo/Tasks/CopyFromDocker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 74808ca8..8d24cb1e 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -86,7 +86,7 @@ public function getCommand(): string error_log('Destination: ' . $this->destination); return sprintf( - 'docker-compose cp %s:%s %s', + 'docker cp %s:%s %s', $this->container, $this->source, $this->destination From be6fd436eed1a503409b8f3e7d94993f018883a5 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 18:03:14 +0530 Subject: [PATCH 49/66] MCLOUD-14015:small change --- .../functional/Robo/Tasks/CopyFromDocker.php | 23 ++++++++++--- tests/functional/Robo/Tasks/CopyToDocker.php | 34 +++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 8d24cb1e..ccf8239f 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,18 +79,31 @@ public function destination(string $destination): self */ public function getCommand(): string { - - // Log the values before using them + error_log('Container for cp: ' . $this->container); + error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - - return sprintf( + $this->container = $this->container ?? null; + + if (!$this->container ) { + throw new \RuntimeException('No container or service defined for copy operation.'); + } + $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', $this->container))); + if (!$containerId) { + throw new \RuntimeException(sprintf('Service "%s" is not running.', $this->container)); + } + error_log('containerID' . $containerId); + + $command = sprintf( 'docker cp %s:%s %s', - $this->container, + $containerId, $this->source, $this->destination ); + // Log the values before using them + + } /** diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index d4631f43..ac34b5a3 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -79,12 +79,34 @@ public function destination(string $destination): self */ public function getCommand(): string { - return sprintf( - 'docker-compose cp %s %s:%s', - $this->source, - $this->container, - $this->destination - ); + // return sprintf( + // 'docker-compose cp %s %s:%s', + // $this->source, + // $this->container, + // $this->destination + // ); + error_log('Container for cp: ' . $this->container); + + error_log('Container for cp: ' . $this->container); + error_log('Source: ' . $this->source); + error_log('Destination: ' . $this->destination); + $this->container = $this->container ?? null; + + if (!$this->container ) { + throw new \RuntimeException('No container or service defined for copy operation.'); + } + $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', $this->container))); + if (!$containerId) { + throw new \RuntimeException(sprintf('Service "%s" is not running.', $this->container)); + } + error_log('containerID' . $containerId); + + $command = sprintf( + 'docker cp %s:%s %s', + $containerId, + $this->source, + $this->destination + ); } /** From 070249f202c1f32270929bee44713b55fbca5054 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 18:18:46 +0530 Subject: [PATCH 50/66] MCLOUD-14015:small change --- .../functional/Robo/Tasks/CopyFromDocker.php | 51 +++++++++++-------- tests/functional/Robo/Tasks/CopyToDocker.php | 51 +++++++++++-------- 2 files changed, 61 insertions(+), 41 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index ccf8239f..96c18078 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -77,35 +77,46 @@ public function destination(string $destination): self /** * @inheritdoc */ - public function getCommand(): string - { - error_log('Container for cp: ' . $this->container); - + public function getCommand(): string +{ error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - $this->container = $this->container ?? null; - - if (!$this->container ) { - throw new \RuntimeException('No container or service defined for copy operation.'); + + if (!$this->container) { + throw new \RuntimeException('No container defined for copy operation.'); + } + + $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); + if ($rawOutput === null) { + throw new \RuntimeException(sprintf( + 'Failed to execute docker-compose command for container "%s".', + $this->container + )); } - $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', $this->container))); - if (!$containerId) { - throw new \RuntimeException(sprintf('Service "%s" is not running.', $this->container)); + + $containerId = trim($rawOutput); + if ($containerId === '') { + throw new \RuntimeException(sprintf( + 'Container "%s" is not running or does not exist.', + $this->container + )); } - error_log('containerID' . $containerId); + error_log('Resolved container ID: ' . $containerId); + + // Safely escape arguments $command = sprintf( 'docker cp %s:%s %s', - $containerId, - $this->source, - $this->destination + escapeshellarg($containerId), + escapeshellarg($this->source), + escapeshellarg($this->destination) ); - // Log the values before using them - - - } - + + error_log('Generated command: ' . $command); + + return $command; +} /** * @inheritdoc */ diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index ac34b5a3..a6e6fc82 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -78,36 +78,45 @@ public function destination(string $destination): self * @inheritdoc */ public function getCommand(): string - { - // return sprintf( - // 'docker-compose cp %s %s:%s', - // $this->source, - // $this->container, - // $this->destination - // ); - error_log('Container for cp: ' . $this->container); - +{ error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - $this->container = $this->container ?? null; - - if (!$this->container ) { - throw new \RuntimeException('No container or service defined for copy operation.'); + + if (!$this->container) { + throw new \RuntimeException('No container defined for copy operation.'); } - $containerId = trim(shell_exec(sprintf('docker-compose ps -q %s', $this->container))); - if (!$containerId) { - throw new \RuntimeException(sprintf('Service "%s" is not running.', $this->container)); + + $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); + if ($rawOutput === null) { + throw new \RuntimeException(sprintf( + 'Failed to execute docker-compose command for container "%s".', + $this->container + )); } - error_log('containerID' . $containerId); + $containerId = trim($rawOutput); + if ($containerId === '') { + throw new \RuntimeException(sprintf( + 'Container "%s" is not running or does not exist.', + $this->container + )); + } + + error_log('Resolved container ID: ' . $containerId); + + // Safely escape arguments $command = sprintf( 'docker cp %s:%s %s', - $containerId, - $this->source, - $this->destination + escapeshellarg($containerId), + escapeshellarg($this->source), + escapeshellarg($this->destination) ); - } + + error_log('Generated command: ' . $command); + + return $command; +} /** * @inheritdoc From 059273b8d3b68b877b8324b4bd6086f1825cf9cf Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 18:37:21 +0530 Subject: [PATCH 51/66] MCLOUD-14015:small change --- tests/functional/Codeception/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 955cb2c3..70179b7a 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -108,7 +108,7 @@ public function runDockerComposeCommand(string $command): bool public function resetFilesOwner(): bool { return $this->runDockerComposeCommand( - 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + 'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' ); } From 9a6f9e258d47a38a07db881d712097ce87af3399 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 18:59:55 +0530 Subject: [PATCH 52/66] MCLOUD-14015:small change --- .../functional/Robo/Tasks/CopyFromDocker.php | 38 +++---------------- tests/functional/Robo/Tasks/CopyToDocker.php | 38 +++---------------- 2 files changed, 12 insertions(+), 64 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index 96c18078..c7decae9 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -79,43 +79,17 @@ public function destination(string $destination): self */ public function getCommand(): string { + // Log the values before using them error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - - if (!$this->container) { - throw new \RuntimeException('No container defined for copy operation.'); - } - - $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); - if ($rawOutput === null) { - throw new \RuntimeException(sprintf( - 'Failed to execute docker-compose command for container "%s".', - $this->container - )); - } - - $containerId = trim($rawOutput); - if ($containerId === '') { - throw new \RuntimeException(sprintf( - 'Container "%s" is not running or does not exist.', - $this->container - )); - } - - error_log('Resolved container ID: ' . $containerId); - - // Safely escape arguments - $command = sprintf( + + return sprintf( 'docker cp %s:%s %s', - escapeshellarg($containerId), - escapeshellarg($this->source), - escapeshellarg($this->destination) + $this->container, + $this->source, + $this->destination ); - - error_log('Generated command: ' . $command); - - return $command; } /** * @inheritdoc diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index a6e6fc82..ac939c56 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -79,43 +79,17 @@ public function destination(string $destination): self */ public function getCommand(): string { + // Log the values before using them error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - - if (!$this->container) { - throw new \RuntimeException('No container defined for copy operation.'); - } - - $rawOutput = shell_exec(sprintf('docker-compose ps -q %s', escapeshellarg($this->container))); - if ($rawOutput === null) { - throw new \RuntimeException(sprintf( - 'Failed to execute docker-compose command for container "%s".', - $this->container - )); - } - - $containerId = trim($rawOutput); - if ($containerId === '') { - throw new \RuntimeException(sprintf( - 'Container "%s" is not running or does not exist.', - $this->container - )); - } - - error_log('Resolved container ID: ' . $containerId); - - // Safely escape arguments - $command = sprintf( + + return sprintf( 'docker cp %s:%s %s', - escapeshellarg($containerId), - escapeshellarg($this->source), - escapeshellarg($this->destination) + $this->container, + $this->source, + $this->destination ); - - error_log('Generated command: ' . $command); - - return $command; } /** From 50b4918d1a0509c9ee939347dd4d7c8af2cc21c1 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 19:13:29 +0530 Subject: [PATCH 53/66] MCLOUD-14015:small change --- tests/functional/Codeception/Docker.php | 30 ++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 70179b7a..7c5d38c4 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,9 +107,33 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { - return $this->runDockerComposeCommand( - 'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' - ); + // return $this->runDockerComposeCommand( + // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + // ); + // Determine if running locally (macOS/Linux) or in CI + $os = PHP_OS_FAMILY; + + if ($os === 'Darwin' || $os === 'Linux') { + // Local dev: determine host directory UID/GID for chown + $command = sprintf( + 'run --user root build bash -c %s', + escapeshellarg( + 'uid=$(stat -c %u . 2>/dev/null || stat -f %u .); ' . + 'gid=$(stat -c %g . 2>/dev/null || stat -f %g .); ' . + 'chown -R $uid:$gid . /composer/cache' + ) + ); + } else { + // CI/Jenkins: simple id -u:id -g works + $command = sprintf( + 'run build bash -c %s', + escapeshellarg('chown -R $(id -u):$(id -g) . /composer/cache') + ); + } + + // Run the command through your existing DockerCompose wrapper + $this->runDockerComposeCommand($command); + } /** From b614bf3ec928b6ee045e03a90b7edb1142a290a5 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 19:38:18 +0530 Subject: [PATCH 54/66] MCLOUD-14015:small change --- tests/functional/Codeception/Docker.php | 30 ++------------------ tests/functional/Robo/Tasks/CopyToDocker.php | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 7c5d38c4..955cb2c3 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -107,33 +107,9 @@ public function runDockerComposeCommand(string $command): bool */ public function resetFilesOwner(): bool { - // return $this->runDockerComposeCommand( - // 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' - // ); - // Determine if running locally (macOS/Linux) or in CI - $os = PHP_OS_FAMILY; - - if ($os === 'Darwin' || $os === 'Linux') { - // Local dev: determine host directory UID/GID for chown - $command = sprintf( - 'run --user root build bash -c %s', - escapeshellarg( - 'uid=$(stat -c %u . 2>/dev/null || stat -f %u .); ' . - 'gid=$(stat -c %g . 2>/dev/null || stat -f %g .); ' . - 'chown -R $uid:$gid . /composer/cache' - ) - ); - } else { - // CI/Jenkins: simple id -u:id -g works - $command = sprintf( - 'run build bash -c %s', - escapeshellarg('chown -R $(id -u):$(id -g) . /composer/cache') - ); - } - - // Run the command through your existing DockerCompose wrapper - $this->runDockerComposeCommand($command); - + return $this->runDockerComposeCommand( + 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + ); } /** diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index ac939c56..96769cf0 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -85,7 +85,7 @@ public function getCommand(): string error_log('Destination: ' . $this->destination); return sprintf( - 'docker cp %s:%s %s', + 'docker cp %s %s:%s', $this->container, $this->source, $this->destination From 81ea2f43328ecd6fc34038d7c3426c2501ef2968 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 23 Sep 2025 19:54:54 +0530 Subject: [PATCH 55/66] MCLOUD-14015:small change --- tests/functional/Robo/Tasks/CopyFromDocker.php | 2 +- tests/functional/Robo/Tasks/CopyToDocker.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index c7decae9..f3299770 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -85,7 +85,7 @@ public function getCommand(): string error_log('Destination: ' . $this->destination); return sprintf( - 'docker cp %s:%s %s', + 'docker-compose cp %s:%s %s', $this->container, $this->source, $this->destination diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index 96769cf0..7072796e 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -85,7 +85,7 @@ public function getCommand(): string error_log('Destination: ' . $this->destination); return sprintf( - 'docker cp %s %s:%s', + 'docker-compose cp %s %s:%s', $this->container, $this->source, $this->destination From 142d45f3d8dc4bdc6e8a56da3a9435123a7ad2da Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 24 Sep 2025 11:50:25 +0530 Subject: [PATCH 56/66] MCLOUD-14015:Change in git permissions command --- tests/functional/Codeception/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 955cb2c3..70179b7a 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -108,7 +108,7 @@ public function runDockerComposeCommand(string $command): bool public function resetFilesOwner(): bool { return $this->runDockerComposeCommand( - 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' + 'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' ); } From 5f2ad3ace7cf2a942dc83bea8d20dc72f50f10ef Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 24 Sep 2025 12:09:30 +0530 Subject: [PATCH 57/66] MCLOUD-14015: Recheck the cp command --- .../functional/Robo/Tasks/CopyFromDocker.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index f3299770..f89ca785 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -83,13 +83,20 @@ public function getCommand(): string error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - + $check_ps_command = sprintf('docker-compose ps -q %s', $this->container); + error_log('ps command: ' . $check_ps_command); return sprintf( - 'docker-compose cp %s:%s %s', - $this->container, - $this->source, - $this->destination - ); + '(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)', + $check_ps_command, + $this->source, + $this->destination, + $this->container, + $this->source, + $this->destination +); + + + } /** * @inheritdoc From 34564c034eb4b8e9e553f0249e7dc3019fc8d001 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Wed, 24 Sep 2025 12:25:47 +0530 Subject: [PATCH 58/66] MCLOUD-14015: Recheck the cp command --- tests/functional/Robo/Tasks/CopyToDocker.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index 7072796e..c0259ea6 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -83,13 +83,18 @@ public function getCommand(): string error_log('Container for cp: ' . $this->container); error_log('Source: ' . $this->source); error_log('Destination: ' . $this->destination); - + $check_ps_command = sprintf('docker-compose ps -q %s', $this->container); + error_log('ps command: ' . $check_ps_command); return sprintf( - 'docker-compose cp %s %s:%s', - $this->container, - $this->source, - $this->destination - ); + '(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)', + $check_ps_command, + $this->source, + $this->destination, + $this->container, + $this->source, + $this->destination +); + } /** From a48fad07fa9b167ef59b20779da60d426af0a751 Mon Sep 17 00:00:00 2001 From: Prateek Karanpuria Date: Wed, 24 Sep 2025 15:22:25 +0530 Subject: [PATCH 59/66] MCLOUD-14015: Docker cp command & git file permission fixes for local+jenkins --- tests/functional/Codeception/Docker.php | 2 +- .../functional/Robo/Tasks/CopyFromDocker.php | 34 +++++++------------ tests/functional/Robo/Tasks/CopyToDocker.php | 29 ++++++---------- 3 files changed, 25 insertions(+), 40 deletions(-) diff --git a/tests/functional/Codeception/Docker.php b/tests/functional/Codeception/Docker.php index 70179b7a..955cb2c3 100644 --- a/tests/functional/Codeception/Docker.php +++ b/tests/functional/Codeception/Docker.php @@ -108,7 +108,7 @@ public function runDockerComposeCommand(string $command): bool public function resetFilesOwner(): bool { return $this->runDockerComposeCommand( - 'run build bash -c "chown -R $(id -u):$(id -g) . /composer/cache"' + 'run --user root build bash -c "uid=$(stat -c %u . 2>/dev/null || stat -f %u .); gid=$(stat -c %g . 2>/dev/null || stat -f %g .); chown -R $uid:$gid . /composer/cache"' ); } diff --git a/tests/functional/Robo/Tasks/CopyFromDocker.php b/tests/functional/Robo/Tasks/CopyFromDocker.php index f89ca785..6c2ef8f0 100644 --- a/tests/functional/Robo/Tasks/CopyFromDocker.php +++ b/tests/functional/Robo/Tasks/CopyFromDocker.php @@ -77,27 +77,19 @@ public function destination(string $destination): self /** * @inheritdoc */ - public function getCommand(): string -{ - // Log the values before using them - error_log('Container for cp: ' . $this->container); - error_log('Source: ' . $this->source); - error_log('Destination: ' . $this->destination); - $check_ps_command = sprintf('docker-compose ps -q %s', $this->container); - error_log('ps command: ' . $check_ps_command); - return sprintf( - '(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)', - $check_ps_command, - $this->source, - $this->destination, - $this->container, - $this->source, - $this->destination -); - - - -} + public function getCommand(): string + { + return sprintf( + '(docker-compose cp %s:%s %s) || (docker cp $(docker-compose ps -q %s):%s %s)', + $this->container, + $this->source, + $this->destination, + $this->container, + $this->source, + $this->destination + ); + } + /** * @inheritdoc */ diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index c0259ea6..9b97a311 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -78,24 +78,17 @@ public function destination(string $destination): self * @inheritdoc */ public function getCommand(): string -{ - // Log the values before using them - error_log('Container for cp: ' . $this->container); - error_log('Source: ' . $this->source); - error_log('Destination: ' . $this->destination); - $check_ps_command = sprintf('docker-compose ps -q %s', $this->container); - error_log('ps command: ' . $check_ps_command); - return sprintf( - '(docker cp %s:%s %s) || (docker-compose cp %s:%s %s)', - $check_ps_command, - $this->source, - $this->destination, - $this->container, - $this->source, - $this->destination -); - -} + { + return sprintf( + '(docker cp %s %s:%s) || (docker-compose cp %s %s:%s)', + $this->source, + $this->container, + $this->destination, + $this->source, + $this->container, + $this->destination + ); + } /** * @inheritdoc From 81dc74968f6fb8ce1c307842093427fc7aafb8d9 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Thu, 25 Sep 2025 15:55:09 +0530 Subject: [PATCH 60/66] MCLOUD-14015:Small change --- tests/functional/Robo/Tasks/CopyToDocker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/Robo/Tasks/CopyToDocker.php b/tests/functional/Robo/Tasks/CopyToDocker.php index 9b97a311..8ccde7d0 100644 --- a/tests/functional/Robo/Tasks/CopyToDocker.php +++ b/tests/functional/Robo/Tasks/CopyToDocker.php @@ -80,7 +80,7 @@ public function destination(string $destination): self public function getCommand(): string { return sprintf( - '(docker cp %s %s:%s) || (docker-compose cp %s %s:%s)', + '(docker-compose cp %s:%s %s) || (docker cp $(docker-compose ps -q %s):%s %s)', $this->source, $this->container, $this->destination, From 9306a4ff0644faf769dc5ffa314885b8d050b1b8 Mon Sep 17 00:00:00 2001 From: Ashvini K Date: Mon, 6 Oct 2025 15:26:20 +0530 Subject: [PATCH 61/66] Updated Funcational Tests --- .../Acceptance/ActivemqArtemis84Cest.php | 78 +++++++- .../Acceptance/ActivemqArtemisCest.php | 179 ++++++++++++++++-- 2 files changed, 238 insertions(+), 19 deletions(-) diff --git a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php index 4b459d51..024f0624 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php @@ -8,6 +8,8 @@ namespace Magento\CloudDocker\Test\Functional\Acceptance; /** + * ActiveMQ Artemis acceptance tests for PHP 8.4 and Magento 2.4.x + * * @group php84 */ class ActivemqArtemis84Cest extends ActivemqArtemisCest @@ -15,5 +17,79 @@ class ActivemqArtemis84Cest extends ActivemqArtemisCest /** * Template version for testing */ - protected const TEMPLATE_VERSION = '2.4.9'; + protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0'; + + /** + * @inheritdoc + */ + protected function basicFunctionalityDataProvider(): array + { + return [ + 'artemis-2.42.0' => [ + 'version' => '2.42.0', + ], + ]; + } + + /** + * @inheritdoc + */ + protected function customConfigurationDataProvider(): array + { + return [ + 'custom-artemis-config' => [ + 'servicesConfig' => [ + 'activemq' => [ + 'type' => 'activemq-artemis:2.42.0', + 'disk' => 2048, + ] + ], + 'expectedEnvVars' => [ + 'ARTEMIS_USER' => 'admin', + 'ARTEMIS_PASSWORD' => 'admin', + ], + ], + 'custom-memory-config' => [ + 'servicesConfig' => [ + 'activemq' => [ + 'type' => 'activemq-artemis:2.42.0', + 'disk' => 4096, + ] + ], + 'expectedEnvVars' => [ + 'ARTEMIS_USER' => 'admin', + 'ARTEMIS_PASSWORD' => 'admin', + ], + ], + ]; + } + + /** + * @inheritdoc + */ + protected function errorScenariosDataProvider(): array + { + return [ + 'invalid-version' => [ + 'servicesConfig' => [ + 'activemq' => [ + 'type' => 'activemq-artemis:invalid.version', + ] + ], + 'expectGenerationFailure' => false, // Docker compose generation should succeed + 'expectStartFailure' => true, // But container start should fail + 'expectedErrorMessage' => null, + ], + 'missing-type' => [ + 'servicesConfig' => [ + 'activemq' => [ + 'disk' => 2048, + ] + ], + 'expectGenerationFailure' => true, // Should fail during generation + 'expectStartFailure' => false, + 'expectedErrorMessage' => 'type', + ], + ]; + } } diff --git a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php index b6fd865c..1ee43b92 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php @@ -12,23 +12,62 @@ use Robo\Exception\TaskException; /** + * Tests ActiveMQ Artemis functionality in Docker environment + * * @group php84 */ -class ActivemqArtemisCest extends AbstractCest +abstract class ActivemqArtemisCest extends AbstractCest { /** * Template version for testing */ - protected const TEMPLATE_VERSION = '2.4.9'; + protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0'; /** + * Builds build:compose command from given test data + * + * @param Example $data + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + private function buildCommand(Example $data): string + { + // Note: $data is not used as ActiveMQ Artemis is configured via services.yaml + // rather than CLI options, but parameter is kept for consistency with other tests + return '--mode=production --no-es --no-os --no-redis --no-valkey'; + } + + /** + * Data provider for basic functionality test + * + * @return array + */ + abstract protected function basicFunctionalityDataProvider(): array; + + /** + * Data provider for custom configuration test + * + * @return array + */ + abstract protected function customConfigurationDataProvider(): array; + + /** + * Data provider for error scenarios test + * + * @return array + */ + abstract protected function errorScenariosDataProvider(): array; + + /** + * Test basic ActiveMQ Artemis functionality + * * @param CliTester $I * @param Example $data - * @dataProvider dataProvider + * @dataProvider basicFunctionalityDataProvider * @return void * @throws TaskException */ - public function testActivemqArtemis(CliTester $I, Example $data): void + public function testBasicFunctionality(CliTester $I, Example $data): void { // Create services.yaml with activemq-artemis configuration $servicesConfig = [ @@ -47,6 +86,97 @@ public function testActivemqArtemis(CliTester $I, Example $data): void $I->seeInOutput('activemq-artemis'); $I->seeInOutput('(healthy)'); + // Test network connectivity + $this->testNetworkConnectivity($I); + + // Test ActiveMQ Artemis CLI functionality + $this->testArtemisCLI($I); + + // Test message producer/consumer functionality + $this->testMessageQueuing($I); + + // Test environment variables + $this->testEnvironmentVariables($I); + } + + /** + * Test ActiveMQ Artemis with custom configuration + * + * @param CliTester $I + * @param Example $data + * @dataProvider customConfigurationDataProvider + * @return void + * @throws TaskException + */ + public function testCustomConfiguration(CliTester $I, Example $data): void + { + // Create services.yaml with custom activemq-artemis configuration + $I->writeServicesYaml($data['servicesConfig']); + + $I->generateDockerCompose($this->buildCommand($data)); + $I->replaceImagesWithCustom(); + $I->startEnvironment(); + + // Verify container is running + $I->runDockerComposeCommand('ps'); + $I->seeInOutput('activemq-artemis'); + $I->seeInOutput('(healthy)'); + + // Test basic connectivity with custom settings + $this->testNetworkConnectivity($I); + + // Verify custom environment variables if specified + if (isset($data['expectedEnvVars'])) { + foreach ($data['expectedEnvVars'] as $envVar => $expectedValue) { + $I->runDockerComposeCommand("exec -T activemq-artemis env | grep {$envVar}"); + $I->seeInOutput("{$envVar}={$expectedValue}"); + } + } + } + + /** + * Test ActiveMQ Artemis error scenarios + * + * @param CliTester $I + * @param Example $data + * @dataProvider errorScenariosDataProvider + * @return void + * @throws TaskException + */ + public function testErrorScenarios(CliTester $I, Example $data): void + { + // Create services.yaml with problematic configuration + $I->writeServicesYaml($data['servicesConfig']); + + $generateResult = $I->generateDockerCompose($this->buildCommand($data)); + + if ($data['expectGenerationFailure']) { + $I->assertFalse($generateResult, 'Docker compose generation should have failed'); + if (isset($data['expectedErrorMessage'])) { + $I->seeInOutput($data['expectedErrorMessage']); + } + return; + } + + $I->assertTrue($generateResult, 'Docker compose generation should succeed'); + $I->replaceImagesWithCustom(); + + $startResult = $I->startEnvironment(); + if ($data['expectStartFailure']) { + $I->assertFalse($startResult, 'Environment start should have failed'); + return; + } + + $I->assertTrue($startResult, 'Environment should start successfully'); + } + + /** + * Test network connectivity to ActiveMQ Artemis ports + * + * @param CliTester $I + */ + private function testNetworkConnectivity(CliTester $I): void + { // Test ActiveMQ Artemis web console accessibility (port 8161) $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 8161'); $I->seeInOutput(''); // nc returns empty output on success @@ -62,7 +192,15 @@ public function testActivemqArtemis(CliTester $I, Example $data): void // Test that ActiveMQ Artemis is accessible through direct host name $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis 61616'); $I->seeInOutput(''); - + } + + /** + * Test ActiveMQ Artemis CLI functionality + * + * @param CliTester $I + */ + private function testArtemisCLI(CliTester $I): void + { // Test ActiveMQ Artemis broker status using artemis CLI $I->runDockerComposeCommand( 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' @@ -81,7 +219,15 @@ public function testActivemqArtemis(CliTester $I, Example $data): void 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' ); $I->seeInOutput('test.queue'); - + } + + /** + * Test message producer/consumer functionality + * + * @param CliTester $I + */ + private function testMessageQueuing(CliTester $I): void + { // Test sending a message to the queue $I->runDockerComposeCommand( 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis producer ' . @@ -102,7 +248,15 @@ public function testActivemqArtemis(CliTester $I, Example $data): void 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' ); $I->seeInOutput('CONNECTION_COUNT'); - + } + + /** + * Test environment variables + * + * @param CliTester $I + */ + private function testEnvironmentVariables(CliTester $I): void + { // Test that environment variables are properly set $I->runDockerComposeCommand('exec -T activemq-artemis env | grep ARTEMIS'); $I->seeInOutput('ARTEMIS_USER=admin'); @@ -123,15 +277,4 @@ private function buildCommand(Example $data): string return '--mode=production --no-es --no-os --no-redis --no-valkey'; } - /** - * @return array - */ - protected function dataProvider(): array - { - return [ - [ - 'version' => '2.17', - ], - ]; - } } From 18ac5914b35a5c30be58714a1ba4f6b622cddb6b Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Mon, 6 Oct 2025 16:14:04 +0530 Subject: [PATCH 62/66] MCLOUD-13771:Fixed unit tests --- .../Acceptance/ActivemqArtemis84Cest.php | 2 +- .../Acceptance/ActivemqArtemisCest.php | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php index 024f0624..4876a3bc 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php @@ -9,7 +9,7 @@ /** * ActiveMQ Artemis acceptance tests for PHP 8.4 and Magento 2.4.x - * + * * @group php84 */ class ActivemqArtemis84Cest extends ActivemqArtemisCest diff --git a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php index 1ee43b92..edf2cf14 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php @@ -13,7 +13,7 @@ /** * Tests ActiveMQ Artemis functionality in Docker environment - * + * * @group php84 */ abstract class ActivemqArtemisCest extends AbstractCest @@ -262,19 +262,4 @@ private function testEnvironmentVariables(CliTester $I): void $I->seeInOutput('ARTEMIS_USER=admin'); $I->seeInOutput('ARTEMIS_PASSWORD=admin'); } - - /** - * Builds build:compose command from given test data - * - * @param Example $data - * @return string - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - private function buildCommand(Example $data): string - { - // Note: $data is not used as ActiveMQ Artemis is configured via services.yaml - // rather than CLI options, but parameter is kept for consistency with other tests - return '--mode=production --no-es --no-os --no-redis --no-valkey'; - } - } From 0294fec182f7b4b5168fc5a4a850ca36cf646418 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 7 Oct 2025 14:02:24 +0530 Subject: [PATCH 63/66] MCLOUD-13771:Merged develop branch --- src/Test/Functional/Acceptance/ActivemqArtemisCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php index edf2cf14..4d8343ff 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php @@ -263,3 +263,4 @@ private function testEnvironmentVariables(CliTester $I): void $I->seeInOutput('ARTEMIS_PASSWORD=admin'); } } + From a9548c65ad1e1db2d7b942d8e7531f1d89af295b Mon Sep 17 00:00:00 2001 From: Ashvini K Date: Tue, 7 Oct 2025 16:03:53 +0530 Subject: [PATCH 64/66] updated tests --- .../Acceptance/ActivemqArtemis84Cest.php | 76 +------ .../Acceptance/ActivemqArtemisCest.php | 185 ++++-------------- 2 files changed, 40 insertions(+), 221 deletions(-) diff --git a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php index 024f0624..4b3d1c2c 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php @@ -18,78 +18,4 @@ class ActivemqArtemis84Cest extends ActivemqArtemisCest * Template version for testing */ protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0'; - - /** - * @inheritdoc - */ - protected function basicFunctionalityDataProvider(): array - { - return [ - 'artemis-2.42.0' => [ - 'version' => '2.42.0', - ], - ]; - } - - /** - * @inheritdoc - */ - protected function customConfigurationDataProvider(): array - { - return [ - 'custom-artemis-config' => [ - 'servicesConfig' => [ - 'activemq' => [ - 'type' => 'activemq-artemis:2.42.0', - 'disk' => 2048, - ] - ], - 'expectedEnvVars' => [ - 'ARTEMIS_USER' => 'admin', - 'ARTEMIS_PASSWORD' => 'admin', - ], - ], - 'custom-memory-config' => [ - 'servicesConfig' => [ - 'activemq' => [ - 'type' => 'activemq-artemis:2.42.0', - 'disk' => 4096, - ] - ], - 'expectedEnvVars' => [ - 'ARTEMIS_USER' => 'admin', - 'ARTEMIS_PASSWORD' => 'admin', - ], - ], - ]; - } - - /** - * @inheritdoc - */ - protected function errorScenariosDataProvider(): array - { - return [ - 'invalid-version' => [ - 'servicesConfig' => [ - 'activemq' => [ - 'type' => 'activemq-artemis:invalid.version', - ] - ], - 'expectGenerationFailure' => false, // Docker compose generation should succeed - 'expectStartFailure' => true, // But container start should fail - 'expectedErrorMessage' => null, - ], - 'missing-type' => [ - 'servicesConfig' => [ - 'activemq' => [ - 'disk' => 2048, - ] - ], - 'expectGenerationFailure' => true, // Should fail during generation - 'expectStartFailure' => false, - 'expectedErrorMessage' => 'type', - ], - ]; - } -} +} \ No newline at end of file diff --git a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php index 1ee43b92..3f6651c3 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php @@ -16,67 +16,24 @@ * * @group php84 */ -abstract class ActivemqArtemisCest extends AbstractCest +class ActivemqArtemisCest extends AbstractCest { /** * Template version for testing */ protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0'; - /** - * Builds build:compose command from given test data - * - * @param Example $data - * @return string - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - private function buildCommand(Example $data): string - { - // Note: $data is not used as ActiveMQ Artemis is configured via services.yaml - // rather than CLI options, but parameter is kept for consistency with other tests - return '--mode=production --no-es --no-os --no-redis --no-valkey'; - } - - /** - * Data provider for basic functionality test - * - * @return array - */ - abstract protected function basicFunctionalityDataProvider(): array; - - /** - * Data provider for custom configuration test - * - * @return array - */ - abstract protected function customConfigurationDataProvider(): array; - - /** - * Data provider for error scenarios test - * - * @return array - */ - abstract protected function errorScenariosDataProvider(): array; - /** * Test basic ActiveMQ Artemis functionality * * @param CliTester $I * @param Example $data - * @dataProvider basicFunctionalityDataProvider + * @dataProvider dataProvider * @return void * @throws TaskException */ - public function testBasicFunctionality(CliTester $I, Example $data): void + public function testActivemqArtemis(CliTester $I, Example $data): void { - // Create services.yaml with activemq-artemis configuration - $servicesConfig = [ - 'activemq' => [ - 'type' => 'activemq-artemis:' . $data['version'] - ] - ]; - $I->writeServicesYaml($servicesConfig); - $I->generateDockerCompose($this->buildCommand($data)); $I->replaceImagesWithCustom(); $I->startEnvironment(); @@ -99,77 +56,6 @@ public function testBasicFunctionality(CliTester $I, Example $data): void $this->testEnvironmentVariables($I); } - /** - * Test ActiveMQ Artemis with custom configuration - * - * @param CliTester $I - * @param Example $data - * @dataProvider customConfigurationDataProvider - * @return void - * @throws TaskException - */ - public function testCustomConfiguration(CliTester $I, Example $data): void - { - // Create services.yaml with custom activemq-artemis configuration - $I->writeServicesYaml($data['servicesConfig']); - - $I->generateDockerCompose($this->buildCommand($data)); - $I->replaceImagesWithCustom(); - $I->startEnvironment(); - - // Verify container is running - $I->runDockerComposeCommand('ps'); - $I->seeInOutput('activemq-artemis'); - $I->seeInOutput('(healthy)'); - - // Test basic connectivity with custom settings - $this->testNetworkConnectivity($I); - - // Verify custom environment variables if specified - if (isset($data['expectedEnvVars'])) { - foreach ($data['expectedEnvVars'] as $envVar => $expectedValue) { - $I->runDockerComposeCommand("exec -T activemq-artemis env | grep {$envVar}"); - $I->seeInOutput("{$envVar}={$expectedValue}"); - } - } - } - - /** - * Test ActiveMQ Artemis error scenarios - * - * @param CliTester $I - * @param Example $data - * @dataProvider errorScenariosDataProvider - * @return void - * @throws TaskException - */ - public function testErrorScenarios(CliTester $I, Example $data): void - { - // Create services.yaml with problematic configuration - $I->writeServicesYaml($data['servicesConfig']); - - $generateResult = $I->generateDockerCompose($this->buildCommand($data)); - - if ($data['expectGenerationFailure']) { - $I->assertFalse($generateResult, 'Docker compose generation should have failed'); - if (isset($data['expectedErrorMessage'])) { - $I->seeInOutput($data['expectedErrorMessage']); - } - return; - } - - $I->assertTrue($generateResult, 'Docker compose generation should succeed'); - $I->replaceImagesWithCustom(); - - $startResult = $I->startEnvironment(); - if ($data['expectStartFailure']) { - $I->assertFalse($startResult, 'Environment start should have failed'); - return; - } - - $I->assertTrue($startResult, 'Environment should start successfully'); - } - /** * Test network connectivity to ActiveMQ Artemis ports * @@ -177,21 +63,17 @@ public function testErrorScenarios(CliTester $I, Example $data): void */ private function testNetworkConnectivity(CliTester $I): void { - // Test ActiveMQ Artemis web console accessibility (port 8161) - $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 8161'); - $I->seeInOutput(''); // nc returns empty output on success + // Test ActiveMQ Artemis web console accessibility (port 8161) using curl instead of nc + $I->runDockerComposeCommand('exec -T fpm curl -f -s http://activemq-artemis.magento2.docker:8161/ > /dev/null'); - // Test ActiveMQ Artemis broker port accessibility (port 61616) - $I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61616'); - $I->seeInOutput(''); + // Test ActiveMQ Artemis broker port accessibility (port 61616) using telnet timeout + $I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61613'); - $I->seeInOutput(''); + $I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "runDockerComposeCommand('exec -T fpm nc -z activemq-artemis 61616'); - $I->seeInOutput(''); + $I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "seeInOutput('Connection brokerURL'); - // Test creating a queue using artemis CLI - $I->runDockerComposeCommand( - 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue create ' . - '--name test.queue --address test.address --routing-type anycast --user admin --password admin' - ); - $I->seeInOutput('successfully'); + // Test that we can see the default system queues + $I->seeInOutput('DLQ'); + $I->seeInOutput('ExpiryQueue'); - // Test listing queues to verify our test queue was created + // Test broker information $I->runDockerComposeCommand( - 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' + 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis address show --user admin --password admin' ); - $I->seeInOutput('test.queue'); + $I->seeInOutput('DLQ'); } /** @@ -228,26 +107,26 @@ private function testArtemisCLI(CliTester $I): void */ private function testMessageQueuing(CliTester $I): void { - // Test sending a message to the queue + // Test sending a message to the default DLQ queue (which always exists) $I->runDockerComposeCommand( 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis producer ' . - '--destination queue://test.queue --message-count 1 --message "Hello ActiveMQ Artemis" ' . + '--destination queue://DLQ --message-count 1 --message "Hello ActiveMQ Artemis Test" ' . '--user admin --password admin' ); $I->seeInOutput('Produced: 1 messages'); - // Test consuming the message from the queue + // Test consuming the message from the DLQ queue $I->runDockerComposeCommand( 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis consumer ' . - '--destination queue://test.queue --message-count 1 --user admin --password admin' + '--destination queue://DLQ --message-count 1 --user admin --password admin' ); - $I->seeInOutput('Hello ActiveMQ Artemis'); + $I->seeInOutput('Consumed: 1 messages'); // Test broker memory and connection info $I->runDockerComposeCommand( 'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin' ); - $I->seeInOutput('CONNECTION_COUNT'); + $I->seeInOutput('Connection brokerURL'); } /** @@ -272,9 +151,23 @@ private function testEnvironmentVariables(CliTester $I): void */ private function buildCommand(Example $data): string { - // Note: $data is not used as ActiveMQ Artemis is configured via services.yaml - // rather than CLI options, but parameter is kept for consistency with other tests - return '--mode=production --no-es --no-os --no-redis --no-valkey'; + $command = sprintf( + '--mode=production', + $data['version'] + ); + + return $command; } -} + /** + * @return array + */ + protected function dataProvider(): array + { + return [ + [ + 'version' => '2.42.0', + ], + ]; + } +} \ No newline at end of file From 98e56ec49b40e4f260bca2546cdd7af687d52da0 Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 7 Oct 2025 16:49:41 +0530 Subject: [PATCH 65/66] MCLOUD-14104: Cloud tools October Release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0fb17f2b..001d2422 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento-cloud-docker", "description": "Magento Cloud Docker", "type": "magento2-component", - "version": "1.4.4", + "version": "1.4.5", "license": [ "OSL-3.0", "AFL-3.0" From 938e9623d988430b424ae5f6443c16409779291e Mon Sep 17 00:00:00 2001 From: shruthi malode Date: Tue, 7 Oct 2025 17:41:32 +0530 Subject: [PATCH 66/66] MCLOUD-14104:PHPCS test fixes --- src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php | 2 +- src/Test/Functional/Acceptance/ActivemqArtemisCest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php index a2c26065..f5bf5718 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php @@ -18,4 +18,4 @@ class ActivemqArtemis84Cest extends ActivemqArtemisCest * Template version for testing */ protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0'; -} \ No newline at end of file +} diff --git a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php index 51d84208..eeaebfb0 100644 --- a/src/Test/Functional/Acceptance/ActivemqArtemisCest.php +++ b/src/Test/Functional/Acceptance/ActivemqArtemisCest.php @@ -142,7 +142,6 @@ private function testEnvironmentVariables(CliTester $I): void $I->seeInOutput('ARTEMIS_PASSWORD=admin'); } - /** * Builds build:compose command from given test data *