diff --git a/app/code/Magento/Indexer/Model/Mview/View/State.php b/app/code/Magento/Indexer/Model/Mview/View/State.php
index 66cc423f189c7..b7b2c2f172dd6 100644
--- a/app/code/Magento/Indexer/Model/Mview/View/State.php
+++ b/app/code/Magento/Indexer/Model/Mview/View/State.php
@@ -69,7 +69,7 @@ public function __construct(
\Magento\Framework\App\DeploymentConfig $configReader = null
) {
if (!isset($data['mode'])) {
- $data['mode'] = self::MODE_DISABLED;
+ $data['mode'] = self::MODE_ENABLED;
}
if (!isset($data['status'])) {
$data['status'] = self::STATUS_IDLE;
@@ -150,8 +150,7 @@ public function getStatus()
{
$status = $this->getData('status');
if ($this->isUseApplicationLock()) {
- if (
- $status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING &&
+ if ($status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING &&
!$this->lockManager->isLocked($this->lockPrefix . $this->getViewId())
) {
return \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE;
diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php
index 05611065aea46..7e84855e0b3e4 100644
--- a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php
+++ b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\Context;
+use Magento\Framework\Mview\View\StateInterface;
use Magento\Framework\Registry;
use Magento\Indexer\Model\Mview\View\State;
use Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection;
@@ -158,4 +159,13 @@ public function testSetterAndGetterWithApplicationLock($setStatus, $getStatus, $
$this->model->setStatus($setStatus);
$this->assertEquals($getStatus, $this->model->getStatus());
}
+
+ public function testDefaultValues(): void
+ {
+ $this->assertEquals(StateInterface::MODE_ENABLED, $this->model->getMode());
+ $this->assertEquals(StateInterface::STATUS_IDLE, $this->model->getStatus());
+ $this->assertNull($this->model->getUpdated());
+ $this->assertNull($this->model->getVersionId());
+ $this->assertNull($this->model->getViewId());
+ }
}
diff --git a/app/code/Magento/Indexer/etc/db_schema.xml b/app/code/Magento/Indexer/etc/db_schema.xml
index e316e50f79e9a..b1434f3a79384 100644
--- a/app/code/Magento/Indexer/etc/db_schema.xml
+++ b/app/code/Magento/Indexer/etc/db_schema.xml
@@ -26,7 +26,7 @@
-
+
'myBucket',
'--remote-storage-region' => 'us-east-1',
]
- ]
+ ],
*/
+ [
+ // Indexers start in 'schedule' mode, but many of our tests assume that
+ // indexers are up to date. Because we don't run cron in our testsuite,
+ // we need to ensure that the indexers are up to date before we run our
+ // tests.
+ 'command' => 'indexer:reindex',
+ 'config' => [],
+ ],
];
diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php b/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php
index ce130d94f91ea..00d447bd53497 100644
--- a/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php
+++ b/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php
@@ -50,13 +50,6 @@ public function install($cleanup)
}
$this->_shell->execute($installCmd, $installArgs);
}
- /* Set Indexer mode as "Update on Save" & Reindex all the Indexers */
- $this->_shell->execute(
- 'php -f ' . BP . '/bin/magento indexer:set-mode realtime -vvv'
- );
- $this->_shell->execute(
- 'php -f ' . BP . '/bin/magento indexer:reindex -vvv'
- );
$this->runPostInstallCommands();
}
diff --git a/dev/tests/integration/etc/post-install-setup-command-config.php.dist b/dev/tests/integration/etc/post-install-setup-command-config.php.dist
index c2a0bdd2cb865..96eea45532bd4 100644
--- a/dev/tests/integration/etc/post-install-setup-command-config.php.dist
+++ b/dev/tests/integration/etc/post-install-setup-command-config.php.dist
@@ -19,6 +19,14 @@ return [
[
'command' => 'setup:upgrade',
'config' => []
- ]
+ ],
*/
+ [
+ // Indexers start in 'schedule' mode, but many of our tests assume that
+ // indexers are up to date. Because we don't run cron in our testsuite,
+ // we need to ensure that the indexers are up to date before we run our
+ // tests.
+ 'command' => 'indexer:reindex',
+ 'config' => [],
+ ],
];
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index ff2ed64cf2ab6..0c792882fab91 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -26,8 +26,6 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\RuntimeException;
use Magento\Framework\Filesystem;
-use Magento\Framework\Indexer\IndexerInterface;
-use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Framework\Module\ModuleList\Loader as ModuleLoader;
use Magento\Framework\Module\ModuleListInterface;
@@ -47,7 +45,6 @@
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Validation\ValidationException;
-use Magento\Indexer\Model\Indexer\Collection;
use Magento\RemoteStorage\Driver\DriverException;
use Magento\Setup\Console\Command\InstallCommand;
use Magento\Setup\Controller\ResponseTypeInterface;
@@ -348,8 +345,6 @@ public function __construct(
* @throws FileSystemException
* @throws LocalizedException
* @throws RuntimeException
- * @SuppressWarnings(PHPMD.NPathComplexity)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function install($request)
{
@@ -387,9 +382,6 @@ public function install($request)
$script[] = ['Disabling Maintenance Mode:', 'setMaintenanceMode', [0]];
$script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []];
$script[] = ['Write installation date...', 'writeInstallationDate', []];
- if (empty($request['magento-init-params'])) {
- $script[] = ['Enabling Update by Schedule Indexer Mode...', 'setIndexerModeSchedule', []];
- }
$estimatedModules = $this->createModulesConfig($request, true);
$total = count($script) + 4 * count(array_filter($estimatedModules));
$this->progress = new Installer\Progress($total, 0);
@@ -1799,32 +1791,4 @@ private function revertRemoteStorageConfiguration()
$configData = [$remoteStorageData->getFileKey() => $remoteStorageData->getData()];
$this->deploymentConfigWriter->saveConfig($configData, true);
}
-
- /**
- * Set Index mode as 'Update by Schedule'
- *
- * @return void
- * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback.
- * @throws LocalizedException
- * @throws \Exception
- */
- private function setIndexerModeSchedule(): void
- {
- /** @var Collection $indexCollection */
- $indexCollection = $this->objectManagerProvider->get()->get(Collection::class);
- $indexerIds = $indexCollection->getAllIds();
- try {
- foreach ($indexerIds as $indexerId) {
- /** @var IndexerInterface $model */
- $model = $this->objectManagerProvider->get()->get(IndexerRegistry::class)
- ->get($indexerId);
- $model->setScheduled(true);
- }
- $this->log->log(__('%1 indexer(s) are in "Update by Schedule" mode.', count($indexerIds)));
- } catch (LocalizedException $e) {
- $this->log->log($e->getMessage());
- } catch (\Exception $e) {
- $this->log->log(__("We couldn't change indexer(s)' mode because of an error: ".$e->getMessage()));
- }
- }
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
index b52e793e203a5..de9fac939d234 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
@@ -29,8 +29,6 @@
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DriverPool;
- use Magento\Framework\Indexer\IndexerInterface;
- use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Framework\Module\ModuleList\Loader;
use Magento\Framework\Module\ModuleListInterface;
@@ -45,7 +43,6 @@
use Magento\Framework\Setup\SchemaListener;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Validation\ValidationException;
- use Magento\Indexer\Model\Indexer\Collection;
use Magento\RemoteStorage\Driver\DriverException;
use Magento\RemoteStorage\Setup\ConfigOptionsList as RemoteStorageValidator;
use Magento\Setup\Console\Command\InstallCommand;
@@ -228,19 +225,6 @@ class InstallerTest extends TestCase
*/
private $patchApplierFactoryMock;
- /**
- * @var Collection|MockObject
- */
- private $indexerMock;
- /**
- * @var IndexerRegistry|MockObject
- */
- private $indexerRegistryMock;
- /**
- * @var IndexerInterface|MockObject
- */
- private $indexerInterfaceMock;
-
/**
* @inheritdoc
*/
@@ -288,10 +272,6 @@ protected function setUp(): void
$this->patchApplierFactoryMock->expects($this->any())->method('create')->willReturn(
$this->patchApplierMock
);
- $this->indexerMock = $this->createMock(Collection::class);
- $this->indexerRegistryMock = $this->createMock(IndexerRegistry::class);
- $this->indexerInterfaceMock = $this->getMockForAbstractClass(IndexerInterface::class);
-
$this->object = $this->createObject();
}
@@ -460,8 +440,6 @@ public function testInstall(array $request, array $logMessages, array $logMetaMe
[Registry::class, $registry],
[SearchConfig::class, $searchConfigMock],
[RemoteStorageValidator::class, $remoteStorageValidatorMock],
- [Collection::class, $this->indexerMock],
- [IndexerRegistry::class, $this->indexerRegistryMock]
]
);
$this->adminFactory->expects($this->any())->method('create')->willReturn(
@@ -477,15 +455,6 @@ public function testInstall(array $request, array $logMessages, array $logMetaMe
$this->filePermissions->expects($this->once())
->method('getMissingWritableDirectoriesForDbUpgrade')
->willReturn([]);
- $this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
- [
- 'catalog_category_product',
- 'catalog_product_category',
- ]
- );
- $this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
- $this->indexerInterfaceMock
- );
$this->logger->expects($this->exactly(count($logMessages)))->method('log')
->willReturnCallback(function ($arg) use ($logMessages) {
if ($arg == $logMessages) {
@@ -546,8 +515,6 @@ public static function installDataProvider()
['Disabling Maintenance Mode:'],
['Post installation file permissions check...'],
['Write installation date...'],
- ['Enabling Update by Schedule Indexer Mode...'],
- ['2 indexer(s) are in "Update by Schedule" mode.'],
['Sample Data is installed with errors. See log file for details']
],
'logMetaMessages' => [
@@ -621,8 +588,6 @@ public static function installDataProvider()
['Disabling Maintenance Mode:'],
['Post installation file permissions check...'],
['Write installation date...'],
- ['Enabling Update by Schedule Indexer Mode...'],
- ['2 indexer(s) are in "Update by Schedule" mode.'],
['Sample Data is installed with errors. See log file for details']
],
'logMetaMessages' => [
@@ -794,19 +759,8 @@ public function testInstallWithOrderIncrementPrefix(array $request, array $logMe
[Registry::class, $registry],
[SearchConfig::class, $searchConfigMock],
[RemoteStorageValidator::class, $remoteStorageValidatorMock],
- [Collection::class, $this->indexerMock],
- [IndexerRegistry::class, $this->indexerRegistryMock]
]
);
- $this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
- [
- 'catalog_category_product',
- 'catalog_product_category',
- ]
- );
- $this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
- $this->indexerInterfaceMock
- );
$this->adminFactory->expects($this->any())->method('create')->willReturn(
$this->createMock(AdminAccount::class)
);
@@ -888,8 +842,6 @@ public static function installWithOrderIncrementPrefixDataProvider(): array
['Disabling Maintenance Mode:'],
['Post installation file permissions check...'],
['Write installation date...'],
- ['Enabling Update by Schedule Indexer Mode...'],
- ['2 indexer(s) are in "Update by Schedule" mode.'],
['Sample Data is installed with errors. See log file for details']
],
'logMetaMessages' => [
@@ -1272,9 +1224,6 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
4 => [\Magento\Framework\App\State::class, $appState],
5 => [Registry::class, $registry],
6 => [Manager::class, $cacheManager],
- 7 => [Collection::class, $this->indexerMock],
- 8 => [IndexerRegistry::class, $this->indexerRegistryMock],
- 9 => [IndexerRegistry::class, $this->indexerRegistryMock]
];
$withArgs = $willReturnArgs = [];
@@ -1306,15 +1255,6 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
}
});
- $this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
- [
- 'catalog_category_product',
- 'catalog_product_category',
- ]
- );
- $this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
- $this->indexerInterfaceMock
- );
$this->adminFactory->expects(static::any())->method('create')->willReturn(
$this->createMock(AdminAccount::class)
);