denis-chudov commented on code in PR #5092: URL: https://github.com/apache/ignite-3/pull/5092#discussion_r1960121588
########## modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/distributionzones/ItDistributionZoneMetaStorageCompactionTest.java: ########## @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.distributionzones; + +import static java.util.stream.Collectors.toSet; +import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl; +import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE; +import static org.apache.ignite.internal.distributionzones.DistributionZonesUtil.zoneDataNodesHistoryKey; +import static org.apache.ignite.internal.metastorage.impl.MetaStorageCompactionTriggerConfiguration.DATA_AVAILABILITY_TIME_SYSTEM_PROPERTY_NAME; +import static org.apache.ignite.internal.metastorage.impl.MetaStorageCompactionTriggerConfiguration.INTERVAL_SYSTEM_PROPERTY_NAME; +import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.executeUpdate; +import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrow; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.InitParametersBuilder; +import org.apache.ignite.internal.ClusterPerClassIntegrationTest; +import org.apache.ignite.internal.app.IgniteImpl; +import org.apache.ignite.internal.catalog.CatalogManager; +import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; +import org.apache.ignite.internal.distributionzones.DataNodesHistory.DataNodesHistorySerializer; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.lang.ByteArray; +import org.apache.ignite.internal.metastorage.Entry; +import org.apache.ignite.internal.metastorage.exceptions.CompactedException; +import org.junit.jupiter.api.Test; + +/** + * Test for case of meta storage compaction. + */ +public class ItDistributionZoneMetaStorageCompactionTest extends ClusterPerClassIntegrationTest { + private static final String ZONE_NAME = "TEST_ZONE"; + + @Override + protected int initialNodes() { + return 2; + } + + @Override + protected void configureInitParameters(InitParametersBuilder builder) { + builder.clusterConfiguration(createClusterConfigWithCompactionProperties(10, 10)); + } + + private static String createClusterConfigWithCompactionProperties(long interval, long dataAvailabilityTime) { + return String.format( + "ignite.system.properties: {" + + "%s = \"%s\", " + + "%s = \"%s\"" + + "}", + INTERVAL_SYSTEM_PROPERTY_NAME, interval, DATA_AVAILABILITY_TIME_SYSTEM_PROPERTY_NAME, dataAvailabilityTime + ); + } + + /** + * Tests that data nodes history is available for timestamp that matches a revision that was compacted. + */ + @Test + public void testCompaction() throws InterruptedException { + String zoneSql = "create zone " + ZONE_NAME + " with partitions=1, storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'" + + ", data_nodes_auto_adjust_scale_down=0"; + + CLUSTER.doInSession(0, session -> { + executeUpdate(zoneSql, session); + }); + + IgniteImpl ignite = unwrapIgniteImpl(CLUSTER.node(0)); + + HybridTimestamp beforeNodesStop = ignite.clock().now(); + + CatalogManager catalogManager = ignite.catalogManager(); + CatalogZoneDescriptor zone = catalogManager.activeCatalog(beforeNodesStop.longValue()) + .zone(ZONE_NAME); + + int zoneId = zone.id(); + + Set<String> dataNodesBeforeNodeStop = dataNodes(ignite, zoneId, beforeNodesStop); + + assertEquals(initialNodes(), dataNodesBeforeNodeStop.size()); + + assertTrue(waitForCondition( + () -> dataNodesInLocalMetaStorage(ignite, zoneId, beforeNodesStop).size() == initialNodes(), + 1000 + )); + + long revisionAfterCreateZone = ignite.metaStorageManager().appliedRevision(); + + ignite.metaStorageManager().put(new ByteArray("dummy_key"), "dummy_value".getBytes()); Review Comment: to increment the revision once more, added 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org