diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d466b903f..e64ec7d7f 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 54f9d8814..896d0832e 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 a9a294aa1..fd8c9e044 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 492aea734..7b273f864 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 static void setup() { // 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 7aabea3f9..421b33b82 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.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.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 static void init() throws ClassNotFoundException { 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 static void init() throws ClassNotFoundException { 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;