This is an automated email from the ASF dual-hosted git repository.
zyxxoo pushed a commit to branch refactor/rust-rewrite-design
in repository https://gitbox.apache.org/repos/asf/hugegraph.git
The following commit(s) were added to refs/heads/refactor/rust-rewrite-design
by this push:
new 025515de5 test(snapshot): detect modified snapshot checksum
025515de5 is described below
commit 025515de5f9616a5f50dea59f3fba7b54928f256
Author: vaughn <[email protected]>
AuthorDate: Sun Sep 13 16:20:53 2026 +0800
test(snapshot): detect modified snapshot checksum
---
.../hugegraph/store/core/snapshot/SnapshotHandlerTest.java | 14 ++++++++++++++
tools/raft-linearizability/test_capture_history.py | 7 +++++++
2 files changed, 21 insertions(+)
diff --git
a/hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/core/snapshot/SnapshotHandlerTest.java
b/hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/core/snapshot/SnapshotHandlerTest.java
index 3d187ee22..a49324120 100644
---
a/hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/core/snapshot/SnapshotHandlerTest.java
+++
b/hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/core/snapshot/SnapshotHandlerTest.java
@@ -18,12 +18,14 @@
package org.apache.hugegraph.store.core.snapshot;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.lang.reflect.Method;
import org.apache.commons.io.FileUtils;
import org.apache.hugegraph.store.core.StoreEngineTestBase;
@@ -208,4 +210,16 @@ public class SnapshotHandlerTest extends
StoreEngineTestBase {
hgSnapshotHandlerUnderTest.onSnapshotLoad(reader, 0L);
assertEquals(true, new File(snapshotDir, "should_not_load").exists());
}
+
+ @Test
+ public void testChecksumChangesWhenSnapshotFileIsModified() throws
Exception {
+ File file = new File("/tmp/snapshot/checksum.sst");
+ FileUtils.writeByteArrayToFile(file, "before".getBytes("UTF-8"));
+ Method method =
SnapshotHandler.class.getDeclaredMethod("calculateChecksum", String.class);
+ method.setAccessible(true);
+ String before = (String) method.invoke(hgSnapshotHandlerUnderTest,
file.getPath());
+ FileUtils.writeByteArrayToFile(file, "after".getBytes("UTF-8"));
+ String after = (String) method.invoke(hgSnapshotHandlerUnderTest,
file.getPath());
+ assertNotEquals(before, after);
+ }
}
diff --git a/tools/raft-linearizability/test_capture_history.py
b/tools/raft-linearizability/test_capture_history.py
index bd18d1a1f..4b2953c48 100644
--- a/tools/raft-linearizability/test_capture_history.py
+++ b/tools/raft-linearizability/test_capture_history.py
@@ -1,3 +1,10 @@
+#!/usr/bin/env python3
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
import importlib.util
import json
from pathlib import Path