test(gateway-test) Update test harness to include SharedGlobalDataRegistry.
MODIFY
gateway/test/pom.xml
gateway/test/pom.xml
<groupId>${project.groupId}</groupId>
<artifactId>apiman-gateway-engine-vertx-eb-inmemory</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apiman-gateway-engine-vertx-shareddata</artifactId>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apiman-distro-data</artifactId>

ADD
gateway/test/src/test/java/io/apiman/gateway/test/junit/vertx3/Vertx3ClusteredGatewayTestServerFactory.java
+/*
+ * Copyright 2017 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.apiman.gateway.test.junit.vertx3;
+
+import io.apiman.test.common.resttest.IGatewayTestServer;
+import io.apiman.test.common.resttest.IGatewayTestServerFactory;
+
+/**
+ * Factory to produce Vertx3 gateway test servers.
+ *
+ * @author Marc Savy {@literal <msavy@redhat.com>}
+ */
+public class Vertx3ClusteredGatewayTestServerFactory implements IGatewayTestServerFactory {
+
+ /**
+ * Constructor.
+ */
+ public Vertx3ClusteredGatewayTestServerFactory() {
+ }
+
+ @Override
+ public IGatewayTestServer createGatewayTestServer() {
+ return new Vertx3GatewayTestServer(true);
+ }
+
+}

