Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions registry-server-runner/postman-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ services:
- REDIS_HOST=redis
- REDIS_PORT=6379
- spring.profiles.active=automation
- APP_BASE_URL=https://postman-docker:8080
build:
context: ..
dockerfile: ./registry-server-runner/Dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ spring.redis.host=${REDIS_HOST}
spring.redis.port=${REDIS_PORT}
etcd.leader.key=/leader
service.registry.logging.aspectJ.enabled=true
service.registry.logging.aspectJ.timing.enabled=true
service.registry.logging.aspectJ.timing.enabled=true
app.base.url=${APP_BASE_URL}
1 change: 1 addition & 0 deletions registry-server-runner/standalone-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ services:
- ETCD_URLS=http://etcd:2379
- REDIS_HOST=redis
- REDIS_PORT=6379
- APP_BASE_URL=https://standalone-docker:8080
build:
context: ..
dockerfile: ./registry-server-runner/Dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class EtcdConfiguration {
private final String etcdLeaderKey;
private final UUID serviceUniqueIdentifier;
private final String baseUrl;
private final URI[] etcdEndpoints;

public EtcdConfiguration(
@Value("${etcd.leader.key}") String etcLeaderKey, @Value("${etcd.urls}") String etcdUrls) {
@Value("${etcd.leader.key}") String etcLeaderKey,
@Value("${app.base.url}") String baseUrl,
@Value("${etcd.urls}") String etcdUrls) {
this.etcdLeaderKey = etcLeaderKey;
serviceUniqueIdentifier = UUID.randomUUID();
this.baseUrl = baseUrl;
etcdEndpoints =
Arrays.stream(etcdUrls.split(","))
.map(
Expand All @@ -36,11 +37,11 @@ public String getEtcdLeaderKey() {
return etcdLeaderKey;
}

public UUID getServiceUniqueIdentifier() {
return serviceUniqueIdentifier;
}

public URI[] getEtcdEndpoints() {
return etcdEndpoints;
}

public String getBaseUrl() {
return baseUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ public void startLeaderElection() {
// Try and be efficient, we wrap all the computations into one request
LockResult lockResult =
lockProcess.lock(
etcdConfiguration.getEtcdLeaderKey(),
etcdConfiguration.getServiceUniqueIdentifier().toString(),
5L);
etcdConfiguration.getEtcdLeaderKey(), etcdConfiguration.getBaseUrl(), 5L);
electionState.setLeaseId(lockResult.leaseId());
if (lockResult.txnResponse().isSucceeded()) {
acquiredLeadership = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.TestPropertySource;

@TestPropertySource(properties = {"etcd.leader.key=/leader"})
@TestPropertySource(properties = {"etcd.leader.key=/leader", "app.base.url=https://localhost:8080"})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ExtendWith(DockerExtension.class)
public class IntegrationTestExtension {
Expand Down
Loading