tkalkirill commented on code in PR #4528: URL: https://github.com/apache/ignite-3/pull/4528#discussion_r1793626721
########## modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/RocksDbKeyValueStorageTest.java: ########## @@ -28,4 +48,256 @@ public class RocksDbKeyValueStorageTest extends BasicOperationsKeyValueStorageTe public KeyValueStorage createStorage() { return new RocksDbKeyValueStorage("test", workDir.resolve("storage"), new NoOpFailureManager()); } + + @Override + protected boolean supportsChecksums() { + return true; + } + + @Test + public void putChecksum() { + byte[] key = key(1); + byte[] val = keyValue(1, 1); + + putToMs(key, val); + Long checksum1 = storage.checksum(1); + + assertThat(checksum1, is(notNullValue())); Review Comment: There can't be null =) ########## modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/RocksDbKeyValueStorageTest.java: ########## @@ -28,4 +48,256 @@ public class RocksDbKeyValueStorageTest extends BasicOperationsKeyValueStorageTe public KeyValueStorage createStorage() { return new RocksDbKeyValueStorage("test", workDir.resolve("storage"), new NoOpFailureManager()); } + + @Override + protected boolean supportsChecksums() { + return true; + } + + @Test + public void putChecksum() { + byte[] key = key(1); + byte[] val = keyValue(1, 1); + + putToMs(key, val); + Long checksum1 = storage.checksum(1); + + assertThat(checksum1, is(notNullValue())); + assertThat(checksum1, is(checksum( + longToBytes(0), // prev checksum + bytes(1), // PUT + intToBytes(key.length), key, + intToBytes(val.length), val + ))); + + // Repeating the same command, the checksum must be different. + putToMs(key, val); + assertThat(storage.checksum(2), is(checksum( + longToBytes(checksum1), + bytes(1), + intToBytes(key.length), key, + intToBytes(val.length), val + ))); + } + + @Test + public void putAllChecksum() { + byte[] key1 = key(1); + byte[] val1 = keyValue(1, 1); + byte[] key2 = key(2); + byte[] val2 = keyValue(2, 2); + + putAllToMs(List.of(key1, key2), List.of(val1, val2)); + Long checksum1 = storage.checksum(1); + + assertThat(checksum1, is(notNullValue())); Review Comment: same ########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java: ########## @@ -191,6 +196,9 @@ public class RocksDbKeyValueStorage implements KeyValueStorage { /** Revision to timestamp mapping column family. */ private volatile ColumnFamily revisionToTs; + /** Revision to checksum mapping column family. */ + private volatile ColumnFamily revisionToChecksum; Review Comment: Ok ########## modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java: ########## @@ -970,6 +970,11 @@ public long getCompactionRevision() { } } + @Override + public @Nullable Long checksum(long revision) { + throw new UnsupportedOperationException(); Review Comment: I don’t insist, we could do it for testing for convenience and not worry too much about what to use in the future, we could make it a separate ticket. ########## modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java: ########## @@ -293,7 +293,7 @@ public boolean invoke( boolean branch = condition.test(e.toArray(new Entry[]{})); Review Comment: Ok ########## modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/RocksDbCompactionKeyValueStorageTest.java: ########## @@ -17,13 +17,29 @@ package org.apache.ignite.internal.metastorage.server; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + import org.apache.ignite.internal.failure.NoOpFailureManager; import org.apache.ignite.internal.metastorage.server.persistence.RocksDbKeyValueStorage; +import org.junit.jupiter.api.Test; /** Compaction test for the RocksDB implementation of {@link KeyValueStorage}. */ public class RocksDbCompactionKeyValueStorageTest extends AbstractCompactionKeyValueStorageTest { @Override public KeyValueStorage createStorage() { return new RocksDbKeyValueStorage("test", workDir.resolve("storage"), new NoOpFailureManager()); } + + @Test + void checksumsAreRemovedForCompactedRevisions() { Review Comment: Ok -- 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