You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "JisoLya (via GitHub)" <gi...@apache.org> on 2026/01/20 08:33:19 UTC

[PR] test(server-test): enable run single unit test [incubator-hugegraph]

JisoLya opened a new pull request, #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940

   <!-- 
     Thank you very much for contributing to Apache HugeGraph, we are happy that you want to help us improve it!
   
     Here are some tips for you:
       1. If this is your first time, please read the [contributing guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
   
       2. If a PR fix/close an issue, type the message "close xxx" (xxx is the link of related 
   issue) in the content, GitHub will auto link it (Required)
   
       3. Name the PR title in "Google Commit Format", start with "feat | fix | perf | refactor | doc | chore", 
         such like: "feat(core): support the PageRank algorithm" or "fix: wrong break in the compute loop" (module is optional)
         skip it if you are unsure about which is the best component.
   
       4. One PR address one issue, better not to mix up multiple issues.
   
       5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click it directly after 
   published)
   -->
   
   ## Purpose of the PR
   
   - close #xxx <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, e.g: close #1024 -->
   
   <!--
   Please explain more context in this section, clarify why the changes are needed. 
   e.g:
   - If you propose a new API, clarify the use case for a new API.
   - If you fix a bug, you can clarify why it is a bug, and should be associated with an issue.
   -->
   
   ## Main Changes
   
   <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. These change logs are helpful for better and faster reviews.)
   
   For example:
   
   - If you introduce a new feature, please show detailed design here or add the link of design documentation.
   - If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
   - If there is a discussion in the mailing list, please add the link. -->
   
   ## Verifying these changes
   
   <!-- Please pick the proper options below -->
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [ ] Already covered by existing tests, such as *(please modify tests here)*.
   - [ ] Need tests and can be verified as follows:
       - xxx
   
   ## Does this PR potentially affect the following parts?
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  Dependencies ([add/update license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses) info & [regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh)) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
   - [ ]  Modify configurations
   - [ ]  The public API
   - [ ]  Other affects (typed here)
   - [ ]  Nope
   
   
   ## Documentation Status
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
   - [ ]  `Doc - Done` <!-- Related docs have been already added or updated -->
   - [ ]  `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
   


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2731177449


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,18 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;
 
     public static HugeGraph graph() {
-        Assert.assertNotNull(graph);
         //Assert.assertFalse(graph.closed());

Review Comment:
   ‼️ **Critical: Missing space before opening brace**
   
   Code style issue - there should be a space before `{` according to project conventions.
   
   ```suggestion
                   if (graph == null) {
                       synchronized (CoreTestSuite.class) {
                           if (graph == null) {
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,18 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;
 
     public static HugeGraph graph() {
-        Assert.assertNotNull(graph);
         //Assert.assertFalse(graph.closed());
+        if (graph == null) {
+            synchronized (CoreTestSuite.class){
+                if (graph == null) {
+                    initEnv();
+                    init();

Review Comment:
   ‼️ **Critical: Exception handling concern in lazy initialization**
   
   The `initEnv()` and `init()` methods can throw exceptions. If an exception occurs inside the synchronized block:
   
   1. `graph` remains `null`
   2. Subsequent calls will retry initialization (possibly desirable, but may cause repeated failures)
   
   Consider whether failed initialization should be remembered to provide a clearer error message on subsequent calls, or at minimum document this behavior.
   
   Also, there's an ordering dependency: `initEnv()` must complete before `init()`. While this works with the current `registered` flag, consider whether you need additional error handling if `initEnv()` succeeds but `init()` fails.



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2726809338


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -55,8 +54,11 @@ public class CoreTestSuite {
     private static HugeGraph graph = null;
 
     public static HugeGraph graph() {
-        Assert.assertNotNull(graph);
         //Assert.assertFalse(graph.closed());
+        if (graph == null) {
+            initEnv();
+            init();
+        }

Review Comment:
   The lazy initialization in the graph() method is not thread-safe. If multiple test threads call graph() concurrently before initialization completes, they could trigger multiple initializations simultaneously, potentially causing race conditions, resource conflicts, or duplicate graph instances. Consider adding synchronization using a synchronized block or double-checked locking pattern to ensure only one thread performs the initialization.



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2734860893


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,29 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;

Review Comment:
   The `registered` variable should be marked as `volatile` to ensure proper visibility across threads. Since this variable is checked and modified from within a synchronized block in the lazy initialization pattern, there's a potential race condition where one thread might not see the updated value set by another thread. Making it `volatile` ensures thread-safe publication of the variable's value.
   ```suggestion
       private static volatile boolean registered = false;
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,29 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;
 
     public static HugeGraph graph() {
-        Assert.assertNotNull(graph);
-        //Assert.assertFalse(graph.closed());
+        if (graph == null) {
+            synchronized (CoreTestSuite.class) {
+                if (graph == null) {
+                    try {
+                        initEnv();
+                        init();
+                    } catch (Throwable e) {
+                        LOG.error("Failed to initialize HugeGraph instance", e);
+                        graph = null;

Review Comment:
   The assignment `graph = null` is redundant here. At this point in the code flow, `graph` is guaranteed to be null because it's only assigned a value in the `init()` method at line 95. This redundant assignment has no effect and can be removed.



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2731178885


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -26,7 +26,6 @@
 import org.apache.hugegraph.testutil.Utils;
 import org.apache.hugegraph.util.Log;
 import org.junit.AfterClass;
-import org.junit.Assert;

Review Comment:
   ⚠️ **Important: Unused import after removing Assert.assertNotNull()**
   
   The `Assert` import at line 29 is now unused since `Assert.assertNotNull(graph)` was removed. The PR diff shows removing the import at line 29, which is correct.
   
   Please verify the build passes without checkstyle/import warnings.



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,18 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;
 

Review Comment:
   ⚠️ **Important: Commented-out code should be removed or documented**
   
   The commented-out line `//Assert.assertFalse(graph.closed());` was already present before this PR. Consider either:
   1. Removing it entirely if it's no longer needed
   2. Adding a TODO comment explaining why it's commented out and when it should be re-enabled
   
   This helps maintain code clarity.



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] test(server-test): enable run single unit test [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2940:
URL: https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2731179754


##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -52,11 +51,18 @@
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;

Review Comment:
   🧹 **Minor: PR description is incomplete**
   
   The PR description template is not filled out:
   - "close #xxx" is not linked to any issue
   - "Main Changes" section is empty
   - No verification method is checked
   
   Please complete the PR description to help reviewers understand the motivation and testing approach.



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org