private void sendGetNetworkStateRequest() throws Throwable { Operation getNetworkState = Operation.createGet(networkStateReference) .setCompletion((o, ex) -> { if (ex != null) { host.failIteration(ex); } else { host.completeIteration(); } }); host.testStart(1); host.send(getNetworkState); host.testWait(); }
private <T> T testExecuteTask(RetriableTaskBuilder<T> task) { ArrayList<T> result = new ArrayList<>(1); host.testStart(1); task.execute().whenComplete((taskResult, ex) -> { if (ex != null) { host.failIteration(ex); } else { result.add(taskResult); host.completeIteration(); } }); host.testWait(); return result.iterator().next(); }
private void delete(URI uri) throws Throwable { this.host.testStart(1); this.host.sendRequest(Operation .createDelete(uri) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion()) .setReferer(this.host.getUri())); this.host.testWait(); }
@Test public void startServiceSelfLinkWithStar() throws Throwable { setUp(false); MinimalTestServiceState initialState = new MinimalTestServiceState(); initialState.id = this.host.nextUUID(); TestContext ctx = this.host.testCreate(1); Operation startPost = Operation .createPost(UriUtils.buildUri(this.host, this.host.nextUUID() + "*")) .setBody(initialState).setCompletion(ctx.getExpectedFailureCompletion()); this.host.startService(startPost, new MinimalTestService()); this.host.testWait(ctx); }
@Test public void testInvalidUri() throws Throwable { TestContext ctx = host.testCreate(1); URI rpPingUri = UriUtils.buildUri(host, "/rp/invalid"); Operation op = Operation.createGet(rpPingUri) .setCompletion(ctx.getExpectedFailureCompletion()); host.send(op); host.testWait(ctx); }
@Test public void allocateExecutor() throws Throwable { setUp(false); Service s = this.host.startServiceAndWait(MinimalTestService.class, UUID.randomUUID() .toString()); ExecutorService exec = this.host.allocateExecutor(s); this.host.testStart(1); exec.execute(() -> { this.host.completeIteration(); }); this.host.testWait(); }
private void verifyRegistryLinksByRegistryFilter(String registryFilter, Collection<String> tenantLinks, Collection<RegistryState> expectedRegistries) { assertNotNull(expectedRegistries); host.testStart(1); RegistryUtil.findRegistries(host, tenantLinks, registryFilter, (registries, errors) -> { if (errors != null && !errors.isEmpty()) { host.failIteration(errors.iterator().next()); } verifyFoundRegistries(expectedRegistries, registries); }); host.testWait(); }
private void sendGetVolumeStateRequest() throws Throwable { Operation getVolumeState = Operation.createGet(volumeStateReference) .setCompletion((o, ex) -> { if (ex != null) { host.failIteration(ex); } else { host.completeIteration(); } }); host.testStart(1); host.send(getVolumeState); host.testWait(); }
private void delete(URI uri) throws Throwable { this.host.testStart(1); this.host.sendRequest(Operation .createDelete(uri) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion()) .setReferer(this.host.getUri())); this.host.testWait(); }
@Test public void startServiceSelfLinkWithStar() throws Throwable { setUp(false); MinimalTestServiceState initialState = new MinimalTestServiceState(); initialState.id = this.host.nextUUID(); TestContext ctx = this.host.testCreate(1); Operation startPost = Operation .createPost(UriUtils.buildUri(this.host, this.host.nextUUID() + "*")) .setBody(initialState).setCompletion(ctx.getExpectedFailureCompletion()); this.host.startService(startPost, new MinimalTestService()); this.host.testWait(ctx); }
@Test public void testSetOperationsFailureWithoutOperations() throws Throwable { OperationJoin operationJoin = OperationJoin.create(); host.testStart(1); try { operationJoin.sendWith(host); host.failIteration(new IllegalStateException("Expected exception")); } catch (IllegalStateException e) { host.completeIteration(); } host.testWait(); }
@Test public void allocateExecutor() throws Throwable { setUp(false); Service s = this.host.startServiceAndWait(MinimalTestService.class, UUID.randomUUID() .toString()); ExecutorService exec = this.host.allocateExecutor(s); this.host.testStart(1); exec.execute(() -> { this.host.completeIteration(); }); this.host.testWait(); }
private void verifyRegistryLinksByHostname(String hostname, Collection<String> tenantLinks, Collection<RegistryState> expectedRegistries) { assertNotNull(expectedRegistries); host.testStart(1); RegistryUtil.findRegistriesByHostname(host, hostname, tenantLinks, (registries, errors) -> { if (errors != null && !errors.isEmpty()) { host.failIteration(errors.iterator().next()); } verifyFoundRegistries(expectedRegistries, registries); }); host.testWait(); }
public void patchUserService(ServiceHost target, String userServiceLink, UserState userState) throws Throwable { URI patchUserUri = UriUtils.buildUri(target, userServiceLink); this.host.testStart(1); this.host.send(Operation .createPatch(patchUserUri) .setBody(userState) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } this.host.completeIteration(); })); this.host.testWait(); }
private void startAndWaitHostNetworkListDataCollection() throws Throwable { host.testStart(1); host.sendRequest(Operation .createPatch(UriUtils.buildUri(host, HostNetworkListDataCollection.DEFAULT_HOST_NETWORK_LIST_DATA_COLLECTION_LINK)) .setBody(networkListCallback) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); // Wait for data collection to finish waitForDataCollectionFinished(); }
@Test public void testSetOperationsFailureWithoutOperations() throws Throwable { OperationJoin operationJoin = OperationJoin.create(); host.testStart(1); try { operationJoin.sendWith(host); host.failIteration(new IllegalStateException("Expected exception")); } catch (IllegalStateException e) { host.completeIteration(); } host.testWait(); }
public void patchUserService(ServiceHost target, String userServiceLink, UserState userState) throws Throwable { URI patchUserUri = UriUtils.buildUri(target, userServiceLink); this.host.testStart(1); this.host.send(Operation .createPatch(patchUserUri) .setBody(userState) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } this.host.completeIteration(); })); this.host.testWait(); }