浏览代码

Test run command, setup tests integration templates

Piotr Kwiecinski 4 年之前
父节点
当前提交
aa7d5d73b3

+ 7 - 0
compose/bin/dev-test-run

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+[ -z "$1" ] && echo "Please specify test type (ex. integration)" && exit
+
+TEST_TYPE="$1"
+shift
+bin/clinotty bash -c "cd dev/tests/${TEST_TYPE} && ../../../vendor/bin/phpunit $*"

+ 6 - 6
compose/bin/setup-integration-tests

@@ -10,11 +10,11 @@ bin/clinotty mysql -h${MYSQL_INTEGRATION_HOST} -uroot -p${MYSQL_ROOT_PASSWORD} $
   bin/cli mysql -uroot -p${MYSQL_ROOT_PASSWORD} -h${MYSQL_INTEGRATION_HOST} \
     -e "GRANT ALL PRIVILEGES ON ${MYSQL_INTEGRATION_DATABASE}.* TO '${MYSQL_INTEGRATION_USER}'@'%';FLUSH PRIVILEGES;"
 
-sed -e "s/'db-host' => 'localhost'/'db-host' => '${MYSQL_INTEGRATION_HOST}'/" \
-  -e "s/'db-user' => 'root'/'db-user' => '${MYSQL_INTEGRATION_USER}'/" \
-  -e "s/'db-password' => '123123q'/'db-password' => '${MYSQL_INTEGRATION_PASSWORD}'/" \
-  -e "s/'amqp-host' => 'localhost'/'amqp-host' => 'rabbitmq'/" \
-  -e "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => 'elasticsearch'/" \
-  src/${MYSQL_INTEGRATION_CONFIG}.dist > src/${MYSQL_INTEGRATION_CONFIG}
+if [[ ! -f "src/${MYSQL_INTEGRATION_CONFIG}" ]]; then
+  MAGENTO_VERSION=$(bin/magento --version --no-ansi | cut -d" " -f 3)
+  MAGENTO_VERSION_SEGMENTS=(${MAGENTO_VERSION//./ })
+  MAGENTO_MAJOR="${MAGENTO_VERSION_SEGMENTS[0]}.${MAGENTO_VERSION_SEGMENTS[1]}"
+  cp template/"${MYSQL_INTEGRATION_CONFIG}"."${MAGENTO_MAJOR}".dist src/${MYSQL_INTEGRATION_CONFIG}
+fi
 
 bin/copytocontainer ${MYSQL_INTEGRATION_CONFIG}

+ 24 - 0
compose/template/dev/tests/integration/etc/install-config-mysql.php.2.3.dist

@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+return [
+    'db-host' => 'db',
+    'db-user' => 'magento',
+    'db-password' => 'magento',
+    'db-name' => 'magento_integration_tests',
+    'db-prefix' => '',
+    'backend-frontname' => 'backend',
+    'search-engine' => 'elasticsearch7',
+    'elasticsearch-host' => 'elasticsearch',
+    'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
+    'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
+    'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
+    'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
+    'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
+    'amqp-host' => 'rabbitmq',
+    'amqp-port' => '5672',
+    'amqp-user' => 'guest',
+    'amqp-password' => 'guest',
+];

+ 24 - 0
compose/template/dev/tests/integration/etc/install-config-mysql.php.2.4.dist

@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+return [
+    'db-host' => 'db',
+    'db-user' => 'magento',
+    'db-password' => 'magento',
+    'db-name' => 'magento_integration_tests',
+    'db-prefix' => '',
+    'backend-frontname' => 'backend',
+    'search-engine' => 'elasticsearch7',
+    'elasticsearch-host' => 'elasticsearch',
+    'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
+    'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
+    'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
+    'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
+    'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
+    'amqp-host' => 'rabbitmq',
+    'amqp-port' => '5672',
+    'amqp-user' => 'guest',
+    'amqp-password' => 'guest',
+];