@Override public void sendRequest(Operation op) { if (enablePostgres && PostgresHostUtils.handleSendRequest(this, op, this::findService)) { return; } super.sendRequest(op); }
@Test public void defaultFailureCompletion() { Operation getToNowhere = getOperationFailure(); // we are just making no exceptions are thrown in the context of the sendRequest call this.host.sendRequest(getToNowhere); }
@Test public void defaultFailureCompletion() { Operation getToNowhere = getOperationFailure(); // we are just making no exceptions are thrown in the context of the sendRequest call this.host.sendRequest(getToNowhere); }
@After public void tearDown() { MockKubernetesAdapterService.clearKubernetesEntities(); if (forDelete.size() != 0) { host.testStart(forDelete.size()); forDelete.forEach(link -> host.sendRequest( Operation .createDelete(UriUtils.buildUri(host, link)) .setReferer(host.getUri()) .setCompletion(host.getCompletion()) )); forDelete.clear(); host.testWait(); } }
private MinimalTestServiceState doPost(MinimalTestServiceState minimalTestState) throws Throwable { List<Service> currentServices = this.host.doThroughputServiceStart(1, MinimalTestService.class, minimalTestState, EnumSet.of(ServiceOption.PERSISTENCE), null); this.services.addAll(currentServices); MinimalTestServiceState[] result = new MinimalTestServiceState[] { null }; this.host.testStart(1); this.host.sendRequest(Operation.createGet(currentServices.get(0).getUri()) .setReferer(this.host.getUri()) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } result[0] = o.getBody(MinimalTestServiceState.class); this.host.completeIteration(); })); this.host.testWait(); return result[0]; }
private MinimalTestServiceState doPost(MinimalTestServiceState minimalTestState) throws Throwable { List<Service> currentServices = this.host.doThroughputServiceStart(1, MinimalTestService.class, minimalTestState, EnumSet.of(ServiceOption.PERSISTENCE), null); this.services.addAll(currentServices); MinimalTestServiceState[] result = new MinimalTestServiceState[] { null }; this.host.testStart(1); this.host.sendRequest(Operation.createGet(currentServices.get(0).getUri()) .setReferer(this.host.getUri()) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } result[0] = o.getBody(MinimalTestServiceState.class); this.host.completeIteration(); })); this.host.testWait(); return result[0]; }
@Test public void testInvalidJsonContainerDescription() throws Throwable { InvalidDescription state = new InvalidDescription(); state.volumes = "test"; Operation op = Operation.createPost(getContainerDescriptionUri()) .setBody(state) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FROM_MIGRATION_TASK) .setReferer(URI.create("/")) .setCompletion((o, e) -> { if (e != null) { host.failIteration(new Exception( "Migration request for invalid json should be successful")); return; } else { host.completeIteration(); } }); host.testStart(1); host.sendRequest(op); 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(); }
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(); }
private void queryTemplateImages() { TestContext ctx = BaseTestCase.testCreate(1); host.sendRequest(Operation.createGet(UriUtils.buildUri(host, templateQuery)) .setReferer(host.getUri()) .setCompletion((o, ex) -> { if (ex != null) { ctx.failIteration(ex); } else { ctx.completeIteration(); } })); ctx.await(); }
private void startDataCollectionAndWait() throws Throwable { host.testStart(1); host.sendRequest(Operation .createPatch(UriUtils.buildUri(host, KubernetesEntityDataCollection .DEFAULT_KUBERNETES_ENTITY_DATA_COLLECTION_LINK)) .setBody(listCallback) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); waitForDataCollectionToFinish(); }
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(); }
private void startAndWaitHostVolumeListDataCollection() throws Throwable { host.testStart(1); host.sendRequest(Operation .createPatch(UriUtils.buildUri(host, HostVolumeListDataCollection.DEFAULT_HOST_VOLUME_LIST_DATA_COLLECTION_LINK)) .setBody(volumeListCallback) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); // Wait for data collection to finish waitForDataCollectionFinished(); }
private void startAndWaitHostContainerListDataCollection() throws Throwable { host.testStart(1); host.sendRequest(Operation .createPatch(UriUtils.buildUri(host, DEFAULT_HOST_CONTAINER_LIST_DATA_COLLECTION_LINK)) .setBody(containerListBody) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); // Wait for data collection to finish waitForDataCollectionFinished(); }
@Test public void testRequestWithNoHostLink() { EntityListCallback request = new EntityListCallback(); host.testStart(1); host.sendRequest( Operation.createPatch(UriUtils.buildUri(host, KubernetesEntityDataCollection .DEFAULT_KUBERNETES_ENTITY_DATA_COLLECTION_LINK)) .setBody(request) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); }
private PlacementHostSelectionTaskState startPlacementTask( PlacementHostSelectionTaskState placementTask, boolean expectError) throws Throwable { PlacementHostSelectionTaskState[] result = new PlacementHostSelectionTaskState[] { null }; host.testStart(1); host.sendRequest(Operation.createPost(host, PlacementHostSelectionTaskService.FACTORY_LINK) .setBody(placementTask) .setReferer(host.getUri()) .setCompletion((o, e) -> { if (e != null) { host.failIteration(e); return; } result[0] = o.getBody(PlacementHostSelectionTaskState.class); host.completeIteration(); })); host.testWait(); return result[0]; }
protected void startInitialBootService( Class<? extends AbstractInitialBootService> serviceClass, String bootServiceSelfLink) throws Throwable { // simulate a restart of the service host host.startServiceAndWait(serviceClass, bootServiceSelfLink); TestContext ctx = testCreate(1); // start initialization of system documents host.sendRequest(Operation.createPost( UriUtils.buildUri(host, serviceClass)) .setReferer(host.getUri()) .setBody(new ServiceDocument()) .setCompletion(ctx.getCompletion())); ctx.await(); } }
private ContainerStats patchStats(ContainerStats patchState) throws Throwable { URI uri = UriUtils.buildUri(host, containerState.documentSelfLink); host.testStart(1); host.sendRequest(Operation.createPatch(uri) .setBody(patchState) .setReferer(host.getUri()) .setCompletion(host.getCompletion())); host.testWait(); ServiceStats serviceStats = getDocument(ServiceStats.class, containerState.documentSelfLink + ServiceHost.SERVICE_URI_SUFFIX_STATS); assertNotNull(serviceStats); return ContainerStats.transform(serviceStats); }
private MinimalTestServiceState doPatch(MinimalTestServiceState minimalTestState) throws Throwable { this.host.testStart(1); MinimalTestServiceState[] result = new MinimalTestServiceState[] { null }; this.host.sendRequest(Operation .createPatch(UriUtils.buildUri(this.host, minimalTestState.documentSelfLink)) .setBody(minimalTestState) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } result[0] = o.getBody(MinimalTestServiceState.class); this.host.completeIteration(); }) .setReferer(this.host.getUri())); this.host.testWait(); return result[0]; }
private MinimalTestServiceState doPatch(MinimalTestServiceState minimalTestState) throws Throwable { this.host.testStart(1); MinimalTestServiceState[] result = new MinimalTestServiceState[] { null }; this.host.sendRequest(Operation .createPatch(UriUtils.buildUri(this.host, minimalTestState.documentSelfLink)) .setBody(minimalTestState) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } result[0] = o.getBody(MinimalTestServiceState.class); this.host.completeIteration(); }) .setReferer(this.host.getUri())); this.host.testWait(); return result[0]; }