MODIFY
gateway/test/src/test/java/io/apiman/gateway/test/junit/vertx3/Vertx3GatewayTestServer.java
gateway/test/src/test/java/io/apiman/gateway/test/junit/vertx3/Vertx3GatewayTestServer.java
*/
package io.apiman.gateway.test.junit.vertx3;
-import com.fasterxml.jackson.databind.JsonNode;
import io.apiman.common.util.ReflectionUtils;
import io.apiman.gateway.platforms.vertx3.common.config.VertxEngineConfig;
import io.apiman.gateway.platforms.vertx3.verticles.InitVerticle;
@@ -25,6 +24,7 @@ import io.vertx.core.AsyncResult;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
+import io.vertx.core.VertxOptions;
import io.vertx.core.json.JsonObject;
import java.io.File;
@@ -33,6 +33,8 @@ import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.concurrent.CountDownLatch;
+import com.fasterxml.jackson.databind.JsonNode;
+
/**
* A Vert.x 3 version of the gateway test server
*
@@ -52,11 +54,10 @@ public class Vertx3GatewayTestServer implements IGatewayTestServer {
private Resetter resetter;
private Vertx vertx;
private JsonObject vertxConf;
+ private boolean clustered;
- /**
- * Constructor.
- */
- public Vertx3GatewayTestServer() {
+ public Vertx3GatewayTestServer(boolean clustered) {
+ this.clustered = clustered;
}
@Override
@@ -94,7 +95,21 @@ public class Vertx3GatewayTestServer implements IGatewayTestServer {
try {
resetter.reset();
- vertx = Vertx.vertx();
+ if (clustered) {
+ CountDownLatch clusteredStart = new CountDownLatch(1);
+ Vertx.clusteredVertx(new VertxOptions().setClustered(clustered).setClusterHost("localhost").setBlockedThreadCheckInterval(9999999), result -> {
+ if (result.succeeded()) {
+ System.out.println("**** Clustered Vert.x started up successfully! ****");
+ this.vertx = result.result();
+ clusteredStart.countDown();
+ } else {
+ throw new RuntimeException(result.cause());
+ }
+ });
+ clusteredStart.await();
+ } else {
+ vertx = Vertx.vertx(new VertxOptions().setBlockedThreadCheckInterval(9999999));
+ }
echoServer.start();
startLatch = new CountDownLatch(1);
@@ -125,6 +140,11 @@ public class Vertx3GatewayTestServer implements IGatewayTestServer {
echoServer.stop();
vertx.close(result -> {
+ if (result.succeeded()) {
+ System.out.println("**** Shut Vert.x down successfully! ****");
+ } else {
+ throw new RuntimeException(result.cause());
+ }
stopLatch.countDown();
});

MODIFY
gateway/test/src/test/java/io/apiman/gateway/test/junit/vertx3/Vertx3GatewayTestServerFactory.java
gateway/test/src/test/java/io/apiman/gateway/test/junit/vertx3/Vertx3GatewayTestServerFactory.java
@@ -33,7 +33,7 @@ public class Vertx3GatewayTestServerFactory implements IGatewayTestServerFactory
@Override
public IGatewayTestServer createGatewayTestServer() {
- return new Vertx3GatewayTestServer();
+ return new Vertx3GatewayTestServer(false);
}
}

ADD
gateway/test/src/test/resources/test-configs/vertx3-shared-global-data.json
+{
+ "factory" : "io.apiman.gateway.test.junit.vertx3.Vertx3ClusteredGatewayTestServerFactory",
+ "config" : "vertx3/conf-shared-global-data.json",
+ "resetter" : "io.apiman.gateway.test.junit.vertx3.NoOpResetter"
+}

ADD
gateway/test/src/test/resources/vertx3/conf-shared-global-data.json
+{
+ "registry": {
+ "class": "io.apiman.gateway.engine.vertx.shareddata.SharedGlobalDataRegistry",
+ "config": {
+ }
+ },
+
+// "writers": {
+// "error": {
+// "class": "io.apiman.gateway.engine.impl.TracePolicyErrorWriter",
+// "config": {}
+// },
+// "policy-failure": {
+// "class": "",
+// "config": {}
+// }
+// },
+
+ "encrypter": {
+ "class": "io.apiman.gateway.engine.impl.DefaultDataEncrypter",
+ "config": {}
+ },
+
+ "plugin-registry": {
+ "class": "io.apiman.gateway.platforms.vertx3.engine.VertxPluginRegistry",
+ "config": {}
+ },
+
+ "connector-factory": {
+ "class": "io.apiman.gateway.platforms.vertx3.connector.ConnectorFactory",
+ "config": {
+ // "tls": {
+ // "allowSelfSigned": true,
+ // "devMode": true,
+ // "trustStore": "/path/to/your/truststore.jks",
+ // "keyStore": "/path/to/your/keystore.jks",
+ // "keyStorePassword": "abc123"
+ // }
+ }
+ },
+
+ "logger-factory": {
+ "class": "io.apiman.gateway.platforms.vertx3.common.config.VertxLoggerDelegate",
+ "config": {}
+ },
+
+ "policy-factory": {
+ "class": "io.apiman.gateway.engine.policy.PolicyFactoryImpl",
+ "config": {
+ }
+ },
+
+ "metrics": {
+ "class": "io.apiman.gateway.test.server.TestMetrics",
+ "config": {}
+ },
+
+ "components": {
+ "IHttpClientComponent": {
+ "class": "io.apiman.gateway.platforms.vertx3.components.HttpClientComponentImpl",
+ "config": {}
+ },
+
+ "ISharedStateComponent": {
+ "class": "io.apiman.gateway.engine.impl.InMemorySharedStateComponent",
+ "config": {}
+ },
+
+ "IRateLimiterComponent": {
+ "class": "io.apiman.gateway.engine.impl.InMemoryRateLimiterComponent",
+ "config": {}
+ },
+
+ "IPolicyFailureFactoryComponent": {
+ "class": "io.apiman.gateway.platforms.vertx3.components.PolicyFailureFactoryComponent",
+ "config": {}
+ },
+
+ "IBufferFactoryComponent": {
+ "class": "io.apiman.gateway.platforms.vertx3.components.BufferFactoryComponentImpl",
+ "config": {}
+ }
+ },
+
+ // Host-name to bind to for this machine.
+ "hostname": "localhost",
+
+ // You can force a particular endpoint to be reported here (e.g.
+ // if you have some clustered setup with exotic DNS setup)
+ //"endpoint": "localhost",
+
+ // Verticle configuration
+ // Port - The port a given verticle listens on (where relevant)
+ // Count - Number of given verticle type launched
+ "verticles": {
+ "http": {
+ "port": 8082,
+ "count": 1
+ },
+ "https": {
+ "port": 8443,
+ "count": 0
+ },
+ "api": {
+ "port": 8081,
+ "count": 1
+ }
+ },
+
+// SSL configuration to the gateway's *front end* (i.e. client <-> gateway).
+//"ssl": {
+// "keystore": {
+// "path": "<keystore path here>",
+// "password": "password"
+// },
+// "truststore": {
+// "path": "<truststore path here>",
+// "password": "password"
+// }
+//},
+
+ // API authentication; presently just BASIC auth.
+ "auth": {
+ "required": "basic",
+ "realm": "apiman-gateway",
+ "basic": { // Password is SHA256 digest encoded as Base64.
+ "admin" : "jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="
+ }
+ },
+
+ // When reporting a API's endpoint, prefer secure (i.e. https)
+ "preferSecure": false
+}

MODIFY
pom.xml
pom.xml
<artifactId>apiman-gateway-engine-vertx-polling</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apiman-gateway-engine-vertx-shareddata</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apiman-gateway-engine-prometheus</artifactId>

test(gateway-test) Update test harness to include SharedGlobalDataRegistry.