sk0x50 commented on code in PR #5245: URL: https://github.com/apache/ignite-3/pull/5245#discussion_r1963458307
########## modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItTransactionsVacuumTest.java: ########## @@ -0,0 +1,142 @@ +/* + * 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.partition.replicator; + +import static org.apache.ignite.internal.TestWrappers.unwrapIgniteTransaction; +import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedFast; +import static org.apache.ignite.internal.tx.impl.ResourceVacuumManager.RESOURCE_VACUUM_INTERVAL_MILLISECONDS_PROPERTY; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.distributionzones.DistributionZonesTestUtil; +import org.apache.ignite.internal.partition.replicator.fixtures.Node; +import org.apache.ignite.internal.table.TableTestUtils; +import org.apache.ignite.internal.table.TableViewInternal; +import org.apache.ignite.internal.testframework.IgniteTestUtils; +import org.apache.ignite.internal.testframework.SystemPropertiesExtension; +import org.apache.ignite.internal.testframework.WithSystemProperty; +import org.apache.ignite.internal.tx.TransactionMeta; +import org.apache.ignite.internal.tx.impl.ReadWriteTransactionImpl; +import org.apache.ignite.table.KeyValueView; +import org.apache.ignite.tx.Transaction; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.extension.ExtendWith; + +// TODO: https://issues.apache.org/jira/browse/IGNITE-22522 remove this test after the switching to zone-based replication + +/** + * Tests transactions vacuum for colocation track. + */ +@ExtendWith(SystemPropertiesExtension.class) +@WithSystemProperty(key = RESOURCE_VACUUM_INTERVAL_MILLISECONDS_PROPERTY, value = "500") +@Timeout(60) +public class ItTransactionsVacuumTest extends AbstractColocationTest { + /** + * Tests transactions vacuum. + * + * @throws Exception If failed. + */ + @Test + public void testTransactionsVacuum() throws Exception { + updateTxnResourceTtl(50L); + + startCluster(1); + Node node = cluster.get(0); + + String zoneName = "test-zone"; + createZone(node, zoneName, 1, 1); + int zoneId = DistributionZonesTestUtil.getZoneId(node.catalogManager, zoneName, node.hybridClock.nowLong()); + + String tableName = "test_table_1"; + createTable(node, zoneName, tableName); + + int tableId = TableTestUtils.getTableId(node.catalogManager, tableName, node.hybridClock.nowLong()); + TableViewInternal tableViewInternal = node.tableManager.table(tableId); + KeyValueView<Long, Integer> tableView = tableViewInternal.keyValueView(Long.class, Integer.class); + + Transaction tx = node.transactions().begin(); + UUID txId = txId(tx); + + tableView.putAll(tx, Map.of(0L, 0, 1L, 1)); + + assertNotNull(volatileTxState(node, txId), "Volatile TX state is absent"); + + assertNull(persistentTxState(node, zoneId, 0, txId), "Persistent TX state exists for non-completed TX"); + + tx.commit(); + + // Check that volatile tx state is removed. + assertTrue(waitForCondition(() -> volatileTxState(node, txId) == null, 10_000)); + + // TODO https://issues.apache.org/jira/browse/IGNITE-24343 Enable this assertion. + // Check that persistent tx state is removed. + // assertTrue(waitForCondition(() -> persistentTxState(node, zoneId, 0, txId) == null, 10_000)); Review Comment: Yes, this assertion should be uncommented when [IGNITE-24343](https://issues.apache.org/jira/browse/IGNITE-24343) is implemented. -- 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