This is an automated email from the ASF dual-hosted git repository. tkalkirill pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new 6a2833db9a IGNITE-21355 Waiting for the start of components from CatalogTestUtils (#3096) 6a2833db9a is described below commit 6a2833db9aadcfc302d6c026d27d3960331cce66 Author: Kirill Tkalenko <tkalkir...@yandex.ru> AuthorDate: Fri Jan 26 11:02:23 2024 +0300 IGNITE-21355 Waiting for the start of components from CatalogTestUtils (#3096) --- .../catalog/CatalogManagerRecoveryTest.java | 6 +-- .../internal/catalog/CatalogTestUtilsTest.java | 20 +++----- .../catalog/commands/CatalogUtilsTest.java | 2 +- .../ignite/internal/catalog/CatalogTestUtils.java | 54 ++++++++++++++-------- .../BaseDistributionZoneManagerTest.java | 20 ++++---- ...ibutionZoneManagerConfigurationChangesTest.java | 12 ++--- .../DistributionZoneRebalanceEngineTest.java | 4 +- .../IndexAvailabilityControllerRestorerTest.java | 13 +++--- .../index/IndexAvailabilityControllerTest.java | 10 ++-- .../internal/index/IndexBuildControllerTest.java | 6 +-- .../ignite/internal/index/IndexChooserTest.java | 2 +- .../ignite/internal/index/IndexManagerTest.java | 7 +-- .../DdlCommandHandlerExceptionHandlingTest.java | 10 ++-- .../internal/sql/engine/framework/TestCluster.java | 8 ++-- .../engine/schema/SqlSchemaManagerImplTest.java | 7 ++- .../table/distributed/TableManagerTest.java | 14 ++---- 16 files changed, 97 insertions(+), 98 deletions(-) diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerRecoveryTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerRecoveryTest.java index f5e6abf7cd..7bc7f8eac5 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerRecoveryTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerRecoveryTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.catalog; +import static java.util.concurrent.CompletableFuture.allOf; import static org.apache.ignite.internal.catalog.BaseCatalogManagerTest.INDEX_NAME; import static org.apache.ignite.internal.catalog.BaseCatalogManagerTest.TABLE_NAME; import static org.apache.ignite.internal.catalog.BaseCatalogManagerTest.simpleIndex; @@ -28,11 +29,9 @@ import static org.hamcrest.Matchers.greaterThan; import java.nio.file.Path; import java.util.concurrent.TimeUnit; -import java.util.stream.Stream; import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; import org.apache.ignite.internal.hlc.HybridTimestamp; -import org.apache.ignite.internal.manager.IgniteComponent; import org.apache.ignite.internal.metastorage.MetaStorageManager; import org.apache.ignite.internal.metastorage.impl.StandaloneMetaStorageManager; import org.apache.ignite.internal.metastorage.server.KeyValueStorage; @@ -115,8 +114,7 @@ public class CatalogManagerRecoveryTest extends BaseIgniteAbstractTest { } private void startComponentsAndDeployWatches() { - Stream.of(metaStorageManager, catalogManager).forEach(IgniteComponent::start); - + assertThat(allOf(metaStorageManager.start(), catalogManager.start()), willCompleteSuccessfully()); assertThat(metaStorageManager.deployWatches(), willCompleteSuccessfully()); } diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTestUtilsTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTestUtilsTest.java index 0fd4d1fbb4..8f26de042d 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTestUtilsTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTestUtilsTest.java @@ -17,8 +17,9 @@ package org.apache.ignite.internal.catalog; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createCatalogManagerWithTestUpdateLog; import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; -import static org.apache.ignite.internal.testframework.IgniteTestUtils.await; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasSize; @@ -37,20 +38,17 @@ import org.hamcrest.Description; import org.hamcrest.Matcher; import org.junit.jupiter.api.Test; -/** - * Tests to verify {@link CatalogTestUtils}. - */ +/** Tests to verify {@link CatalogTestUtils}. */ class CatalogTestUtilsTest extends BaseIgniteAbstractTest { - /** * Simple smoke test to verify test manager is able to process several versions of catalog, * and returned instance follows the contract. */ @Test void testManagerWorksAsExpected() throws Exception { - CatalogManager manager = CatalogTestUtils.createCatalogManagerWithTestUpdateLog("test", new HybridClockImpl()); + CatalogManager manager = createCatalogManagerWithTestUpdateLog("test", new HybridClockImpl()); - manager.start(); + assertThat(manager.start(), willCompleteSuccessfully()); CreateTableCommandBuilder createTableTemplate = CreateTableCommand.builder() .schemaName("PUBLIC") @@ -60,15 +58,11 @@ class CatalogTestUtilsTest extends BaseIgniteAbstractTest { )) .primaryKeyColumns(List.of("C1")); - await(manager.execute( - createTableTemplate.tableName("T1").build() - )); + assertThat(manager.execute(createTableTemplate.tableName("T1").build()), willCompleteSuccessfully()); int version1 = manager.latestCatalogVersion(); - await(manager.execute( - createTableTemplate.tableName("T2").build() - )); + assertThat(manager.execute(createTableTemplate.tableName("T2").build()), willCompleteSuccessfully()); int version2 = manager.latestCatalogVersion(); diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java index f73e019e84..9f2b67ad06 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java @@ -68,7 +68,7 @@ public class CatalogUtilsTest extends BaseIgniteAbstractTest { @BeforeEach void setUp() { - catalogManager.start(); + assertThat(catalogManager.start(), willCompleteSuccessfully()); } @AfterEach diff --git a/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/CatalogTestUtils.java b/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/CatalogTestUtils.java index 232d8f6edd..ccd14b5d7c 100644 --- a/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/CatalogTestUtils.java +++ b/modules/catalog/src/testFixtures/java/org/apache/ignite/internal/catalog/CatalogTestUtils.java @@ -19,10 +19,8 @@ package org.apache.ignite.internal.catalog; import static java.util.concurrent.CompletableFuture.allOf; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_NAME; -import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; import static org.apache.ignite.internal.util.CompletableFutures.falseCompletedFuture; import static org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.List; @@ -50,9 +48,7 @@ import org.apache.ignite.internal.metastorage.server.SimpleInMemoryKeyValueStora import org.apache.ignite.lang.ErrorGroups.Common; import org.apache.ignite.sql.ColumnType; -/** - * Utilities for working with the catalog in tests. - */ +/** Utilities for working with the catalog in tests. */ public class CatalogTestUtils { /** * Creates a test implementation of {@link CatalogManager}. @@ -70,14 +66,42 @@ public class CatalogTestUtils { return new CatalogManagerImpl(new UpdateLogImpl(metastore), clockWaiter) { @Override public CompletableFuture<Void> start() { - metastore.start(); - clockWaiter.start(); + return allOf(metastore.start(), clockWaiter.start(), super.start()).thenCompose(unused -> metastore.deployWatches()); + } - super.start(); + @Override + public void beforeNodeStop() { + super.beforeNodeStop(); - assertThat(metastore.deployWatches(), willCompleteSuccessfully()); + clockWaiter.beforeNodeStop(); + metastore.beforeNodeStop(); + } - return nullCompletedFuture(); + @Override + public void stop() throws Exception { + super.stop(); + + clockWaiter.stop(); + metastore.stop(); + } + }; + } + + /** + * Creates a test implementation of {@link CatalogManager}. + * + * <p>NOTE: Uses {@link CatalogManagerImpl} under the hood and creates the internals it needs, may change in the future. + * + * @param nodeName Node name. + * @param clockWaiter Clock waiter. + */ + public static CatalogManager createTestCatalogManager(String nodeName, ClockWaiter clockWaiter) { + StandaloneMetaStorageManager metastore = StandaloneMetaStorageManager.create(new SimpleInMemoryKeyValueStorage(nodeName)); + + return new CatalogManagerImpl(new UpdateLogImpl(metastore), clockWaiter) { + @Override + public CompletableFuture<Void> start() { + return allOf(metastore.start(), super.start()).thenCompose(unused -> metastore.deployWatches()); } @Override @@ -113,11 +137,7 @@ public class CatalogTestUtils { return new CatalogManagerImpl(new UpdateLogImpl(metastore), clockWaiter) { @Override public CompletableFuture<Void> start() { - clockWaiter.start(); - - super.start(); - - return nullCompletedFuture(); + return allOf(clockWaiter.start(), super.start()); } @Override @@ -155,9 +175,7 @@ public class CatalogTestUtils { return new CatalogManagerImpl(new TestUpdateLog(clock), clockWaiter) { @Override public CompletableFuture<Void> start() { - CompletableFuture<Void> fut = clockWaiter.start(); - - return allOf(fut, super.start()); + return allOf(clockWaiter.start(), super.start()); } @Override diff --git a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/BaseDistributionZoneManagerTest.java b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/BaseDistributionZoneManagerTest.java index b3a804c104..130a2c9d71 100644 --- a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/BaseDistributionZoneManagerTest.java +++ b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/BaseDistributionZoneManagerTest.java @@ -17,7 +17,10 @@ package org.apache.ignite.internal.distributionzones; +import static java.util.concurrent.CompletableFuture.allOf; import static java.util.concurrent.CompletableFuture.completedFuture; +import static java.util.stream.Collectors.toList; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; @@ -31,7 +34,6 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.LongFunction; import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.CatalogTestUtils; import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager; import org.apache.ignite.internal.cluster.management.raft.ClusterStateStorage; import org.apache.ignite.internal.cluster.management.raft.TestClusterStateStorage; @@ -52,9 +54,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; -/** - * Base class for {@link DistributionZoneManager} unit tests. - */ +/** Base class for {@link DistributionZoneManager} unit tests. */ @ExtendWith(ConfigurationExtension.class) public abstract class BaseDistributionZoneManagerTest extends BaseIgniteAbstractTest { protected static final String ZONE_NAME = "zone1"; @@ -80,7 +80,7 @@ public abstract class BaseDistributionZoneManagerTest extends BaseIgniteAbstract private final List<IgniteComponent> components = new ArrayList<>(); @BeforeEach - void setUp() throws InterruptedException { + void setUp() throws Exception { String nodeName = "test"; keyValueStorage = spy(new SimpleInMemoryKeyValueStorage(nodeName)); @@ -102,7 +102,7 @@ public abstract class BaseDistributionZoneManagerTest extends BaseIgniteAbstract Consumer<LongFunction<CompletableFuture<?>>> revisionUpdater = (LongFunction<CompletableFuture<?>> function) -> metaStorageManager.registerRevisionUpdateListener(function::apply); - catalogManager = CatalogTestUtils.createTestCatalogManager(nodeName, clock, metaStorageManager); + catalogManager = createTestCatalogManager(nodeName, clock, metaStorageManager); components.add(catalogManager); distributionZoneManager = new DistributionZoneManager( @@ -114,7 +114,10 @@ public abstract class BaseDistributionZoneManagerTest extends BaseIgniteAbstract ); // Not adding 'distributionZoneManager' on purpose, it's started manually. - components.forEach(IgniteComponent::start); + assertThat( + allOf(components.stream().map(IgniteComponent::start).collect(toList()).toArray(CompletableFuture[]::new)), + willCompleteSuccessfully() + ); } @AfterEach @@ -130,8 +133,7 @@ public abstract class BaseDistributionZoneManagerTest extends BaseIgniteAbstract } void startDistributionZoneManager() { - distributionZoneManager.start(); - + assertThat(allOf(distributionZoneManager.start()), willCompleteSuccessfully()); assertThat(metaStorageManager.deployWatches(), willCompleteSuccessfully()); } diff --git a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java index de90365bef..882291c548 100644 --- a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java +++ b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java @@ -24,8 +24,6 @@ import static org.apache.ignite.internal.distributionzones.DistributionZonesTest import static org.apache.ignite.internal.distributionzones.DistributionZonesUtil.zoneScaleDownChangeTriggerKey; import static org.apache.ignite.internal.distributionzones.DistributionZonesUtil.zoneScaleUpChangeTriggerKey; import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; -import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -36,9 +34,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** - * Tests distribution zones configuration changes and reaction to that changes. - */ +/** Tests distribution zones configuration changes and reaction to that changes. */ public class DistributionZoneManagerConfigurationChangesTest extends BaseDistributionZoneManagerTest { private static final String ZONE_NAME = "zone1"; @@ -50,12 +46,10 @@ public class DistributionZoneManagerConfigurationChangesTest extends BaseDistrib @BeforeEach @Override - public void setUp() throws InterruptedException { + public void setUp() throws Exception { super.setUp(); - distributionZoneManager.start(); - - assertThat(metaStorageManager.deployWatches(), willCompleteSuccessfully()); + startDistributionZoneManager(); topology.putNode(NODE_1); diff --git a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngineTest.java b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngineTest.java index d4db410b60..2c5afff56c 100644 --- a/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngineTest.java +++ b/modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngineTest.java @@ -31,9 +31,11 @@ import static org.apache.ignite.internal.distributionzones.DistributionZonesUtil import static org.apache.ignite.internal.distributionzones.rebalance.RebalanceUtil.stablePartAssignmentsKey; import static org.apache.ignite.internal.table.TableTestUtils.getTableIdStrict; import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; import static org.apache.ignite.internal.util.ByteUtils.fromBytes; import static org.apache.ignite.internal.util.ByteUtils.toBytes; import static org.apache.ignite.sql.ColumnType.STRING; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -131,7 +133,7 @@ public class DistributionZoneRebalanceEngineTest extends IgniteAbstractTest { String nodeName = "test"; catalogManager = createTestCatalogManager(nodeName, clock); - catalogManager.start(); + assertThat(catalogManager.start(), willCompleteSuccessfully()); createZone(ZONE_NAME_0, 1, 128); createZone(ZONE_NAME_1, 2, 128); diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerRestorerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerRestorerTest.java index 844812d678..dd061bde68 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerRestorerTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerRestorerTest.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.index; +import static java.util.concurrent.CompletableFuture.allOf; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.index.IndexManagementUtils.getPartitionCountFromCatalog; import static org.apache.ignite.internal.index.IndexManagementUtils.inProgressBuildIndexMetastoreKey; import static org.apache.ignite.internal.index.IndexManagementUtils.partitionBuildIndexMetastoreKey; @@ -46,12 +48,9 @@ import static org.mockito.Mockito.when; import java.nio.file.Path; import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.CatalogTestUtils; import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; -import org.apache.ignite.internal.manager.IgniteComponent; import org.apache.ignite.internal.metastorage.impl.MetaStorageManagerImpl; import org.apache.ignite.internal.metastorage.impl.StandaloneMetaStorageManager; import org.apache.ignite.internal.metastorage.server.KeyValueStorage; @@ -92,9 +91,9 @@ public class IndexAvailabilityControllerRestorerTest extends BaseIgniteAbstractT metaStorageManager = StandaloneMetaStorageManager.create(keyValueStorage); - catalogManager = CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock, metaStorageManager); + catalogManager = createTestCatalogManager(NODE_NAME, clock, metaStorageManager); - Stream.of(metaStorageManager, catalogManager).forEach(IgniteComponent::start); + assertThat(allOf(metaStorageManager.start(), catalogManager.start()), willCompleteSuccessfully()); deployWatches(); @@ -201,9 +200,9 @@ public class IndexAvailabilityControllerRestorerTest extends BaseIgniteAbstractT metaStorageManager = StandaloneMetaStorageManager.create(keyValueStorage); - catalogManager = spy(CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock, metaStorageManager)); + catalogManager = spy(createTestCatalogManager(NODE_NAME, clock, metaStorageManager)); - Stream.of(metaStorageManager, catalogManager).forEach(IgniteComponent::start); + assertThat(allOf(metaStorageManager.start(), catalogManager.start()), willCompleteSuccessfully()); } private void deployWatches() throws Exception { diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerTest.java index d076b10908..3044c97e22 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexAvailabilityControllerTest.java @@ -17,8 +17,10 @@ package org.apache.ignite.internal.index; +import static java.util.concurrent.CompletableFuture.allOf; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_NAME; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_ZONE_NAME; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexName; import static org.apache.ignite.internal.catalog.descriptors.CatalogIndexStatus.AVAILABLE; import static org.apache.ignite.internal.index.TestIndexManagementUtils.COLUMN_NAME; @@ -41,15 +43,12 @@ import static org.mockito.Mockito.when; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.CatalogTestUtils; import org.apache.ignite.internal.catalog.commands.AlterZoneCommand; import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; import org.apache.ignite.internal.lang.ByteArray; -import org.apache.ignite.internal.manager.IgniteComponent; import org.apache.ignite.internal.metastorage.Entry; import org.apache.ignite.internal.metastorage.impl.MetaStorageManagerImpl; import org.apache.ignite.internal.metastorage.impl.StandaloneMetaStorageManager; @@ -75,7 +74,7 @@ public class IndexAvailabilityControllerTest extends BaseIgniteAbstractTest { private final MetaStorageManagerImpl metaStorageManager = StandaloneMetaStorageManager.create(); - private final CatalogManager catalogManager = CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock, metaStorageManager); + private final CatalogManager catalogManager = createTestCatalogManager(NODE_NAME, clock, metaStorageManager); private final IndexBuilder indexBuilder = new IndexBuilder( NODE_NAME, @@ -91,8 +90,7 @@ public class IndexAvailabilityControllerTest extends BaseIgniteAbstractTest { @BeforeEach void setUp() { - Stream.of(metaStorageManager, catalogManager).forEach(IgniteComponent::start); - + assertThat(allOf(metaStorageManager.start(), catalogManager.start()), willCompleteSuccessfully()); assertThat(metaStorageManager.deployWatches(), willCompleteSuccessfully()); CatalogZoneDescriptor zoneDescriptor = catalogManager.zone(DEFAULT_ZONE_NAME, clock.nowLong()); diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuildControllerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuildControllerTest.java index 110fc66da8..59278dbefc 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuildControllerTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexBuildControllerTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.index; import static java.util.concurrent.CompletableFuture.completedFuture; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_NAME; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexName; import static org.apache.ignite.internal.index.TestIndexManagementUtils.COLUMN_NAME; import static org.apache.ignite.internal.index.TestIndexManagementUtils.INDEX_NAME; @@ -48,7 +49,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.CatalogTestUtils; import org.apache.ignite.internal.catalog.commands.MakeIndexAvailableCommand; import org.apache.ignite.internal.catalog.commands.StartBuildingIndexCommand; import org.apache.ignite.internal.event.AbstractEventProducer; @@ -105,8 +105,8 @@ public class IndexBuildControllerTest extends BaseIgniteAbstractTest { ClusterService clusterService = mock(ClusterService.class, invocation -> mock(TopologyService.class, invocation1 -> LOCAL_NODE)); - catalogManager = CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock); - catalogManager.start(); + catalogManager = createTestCatalogManager(NODE_NAME, clock); + assertThat(catalogManager.start(), willCompleteSuccessfully()); indexBuildController = new IndexBuildController(indexBuilder, indexManager, catalogManager, clusterService, placementDriver, clock); diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexChooserTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexChooserTest.java index 6e7742d16e..45db3e1efc 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexChooserTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexChooserTest.java @@ -63,7 +63,7 @@ public class IndexChooserTest extends BaseIgniteAbstractTest { @BeforeEach void setUp() { - catalogManager.start(); + assertThat(catalogManager.start(), willCompleteSuccessfully()); createTable(catalogManager, TABLE_NAME, COLUMN_NAME); diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java index dc7d27a507..9b49cdff0b 100644 --- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java +++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java @@ -17,10 +17,12 @@ package org.apache.ignite.internal.index; +import static java.util.concurrent.CompletableFuture.allOf; import static java.util.concurrent.CompletableFuture.completedFuture; import static java.util.stream.Collectors.toList; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_NAME; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_ZONE_NAME; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_DATA_REGION; import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexName; import static org.apache.ignite.internal.index.TestIndexManagementUtils.COLUMN_NAME; @@ -72,7 +74,6 @@ import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; import org.apache.ignite.internal.catalog.events.CatalogEvent; import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; -import org.apache.ignite.internal.manager.IgniteComponent; import org.apache.ignite.internal.metastorage.impl.MetaStorageManagerImpl; import org.apache.ignite.internal.metastorage.impl.MetaStorageService; import org.apache.ignite.internal.metastorage.impl.StandaloneMetaStorageManager; @@ -389,7 +390,7 @@ public class IndexManagerTest extends BaseIgniteAbstractTest { private void createAndStartComponents() { metaStorageManager = StandaloneMetaStorageManager.create(new TestRocksDbKeyValueStorage(NODE_NAME, workDir)); - catalogManager = CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock, metaStorageManager); + catalogManager = createTestCatalogManager(NODE_NAME, clock, metaStorageManager); indexManager = new IndexManager( mockSchemaManager, @@ -399,7 +400,7 @@ public class IndexManagerTest extends BaseIgniteAbstractTest { (LongFunction<CompletableFuture<?>> function) -> metaStorageManager.registerRevisionUpdateListener(function::apply) ); - List.of(metaStorageManager, catalogManager, indexManager).forEach(IgniteComponent::start); + assertThat(allOf(metaStorageManager.start(), catalogManager.start(), indexManager.start()), willCompleteSuccessfully()); assertThat(metaStorageManager.recoveryFinishedFuture(), willCompleteSuccessfully()); assertThat(metaStorageManager.notifyRevisionUpdateListenerOnStart(), willCompleteSuccessfully()); diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java index eecca1d063..45a220604f 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandlerExceptionHandlingTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.sql.engine.exec.ddl; +import static org.apache.ignite.internal.catalog.CatalogTestUtils.createTestCatalogManager; import static org.apache.ignite.internal.distributionzones.DistributionZonesTestUtil.createZone; import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrow; import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; @@ -24,7 +25,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.util.concurrent.CompletableFuture; import org.apache.ignite.internal.catalog.CatalogManager; -import org.apache.ignite.internal.catalog.CatalogTestUtils; import org.apache.ignite.internal.catalog.DistributionZoneExistsValidationException; import org.apache.ignite.internal.catalog.DistributionZoneNotFoundValidationException; import org.apache.ignite.internal.hlc.HybridClockImpl; @@ -35,9 +35,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** - * Tests distribution zone command exception handling. - */ +/** Tests distribution zone command exception handling. */ public class DdlCommandHandlerExceptionHandlingTest extends IgniteAbstractTest { private DdlCommandHandler commandHandler; @@ -47,8 +45,8 @@ public class DdlCommandHandlerExceptionHandlingTest extends IgniteAbstractTest { @BeforeEach void before() { - catalogManager = CatalogTestUtils.createTestCatalogManager("test", new HybridClockImpl()); - catalogManager.start(); + catalogManager = createTestCatalogManager("test", new HybridClockImpl()); + assertThat(catalogManager.start(), willCompleteSuccessfully()); commandHandler = new DdlCommandHandler(catalogManager); } diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestCluster.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestCluster.java index 8549b80a2b..b94b8b9f28 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestCluster.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestCluster.java @@ -17,6 +17,9 @@ package org.apache.ignite.internal.sql.engine.framework; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; +import static org.hamcrest.MatcherAssert.assertThat; + import java.util.Collections; import java.util.List; import java.util.Map; @@ -69,18 +72,15 @@ public class TestCluster implements LifecycleAware { return nodeByName.get(name); } - /** {@inheritDoc} */ @Override public void start() { components.forEach(LifecycleAware::start); nodeByName.values().forEach(TestNode::start); - initClosure.run(); } - /** {@inheritDoc} */ @Override public void stop() throws Exception { List<AutoCloseable> closeables = Stream.concat( @@ -103,7 +103,7 @@ public class TestCluster implements LifecycleAware { @Override public void start() { - component.start(); + assertThat(component.start(), willCompleteSuccessfully()); } @Override diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImplTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImplTest.java index 027ab6d737..5a8f5d5f62 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImplTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImplTest.java @@ -20,6 +20,7 @@ package org.apache.ignite.internal.sql.engine.schema; import static org.apache.ignite.internal.sql.engine.util.TypeUtils.columnType2NativeType; import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrowsWithCause; import static org.apache.ignite.internal.testframework.IgniteTestUtils.await; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -83,9 +84,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.mockito.junit.jupiter.MockitoExtension; -/** - * Tests for {@link SqlSchemaManagerImpl}. - */ +/** Tests for {@link SqlSchemaManagerImpl}. */ @ExtendWith(MockitoExtension.class) public class SqlSchemaManagerImplTest extends BaseIgniteAbstractTest { private static final String PUBLIC_SCHEMA_NAME = "PUBLIC"; @@ -99,7 +98,7 @@ public class SqlSchemaManagerImplTest extends BaseIgniteAbstractTest { catalogManager = CatalogTestUtils.createCatalogManagerWithTestUpdateLog("test", new HybridClockImpl()); sqlSchemaManager = new SqlSchemaManagerImpl(catalogManager, CaffeineCacheFactory.INSTANCE, 200); - catalogManager.start(); + assertThat(catalogManager.start(), willCompleteSuccessfully()); } @AfterEach diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java index 984c7c50f8..1ac057fc18 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.table.distributed; +import static java.util.concurrent.CompletableFuture.allOf; import static java.util.concurrent.CompletableFuture.completedFuture; import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_NAME; import static org.apache.ignite.internal.catalog.events.CatalogEvent.TABLE_CREATE; @@ -135,9 +136,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -/** - * Tests scenarios for table manager. - */ +/** Tests scenarios for table manager. */ @ExtendWith({MockitoExtension.class, ConfigurationExtension.class}) @MockitoSettings(strictness = Strictness.LENIENT) public class TableManagerTest extends IgniteAbstractTest { @@ -235,8 +234,7 @@ public class TableManagerTest extends IgniteAbstractTest { catalogMetastore = StandaloneMetaStorageManager.create(new SimpleInMemoryKeyValueStorage(NODE_NAME)); catalogManager = CatalogTestUtils.createTestCatalogManager(NODE_NAME, clock, catalogMetastore); - catalogMetastore.start(); - catalogManager.start(); + assertThat(allOf(catalogMetastore.start(), catalogManager.start()), willCompleteSuccessfully()); revisionUpdater = (LongFunction<CompletableFuture<?>> function) -> catalogMetastore.registerRevisionUpdateListener(function::apply); @@ -753,9 +751,7 @@ public class TableManagerTest extends IgniteAbstractTest { } }; - sm.start(); - - tableManager.start(); + assertThat(allOf(sm.start(), tableManager.start()), willCompleteSuccessfully()); tblManagerFut.complete(tableManager); @@ -775,7 +771,7 @@ public class TableManagerTest extends IgniteAbstractTest { dataStorageModules.createStorageEngines(NODE_NAME, mockedRegistry, storagePath, null) ); - manager.start(); + assertThat(manager.start(), willCompleteSuccessfully()); return manager; }