Skip to content

Commit

Permalink
Change etcd url only for ci (#245)
Browse files Browse the repository at this point in the history
* Use etcd in the k8s to test

* remove unnecessary synchronized

* Address comment

---------

Co-authored-by: imbajin <[email protected]>
  • Loading branch information
coderzc and imbajin authored May 25, 2023
1 parent c806528 commit 31b63b2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions computer-dist/src/assembly/travis/start-etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} &
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 31b63b2

Please sign in to comment.