tkalkirill commented on code in PR #2871:
URL: https://github.com/apache/ignite-3/pull/2871#discussion_r1406173368
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/commands/CatalogUtilsTest.java:
##########
@@ -189,6 +217,187 @@ void testFromParamsAndPreviousValueWithAutoAdjustFields()
{
);
}
+ @Test
+ void testCollectIndexesAfterCreateTable() throws Exception {
+ withCatalogManager(catalogManager -> {
+ createTable(catalogManager, TABLE_NAME);
+
+ int latestCatalogVersion = catalogManager.latestCatalogVersion();
+ int earliestCatalogVersion =
catalogManager.earliestCatalogVersion();
+
+ int tableId = tableId(catalogManager, latestCatalogVersion,
TABLE_NAME);
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
latestCatalogVersion, latestCatalogVersion),
+ contains(index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME))
+ );
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
earliestCatalogVersion, latestCatalogVersion),
+ contains(index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME))
+ );
+ });
+ }
+
+ @Test
+ void testCollectIndexesAfterCreateIndex() throws Exception {
+ withCatalogManager(catalogManager -> {
+ createTable(catalogManager, TABLE_NAME);
+ createIndex(catalogManager, TABLE_NAME, INDEX_NAME);
+
+ int latestCatalogVersion = catalogManager.latestCatalogVersion();
+ int earliestCatalogVersion =
catalogManager.earliestCatalogVersion();
+
+ int tableId = tableId(catalogManager, latestCatalogVersion,
TABLE_NAME);
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
latestCatalogVersion, latestCatalogVersion),
+ contains(
+ index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME),
+ index(catalogManager, latestCatalogVersion,
INDEX_NAME)
+ )
+ );
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
earliestCatalogVersion, latestCatalogVersion),
+ contains(
+ index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME),
+ index(catalogManager, latestCatalogVersion,
INDEX_NAME)
+ )
+ );
+ });
+ }
+
+ @Test
+ void testCollectIndexesAfterCreateIndexAndMakeAvailableIndex() throws
Exception {
+ withCatalogManager(catalogManager -> {
+ String indexName0 = INDEX_NAME + 0;
+ String indexName1 = INDEX_NAME + 1;
+
+ createTable(catalogManager, TABLE_NAME);
+ createIndex(catalogManager, TABLE_NAME, indexName0);
+ createIndex(catalogManager, TABLE_NAME, indexName1);
+
+ makeIndexAvailable(catalogManager, indexName1);
+
+ int latestCatalogVersion = catalogManager.latestCatalogVersion();
+ int earliestCatalogVersion =
catalogManager.earliestCatalogVersion();
+
+ int tableId = tableId(catalogManager, latestCatalogVersion,
TABLE_NAME);
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
latestCatalogVersion, latestCatalogVersion),
+ contains(
+ index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME),
+ index(catalogManager, latestCatalogVersion,
indexName0),
+ index(catalogManager, latestCatalogVersion,
indexName1)
+ )
+ );
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
earliestCatalogVersion, latestCatalogVersion),
+ contains(
+ index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME),
+ index(catalogManager, latestCatalogVersion,
indexName0),
+ index(catalogManager, latestCatalogVersion,
indexName1)
+ )
+ );
+ });
+ }
+
+ @Test
+ void testCollectIndexesAfterDropIndexes() throws Exception {
+ withCatalogManager(catalogManager -> {
+ String indexName0 = INDEX_NAME + 0;
+ String indexName1 = INDEX_NAME + 1;
+
+ createTable(catalogManager, TABLE_NAME);
+ createIndex(catalogManager, TABLE_NAME, indexName0);
+ createIndex(catalogManager, TABLE_NAME, indexName1);
+
+ makeIndexAvailable(catalogManager, indexName1);
+
+ int catalogVersionBeforeDropIndex0 =
catalogManager.latestCatalogVersion();
+
+ dropIndex(catalogManager, indexName0);
+
+ int catalogVersionBeforeDropIndex1 =
catalogManager.latestCatalogVersion();
+
+ dropIndex(catalogManager, indexName1);
+
+ int latestCatalogVersion = catalogManager.latestCatalogVersion();
+ int earliestCatalogVersion =
catalogManager.earliestCatalogVersion();
+
+ int tableId = tableId(catalogManager, latestCatalogVersion,
TABLE_NAME);
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
latestCatalogVersion, latestCatalogVersion),
+ contains(index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME))
+ );
+
+ assertThat(
+ collectIndexes(catalogManager, tableId,
earliestCatalogVersion, latestCatalogVersion),
+ contains(
+ index(catalogManager, latestCatalogVersion,
PK_INDEX_NAME),
+ index(catalogManager,
catalogVersionBeforeDropIndex0, indexName0),
+ index(catalogManager,
catalogVersionBeforeDropIndex1, indexName1)
+ )
+ );
+ });
+ }
+
+ @Test
+ void testCollectIndexesComplexCase() throws Exception {
Review Comment:
I tried to leave a comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]