Skip to content

Commit

Permalink
Merge pull request #169 from roggerj/master
Browse files Browse the repository at this point in the history
#162 integration tests for gateleen hook js
  • Loading branch information
lbovet authored Sep 19, 2017
2 parents 1ea42bb + 266dad9 commit 8f568b9
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target
.vertx
build
.gradle
playground_logs.log
26 changes: 22 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
language: java
# We use the deprecated travis environment "precise", because Gateleen does not yet support the newer redis version of the "trusty" environment.
dist: precise
jdk:
- oraclejdk8
services:
- redis-server
script:
- redis-server
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# Because newer versions of Chrome are not supported for the deprecated "precise" environment of travis we are using,
# we download and install an older version of Chrome (v. 48), along with some dependencies.
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget http://www.slimjet.com/chrome/download-chrome.php?file=lnx%2Fchrome64_48.0.2564.109.deb
- sudo dpkg -i download-chrome.php?file=lnx%2Fchrome64_48.0.2564.109.deb
# We also download the newest version of Chrome Driver that still supports our old version of Chrome (v. 48).
- wget https://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip -d gateleen-test/src/test/resources/
script:
- ./gradlew build
- ./gradlew :gateleen-test:test -PintegrationTests
- java -jar gateleen-playground/build/libs/playground.jar &> playground_logs.log &
# TODO: Instead of sleeping, should we rather make sure that the server Playground actually is running?
- sleep 5s
- ./gradlew :gateleen-playground:uploadStaticFiles
- ./gradlew :gateleen-test:test -PuiIntegrationTests -Dsel_chrome_driver=src/test/resources/chromedriver
- kill $(ps -ef | grep playground | awk '{ print $2 }')
- ./gradlew :gateleen-test:test -PnonUiIntegrationTests
- ./gradlew jacocoTestReport
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.json.JsonObject;
Expand All @@ -16,16 +15,16 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePropertySource;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager;
import org.swisspush.gateleen.core.lock.Lock;
import org.swisspush.gateleen.core.lock.impl.RedisBasedLock;
import org.swisspush.gateleen.delegate.DelegateHandler;
import org.swisspush.gateleen.core.cors.CORSHandler;
import org.swisspush.gateleen.core.event.EventBusHandler;
import org.swisspush.gateleen.core.http.LocalHttpClient;
import org.swisspush.gateleen.core.lock.Lock;
import org.swisspush.gateleen.core.lock.impl.RedisBasedLock;
import org.swisspush.gateleen.core.resource.CopyResourceHandler;
import org.swisspush.gateleen.core.storage.EventBusResourceStorage;
import org.swisspush.gateleen.core.storage.ResourceStorage;
import org.swisspush.gateleen.core.util.Address;
import org.swisspush.gateleen.delegate.DelegateHandler;
import org.swisspush.gateleen.delta.DeltaHandler;
import org.swisspush.gateleen.expansion.ExpansionHandler;
import org.swisspush.gateleen.expansion.ZipExtractHandler;
Expand All @@ -34,15 +33,15 @@
import org.swisspush.gateleen.hook.reducedpropagation.impl.RedisReducedPropagationStorage;
import org.swisspush.gateleen.logging.LogController;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.logging.RequestLoggingConsumer;
import org.swisspush.gateleen.monitoring.CustomRedisMonitor;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.monitoring.ResetMetricsController;
import org.swisspush.gateleen.qos.QoSHandler;
import org.swisspush.gateleen.queue.queuing.QueueBrowser;
import org.swisspush.gateleen.queue.queuing.QueueClient;
import org.swisspush.gateleen.queue.queuing.QueueProcessor;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.*;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.QueueCircuitBreaker;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.QueueCircuitBreakerStorage;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.api.QueueCircuitBreakerHttpRequestHandler;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.configuration.QueueCircuitBreakerConfigurationResourceManager;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.impl.QueueCircuitBreakerImpl;
Expand All @@ -68,20 +67,19 @@
*/
public class Server extends AbstractVerticle {

public static final String PREFIX = RunConfig.SERVER_NAME + ".";
public static final String ROOT = "/playground";
public static final String SERVER_ROOT = ROOT + "/server";
public static final String RULES_ROOT = SERVER_ROOT + "/admin/v1/routing/rules";
private static final String PREFIX = RunConfig.SERVER_NAME + ".";
private static final String ROOT = "/playground";
private static final String SERVER_ROOT = ROOT + "/server";
private static final String RULES_ROOT = SERVER_ROOT + "/admin/v1/routing/rules";

public static final String ROLE_PATTERN = "^z-playground[-_](.*)$";
private static final String ROLE_PATTERN = "^z-playground[-_](.*)$";

public static final String JMX_DOMAIN = "org.swisspush.gateleen";
private static final String JMX_DOMAIN = "org.swisspush.gateleen";
private HttpServer mainServer;

private Authorizer authorizer;
private Router router;
private LoggingResourceManager loggingResourceManager;
private RequestLoggingConsumer requestLoggingConsumer;
private ConfigurationResourceManager configurationResourceManager;
private ValidationResourceManager validationResourceManager;
private SchedulerResourceManager schedulerResourceManager;
Expand Down Expand Up @@ -112,15 +110,14 @@ public class Server extends AbstractVerticle {
private Logger log = LoggerFactory.getLogger(Server.class);

public static void main(String[] args) {
Vertx.vertx().deployVerticle("org.swisspush.gateleen.playground.Server", event -> {
LoggerFactory.getLogger(Server.class).info("[_] Gateleen - http://localhost:7012/gateleen/");
});
Vertx.vertx().deployVerticle("org.swisspush.gateleen.playground.Server", event ->
LoggerFactory.getLogger(Server.class).info("[_] Gateleen - http://localhost:7012/gateleen/")
);
}

@Override
public void start() {
final LocalHttpClient selfClient = new LocalHttpClient(vertx);
final HttpClient selfClientExpansionHandler = selfClient;
final JsonObject info = new JsonObject();
final Map<String, Object> props = RunConfig.buildRedisProps("localhost", defaultRedisPort);

Expand All @@ -134,10 +131,10 @@ public void start() {
String externalConfig = System.getProperty("org.swisspush.config.dir") + "/config.properties";
Resource externalConfigResource = new FileSystemResource(externalConfig);
if (externalConfigResource.exists()) {
log.info("Merging external config " + externalConfig);
log.info("Merging external config {}", externalConfig);
props.putAll(RunConfig.subMap(new ResourcePropertySource(externalConfigResource).getSource(), "redis."));
} else {
log.info("No external config found under " + externalConfig);
log.info("No external config found under {}", externalConfig);
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -156,21 +153,19 @@ public void start() {
storage = new EventBusResourceStorage(vertx.eventBus(), Address.storageAddress() + "-main");
corsHandler = new CORSHandler();
deltaHandler = new DeltaHandler(redisClient, selfClient);
expansionHandler = new ExpansionHandler(vertx, storage, selfClientExpansionHandler, props, ROOT, RULES_ROOT);
expansionHandler = new ExpansionHandler(vertx, storage, selfClient, props, ROOT, RULES_ROOT);
copyResourceHandler = new CopyResourceHandler(selfClient, SERVER_ROOT + "/v1/copy");
monitoringHandler = new MonitoringHandler(vertx, storage, PREFIX, SERVER_ROOT + "/monitoring/rpr");
qosHandler = new QoSHandler(vertx, storage, SERVER_ROOT + "/admin/v1/qos", props, PREFIX);
qosHandler.enableResourceLogging(true);
configurationResourceManager = new ConfigurationResourceManager(vertx, storage);
configurationResourceManager.enableResourceLogging(true);
String eventBusConfigurationResource = SERVER_ROOT + "/admin/v1/hookconfig";
eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/", SERVER_ROOT + "/event/v1/sock/*", "event-", "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource);
eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/", SERVER_ROOT + "/event/v1/sock/*", "event/channels/", "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource);
eventBusHandler.setEventbusBridgePingInterval(RunConfig.EVENTBUS_BRIDGE_PING_INTERVAL);
loggingResourceManager = new LoggingResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/logging");
loggingResourceManager.enableResourceLogging(true);

requestLoggingConsumer = new RequestLoggingConsumer(vertx, loggingResourceManager);

userProfileHandler = new UserProfileHandler(vertx, storage, RunConfig.buildUserProfileConfiguration());
userProfileHandler.enableResourceLogging(true);
roleProfileHandler = new RoleProfileHandler(vertx, storage, SERVER_ROOT + "/roles/v1/([^/]+)/profile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link href="css/gateleen.css" rel="stylesheet">
<script src="js/angularjs/angular.min.js"></script>
<script src="js/angularjs/angular-animate.js"></script>

<script src="js/sockjs.js"></script>
<script src="js/vertxbus.js"></script>

<script src="js/angularjs/angular.min.js"></script>
<script src="js/angularjs/angular-animate.js"></script>

<script src="js/gateleen-hook.js"></script>
</head>

Expand Down Expand Up @@ -76,52 +78,52 @@
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="Place Single Hook"
ng-click="hookJs.install('hook-demo')">Place Single Hook
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="Place Single Fetching Hook"
ng-click="hookJs.install('hook-demo', 'single')">Place Single Fetching Hook
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="Place Collection Hook"
ng-click="hookJs.install('messages/')">Place Collection Hook
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="Place Collection Fetching Hook"
ng-click="hookJs.install('messages/', 'collection')">Place Collection Fetching Hook
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block" ng-click="hookJs.remove()">
Remove Last Hook
<button type="button" class="btn btn-primary btn-lg btn-block" id="Remove Last Hook"
ng-click="hookJs.remove()">Remove Last Hook
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="PUT Single"
ng-click="hookJs.put('hook-demo')">PUT Single
</button>
</br>
<button type="button" class="btn btn-primary btn-lg btn-block"
<button type="button" class="btn btn-primary btn-lg btn-block" id="PUT Collection"
ng-click="hookJs.put('messages', true)">PUT Collection
</button>
</div>

<div class="col-md-9">
<div class="row">
<div class="col-md-6">
<button type="button" class="btn btn-info btn-lg btn-block"
<button type="button" class="btn btn-info btn-lg btn-block" id="Clear log"
ng-click="hookJs.clearLog()">Clear log
</button>
</div>

<div class="col-md-6">
<button type="button" class="btn btn-info btn-lg btn-block"
<button type="button" class="btn btn-info btn-lg btn-block" id="Clear collection"
ng-click="hookJs.clearCollection('messages')">Clear collection
</button>
</div>
</div>
</br>
<div class="row" style="padding-right: 15px">
<ul class="list-group" ng-show="hookJs.messages">
<ul class="list-group" ng-show="hookJs.messages" id="hookjs messages">
<li class="list-group-item" ng-repeat="message in hookJs.messages track by $index">
{{message.info}}{{message.text}}
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.swisspush.gateleen.queue.queuing.circuitbreaker.lua;

import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.swisspush.gateleen.core.lua.AbstractLuaScriptTest;
Expand All @@ -25,6 +26,7 @@ public class QueueCircuitBreakerUnlockSamplesLuaScriptTests extends AbstractLuaS
private final String circuitQueuesKeyPrefix = "q:";
private final String circuitQueuesKeySuffix = ":queues";

// @Ignore
@Test
public void testUnlockSamples(){

Expand Down
29 changes: 27 additions & 2 deletions gateleen-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,35 @@ dependencies {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}
testCompile (group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-edge-driver'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-firefox-driver'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-ie-driver'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-opera-driver'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-safari-driver'
}
testCompile (group: 'info.cukes', name: 'cucumber-java', version: "$cukeVersion")
testCompile (group: 'info.cukes', name: 'cucumber-junit', version: "$cukeVersion")
}

test {
onlyIf {
project.hasProperty("integrationTests")
project.hasProperty("nonUiIntegrationTests") || project.hasProperty("uiIntegrationTests")
}

systemProperty "sel_chrome_driver", System.getProperty("sel_chrome_driver")

filter {

if (project.hasProperty("nonUiIntegrationTests")) {
include "org/swisspush/gateleen/**"
exclude "org/swisspush/gateleen/hookjs/**"
}

if (project.hasProperty("uiIntegrationTests")) {
include "org/swisspush/gateleen/hookjs/**"
}
}
}

outputs.upToDateWhen { false }
}
Loading

0 comments on commit 8f568b9

Please sign in to comment.