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 VerificationHost createVerificationHost() throws Throwable { VerificationHost host = VerificationHost.create(0); host.start(); // in-memory index related services host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); InMemoryLuceneDocumentIndexService inMemoryIndexService = new InMemoryLuceneDocumentIndexService(); Service inMemoryExampleFactory = InMemoryExampleService.createFactory(); host.startService(Operation.createPost(host, ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX), inMemoryIndexService); host.startService(Operation.createPost(host, InMemoryExampleService.FACTORY_LINK), inMemoryExampleFactory); host.waitForServiceAvailable(ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX, InMemoryExampleService.FACTORY_LINK); return host; }
private void waitForServices(String... services) { host.testStart(services.length); host.registerForServiceAvailability(host.getCompletion(), services); host.testWait(); }
public CompletionHandler getCompletion() { return (o, e) -> { if (e != null) { failIteration(e); return; } completeIteration(); }; }
private void deleteServices(List<URI> targetServiceURIs) throws Throwable { this.host.testStart(targetServiceURIs.size()); for (URI u : targetServiceURIs) { this.host.send(Operation.createDelete(u) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion())); } this.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 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 List<MinimalTestServiceState> queryDocumentWithBaseUri(String documentSelfLink) throws Throwable { this.host.testStart(1); this.queryHelper.setDocumentLink(documentSelfLink) .setResultHandler(handler()) .setBaseUri(this.host.getUri()) .sendWith(this.host); this.host.testWait(); return this.minimalTestStates; }
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 VerificationHost setupMetricHost() throws Throwable { // Start a metric Host separately. VerificationHost metricHost = VerificationHost.create(0); metricHost.start(); ServiceTypeCluster.METRIC_SERVICE.setUri(metricHost.getUri().toString()); PhotonModelMetricServices.startServices(metricHost); return metricHost; }
@Before public void setup() { URI sandbox = this.host.getStorageSandbox(); this.host.log("Sandbox in %s", sandbox); DirectoryContentService dirService = new DirectoryContentService(new File(sandbox).toPath()); this.host.startService(Operation.createPost(UriUtils.buildUri(this.host, SELF_LINK)), dirService); this.host.waitForServiceAvailable(SELF_LINK); }
@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); }
@Before public void setup() throws Throwable { this.host = VerificationHost.create(0); this.host.start(); this.host.startServiceAndWait(new NsOwner(), NsOwner.SELF_LINK, new ServiceDocument()); }
private List<MinimalTestServiceState> queryDocumentUpdatedSince( long documentSinceUpdateTimeMicros, String documentSelfLink) throws Throwable { this.host.testStart(1); this.queryHelper.setUpdatedDocumentSince(documentSinceUpdateTimeMicros, documentSelfLink) .setResultHandler(handler()) .sendWith(host); this.host.testWait(); return this.minimalTestStates; }
@After public void after() throws Throwable { DeploymentProfileConfig.getInstance().setTest(false); try { host.tearDownInProcessPeers(); host.tearDown(); } catch (CancellationException e) { host.log(Level.FINE, e.getClass().getName()); } host = null; }
private void subscribeToService(URI uri, ServiceSubscriber sr) { if (sr.usePublicUri) { sr = Utils.clone(sr); sr.reference = UriUtils.buildPublicUri(this.host, sr.reference.getPath()); } URI subUri = UriUtils.buildSubscriptionUri(uri); this.host.send(Operation.createPost(subUri) .setCompletion(this.host.getCompletion()) .setReferer(this.host.getReferer()) .setBody(sr) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_QUEUE_FOR_SERVICE_AVAILABILITY)); }
private void deleteEntity(String entityLink) throws Throwable { Operation delete = Operation.createDelete(host, entityLink) .setReferer(host.getUri()); host.sendWithFuture(delete) .exceptionally(ex -> { host.log(Level.SEVERE, "Failed to delete entity [%s]: %s", entityLink, Utils.toString(ex)); throw ex instanceof CompletionException ? (CompletionException) ex : new CompletionException(ex); }).get(); }
public void setupDockerNetworkAdapterService() { dockerNetworkAdapterServiceUri = UriUtils.buildUri(host, DockerNetworkAdapterService.class); dockerNetworkAdapterService = new DockerNetworkAdapterService() { @Override protected DockerAdapterCommandExecutor getCommandExecutor() { return getTestCommandExecutor(); } }; host.startService(Operation.createPost(dockerNetworkAdapterServiceUri), dockerNetworkAdapterService); }