public WebAppMonitor assertSuccessFraction(String message, double fraction) { int failures = getFailures(); int attempts = getAttempts(); if ((failures > (1-fraction) * attempts + 0.0001) || attempts <= 0) { Assert.fail(message+" -- webapp access failures! " + "("+failures+" failed of "+attempts+" monitoring attempts) against "+getUrl()+"; " + "last was "+getLastStatus()+" taking "+getLastTime()+"ms" + (getLastFailure() != null ? "; last failure was "+getLastFailure() : "")); } return this; } public WebAppMonitor resetCounts() {
public WebAppMonitor assertNoFailures(String message) { return assertSuccessFraction(message, 1.0); } public WebAppMonitor assertAttemptsMade(int minAttempts, String message) {
public int getAttempts() { return getFailures()+getSuccesses(); } public boolean getLastWasFailed() {
public boolean getLastWasFailed() { return isResponseOkay(getLastStatus()); } public Object getLastStatus() {
}}); WebAppMonitor monitor = new WebAppMonitor(nginx.getAttribute(WebAppService.ROOT_URL)) .logFailures(log) .delayMillis(0); Thread t = new Thread(monitor); t.start(); log.info("service continuity test, startup, "+monitor.getAttempts()+" requests made"); monitor.assertAttemptsMade(10, "startup").assertNoFailures("startup").resetCounts(); log.info("service continuity test, iteration "+i+", "+monitor.getAttempts()+" requests made"); monitor.assertAttemptsMade(10, "reloaded").assertNoFailures("reloaded").resetCounts();
assertEquals(monitor.getFailures(), 0);
private WebAppMonitor newWebAppMonitor(String url, int expectedResponseCode) { WebAppMonitor monitor = new WebAppMonitor(url) // .delayMillis(0) FIXME Re-enable to fast polling .expectedResponseCode(expectedResponseCode) .logFailures(LOG); webAppMonitors.add(monitor); executor.execute(monitor); return monitor; }
private WebAppMonitor newWebAppMonitor(String url) { WebAppMonitor monitor = new WebAppMonitor(url) // .delayMillis(0) .logFailures(LOG); webAppMonitors.add(monitor); executor.execute(monitor); return monitor; }
public WebAppMonitor assertAttemptsMade(int minAttempts, String message) { if (getAttempts()<minAttempts) { Assert.fail(message+" -- webapp access failures! " + "(0 attempts made; probably blocked on server)"); } return this; } public WebAppMonitor waitForAtLeastOneAttempt() {
assertHttpStatusCodeEventuallyEquals(rootUrl, 404); assertEquals(monitor.getFailures(), 0);
private WebAppMonitor newWebAppMonitor(String url) { WebAppMonitor monitor = new WebAppMonitor(url) // .delayMillis(0) .logFailures(LOG); webAppMonitors.add(monitor); executor.execute(monitor); return monitor; }
@Override public void run() { Assert.assertTrue(getAttempts() >= 1); }}); return this;
assertEquals(monitor.getFailures(), 0);
private WebAppMonitor newWebAppMonitor(String url) { WebAppMonitor monitor = new WebAppMonitor(url) // .delayMillis(0) .logFailures(LOG); webAppMonitors.add(monitor); executor.execute(monitor); return monitor; }
EntityAsserts.assertAttributeChangesEventually(newServer, JBoss7Server.PROCESSING_TIME_FRACTION_IN_WINDOW); assertEquals(monitor.getFailures(), 0);
assertEquals(monitor.getFailures(), 0);
assertEquals(monitor.getFailures(), 0);