given().pollDelay(0, MILLISECONDS).and().ignoreExceptions().await().until(new Callable<Boolean>() { @Override public Boolean call() {
@Test public void unframed() throws Exception { makeUnframedRequest("world"); makeUnframedRequest("world"); makeUnframedRequest("space"); makeUnframedRequest("world"); makeUnframedRequest("space"); makeUnframedRequest("space"); makeUnframedRequest("world"); // Chance that get() returns NPE before the metric is first added, so ignore exceptions. given().ignoreExceptions().untilAsserted(() -> assertThat( findServerMeter("UnaryCall2", "requests", COUNT, "result", "success", "httpStatus", "200")) .contains(4.0)); given().ignoreExceptions().untilAsserted(() -> assertThat( findServerMeter("UnaryCall2", "requests", COUNT, "result", "failure", "httpStatus", "500")) .contains(3.0)); assertThat(findServerMeter("UnaryCall2", "responseLength", COUNT, "httpStatus", "200")).contains(4.0); assertThat(findServerMeter("UnaryCall2", "responseLength", COUNT, "httpStatus", "500")).contains(3.0); assertThat(findServerMeter("UnaryCall2", "responseLength", TOTAL, "httpStatus", "200")).contains(0.0); assertThat(findServerMeter("UnaryCall2", "responseLength", TOTAL, "httpStatus", "500")).contains(225.0); }
given().ignoreExceptions().untilAsserted(() -> assertThat( findServerMeter("UnaryCall", "requests", COUNT, "result", "success", "httpStatus", "200")) .contains(4.0)); given().ignoreExceptions().untilAsserted(() -> assertThat( findServerMeter("UnaryCall", "requests", COUNT, "result", "failure", "httpStatus", "200")) .contains(3.0)); given().ignoreExceptions().untilAsserted(() -> assertThat( findClientMeter("UnaryCall", "requests", COUNT, "result", "success")).contains(4.0)); given().ignoreExceptions().untilAsserted(() -> assertThat( findClientMeter("UnaryCall", "requests", COUNT, "result", "failure")).contains(3.0));
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingPollIntervalUsingTimeunit() { new Asynch(fakeRepository).perform(); with().pollInterval(20, TimeUnit.MILLISECONDS).await().until(fakeRepositoryValueEqualsOne()); given().pollInterval(20, TimeUnit.MILLISECONDS).await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
private void waitForDiferenciaToBecomeHealthy() { try { given().ignoreExceptions() .await().atMost(10, TimeUnit.SECONDS).until(diferenciaClient::healthy); } catch (ConditionTimeoutException e) { throw new IllegalStateException(diferenciaExecutor.checkForFailure(), e); } }
@Test public void testLogsController() throws IOException { final String expectedDBState = resource("logs-controller-db.json").trim(); final String podLogs = resource("test-pod-x23x.txt"); final InputStream podLogsStream = new ByteArrayInputStream(podLogs.getBytes(StandardCharsets.UTF_8)); try (ActivityTrackingController controller = new StubbedController(jsondb, dbi, client, podLogsStream, ZonedDateTime.parse("2018-01-12T21:22:02.068338027Z").toInstant().toEpochMilli())) { controller.setStartupDelay("0 seconds"); controller.setRetention(Integer.MAX_VALUE); controller.open(); // Eventually all the log data should make it into the jsondb given().await() .atMost(20, SECONDS) .pollInterval(1, SECONDS) .untilAsserted(() -> { String db = jsondb.getAsString("/", new GetOptions().prettyPrint(true)); assertThat(db).isEqualTo(expectedDBState); }); } }
@Test public void shouldRetainLastRetainActivityLogs() throws IOException { try (InputStream podLogsStream = logStream(1100); ActivityTrackingController controller = new StubbedController(jsondb, dbi, client, podLogsStream, System.currentTimeMillis())) { controller.setStartupDelay("0 seconds"); controller.setCleanUpInterval("15 minutes"); controller.open(); // Eventually all the log data should make it into the jsondb given().await() .atMost(20, SECONDS) .pollInterval(1, SECONDS) .untilAsserted(() -> { final String json = jsondb.getAsString("/", new GetOptions().prettyPrint(true)); assertThat(json).isNotNull(); final JsonNode tree = Json.reader().readTree(json); assertThat(tree.get("activity").get("exchanges").get("my-integration").size()).isGreaterThan(1000); }); controller.cleanupLogs(); final String json = jsondb.getAsString("/", new GetOptions().prettyPrint(true)); assertThat(json).isNotNull(); final JsonNode tree = Json.reader().readTree(json); assertThat(tree.get("activity").get("exchanges").get("my-integration").size()).isLessThanOrEqualTo(controller.getRetention()); } }
given().await() .atMost(20, SECONDS) .pollInterval(1, SECONDS)
given().await() .atMost(20, SECONDS) .pollInterval(1, SECONDS)
@Override public Object invoke(final Object proxy, final MethodInfo methodInfo, final Configuration configuration) { final AppiumDriver driver = configuration.getContext(AppiumDriverContext.class) .orElseThrow(() -> new AtlasException("AppiumDriver is missing")).getValue(); given().atMost(120, SECONDS).pollInterval(1, SECONDS).ignoreExceptions().until(() -> { if (!displayed().matches(proxy)) { final Dimension size = driver.manage().window().getSize(); final int startX = size.width / 2; final int startY = (int) (size.height * TOP.getValue()); final int endX = size.width / 2; final int endY = (int) (size.height * BOTTOM.getValue()); final TouchAction touchAction = new TouchAction(driver); touchAction.longPress(new PointOption().withCoordinates(startX, startY)) .moveTo(new PointOption().withCoordinates(endX, endY)).release().perform(); } return displayed().matches(proxy); }); return proxy; } }
@Override public Object invoke(final Object proxy, final MethodInfo methodInfo, final Configuration configuration) { final AppiumDriver driver = configuration.getContext(AppiumDriverContext.class) .orElseThrow(() -> new AtlasException("AppiumDriver is missing")).getValue(); given().atMost(120, SECONDS).pollInterval(1, SECONDS).ignoreExceptions().until(() -> { if (!displayed().matches(proxy)) { final Dimension size = driver.manage().window().getSize(); final int startX = size.width / 2; final int startY = (int) (size.height * BOTTOM.getValue()); final int endX = size.width / 2; final int endY = (int) (size.height * TOP.getValue()); final TouchAction touchAction = new TouchAction(driver); touchAction.longPress(new PointOption().withCoordinates(startX, startY)) .moveTo(new PointOption().withCoordinates(endX, endY)).release().perform(); } return displayed().matches(proxy); }); return proxy; } }