Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/loader-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
TRAVIS_DIR: hugegraph-loader/assembly/travis
STATIC_DIR: hugegraph-loader/assembly/static
# TODO: replace it with the (latest - n) commit id (n >= 15)
# hugegraph commit date: 2024-12-09
COMMIT_ID: f838897
# hugegraph commit date: 2025-10-30
COMMIT_ID: 5b3d295
DB_USER: root
DB_PASS: root
DB_DATABASE: load_test
Expand All @@ -43,13 +43,13 @@ jobs:
fetch-depth: 2

- name: Install JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.JAVA_VERSION }}
distribution: 'adopt'

- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
mvn test -P kafka

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: target/jacoco.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,8 @@ public void clear(String graph, boolean clearSchema) {
}

public void clear(String graph, String message) {
clear(null, graph, message);
}

public void clear(String graphSpace, String graph, String message) {
String path = (graphSpace == null)
? joinPath(this.path(), graph, CLEAR)
: joinPath(this.path(), graphSpace, graph, CLEAR);
this.client.delete(path, ImmutableMap.of(CONFIRM_MESSAGE, message));
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}

public Map<String, String> update(String name, String nickname) {
Expand Down Expand Up @@ -204,85 +198,51 @@ public Map<String, String> reload() {
}

public void mode(String graph, GraphMode mode) {
mode(null, graph, mode);
}

public void mode(String graphSpace, String graph, GraphMode mode) {
// NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
// be encoded to "%2F". So use "mode" here, although inaccurate.
if (graphSpace == null) {
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
return;
}
this.client.put(joinPath(this.path(), graphSpace, graph, MODE), null, mode);
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
}

public void readMode(String graph, GraphReadMode readMode) {
readMode(null, graph, readMode);
public GraphMode mode(String graph) {
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);
if (value == null) {
throw new InvalidResponseException("Invalid response, expect 'mode' in response");
}
try {
return GraphMode.valueOf(value);
} catch (IllegalArgumentException e) {
throw new InvalidResponseException("Invalid GraphMode value '%s'", value);
}
}


public void readMode(String graphSpace, String graph, GraphReadMode readMode) {
public void readMode(String graph, GraphReadMode readMode) {
this.client.checkApiVersion("0.59", "graph read mode");
// NOTE: Must provide id for PUT. If you use "graph/graph_read_mode", "/"
// will be encoded to "%2F". So use "graph_read_mode" here, although
// inaccurate.
if (graphSpace == null) {
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode);
return;
}
this.client.put(joinPath(this.path(), graphSpace, graph, GRAPH_READ_MODE), null, readMode);
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode);
}

/**
* Get graph mode value from server response
*
* @param graphSpace the graph space name, null for non-graphspace mode
* @param graph the graph name
* @param modeKey the mode key in response (MODE or GRAPH_READ_MODE)
* @param enumClass the enum class type
* @return the mode enum value
*/
private <T extends Enum<T>> T getModeValue(String graphSpace, String graph,
String modeKey, Class<T> enumClass) {
String path = (graphSpace != null)
? joinPath(this.path(), graphSpace, graph)
: joinPath(this.path(), graph);

RestResult result = this.client.get(path, modeKey);
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);
@SuppressWarnings("unchecked")
Map<String, String> map = result.readObject(Map.class);
String value = map.get(modeKey);

Map<String, String> readMode = result.readObject(Map.class);
String value = readMode.get(GRAPH_READ_MODE);
if (value == null) {
throw new InvalidResponseException(
"Invalid response, expect '%s' in response", modeKey);
throw new InvalidResponseException("Invalid response, expect 'graph_read_mode' " +
"in response");
}
try {
return Enum.valueOf(enumClass, value);
return GraphReadMode.valueOf(value);
} catch (IllegalArgumentException e) {
throw new InvalidResponseException(
"Invalid %s value '%s'", enumClass.getSimpleName(), value);
throw new InvalidResponseException("Invalid GraphReadMode value '%s'", value);
}
}

public GraphMode mode(String graphSpace, String graph) {
return getModeValue(graphSpace, graph, MODE, GraphMode.class);
}

