You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by ji...@apache.org on 2023/05/25 00:04:42 UTC
[incubator-hugegraph-computer] branch master updated: Change etcd url only for ci (#245)
This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-computer.git
The following commit(s) were added to refs/heads/master by this push:
new 31b63b28 Change etcd url only for ci (#245)
31b63b28 is described below
commit 31b63b289b22aa0665b83d9fbde77aeb1de17420
Author: Cong Zhao <zh...@apache.org>
AuthorDate: Thu May 25 08:04:36 2023 +0800
Change etcd url only for ci (#245)
* Use etcd in the k8s to test
* remove unnecessary synchronized
* Address comment
---------
Co-authored-by: imbajin <ji...@apache.org>
---
.github/workflows/ci.yml | 1 +
computer-dist/src/assembly/travis/start-etcd.sh | 4 ++--
.../hugegraph/computer/k8s/AbstractK8sTest.java | 9 +++-----
.../suite/integrate/IntegrateTestSuite.java | 15 +++++++------
.../computer/suite/unit/UnitTestBase.java | 25 ++++++++++++++++------
5 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d466b903..e64ec7d7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,6 +14,7 @@ jobs:
TRAVIS_DIR: computer-dist/src/assembly/travis
KUBERNETES_VERSION: 1.20.1
HUGEGRAPH_SERVER_COMMIT_ID: d01c8737d7d5909119671953521f1401dcd1a188
+ BSP_ETCD_URL: http://localhost:2579
steps:
- name: Checkout
diff --git a/computer-dist/src/assembly/travis/start-etcd.sh b/computer-dist/src/assembly/travis/start-etcd.sh
index 54f9d881..896d0832 100644
--- a/computer-dist/src/assembly/travis/start-etcd.sh
+++ b/computer-dist/src/assembly/travis/start-etcd.sh
@@ -26,5 +26,5 @@ chmod a+x ${TRAVIS_DIR}/etcd
${TRAVIS_DIR}/etcd/etcd --name etcd-test \
--initial-advertise-peer-urls http://localhost:2580 \
--listen-peer-urls http://localhost:2580 \
- --advertise-client-urls http://localhost:2579 \
- --listen-client-urls http://localhost:2579 &
+ --advertise-client-urls ${BSP_ETCD_URL} \
+ --listen-client-urls ${BSP_ETCD_URL} &
diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/AbstractK8sTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/AbstractK8sTest.java
index a9a294aa..fd8c9e04 100644
--- a/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/AbstractK8sTest.java
+++ b/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/AbstractK8sTest.java
@@ -74,14 +74,11 @@ public abstract class AbstractK8sTest {
static {
OptionSpace.register("computer",
- "org.apache.hugegraph.computer.core.config." +
- "ComputerOptions");
+ "org.apache.hugegraph.computer.core.config.ComputerOptions");
OptionSpace.register("computer-k8s-driver",
- "org.apache.hugegraph.computer.k8s.config" +
- ".KubeDriverOptions");
+ "org.apache.hugegraph.computer.k8s.config.KubeDriverOptions");
OptionSpace.register("computer-k8s-spec",
- "org.apache.hugegraph.computer.k8s.config" +
- ".KubeSpecOptions");
+ "org.apache.hugegraph.computer.k8s.config.KubeSpecOptions");
}
protected void updateOptions(String key, Object value) {
diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/suite/integrate/IntegrateTestSuite.java b/computer-test/src/main/java/org/apache/hugegraph/computer/suite/integrate/IntegrateTestSuite.java
index 492aea73..7b273f86 100644
--- a/computer-test/src/main/java/org/apache/hugegraph/computer/suite/integrate/IntegrateTestSuite.java
+++ b/computer-test/src/main/java/org/apache/hugegraph/computer/suite/integrate/IntegrateTestSuite.java
@@ -17,6 +17,7 @@
package org.apache.hugegraph.computer.suite.integrate;
+import org.apache.commons.lang3.StringUtils;
import org.apache.hugegraph.computer.core.config.ComputerOptions;
import org.apache.hugegraph.config.OptionSpace;
import org.apache.hugegraph.testutil.Whitebox;
@@ -43,12 +44,14 @@ public class IntegrateTestSuite {
// Don't forget to register options
OptionSpace.register("computer",
- "org.apache.hugegraph.computer.core.config." +
- "ComputerOptions");
- OptionSpace.register("computer-rpc",
- "org.apache.hugegraph.config.RpcOptions");
+ "org.apache.hugegraph.computer.core.config.ComputerOptions");
+ OptionSpace.register("computer-rpc", "org.apache.hugegraph.config.RpcOptions");
+
+ String etcdUrl = System.getenv("BSP_ETCD_URL");
+ if (StringUtils.isNotBlank(etcdUrl)) {
+ Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
+ "defaultValue", etcdUrl);
+ }
- Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
- "defaultValue", "http://localhost:2579");
}
}
diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/suite/unit/UnitTestBase.java b/computer-test/src/main/java/org/apache/hugegraph/computer/suite/unit/UnitTestBase.java
index 7aabea3f..421b33b8 100644
--- a/computer-test/src/main/java/org/apache/hugegraph/computer/suite/unit/UnitTestBase.java
+++ b/computer-test/src/main/java/org/apache/hugegraph/computer/suite/unit/UnitTestBase.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
+import org.apache.commons.lang3.StringUtils;
import org.apache.hugegraph.computer.core.common.ComputerContext;
import org.apache.hugegraph.computer.core.common.Constants;
import org.apache.hugegraph.computer.core.common.exception.ComputerException;
@@ -55,6 +56,7 @@ import org.apache.hugegraph.testutil.Whitebox;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.Log;
import org.apache.logging.log4j.LogManager;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
@@ -79,9 +81,12 @@ public class UnitTestBase {
LOG.info("Setup for UnitTestSuite of hugegraph-computer");
- Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
- "defaultValue",
- "http://localhost:2579");
+ String etcdUrl = System.getenv("BSP_ETCD_URL");
+ if (StringUtils.isNotBlank(etcdUrl)) {
+ Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
+ "defaultValue", etcdUrl);
+ }
+
Whitebox.setInternalState(ComputerOptions.HUGEGRAPH_URL,
"defaultValue",
"http://127.0.0.1:8080");
@@ -125,16 +130,22 @@ public class UnitTestBase {
Class.forName(IdType.class.getName());
// Don't forget to register options
OptionSpace.register("computer",
- "org.apache.hugegraph.computer.core.config." +
- "ComputerOptions");
- OptionSpace.register("computer-rpc",
- "org.apache.hugegraph.config.RpcOptions");
+ "org.apache.hugegraph.computer.core.config.ComputerOptions");
+ OptionSpace.register("computer-rpc", "org.apache.hugegraph.config.RpcOptions");
UnitTestBase.updateOptions(
ComputerOptions.ALGORITHM_RESULT_CLASS, LongValue.class.getName()
);
}
+ @AfterClass
+ public static void cleanup() {
+ if (CLIENT != null) {
+ CLIENT.close();
+ CLIENT = null;
+ }
+ }
+
public static void assertIdEqualAfterWriteAndRead(Id oldId)
throws IOException {
byte[] bytes;