Skip to content

Commit 31b63b2

Browse files
coderzcimbajin
andauthored
Change etcd url only for ci (#245)
* Use etcd in the k8s to test * remove unnecessary synchronized * Address comment --------- Co-authored-by: imbajin <jin@apache.org>
1 parent c806528 commit 31b63b2

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
TRAVIS_DIR: computer-dist/src/assembly/travis
1515
KUBERNETES_VERSION: 1.20.1
1616
HUGEGRAPH_SERVER_COMMIT_ID: d01c8737d7d5909119671953521f1401dcd1a188
17+
BSP_ETCD_URL: http://localhost:2579
1718

1819
steps:
1920
- name: Checkout

computer-dist/src/assembly/travis/start-etcd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ chmod a+x ${TRAVIS_DIR}/etcd
2626
${TRAVIS_DIR}/etcd/etcd --name etcd-test \
2727
--initial-advertise-peer-urls http://localhost:2580 \
2828
--listen-peer-urls http://localhost:2580 \
29-
--advertise-client-urls http://localhost:2579 \
30-
--listen-client-urls http://localhost:2579 &
29+
--advertise-client-urls ${BSP_ETCD_URL} \
30+
--listen-client-urls ${BSP_ETCD_URL} &

computer-test/src/main/java/org/apache/hugegraph/computer/k8s/AbstractK8sTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,11 @@ public abstract class AbstractK8sTest {
7474

7575
static {
7676
OptionSpace.register("computer",
77-
"org.apache.hugegraph.computer.core.config." +
78-
"ComputerOptions");
77+
"org.apache.hugegraph.computer.core.config.ComputerOptions");
7978
OptionSpace.register("computer-k8s-driver",
80-
"org.apache.hugegraph.computer.k8s.config" +
81-
".KubeDriverOptions");
79+
"org.apache.hugegraph.computer.k8s.config.KubeDriverOptions");
8280
OptionSpace.register("computer-k8s-spec",
83-
"org.apache.hugegraph.computer.k8s.config" +
84-
".KubeSpecOptions");
81+
"org.apache.hugegraph.computer.k8s.config.KubeSpecOptions");
8582
}
8683

8784
protected void updateOptions(String key, Object value) {

computer-test/src/main/java/org/apache/hugegraph/computer/suite/integrate/IntegrateTestSuite.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.hugegraph.computer.suite.integrate;
1919

20+
import org.apache.commons.lang3.StringUtils;
2021
import org.apache.hugegraph.computer.core.config.ComputerOptions;
2122
import org.apache.hugegraph.config.OptionSpace;
2223
import org.apache.hugegraph.testutil.Whitebox;
@@ -43,12 +44,14 @@ public static void setup() {
4344

4445
// Don't forget to register options
4546
OptionSpace.register("computer",
46-
"org.apache.hugegraph.computer.core.config." +
47-
"ComputerOptions");
48-
OptionSpace.register("computer-rpc",
49-
"org.apache.hugegraph.config.RpcOptions");
47+
"org.apache.hugegraph.computer.core.config.ComputerOptions");
48+
OptionSpace.register("computer-rpc", "org.apache.hugegraph.config.RpcOptions");
49+
50+
String etcdUrl = System.getenv("BSP_ETCD_URL");
51+
if (StringUtils.isNotBlank(etcdUrl)) {
52+
Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
53+
"defaultValue", etcdUrl);
54+
}
5055

51-
Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
52-
"defaultValue", "http://localhost:2579");
5356
}
5457
}

computer-test/src/main/java/org/apache/hugegraph/computer/suite/unit/UnitTestBase.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323
import java.util.Random;
2424

25+
import org.apache.commons.lang3.StringUtils;
2526
import org.apache.hugegraph.computer.core.common.ComputerContext;
2627
import org.apache.hugegraph.computer.core.common.Constants;
2728
import org.apache.hugegraph.computer.core.common.exception.ComputerException;
@@ -55,6 +56,7 @@
5556
import org.apache.hugegraph.util.E;
5657
import org.apache.hugegraph.util.Log;
5758
import org.apache.logging.log4j.LogManager;
59+
import org.junit.AfterClass;
5860
import org.junit.BeforeClass;
5961
import org.slf4j.Logger;
6062

@@ -79,9 +81,12 @@ public static void init() throws ClassNotFoundException {
7981

8082
LOG.info("Setup for UnitTestSuite of hugegraph-computer");
8183

82-
Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
83-
"defaultValue",
84-
"http://localhost:2579");
84+
String etcdUrl = System.getenv("BSP_ETCD_URL");
85+
if (StringUtils.isNotBlank(etcdUrl)) {
86+
Whitebox.setInternalState(ComputerOptions.BSP_ETCD_ENDPOINTS,
87+
"defaultValue", etcdUrl);
88+
}
89+
8590
Whitebox.setInternalState(ComputerOptions.HUGEGRAPH_URL,
8691
"defaultValue",
8792
"http://127.0.0.1:8080");
@@ -125,16 +130,22 @@ public static void init() throws ClassNotFoundException {
125130
Class.forName(IdType.class.getName());
126131
// Don't forget to register options
127132
OptionSpace.register("computer",
128-
"org.apache.hugegraph.computer.core.config." +
129-
"ComputerOptions");
130-
OptionSpace.register("computer-rpc",
131-
"org.apache.hugegraph.config.RpcOptions");
133+
"org.apache.hugegraph.computer.core.config.ComputerOptions");
134+
OptionSpace.register("computer-rpc", "org.apache.hugegraph.config.RpcOptions");
132135

133136
UnitTestBase.updateOptions(
134137
ComputerOptions.ALGORITHM_RESULT_CLASS, LongValue.class.getName()
135138
);
136139
}
137140

141+
@AfterClass
142+
public static void cleanup() {
143+
if (CLIENT != null) {
144+
CLIENT.close();
145+
CLIENT = null;
146+
}
147+
}
148+
138149
public static void assertIdEqualAfterWriteAndRead(Id oldId)
139150
throws IOException {
140151
byte[] bytes;

0 commit comments

Comments
 (0)