public GraphMode mode(String graph) {
return mode(null, graph);
}

public GraphReadMode readMode(String graphSpace, String graph) {
this.client.checkApiVersion("0.59", "graph read mode");
return getModeValue(graphSpace, graph, GRAPH_READ_MODE, GraphReadMode.class);
}

public GraphReadMode readMode(String graph) {
return readMode(null, graph);
}

public String clone(String graph, Map<String, Object> body) {
RestResult result = this.client.post(joinPath(this.path(), graph,
"clone"), body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ public void clearGraph(String graph, String message) {
this.graphsAPI.clear(graph, message);
}

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

public void update(String graph, String nickname) {
this.graphsAPI.update(graph, nickname);
}
Expand All @@ -119,30 +115,14 @@ public void mode(String graph, GraphMode mode) {
this.graphsAPI.mode(graph, mode);
}

public void mode(String graphSpace, String graph, GraphMode mode) {
this.graphsAPI.mode(graphSpace, graph, mode);
}

public GraphMode mode(String graph) {
return this.graphsAPI.mode(graph);
}

public GraphMode mode(String graphSpace, String graph) {
return this.graphsAPI.mode(graphSpace, graph);
}

public void readMode(String graphSpace, String graph, GraphReadMode readMode) {
this.graphsAPI.readMode(graphSpace, graph, readMode);
}

public void readMode(String graph, GraphReadMode readMode) {
this.graphsAPI.readMode(graph, readMode);
}

public GraphReadMode readMode(String graphSpace, String graph) {
return this.graphsAPI.readMode(graphSpace, graph);
}

public GraphReadMode readMode(String graph) {
return this.graphsAPI.readMode(graph);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ mkdir ${HTTPS_SERVER_DIR}
cp -r apache-hugegraph-*/. ${HTTPS_SERVER_DIR}
cd "$(find apache-hugegraph-* | head -1)"
# start HugeGraphServer with http protocol
bin/init-store.sh || exit 1
sed -i 's|gremlin.graph=org.apache.hugegraph.HugeFactory|gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy|' conf/graphs/hugegraph.properties
sed -i 's|#auth.authenticator=.*|auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator|' conf/rest-server.properties
sed -i 's|#auth.admin_pa=.*|auth.admin_pa=pa|' conf/rest-server.properties
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 测试代码中硬编码认证信息

在测试脚本中直接硬编码 admin/pa 凭证存在以下问题:

  1. 降低了测试的灵活性
  2. 如果服务器配置改变,测试会失败
  3. 不符合配置外部化最佳实践

建议:

  • 使用环境变量 HUGEGRAPH_ADMIN_PASSWORD
  • 或从配置文件读取
  • 提供默认值作为后备
Suggested change
sed -i 's|#auth.admin_pa=.*|auth.admin_pa=pa|' conf/rest-server.properties
ADMIN_PASSWORD=${HUGEGRAPH_ADMIN_PASSWORD:-pa}
sed -i "s|#auth.admin_pa=.*|auth.admin_pa=$ADMIN_PASSWORD|" conf/rest-server.properties
echo -e "$ADMIN_PASSWORD" | bin/init-store.sh || exit 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the username and password are already written in .properties, the sed command is only to let them show out

echo -e "pa" | bin/init-store.sh || exit 1
bin/start-hugegraph.sh || exit 1

cd ../${HTTPS_SERVER_DIR}
Expand All @@ -53,6 +56,9 @@ sed -i "s/#port: 8182/port: 8282/g" "$GREMLIN_SERVER_CONFIG"
echo "gremlinserver.url=http://127.0.0.1:8282" >> ${REST_SERVER_CONFIG}

# start HugeGraphServer with https protocol
bin/init-store.sh
sed -i 's|gremlin.graph=org.apache.hugegraph.HugeFactory|gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy|' conf/graphs/hugegraph.properties
sed -i 's|#auth.authenticator=.*|auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator|' conf/rest-server.properties
sed -i 's|#auth.admin_pa=.*|auth.admin_pa=pa|' conf/rest-server.properties
echo -e "pa" | bin/init-store.sh || exit 1
bin/start-hugegraph.sh
cd ../
Loading
Loading