Skip to content
Permalink
Browse files
improve some test (#139)
Change-Id: I4063e5690fe1ed0c1c5556302881a24518ac4424
  • Loading branch information
javeme committed Dec 27, 2021
1 parent d9e1abe commit cff2c656fb2ea74f3fe11442ee874a3b760effaa
Showing 6 changed files with 50 additions and 35 deletions.
@@ -33,8 +33,8 @@
import com.baidu.hugegraph.driver.SchemaManager;
import com.baidu.hugegraph.exception.ServerException;
import com.baidu.hugegraph.structure.constant.GraphReadMode;
import com.baidu.hugegraph.structure.constant.WriteType;
import com.baidu.hugegraph.structure.constant.T;
import com.baidu.hugegraph.structure.constant.WriteType;
import com.baidu.hugegraph.structure.graph.Vertex;
import com.baidu.hugegraph.structure.gremlin.ResultSet;
import com.baidu.hugegraph.structure.schema.PropertyKey;
@@ -347,29 +347,30 @@ public void testOlapPropertyWrite() {

PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
propertyKeyWithTask = propertyKeyAPI.create(pagerank);
long taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
long taskId1 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId1);

PropertyKey wcc = schema().propertyKey("wcc")
.asText()
.writeType(WriteType.OLAP_SECONDARY)
.build();

propertyKeyWithTask = propertyKeyAPI.create(wcc);
taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
long taskId2 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId2);

PropertyKey none = schema().propertyKey("none")
.asText()
.writeType(WriteType.OLAP_COMMON)
.build();

propertyKeyWithTask = propertyKeyAPI.create(none);
taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
long taskId3 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId3);

waitUntilTaskCompleted(taskId1);
waitUntilTaskCompleted(taskId2);
waitUntilTaskCompleted(taskId3);

// Add olap properties
vertices = new ArrayList<>(100);
@@ -446,19 +447,20 @@ public void testOlapPropertyWrite() {

// Clear olap property key
propertyKeyWithTask = propertyKeyAPI.clear(pagerank);
taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
taskId1 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId1);

propertyKeyWithTask = propertyKeyAPI.clear(wcc);
taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
taskId2 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId2);

propertyKeyWithTask = propertyKeyAPI.clear(none);
taskId = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
taskId3 = propertyKeyWithTask.taskId();
Assert.assertNotEquals(0L, taskId3);

waitUntilTaskCompleted(taskId1);
waitUntilTaskCompleted(taskId2);
waitUntilTaskCompleted(taskId3);

// Query after clear olap property key
request = new GremlinRequest("g.V().has(\"pagerank\", P.gte(5))");
@@ -471,17 +473,18 @@ public void testOlapPropertyWrite() {
Assert.assertEquals(0, resultSet.size());

// Delete olap property key
taskId = propertyKeyAPI.delete(pagerank.name());
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
taskId1 = propertyKeyAPI.delete(pagerank.name());
Assert.assertNotEquals(0L, taskId1);

taskId2 = propertyKeyAPI.delete(wcc.name());
Assert.assertNotEquals(0L, taskId2);

taskId = propertyKeyAPI.delete(wcc.name());
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
taskId3 = propertyKeyAPI.delete(none.name());
Assert.assertNotEquals(0L, taskId3);

taskId = propertyKeyAPI.delete(none.name());
Assert.assertNotEquals(0L, taskId);
waitUntilTaskCompleted(taskId);
waitUntilTaskCompleted(taskId1);
waitUntilTaskCompleted(taskId2);
waitUntilTaskCompleted(taskId3);

// Query after delete olap property key
Assert.assertThrows(ServerException.class, () -> {
@@ -68,7 +68,7 @@ public void testLogin() {
User user1 = new User();
user1.name("user1");
user1.password("p1");
User user = userAPI.create(user1);
userAPI.create(user1);

LoginResult result = loginAPI.login(login);
Assert.assertNotNull(result);
@@ -62,7 +62,7 @@ public void testLogout() {
User user1 = new User();
user1.name("user1");
user1.password("p1");
User user = userAPI.create(user1);
userAPI.create(user1);

Login login = new Login();
login.name("user1");
@@ -85,6 +85,7 @@ public void testVerify() {
String token = result.token();
RestClient client = Whitebox.getInternalState(tokenAPI, "client");
client.setAuthContext("Bearer " + token);

TokenPayload payload = tokenAPI.verifyToken();
Assert.assertEquals("user1", payload.username());
Assert.assertEquals(user.id(), payload.userId());
@@ -95,5 +96,16 @@ public void testVerify() {
}, e -> {
Assert.assertContains("Invalid token", e.getMessage());
});

RestClient client2 = Whitebox.getInternalState(logoutAPI, "client");
Assert.assertThrows(ServerException.class, () -> {
logoutAPI.logout();
}, e -> {
Assert.assertContains("Only HTTP Bearer authentication is supported",
e.getMessage());
});

client2.setAuthContext("Bearer " + token);
logoutAPI.logout();
}
}
@@ -36,8 +36,7 @@
AuthManagerTest.class,
TraverserManagerTest.class,
MetricsManagerTest.class,
// TODO: Ubuntu20.04 can't run it correctly, fix it later
//HugeClientHttpsTest.class,
HugeClientHttpsTest.class,
HugeClientTest.class
})
public class FuncTestSuite {
@@ -42,7 +42,8 @@ public class HugeClientHttpsTest {
private static final int MAX_CONNS_PER_ROUTE = 10;
private static final int MAX_CONNS = 10;
private static final int IDLE_TIME = 30;
private static final String TRUST_STORE_FILE = "src/test/resources/hugegraph.truststore";
private static final String TRUST_STORE_FILE =
"src/test/resources/hugegraph.truststore";
private static final String TRUST_STORE_PASSWORD = "hugegraph";

private static HugeClient client;
@@ -66,7 +67,6 @@ public void testHttpsClientBuilderWithConnection() {
@Test
public void testHttpsClientWithConnectionPoolNoUserParam() {
client = HugeClient.builder(BASE_URL, GRAPH)
.configUser(USERNAME, PASSWORD)
.configTimeout(TIMEOUT)
.configPool(MAX_CONNS, MAX_CONNS_PER_ROUTE)
.configSSL(TRUST_STORE_FILE, TRUST_STORE_PASSWORD)
@@ -175,7 +175,8 @@ private void addVertexAndCheckPropertyValue() {
Vertex marko = graph.addVertex(T.label, "person", "name", "marko",
"age", 29, "city", "Beijing");
Map<String, Object> props = ImmutableMap.of("name", "marko",
"age", 29, "city", "Beijing");
"age", 29,
"city", "Beijing");
Assert.assertEquals(props, marko.properties());
}
}

0 comments on commit cff2c65

Please sign in to comment.