private List<ContainerDescription> queryDocument(String documentSelfLink) throws Throwable { host.testStart(1); query.queryDocument(documentSelfLink, handler(true)); host.testWait(); return descs; }
private void getHealthConfig(String containerDescriptionLink, Consumer<HealthConfig> callback) { ServiceDocumentQuery<ContainerDescription> query = new ServiceDocumentQuery<ContainerDescription>( host, ContainerDescription.class); String healthConfigUriPath = UriUtils.buildUriPath(containerDescriptionLink); query.queryDocument(healthConfigUriPath, (r) -> { if (r.hasException()) { host.log(Level.FINE, "Failed to retrieve container's health config: %s - %s", containerState.documentSelfLink, r.getException()); } else if (r.hasResult() && r.getResult().healthConfig != null) { callback.accept(r.getResult().healthConfig); } else { host.log(Level.FINE, "Container's health config: %s not found.", containerState.documentSelfLink); HealthConfig defaultConfig = createDefaultHealthConfig(); callback.accept(defaultConfig); } }); }
private void waitForDataCollectionFinished() throws Throwable { AtomicBoolean cotinue = new AtomicBoolean(); String dataCollectionLink = HostVolumeListDataCollection.DEFAULT_HOST_VOLUME_LIST_DATA_COLLECTION_LINK; waitFor(() -> { ServiceDocumentQuery<HostVolumeListDataCollectionState> query = new ServiceDocumentQuery<>( host, HostVolumeListDataCollectionState.class); query.queryDocument(dataCollectionLink, (r) -> { if (r.hasException()) { host.log( "Exception while retrieving default host volume list data collection: " + (r.getException() instanceof CancellationException ? r.getException().getMessage() : Utils.toString(r.getException()))); cotinue.set(true); } else if (r.hasResult()) { if (r.getResult().containerHostLinks.isEmpty()) { cotinue.set(true); } } }); return cotinue.get(); }); }
private void checkForDefaultHostDescription(String descriptionLink, String descriptionId) { new ServiceDocumentQuery<>(getHost(), ComputeDescription.class) .queryDocument(descriptionLink, (r) -> { if (r.hasException()) { r.throwRunTimeException();
private void waitForDataCollectionFinished() throws Throwable { AtomicBoolean cotinue = new AtomicBoolean(); String dataCollectionLink = DEFAULT_HOST_CONTAINER_LIST_DATA_COLLECTION_LINK; waitFor(() -> { ServiceDocumentQuery<HostContainerListDataCollectionState> query = new ServiceDocumentQuery<>(host, HostContainerListDataCollectionState.class); query.queryDocument( dataCollectionLink, (r) -> { if (r.hasException()) { host.log("Exception while retrieving default host container list data" + " collection: " + (r.getException() instanceof CancellationException ? r.getException().getMessage() : Utils.toString(r.getException()))); cotinue.set(true); } else if (r.hasResult()) { if (r.getResult().containerHostLinks.isEmpty()) { cotinue.set(true); } } }); return cotinue.get(); }); }
private void waitForDataCollectionToFinish() throws Throwable { AtomicBoolean finished = new AtomicBoolean(); String dataCollectionLink = KubernetesEntityDataCollection.DEFAULT_KUBERNETES_ENTITY_DATA_COLLECTION_LINK; waitFor(() -> { ServiceDocumentQuery<KubernetesEntityDataCollectionState> query = new ServiceDocumentQuery<>( host, KubernetesEntityDataCollectionState.class); query.queryDocument(dataCollectionLink, (r) -> { if (r.hasException()) { host.log( "Exception while retrieving default host network list data collection: " + (r.getException() instanceof CancellationException ? r.getException().getMessage() : Utils.toString(r.getException()))); finished.set(true); } else if (r.hasResult()) { if (r.getResult().computeHostLinks.isEmpty()) { finished.set(true); } } }); return finished.get(); }); }
private void waitForDataCollectionFinished() throws Throwable { AtomicBoolean cotinue = new AtomicBoolean(); String dataCollectionLink = HostNetworkListDataCollection.DEFAULT_HOST_NETWORK_LIST_DATA_COLLECTION_LINK; waitFor(() -> { ServiceDocumentQuery<HostNetworkListDataCollectionState> query = new ServiceDocumentQuery<>( host, HostNetworkListDataCollectionState.class); query.queryDocument(dataCollectionLink, (r) -> { if (r.hasException()) { host.log( "Exception while retrieving default host network list data collection: " + (r.getException() instanceof CancellationException ? r.getException().getMessage() : Utils.toString(r.getException()))); cotinue.set(true); } else if (r.hasResult()) { if (r.getResult().containerHostLinks.isEmpty()) { cotinue.set(true); } } }); return cotinue.get(); }); }
@Test public void testDeleteWhenNoActiveReservation() throws Throwable { GroupResourcePlacementState placementState = createAndStoreGroupResourcePlacement(); try { DeploymentProfileConfig.getInstance().setTest(false); doDelete(UriUtils.buildUri(host, placementState.documentSelfLink), false); } finally { DeploymentProfileConfig.getInstance().setTest(true); } ServiceDocumentQuery<GroupResourcePlacementState> query = new ServiceDocumentQuery<>(host, GroupResourcePlacementState.class); AtomicBoolean deleted = new AtomicBoolean(); CountDownLatch countDownLatch = new CountDownLatch(1); query.queryDocument(placementState.documentSelfLink, (r) -> { if (!r.hasException() && !r.hasResult()) { deleted.set(true); countDownLatch.countDown(); } }); countDownLatch.await(); assertTrue(deleted.get()); }
private ContainerState waitForContainer(String containerLink, String image, PowerState expectedPowerState, String errorMessage) throws Throwable { ContainerState[] result = new ContainerState[1]; AtomicBoolean cotinue = new AtomicBoolean(); waitFor(errorMessage, () -> { ServiceDocumentQuery<ContainerState> query = new ServiceDocumentQuery<>(host, ContainerState.class); query.queryDocument(containerLink, (r) -> { if (r.hasException()) { host.log("Exception while retrieving ContainerState: " + (r.getException() instanceof CancellationException ? r.getException() .getMessage() : Utils.toString(r.getException()))); cotinue.set(true); } else if (r.hasResult()) { // wait until container is ready with the expected image if (r.getResult().id != null && image.equals(r.getResult().image)) { if (expectedPowerState == null || expectedPowerState == r.getResult().powerState) { cotinue.set(true); result[0] = r.getResult(); } } } }); return cotinue.get(); }); return result[0]; }
private static void ensurePropertyExists(ServiceHost host, String propertyKey, Runnable callback) { new ServiceDocumentQuery<>(host, ConfigurationState.class) .queryDocument( UriUtils.buildUriPath(ConfigurationFactoryService.SELF_LINK, propertyKey), (r) -> {
ServiceDocumentQuery<ContainerDescription> query = new ServiceDocumentQuery<>(getHost(), ContainerDescription.class); query.queryDocument( containerDescriptionLink, (r) -> {
private void verifySubscriptionTargetExists(Runnable handler) { new ServiceDocumentQuery<>(host, ConfigurationState.class) .queryDocument(SSL_TRUST_CONFIG_SUBSCRIBE_FOR_LINK, (r) -> { if (r.hasException()) { r.throwRunTimeException();
ContainerState.class); query.queryDocument(containerStateLink, (r) -> { if (r.hasException()) { logWarning("Failure retrieving system container: %s",
AtomicBoolean deleted = new AtomicBoolean(); host.testStart(1); query.queryDocument(compositeComponent.documentSelfLink, (r) -> { if (r.hasException()) { host.failIteration(r.getException());
@SuppressWarnings("unchecked") protected <T extends ServiceDocument> T searchForDocument(Class<T> type, String selfLink) throws Throwable { Object[] result = new Object[] { null }; TestContext ctx = testCreate(1); @SuppressWarnings("rawtypes") ServiceDocumentQuery<?> query = new ServiceDocumentQuery(host, type); query.queryDocument( selfLink, (r) -> { if (r.hasException()) { host.log( Level.SEVERE, "Exception during search for resource not found: %s for type: %s. Error message: %s", selfLink, type.getSimpleName(), r.getException().getMessage()); ctx.failIteration(r.getException()); } else if (r.hasResult()) { result[0] = r.getResult(); host.log(Level.WARNING, "Resource found: %s for type %s", selfLink, type.getSimpleName()); ctx.completeIteration(); } else { host.log("Resource not found: %s for type %s", selfLink, type.getSimpleName()); ctx.completeIteration(); } }); ctx.await(); return (T) result[0]; }
AtomicBoolean deleted = new AtomicBoolean(); host.testStart(1); query.queryDocument(compositeComponent.documentSelfLink, (r) -> { if (r.hasException()) { host.failIteration(r.getException()); AtomicBoolean deleted = new AtomicBoolean(); host.testStart(1); query.queryDocument(compositeComponent.documentSelfLink, (r) -> { if (r.hasException()) { host.failIteration(r.getException());
AtomicBoolean deleted = new AtomicBoolean(); host.testStart(1); query.queryDocument(compositeComponent.documentSelfLink, (r) -> { if (r.hasException()) { host.failIteration(r.getException()); AtomicBoolean deleted = new AtomicBoolean(); host.testStart(1); query.queryDocument(compositeComponent.documentSelfLink, (r) -> { if (r.hasException()) { host.failIteration(r.getException());
private static void deleteDefaultRegistry(ServiceHost host) { new ServiceDocumentQuery<RegistryState>(host, RegistryState.class) .queryDocument(DEFAULT_INSTANCE_LINK, (r) -> { if (r.hasException()) { r.throwRunTimeException();
.queryDocument( fullSslTrustDocumentSelfLink, (r) -> {