From 736ccb584f2be6929e1d078190d13245e2f7ef2c Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Fri, 21 Jan 2022 17:23:05 +0800 Subject: [PATCH 1/3] set timeout of raft api test to 60s Change-Id: Ifa93e46992e79cc9b0adc93ad529b72169ec7a7f --- .../src/assembly/travis/conf-raft1/gremlin-server.yaml | 2 +- .../src/assembly/travis/conf-raft1/rest-server.properties | 3 +++ .../src/assembly/travis/conf-raft2/gremlin-server.yaml | 2 +- .../src/assembly/travis/conf-raft2/rest-server.properties | 3 +++ .../src/assembly/travis/conf-raft3/gremlin-server.yaml | 2 +- .../src/assembly/travis/conf-raft3/rest-server.properties | 3 +++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hugegraph-dist/src/assembly/travis/conf-raft1/gremlin-server.yaml b/hugegraph-dist/src/assembly/travis/conf-raft1/gremlin-server.yaml index 29242f954e..41b02ac781 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft1/gremlin-server.yaml +++ b/hugegraph-dist/src/assembly/travis/conf-raft1/gremlin-server.yaml @@ -3,7 +3,7 @@ port: 8181 # timeout in ms of gremlin query -scriptEvaluationTimeout: 30000 +scriptEvaluationTimeout: 60000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer # don't set graph at here, this happens after support for dynamically adding graph diff --git a/hugegraph-dist/src/assembly/travis/conf-raft1/rest-server.properties b/hugegraph-dist/src/assembly/travis/conf-raft1/rest-server.properties index 2611b95a2f..25b6b283d3 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft1/rest-server.properties +++ b/hugegraph-dist/src/assembly/travis/conf-raft1/rest-server.properties @@ -9,3 +9,6 @@ rpc.remote_url=127.0.0.1:8091,127.0.0.1:8092,127.0.0.1:8093 server.id=server1 server.role=master + +restserver.request_timeout=60 +gremlinserver.timeout=60 diff --git a/hugegraph-dist/src/assembly/travis/conf-raft2/gremlin-server.yaml b/hugegraph-dist/src/assembly/travis/conf-raft2/gremlin-server.yaml index fcc0c351e4..119763cc4d 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft2/gremlin-server.yaml +++ b/hugegraph-dist/src/assembly/travis/conf-raft2/gremlin-server.yaml @@ -3,7 +3,7 @@ port: 8182 # timeout in ms of gremlin query -scriptEvaluationTimeout: 30000 +scriptEvaluationTimeout: 60000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer # don't set graph at here, this happens after support for dynamically adding graph diff --git a/hugegraph-dist/src/assembly/travis/conf-raft2/rest-server.properties b/hugegraph-dist/src/assembly/travis/conf-raft2/rest-server.properties index cde90ac068..f1eb1b4584 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft2/rest-server.properties +++ b/hugegraph-dist/src/assembly/travis/conf-raft2/rest-server.properties @@ -9,3 +9,6 @@ rpc.remote_url=127.0.0.1:8091,127.0.0.1:8092,127.0.0.1:8093 server.id=server2 server.role=worker + +restserver.request_timeout=60 +gremlinserver.timeout=60 diff --git a/hugegraph-dist/src/assembly/travis/conf-raft3/gremlin-server.yaml b/hugegraph-dist/src/assembly/travis/conf-raft3/gremlin-server.yaml index 218f49964d..9ecfd01fe9 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft3/gremlin-server.yaml +++ b/hugegraph-dist/src/assembly/travis/conf-raft3/gremlin-server.yaml @@ -3,7 +3,7 @@ port: 8183 # timeout in ms of gremlin query -scriptEvaluationTimeout: 30000 +scriptEvaluationTimeout: 60000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer # don't set graph at here, this happens after support for dynamically adding graph diff --git a/hugegraph-dist/src/assembly/travis/conf-raft3/rest-server.properties b/hugegraph-dist/src/assembly/travis/conf-raft3/rest-server.properties index e8e72a3fd3..e31d3d286f 100644 --- a/hugegraph-dist/src/assembly/travis/conf-raft3/rest-server.properties +++ b/hugegraph-dist/src/assembly/travis/conf-raft3/rest-server.properties @@ -9,3 +9,6 @@ rpc.remote_url=127.0.0.1:8091,127.0.0.1:8092,127.0.0.1:8093 server.id=server3 server.role=worker + +restserver.request_timeout=60 +gremlinserver.timeout=60 From b2763983f69dabc077f8a657b508e23d00ebc2ab Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Tue, 8 Feb 2022 20:20:00 +0800 Subject: [PATCH 2/3] improve test error log Change-Id: I0f3a00558ed9ccb4abb92465e13fae8fbcfd7338 --- .../main/java/com/baidu/hugegraph/api/TaskApiTest.java | 9 ++++++++- .../main/java/com/baidu/hugegraph/unit/BaseUnitTest.java | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/TaskApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/TaskApiTest.java index 8884e5b242..50b2812844 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/TaskApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/TaskApiTest.java @@ -52,10 +52,17 @@ public void testList() { assertArrayContains(tasks, "id", taskId); waitTaskSuccess(taskId); + /* + * FIXME: sometimes may get results of RUNNING tasks after the task + * status is SUCCESS, which is stored in DB if there are worker + * nodes in raft-api test. + * NOTE: seems the master node won't store task status in memory, + * because only worker nodes store task status in memory. + */ r = client().get(path, ImmutableMap.of("status", "RUNNING")); content = assertResponseStatus(200, r); tasks = assertJsonContains(content, "tasks"); - Assert.assertTrue(tasks.isEmpty()); + Assert.assertTrue(tasks.toString(), tasks.isEmpty()); } @Test diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/BaseUnitTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/BaseUnitTest.java index ab78a17bba..21eb2abef5 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/BaseUnitTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/BaseUnitTest.java @@ -30,12 +30,17 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import org.slf4j.Logger; +import com.baidu.hugegraph.HugeException; import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.util.Log; import com.baidu.hugegraph.util.TimeUtil; public class BaseUnitTest { + protected static final Logger LOG = Log.logger(BaseUnitTest.class); + @BeforeClass public static void init() { // pass @@ -67,7 +72,9 @@ protected static final void runWithThreads(int threads, Runnable task) { try { future.get(); } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); + Throwable root = HugeException.rootCause(e); + LOG.error(root.getMessage(), root); + throw new RuntimeException(root.getMessage(), e); } } } From 8c8cab48d4e858a6c94c57ef9b595555b6d89e1c Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Wed, 9 Feb 2022 18:07:39 +0800 Subject: [PATCH 3/3] improve error message "Failed to list indexlabels" Change-Id: I4de923541ba6291f07779a4dedcafad887ac3037 --- .../main/java/com/baidu/hugegraph/api/BaseApiTest.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java index ac44371254..4531f2bfee 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java @@ -495,10 +495,7 @@ protected static void clearGraph() { String path = URL_PREFIX + urlSuffix; String type = urlSuffix.substring(urlSuffix.lastIndexOf('/') + 1); Response r = client.get(path); - if (r.getStatus() != 200) { - throw new HugeException("Failed to list " + type); - } - String content = r.readEntity(String.class); + String content = assertResponseStatus(200, r); @SuppressWarnings("rawtypes") List list = readList(content, type, Map.class); List ids = list.stream().map(e -> e.get("id")) @@ -517,10 +514,7 @@ protected static void clearSchema() { String path = URL_PREFIX + urlSuffix; String type = urlSuffix.substring(urlSuffix.lastIndexOf('/') + 1); Response r = client.get(path); - if (r.getStatus() != 200) { - throw new HugeException("Failed to list " + type); - } - String content = r.readEntity(String.class); + String content = assertResponseStatus(200, r); @SuppressWarnings("rawtypes") List list = readList(content, type, Map.class); List names = list.stream().map(e -> e.get("name"))