@Test
    public void snapshotTest() throws Exception {
        final File backupDir = new File("backup");
        if (backupDir.exists()) {
            FileUtils.deleteDirectory(backupDir);
        }
        FileUtils.forceMkdir(backupDir);
        for (int i = 0; i < 100000; i++) {
            final String v = String.valueOf(i);
            this.kvStore.put(makeKey(v), makeValue(v), null);
        }
        for (int i = 0; i < 10000; i++) {
            this.kvStore.getSequence(makeKey((i % 100) + "seq_test"), 10, null);
        }
        final Region region = new Region();
        KVStoreSnapshotFile kvStoreSnapshotFile = KVStoreSnapshotFileFactory.getKVStoreSnapshotFile(this.kvStore);
        final ExecutorService snapshotPool = StoreEngineHelper.createSnapshotExecutor(1, 2);
        final TestSnapshotWriter snapshotWriter = new TestSnapshotWriter(backupDir.getAbsolutePath());
        final CountDownLatch latch = new CountDownLatch(1);
        final Closure done = status -> {
            assertTrue(status.isOk());
            latch.countDown();
        };
        kvStoreSnapshotFile.save(snapshotWriter, region, done, snapshotPool);
        latch.await();
        final LocalFileMeta meta = (LocalFileMeta) snapshotWriter.getFileMeta(SNAPSHOT_ARCHIVE);
        assertNotNull(meta);

        assertNotNull(get(makeKey("1")));

        this.kvStore.put(makeKey("100001"), makeValue("100001"), null);
        assertNotNull(get(makeKey("100001")));

        this.kvStore.shutdown();
        this.kvStore = new MemoryRawKVStore();
        final MemoryDBOptions dbOpts = new MemoryDBOptions();
        this.kvStore.init(dbOpts);

        assertNull(get(makeKey("1")));

        final TestSnapshotReader snapshotReader = new TestSnapshotReader(snapshotWriter.metaTable, backupDir.getAbsolutePath());
        kvStoreSnapshotFile = KVStoreSnapshotFileFactory.getKVStoreSnapshotFile(this.kvStore);
        final boolean ret = kvStoreSnapshotFile.load(snapshotReader, region);
        assertTrue(ret);


        for (int i = 0; i < 100000; i++) {
            final String v = String.valueOf(i);
            assertArrayEquals(makeValue(v), get(makeKey(v)));
        }

        // Key[100001] is put after the snapshot, so key[100001] should not exist
        assertNull(get(makeKey("100001")));

        FileUtils.deleteDirectory(backupDir);
        ExecutorServiceHelper.shutdownAndAwaitTermination(snapshotPool);
    }
Test method: {@link MemoryRawKVStore#delete(List, KVStoreClosure)}
jraft-rheakv/rheakv-core/src/test/java/com/alipay/sofa/jraft/rhea/storage/memorydb/MemoryKVStoreTest.java