![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/dev/tests/integration/testsuite/Magento/Test/Integrity/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Test\Integrity; use Magento\TestFramework\Helper\Bootstrap; class DatabaseTest extends \PHPUnit\Framework\TestCase { /** * Assure that there are no redundant indexes declared in database */ public function testDuplicateKeys() { if (!defined('PERCONA_TOOLKIT_BIN_DIR')) { $this->markTestSkipped('Path to Percona Toolkit is not specified.'); } $checkerPath = PERCONA_TOOLKIT_BIN_DIR . '/pt-duplicate-key-checker'; $db = Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); $command = $checkerPath . ' -d ' . $db->getSchema() . ' h=' . $db->getHost()['db-host'] . ',u=' . $db->getUser() . ',p=' . $db->getPassword(); // exec() have to be here since this is test. // phpcs:ignore Magento2.Security.InsecureFunction exec($command, $output, $exitCode); $this->assertEquals(0, $exitCode); $output = implode(PHP_EOL, $output); if (preg_match('/Total Duplicate Indexes\s+(\d+)/', $output, $matches)) { $this->fail($matches[1] . ' duplicate indexes found.' . PHP_EOL . PHP_EOL . $output); } } }