Skip to content

Commit

Permalink
Adapt Stork configs to the new style[1]
Browse files Browse the repository at this point in the history
[1] quarkusio/quarkus#24184
NB: Changes in OCP tests were not tested, see @DisabledOnQuarkusVersion
annotation for explanation
  • Loading branch information
fedinskiy committed May 31, 2022
1 parent 2460a06 commit dab12fd
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class PongReplicaResource {

private static final String DEFAULT_PONG_REPLICA_RESPONSE = "pongReplica";

@ConfigProperty(name = "stork.pong-replica.service-discovery.consul-host", defaultValue = "localhost")
@ConfigProperty(name = "quarkus.stork.pong-replica.service-discovery.consul-host", defaultValue = "localhost")
String host;
@ConfigProperty(name = "stork.pong-replica.service-discovery.consul-port", defaultValue = "8500")
@ConfigProperty(name = "quarkus.stork.pong-replica.service-discovery.consul-port", defaultValue = "8500")
String port;
@ConfigProperty(name = "pong-replica-service-port", defaultValue = "8080")
String pongPort;
@ConfigProperty(name = "pong-replica-service-host", defaultValue = "localhost")
String pongHost;
@ConfigProperty(name = "stork.pong-replica.service-discovery", defaultValue = "consul")
@ConfigProperty(name = "quarkus.stork.pong-replica.service-discovery.type", defaultValue = "consul")
String serviceDiscoveryType;

public void init(@Observes StartupEvent ev, Vertx vertx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public class PongResource {
private static final String HEADER_ID = "x-id";
private String instanceUniqueId;

@ConfigProperty(name = "stork.pong.service-discovery.consul-host", defaultValue = "localhost")
@ConfigProperty(name = "quarkus.stork.pong.service-discovery.consul-host", defaultValue = "localhost")
String host;
@ConfigProperty(name = "stork.pong.service-discovery.consul-port", defaultValue = "8500")
@ConfigProperty(name = "quarkus.stork.pong.service-discovery.consul-port", defaultValue = "8500")
String port;
@ConfigProperty(name = "pong-service-port", defaultValue = "8080")
String pongPort;
@ConfigProperty(name = "pong-service-host", defaultValue = "localhost")
String pongHost;
@ConfigProperty(name = "stork.pong.service-discovery", defaultValue = "consul")
@ConfigProperty(name = "quarkus.stork.pong.service-discovery.type", defaultValue = "consul")
String serviceDiscoveryType;

public void init(@Observes StartupEvent ev, Vertx vertx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
@RouteBase(path = "/pung", produces = MediaType.TEXT_PLAIN)
public class PungResource {

@ConfigProperty(name = "stork.pung.service-discovery.consul-host", defaultValue = "localhost")
@ConfigProperty(name = "quarkus.stork.pung.service-discovery.consul-host", defaultValue = "localhost")
String host;
@ConfigProperty(name = "stork.pung.service-discovery.consul-port", defaultValue = "8500")
@ConfigProperty(name = "quarkus.stork.pung.service-discovery.consul-port", defaultValue = "8500")
String port;
@ConfigProperty(name = "pung-service-port", defaultValue = "8080")
String pungPort;
@ConfigProperty(name = "pung-service-host", defaultValue = "localhost")
String pungHost;
@ConfigProperty(name = "stork.pung.service-discovery", defaultValue = "consul")
@ConfigProperty(name = "quarkus.stork.pung.service-discovery.type", defaultValue = "consul")
String serviceDiscoveryType;

public void init(@Observes StartupEvent ev, Vertx vertx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ public class NativeStorkServiceDiscoveryIT extends AbstractCommonTestCases {
.withProperty("quarkus.http.port", PUNG_PORT)
.withProperty("pung-service-port", PUNG_PORT)
.withProperty("pung-service-host", "localhost")
.withProperty("stork.pung.service-discovery", "consul")
.withProperty("stork.pung.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pung.service-discovery.consul-host", () -> getConsultEndpoint(consul.getConsulEndpoint()));
.withProperty("quarkus.stork.pung.service-discovery.type", "consul")
.withProperty("quarkus.stork.pung.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pung.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()));

@QuarkusApplication(classes = { PingResource.class, MyBackendPungProxy.class, MyBackendPongProxy.class })
static RestService pingService = new RestService()
.withProperty("stork.pung.service-discovery", "consul")
.withProperty("stork.pung.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pung.service-discovery.consul-host", () -> getConsultEndpoint(consul.getConsulEndpoint()));
.withProperty("quarkus.stork.pung.service-discovery.type", "consul")
.withProperty("quarkus.stork.pung.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pung.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()));

@Test
public void invokeServiceByName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ public class OpenShiftStorkServiceDiscoveryIT extends AbstractCommonTestCases {

@QuarkusApplication(classes = PungResource.class)
static RestService pung = new RestService()
.withProperty("stork.pung.service-discovery", "kubernetes")
.withProperty("stork.pung.service-discovery.k8s-namespace", "all");
.withProperty("quarkus.stork.pung.service-discovery.type", "kubernetes")
.withProperty("quarkus.stork.pung.service-discovery.k8s-namespace", "all");

@QuarkusApplication(classes = PongResource.class)
static RestService pong = new RestService()
.onPostStart(app -> openshift.scaleTo(app, PONG_INSTANCES_AMOUNT))
.withProperty("stork.pong.service-discovery", "kubernetes")
.withProperty("stork.pong.service-discovery.k8s-namespace", "all");
.withProperty("quarkus.stork.pong.service-discovery.type", "kubernetes")
.withProperty("quarkus.stork.pong.service-discovery.k8s-namespace", "all");

@QuarkusApplication(classes = { PingResource.class, MyBackendPungProxy.class, MyBackendPongProxy.class })
static RestService ping = new RestService().onPreStart(app -> setupClusterRoles())
.withProperty("stork.pong.service-discovery", "kubernetes")
.withProperty("stork.pong.service-discovery.k8s-namespace", "all")
.withProperty("stork.pung.service-discovery", "kubernetes")
.withProperty("stork.pung.service-discovery.k8s-namespace", "all");
.withProperty("quarkus.stork.pong.service-discovery.type", "kubernetes")
.withProperty("quarkus.stork.pong.service-discovery.k8s-namespace", "all")
.withProperty("quarkus.stork.pung.service-discovery.type", "kubernetes")
.withProperty("quarkus.stork.pung.service-discovery.k8s-namespace", "all");

@AfterAll
public static void tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,37 @@ public class StorkLoadBalancerIT extends AbstractCommonTestCases {
.withProperty("quarkus.http.port", PONG_PORT)
.withProperty("pong-service-port", PONG_PORT)
.withProperty("pong-service-host", "localhost")
.withProperty("stork.pong.service-discovery.refresh-period", "1")
.withProperty("stork.pong.service-discovery", "consul")
.withProperty("stork.pong.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pong.service-discovery.consul-host", () -> getConsultEndpoint(consul.getConsulEndpoint()));
.withProperty("quarkus.stork.pong.service-discovery.refresh-period", "1")
.withProperty("quarkus.stork.pong.service-discovery.type", "consul")
.withProperty("quarkus.stork.pong.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pong.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()));

@QuarkusApplication(classes = PongReplicaResource.class)
static RestService pongReplicaService = new RestService()
.withProperty("quarkus.http.port", PONG_REPLICA_PORT)
.withProperty("pong-replica-service-port", PONG_REPLICA_PORT)
.withProperty("pong-replica-service-host", "localhost")
.withProperty("stork.pong-replica.service-discovery.refresh-period", "1")
.withProperty("stork.pong-replica.service-discovery", "consul")
.withProperty("stork.pong-replica.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pong-replica.service-discovery.consul-host",
.withProperty("quarkus.stork.pong-replica.service-discovery.refresh-period", "1")
.withProperty("quarkus.stork.pong-replica.service-discovery.type", "consul")
.withProperty("quarkus.stork.pong-replica.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pong-replica.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()));

@QuarkusApplication(classes = { PingResource.class, MyBackendPungProxy.class, MyBackendPongProxy.class })
static RestService mainPingService = new RestService()
.withProperty("stork.pong-replica.service-discovery", "consul")
.withProperty("stork.pong-replica.service-discovery.refresh-period", "1")
.withProperty("stork.pong-replica.load-balancer", "round-robin")
.withProperty("stork.pong-replica.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pong-replica.service-discovery.consul-host",
.withProperty("quarkus.stork.pong-replica.service-discovery.type", "consul")
.withProperty("quarkus.stork.pong-replica.service-discovery.refresh-period", "1")
.withProperty("quarkus.stork.pong-replica.load-balancer", "round-robin")
.withProperty("quarkus.stork.pong-replica.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pong-replica.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()))
.withProperty("stork.pong.service-discovery", "consul")
.withProperty("stork.pong.service-discovery.refresh-period", "1")
.withProperty("stork.pong.load-balancer", "round-robin")
.withProperty("stork.pong.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("stork.pong.service-discovery.consul-host", () -> getConsultEndpoint(consul.getConsulEndpoint()));
.withProperty("quarkus.stork.pong.service-discovery.type", "consul")
.withProperty("quarkus.stork.pong.service-discovery.refresh-period", "1")
.withProperty("quarkus.stork.pong.load-balancer", "round-robin")
.withProperty("quarkus.stork.pong.service-discovery.consul-port", () -> String.valueOf(consul.getPort()))
.withProperty("quarkus.stork.pong.service-discovery.consul-host",
() -> getConsultEndpoint(consul.getConsulEndpoint()));

@Test
public void storkLoadBalancerByRoundRobin() {
Expand Down

0 comments on commit dab12fd

Please sign in to comment.