bitflicker64 commented on code in PR #3309:
URL: https://github.com/apache/hugegraph/pull/3309#discussion_r4245718635


##########
hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/rocksdb/SessionOperatorTest.java:
##########
@@ -0,0 +1,268 @@
+/*
+ * 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.hugegraph.store.rocksdb;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hugegraph.rocksdb.access.DBStoreException;
+import org.apache.hugegraph.rocksdb.access.RocksDBSession;
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.BackendColumn;
+import org.apache.hugegraph.rocksdb.access.ScanIterator;
+import org.apache.hugegraph.rocksdb.access.SessionOperator;
+import org.apache.hugegraph.rocksdb.access.SessionOperatorImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class SessionOperatorTest extends BaseRocksDbTest {
+
+    private static final String TABLE = "tbl";
+    private static final String GRAPH = "op-graph";
+
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+
+    private ExecutorService prober;
+    private String dataPath;
+    private RocksDBSession session;
+    private int probes;
+
+    private static byte[] b(String s) {
+        return s.getBytes(StandardCharsets.UTF_8);
+    }
+
+    private static List<String> keys(ScanIterator it) {
+        List<String> keys = new ArrayList<>();
+        try {
+            while (it.hasNext()) {
+                BackendColumn col = it.next();
+                keys.add(new String(col.name, StandardCharsets.UTF_8));
+            }
+        } finally {
+            it.close();
+        }
+        return keys;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        this.prober = Executors.newSingleThreadExecutor(r -> {
+            Thread t = new Thread(r, "cf-lock-prober");
+            t.setDaemon(true);
+            return t;
+        });
+        this.dataPath = this.folder.newFolder("data").getAbsolutePath();
+        this.session = new RocksDBSession(hConfig, this.dataPath, GRAPH, 0);
+        this.session.checkTable(TABLE);
+    }
+
+    @After
+    public void tearDown() {
+        if (this.session != null) {
+            this.session.close();

Review Comment:
   Fixed in 1c0a9a0ee. `tearDown()` now unlocks the read holds the test thread 
still owns (looping until `IllegalMonitorStateException`) before 
`session.close()`, and a `Timeout.seconds(60)` rule backs it up. Checked with 
your repro: with line 138 forced to fail, the test now reports that assertion 
in 8 s. With the unlock loop removed as well, the rule fails `tearDown` with 
`TestTimedOutException` after 60 s instead of hanging. `SessionOperatorTest` 
alone passed twice (8/0), and `store-rocksdb-test` 19/0.



-- 
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]

Reply via email to