Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 4c54cf9

Browse files
authored
feat: randomize cluster port for etcd (#62)
1 parent 29cc558 commit 4c54cf9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/main/java/io/javaoperatorsdk/jenvtest/process/EtcdProcess.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ public EtcdProcess(BinaryManager binaryManager,
3232
public int startEtcd() {
3333
var etcdBinary = binaryManager.binaries().getEtcd();
3434
var port = Utils.findFreePort();
35+
var peerPort = Utils.findFreePort();
3536
try {
3637
if (!etcdBinary.exists()) {
3738
throw new JenvtestException(
3839
"Missing binary for etcd on path: " + etcdBinary.getAbsolutePath());
3940
}
4041
etcdProcess = new ProcessBuilder(etcdBinary.getAbsolutePath(),
41-
"--listen-client-urls=http://0.0.0.0:" + port,
42-
"--advertise-client-urls=http://0.0.0.0:" + port)
42+
"--listen-client-urls", "http://0.0.0.0:" + port,
43+
"--advertise-client-urls", "http://0.0.0.0:" + port,
44+
// the below added because of stability
45+
"--initial-cluster", "default=http://localhost:" + peerPort,
46+
"--initial-advertise-peer-urls", "http://localhost:" + peerPort,
47+
"--listen-peer-urls", "http://localhost:" + peerPort)
4348
.start();
4449
Utils.redirectProcessOutputToLogger(etcdProcess.getInputStream(), etcdLog);
4550
Utils.redirectProcessOutputToLogger(etcdProcess.getErrorStream(), etcdLog);

0 commit comments

Comments
 (0)