Skip to content

Commit

Permalink
Merge pull request #961 from aureamunoz/fix-eureka-hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier authored Oct 20, 2024
2 parents 59540c9 + 38542b8 commit bc0e00a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Uni<Void> registerServiceInstance(String serviceName, Metadata<EurekaMeta
int defaultPort) {

return registerApplicationInstance(client, serviceName,
metadata.getMetadata().get(EurekaMetadataKey.META_EUREKA_SERVICE_ID).toString(), "192.5.10.236", "acme.com",
metadata.getMetadata().get(EurekaMetadataKey.META_EUREKA_SERVICE_ID).toString(), ipAddress, null,
defaultPort, null, -1, "UP", "");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.smallrye.stork.impl.EurekaMetadataKey;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProviderBean;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;
Expand Down Expand Up @@ -93,7 +94,7 @@ public void testRegistrationServiceInstances(TestInfo info) {

CountDownLatch registrationLatch = new CountDownLatch(1);
eurekaServiceRegistrar.registerServiceInstance(serviceName, Metadata.of(EurekaMetadataKey.class)
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "acme.com", 8406).subscribe()
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "localhost", 8406).subscribe()
.with(success -> registrationLatch.countDown(), failure -> fail(""));

await().atMost(Duration.ofSeconds(10))
Expand All @@ -109,6 +110,14 @@ public void testRegistrationServiceInstances(TestInfo info) {
assertThat(httpResponse).isNotNull();
assertThat(httpResponse.statusCode()).isEqualTo(200);

JsonObject jsonResponse = httpResponse.bodyAsJsonObject();
JsonObject application = jsonResponse.getJsonObject("application");
JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0);

assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service");
assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost");
assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.smallrye.stork.impl.EurekaMetadataKey;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProvider;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void testRegistrationServiceInstances(TestInfo info) {
CountDownLatch registrationLatch = new CountDownLatch(1);

eurekaServiceRegistrar.registerServiceInstance(serviceName, Metadata.of(EurekaMetadataKey.class)
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "acme.com", 8406).subscribe()
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "localhost", 8406).subscribe()
.with(success -> registrationLatch.countDown(), failure -> fail(""));

await().atMost(Duration.ofSeconds(10))
Expand All @@ -93,6 +94,14 @@ public void testRegistrationServiceInstances(TestInfo info) {
assertThat(httpResponse).isNotNull();
assertThat(httpResponse.statusCode()).isEqualTo(200);

JsonObject jsonResponse = httpResponse.bodyAsJsonObject();
JsonObject application = jsonResponse.getJsonObject("application");
JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0);

assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service");
assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost");
assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406);

}

}

0 comments on commit bc0e00a

Please sign in to comment.