imbajin commented on code in PR #2982:
URL: https://github.com/apache/hugegraph/pull/2982#discussion_r3356297961
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java:
##########
@@ -2683,6 +2683,28 @@ public void testQueryEdgesByIdWithGraphAPI() {
Assert.assertEquals(2, edges.size());
}
+ @Test
+ public void testQueryEdgesByNonConsecutiveDuplicateIds() {
+ HugeGraph graph = graph();
+ init18Edges();
+
+ List<Edge> allEdges = graph.traversal().E().toList();
+ Assert.assertTrue("need at least 2 edges", allEdges.size() >= 2);
+
+ Object id1 = allEdges.get(0).id();
+ Object id2 = allEdges.get(1).id();
+
+ // Graph API does not guarantee duplicate results for duplicate ids
+ List<Edge> edges = ImmutableList.copyOf(graph.edges(id1, id2, id1));
+ Assert.assertTrue(edges.size() >= 2);
Review Comment:
⚠️ 这个回归测试还没有真正锁住非连续重复 edge id 的语义。
当前 `graph.edges(id1, id2, id1)` 只断言 `edges.size() >= 2` 且结果包含
`id1/id2`。如果实现再次退化成错误结果 `[id1, id2]`,这个测试仍然会通过。
这里风险路径正是:
```text
graph.edges(id1, id2, id1)
-> GraphTransaction fast path
-> RocksDB Edge queryByIds()
-> backend iterator 直接返回
```
建议把断言改成精确校验 3 条结果,并确认顺序或至少确认 `id1` 出现两次:
```java
Assert.assertEquals(3, edges.size());
Assert.assertEquals(id1, edges.get(0).id());
Assert.assertEquals(id2, edges.get(1).id());
Assert.assertEquals(id1, edges.get(2).id());
```
这样才能真正覆盖这次 PR 要修住的 Graph API multiplicity 行为。
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]