Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
Change-Id: Id14191f3c02ad85de67c6ba66535ce5a4b167543
  • Loading branch information
javeme committed Dec 24, 2021
1 parent ea0df91 commit f8c0ac5
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 142 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-20.04
env:
TRAVIS_DIR: assembly/travis
COMMIT_ID: 2dd2d7c3fd7cb42cd7338d70a73e04b0c5604487
COMMIT_ID: d213166eb2185cbb6bd8bd5d201b7167e7b98993
steps:
- name: Install JDK 8
uses: actions/setup-java@v2
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Prepare env and service
run: |
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID | grep -v "Downloading\|Downloaded"
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID
- name: Run test
run: |
Expand Down
1 change: 0 additions & 1 deletion BCLOUD

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion assembly/travis/conf/gremlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ scriptEvaluationTimeout: 30000

channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
graphs: {
hugegraph: conf/hugegraph.properties
}
scriptEngines: {
gremlin-groovy: {
Expand Down
2 changes: 1 addition & 1 deletion assembly/travis/conf/rest-server.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ restserver.url=http://127.0.0.1:8080
#gremlinserver.url=http://127.0.0.1:8182

# graphs list with pair NAME:CONF_PATH
graphs=[hugegraph:conf/hugegraph.properties]
graphs=assembly/travis/conf/graphs

# authentication
auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator
Expand Down
26 changes: 17 additions & 9 deletions assembly/travis/install-hugegraph-from-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ fi

COMMIT_ID=$1
HUGEGRAPH_GIT_URL="https://github.com/hugegraph/hugegraph.git"
GIT_DIR=hugegraph

# download code and compile
git clone --depth 100 ${HUGEGRAPH_GIT_URL}
cd hugegraph
cd "${GIT_DIR}"
git checkout ${COMMIT_ID}
mvn package -DskipTests
mv hugegraph-*.tar.gz ../

TAR=$(echo hugegraph-*.tar.gz)
tar -zxvf "${TAR}" -C ../
cd ../
rm -rf hugegraph
tar -zxvf hugegraph-*.tar.gz
rm -rf "${GIT_DIR}"

HTTP_SERVER_DIR=$(echo hugegraph-*)
HTTPS_SERVER_DIR="hugegraph_https"
mkdir ${HTTPS_SERVER_DIR}
cp -r hugegraph-*/. ${HTTPS_SERVER_DIR}
cd "$(find hugegraph-* | head -1)"
cp ../$TRAVIS_DIR/conf/* conf

cp -r "${HTTP_SERVER_DIR}" "${HTTPS_SERVER_DIR}"

# config auth options just for http server
cp -r "${TRAVIS_DIR}"/conf/ "${HTTP_SERVER_DIR}"/conf/

# start HugeGraphServer with http protocol
cd "${HTTP_SERVER_DIR}"
echo -e "pa" | bin/init-store.sh || exit 1
bin/start-hugegraph.sh || exit 1

cd ../${HTTPS_SERVER_DIR}
# config options for https server
cd ../"${HTTPS_SERVER_DIR}"
REST_SERVER_CONFIG="conf/rest-server.properties"
GREMLIN_SERVER_CONFIG="conf/gremlin-server.yaml"
sed -i "s?http://127.0.0.1:8080?https://127.0.0.1:8443?g" "$REST_SERVER_CONFIG"
Expand Down
69 changes: 0 additions & 69 deletions assembly/travis/install-hugegraph-from-tar.sh

This file was deleted.

29 changes: 15 additions & 14 deletions src/main/java/com/baidu/hugegraph/api/graphs/GraphsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@

public class GraphsAPI extends API {

private static final String CONFIRM_MESSAGE = "confirm_message";
private static final String DELIMITER = "/";
private static final String MODE = "mode";
private static final String GRAPH_READ_MODE = "graph_read_mode";
private static final String CLEAR = "clear";

private static final String CONFIRM_MESSAGE = "confirm_message";

public GraphsAPI(RestClient client) {
super(client);
Expand Down Expand Up @@ -80,11 +82,11 @@ public List<String> list() {
}

public void clear(String graph, String message) {
this.client.delete(joinPath(this.path(), graph, "clear"),
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}

public void delete(String graph, String message) {
public void drop(String graph, String message) {
this.client.checkApiVersion("0.67", "dynamic graph delete");
this.client.delete(joinPath(this.path(), graph),
ImmutableMap.of(CONFIRM_MESSAGE, message));
Expand All @@ -93,12 +95,11 @@ public void delete(String graph, String message) {
public void mode(String graph, GraphMode mode) {
// NOTE: Must provide id for PUT. If use "graph/mode", "/" will
// be encoded to "%2F". So use "mode" here although inaccurate.
this.client.put(joinPath(this.path(), graph), MODE, mode);
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
}

public GraphMode mode(String graph) {
RestResult result = this.client.get(joinPath(this.path(), graph),
MODE);
RestResult result = this.client.get(joinPath(this.path(), graph), MODE);
@SuppressWarnings("unchecked")
Map<String, String> mode = result.readObject(Map.class);
String value = mode.get(MODE);
Expand All @@ -119,14 +120,14 @@ public void readMode(String graph, GraphReadMode readMode) {
// NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/"
// will be encoded to "%2F". So use "graph_read_mode" here although
// inaccurate.
this.client.put(joinPath(this.path(), graph),
GRAPH_READ_MODE, readMode);
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE),
null, readMode);
}

public GraphReadMode readMode(String graph) {
this.client.checkApiVersion("0.59", "graph read mode");
RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
@SuppressWarnings("unchecked")
Map<String, String> readMode = result.readObject(Map.class);
String value = readMode.get(GRAPH_READ_MODE);
Expand All @@ -142,11 +143,11 @@ public GraphReadMode readMode(String graph) {
}
}

private static String joinPath(String path, String id) {
return String.join(DELIMITER, path, id);
private static String joinPath(String path, String graph) {
return String.join(DELIMITER, path, graph);
}

private static String joinPath(String path, String id, String action) {
return String.join(DELIMITER, path, id, action);
private static String joinPath(String path, String graph, String action) {
return String.join(DELIMITER, path, graph, action);
}
}
44 changes: 8 additions & 36 deletions src/main/java/com/baidu/hugegraph/driver/GraphsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@

package com.baidu.hugegraph.driver;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;

import com.baidu.hugegraph.api.graphs.GraphsAPI;
import com.baidu.hugegraph.client.RestClient;
import com.baidu.hugegraph.rest.ClientException;
import com.baidu.hugegraph.structure.constant.GraphMode;
import com.baidu.hugegraph.structure.constant.GraphReadMode;

Expand All @@ -42,34 +35,13 @@ public GraphsManager(RestClient client) {
this.graphsAPI = new GraphsAPI(client);
}

public Map<String, String> createGraph(String name, String config) {
return this.createGraph(name, null, config);
}

public Map<String, String> createGraph(String name, String cloneGraphName,
String config) {
return this.graphsAPI.create(name, cloneGraphName, config);
}

public Map<String, String> createGraph(String name, File file) {
String config;
try {
config = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ClientException("Failed to read config file: %s", file);
}
return this.createGraph(name, config);
public Map<String, String> createGraph(String name, String configText) {
return this.graphsAPI.create(name, null, configText);
}

public Map<String, String> createGraph(String name, String cloneGraphName,
File file) {
String config;
try {
config = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ClientException("Failed to read config file: %s", file);
}
return this.createGraph(name, cloneGraphName, config);
public Map<String, String> cloneGraph(String name, String cloneGraphName,
String configText) {
return this.graphsAPI.create(name, cloneGraphName, configText);
}

public Map<String, String> getGraph(String graph) {
Expand All @@ -80,12 +52,12 @@ public List<String> listGraph() {
return this.graphsAPI.list();
}

public void clear(String graph, String message) {
public void clearGraph(String graph, String message) {
this.graphsAPI.clear(graph, message);
}

public void remove(String graph, String message) {
this.graphsAPI.delete(graph, message);
public void dropGraph(String graph, String message) {
this.graphsAPI.drop(graph, message);
}

public void mode(String graph, GraphMode mode) {
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/com/baidu/hugegraph/api/GraphsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public class GraphsApiTest extends BaseApiTest {

private static final String GRAPH2 = "hugegraph2";
private static final String CONFIG2_PATH =
"src/test/resources/hugegraph2.properties";
"src/test/resources/hugegraph-create.properties";

private static final String GRAPH3 = "hugegraph3";
private static final String CONFIG3_PATH =
"src/test/resources/hugegraph3.properties";
"src/test/resources/hugegraph-clone.properties";

@Test
public void testCreateAndRemoveGraph() {
public void testCreateAndDropGraph() {
int initialGraphNumber = graphsAPI.list().size();

// Create new graph dynamically
Expand Down Expand Up @@ -113,16 +113,16 @@ public void testCreateAndRemoveGraph() {
Assert.assertEquals(initialGraphNumber + 1, graphsAPI.list().size());

// Remove new created graph dynamically
graphsAPI.delete(GRAPH2, "I'm sure to drop the graph");
graphsAPI.drop(GRAPH2, "I'm sure to drop the graph");

Assert.assertEquals(initialGraphNumber, graphsAPI.list().size());
}

@Test
public void testCreateWithCloneAndRemoveGraph() {
public void testCloneAndDropGraph() {
int initialGraphNumber = graphsAPI.list().size();

// Create new graph dynamically
// Clone a new graph from exist a graph dynamically
String config;
try {
config = FileUtils.readFileToString(new File(CONFIG3_PATH),
Expand Down Expand Up @@ -185,7 +185,7 @@ public void testCreateWithCloneAndRemoveGraph() {
Assert.assertEquals(initialGraphNumber + 1, graphsAPI.list().size());

// Remove new created graph dynamically
graphsAPI.delete(GRAPH3, "I'm sure to drop the graph");
graphsAPI.drop(GRAPH3, "I'm sure to drop the graph");

Assert.assertEquals(initialGraphNumber, graphsAPI.list().size());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
backend=rocksdb
serializer=binary
store=hugegraph3
rocksdb.data_path=./hg3
rocksdb.wal_path=./hg3
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy
backend=rocksdb
serializer=binary
store=hugegraph2
Expand Down

0 comments on commit f8c0ac5

Please sign in to comment.