Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 241a81b

Browse files
committed
Support running tests in cluster from PhpStorm #77
- Added ability to run integration tests - Added devbox tests which verify that it is possible to run Magento unit and integration tests over ssh
1 parent df951c7 commit 241a81b

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

scripts/host/configure_tests.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ if [[ ! -f "${magento_tests_root}/integration/phpunit.xml" ]] && [[ -f "${magent
2828

2929
if [[ ! -f "${magento_tests_root}/integration/etc/install-config-mysql.php" ]] && [[ -f "${magento_tests_root}/integration/etc/install-config-mysql.php.dist" ]]; then
3030
cp "${magento_tests_root}/integration/etc/install-config-mysql.php.dist" "${magento_tests_root}/integration/etc/install-config-mysql.php"
31-
sed -i.back "s|'db-password' => '123123q'|'db-password' => ''|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
32-
sed -i.back "s|\];|\\
33-
'amqp-host' => 'localhost',\\
34-
'amqp-port' => '5672',\\
35-
'amqp-user' => 'guest',\\
36-
'amqp-password' => 'guest'\\
37-
];|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
31+
sed -i.back "s|'db-host' => 'localhost'|'db-host' => 'magento2-mysql'|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
32+
sed -i.back "s|'db-name' => 'magento_integration_tests'|'db-name' => 'magento_$(getContext)_integration_tests'|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
33+
sed -i.back "s|'amqp-host' => 'localhost'|'amqp-host' => 'magento2-rabbitmq'|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
34+
sed -i.back "s|'amqp-user' => 'guest'|'amqp-user' => 'admin'|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
35+
sed -i.back "s|'amqp-password' => 'guest'|'amqp-password' => '123123q'|g" "${magento_tests_root}/integration/etc/install-config-mysql.php"
3836
rm -f "${magento_tests_root}/integration/etc/install-config-mysql.php.back"
3937
fi
4038
fi

tests/MultiInstanceWithCeFromComposerNoNfsTest.sh

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ function testMultiInstanceWithCeFromComposerNoNfs()
8080
executeExtendedCommonAssertions
8181

8282
assertMainPageServedByBuiltInCache
83+
84+
assertMagentoUnitTestsWork
85+
assertMagentoIntegrationTestsWork
8386
}
8487

8588
## Call and Run all Tests

tests/_files/run_php_over_ssh_in_cluster.sh tests/_files/run_command_over_ssh_in_cluster.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/expect -f
2-
2+
3+
set arguments [lindex $argv 0]
4+
35
set timeout -1
46

5-
spawn ssh root@magento.default -p 30022 -o "StrictHostKeyChecking no" -- 'php' '-i'
7+
spawn ssh root@magento.default -p 30022 -o "StrictHostKeyChecking no" -- "${arguments}"
68

79
expect "root@magento.default's password: "
810

tests/include/assertions.sh

+21-2
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ function assertRemotePhpWorks()
540540
echo "${blue}## assertRemotePhpWorks${regular}"
541541
echo "## assertRemotePhpWorks" >>${current_log_file_path}
542542

543-
remote_php_ini_contents="$(expect "${tests_dir}/_files/run_php_over_ssh_in_cluster.sh")"
543+
remote_php_version_contents="$(expect "${tests_dir}/_files/run_command_over_ssh_in_cluster.sh" "php -v")"
544544

545-
assertTrue "Remote PHP is not accessible ('php -i' failed to execute over ssh)." '[[ ${remote_php_ini_contents} =~ "PHP License" ]]'
545+
assertTrue "Remote PHP is not accessible ('php -v' failed to execute over ssh)." '[[ ${remote_php_version_contents} =~ "with Xdebug" ]]'
546546
}
547547

548548
function assertXdebugContainerWorks()
@@ -554,5 +554,24 @@ function assertXdebugContainerWorks()
554554
magento_page_content="$(curl -sL --cookie "XDEBUG_SESSION=PHPSTORM" "${current_magento_base_url}/customer/account/create/")"
555555
pattern="Magento.* All rights reserved."
556556
assertTrue "Account creation page is not accessible when queried with XDEBUG_SESSION cookie. URL: '${current_magento_base_url}/customer/account/create/'" '[[ ${magento_page_content} =~ ${pattern} ]]'
557+
}
558+
559+
function assertMagentoUnitTestsWork()
560+
{
561+
echo "${blue}## assertMagentoUnitTestsWork${regular}"
562+
echo "## assertMagentoUnitTestsWork" >>${current_log_file_path}
563+
564+
remote_unit_test_execution_status="$(expect "${tests_dir}/_files/run_command_over_ssh_in_cluster.sh" "php '${devbox_dir}/$(getDevBoxContext)/vendor/phpunit/phpunit/phpunit' --configuration '${devbox_dir}/$(getDevBoxContext)/dev/tests/unit/phpunit.xml' --filter testGetAttributes '${devbox_dir}/$(getDevBoxContext)/vendor/magento/module-catalog/Test/Unit/Model/ProductTest.php'")"
565+
566+
assertTrue "Unit tests are not configured properly (failed to run them over ssh)." '[[ ${remote_unit_test_execution_status} =~ "OK (1 test, 2 assertions)" ]]'
567+
}
568+
569+
function assertMagentoIntegrationTestsWork()
570+
{
571+
echo "${blue}## assertMagentoIntegrationTestsWork${regular}"
572+
echo "## assertMagentoIntegrationTestsWork" >>${current_log_file_path}
573+
574+
remote_integration_test_execution_status="$(expect "${tests_dir}/_files/run_command_over_ssh_in_cluster.sh" "php '${devbox_dir}/$(getDevBoxContext)/vendor/phpunit/phpunit/phpunit' --configuration '${devbox_dir}/$(getDevBoxContext)/dev/tests/integration/phpunit.xml' --filter testGetAddressById '${devbox_dir}/$(getDevBoxContext)/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php'")"
557575

576+
assertTrue "Integration tests are not configured properly (failed to run them over ssh)." '[[ ${remote_integration_test_execution_status} =~ "OK (2 tests, 3 assertions)" ]]'
558577
}

0 commit comments

Comments
 (0)