From a31a667879d2f8c3a9e926c4c03370f5e1bbeef7 Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Thu, 6 Jan 2022 22:45:51 +0800 Subject: [PATCH] don't clear non-shared-storage backend Change-Id: I95913fb9c4a2384492bd8a81c1d94e905dd344e6 --- .../baidu/hugegraph/api/GremlinApiTest.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java index c983ca1134..cff29cedb1 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java @@ -24,6 +24,7 @@ import javax.ws.rs.core.Response; +import org.junit.Assume; import org.junit.Test; import com.baidu.hugegraph.testutil.Assert; @@ -86,12 +87,29 @@ public void testScript() { @Test public void testClearAndInit() { String body = "{" + + "\"gremlin\":\"hugegraph.backendStoreFeatures()" + + " .supportsSharedStorage();\"," + + "\"bindings\":{}," + + "\"language\":\"gremlin-groovy\"," + + "\"aliases\":{\"g\":\"__g_hugegraph\"}}"; + String content = assertResponseStatus(200, client().post(path, body)); + Map result = assertJsonContains(content, "result"); + @SuppressWarnings({ "unchecked" }) + Object data = ((List) assertMapContains(result, "data")).get(0); + boolean supportsSharedStorage = (boolean) data; + Assume.assumeTrue("Can't clear non-shared-storage backend", + supportsSharedStorage); + + body = "{" + "\"gremlin\":\"" - + "def auth = hugegraph.hugegraph().authManager();" - + "def admin = auth.findUser('admin');" - + "hugegraph.clearBackend();" - + "hugegraph.initBackend();" - + "auth.createUser(admin);\"," + + " if (!hugegraph.backendStoreFeatures()" + + " .supportsSharedStorage())" + + " return;" + + " def auth = hugegraph.hugegraph().authManager();" + + " def admin = auth.findUser('admin');" + + " hugegraph.clearBackend();" + + " hugegraph.initBackend();" + + " auth.createUser(admin);\"," + "\"bindings\":{}," + "\"language\":\"gremlin-groovy\"," + "\"aliases\":{\"g\":\"__g_hugegraph\"}}"; @@ -99,7 +117,7 @@ public void testClearAndInit() { body = "{" + "\"gremlin\":\"hugegraph.serverStarted(" - + "IdGenerator.of('server1'), NodeRole.MASTER)\"," + + " IdGenerator.of('server1'), NodeRole.MASTER)\"," + "\"bindings\":{}," + "\"language\":\"gremlin-groovy\"," + "\"aliases\":{\"g\":\"__g_hugegraph\"}}";