Skip to content

Commit

Permalink
don't clear non-shared-storage backend
Browse files Browse the repository at this point in the history
Change-Id: I95913fb9c4a2384492bd8a81c1d94e905dd344e6
  • Loading branch information
javeme committed Jan 6, 2022
1 parent 470872b commit a31a667
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import javax.ws.rs.core.Response;

import org.junit.Assume;
import org.junit.Test;

import com.baidu.hugegraph.testutil.Assert;
Expand Down Expand Up @@ -86,20 +87,37 @@ 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<Object>) 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\"}}";
assertResponseStatus(200, client().post(path, body));

body = "{"
+ "\"gremlin\":\"hugegraph.serverStarted("
+ "IdGenerator.of('server1'), NodeRole.MASTER)\","
+ " IdGenerator.of('server1'), NodeRole.MASTER)\","
+ "\"bindings\":{},"
+ "\"language\":\"gremlin-groovy\","
+ "\"aliases\":{\"g\":\"__g_hugegraph\"}}";
Expand Down

0 comments on commit a31a667

Please sign in to comment.