use of com.vmware.xenon.common.ServiceDocumentQueryResult in project photon-model by vmware.
the class ProvisioningUtils method getVMCount.
public static int getVMCount(VerificationHost host, URI peerURI) throws Throwable {
ServiceDocumentQueryResult res;
res = host.getFactoryState(UriUtils.buildExpandLinksQueryUri(createServiceURI(host, peerURI, ComputeService.FACTORY_LINK)));
return res.documents.size() - 1;
}
use of com.vmware.xenon.common.ServiceDocumentQueryResult in project photon-model by vmware.
the class ProvisioningUtils method queryComputeInstances.
public static ServiceDocumentQueryResult queryComputeInstances(VerificationHost host, URI peerURI, int desiredCount) throws Throwable {
Date expiration = host.getTestExpiration();
ServiceDocumentQueryResult res;
do {
res = host.getFactoryState(UriUtils.buildExpandLinksQueryUri(createServiceURI(host, peerURI, ComputeService.FACTORY_LINK)));
if (res.documents.size() == desiredCount) {
return res;
}
} while (new Date().before(expiration));
throw new TimeoutException("Desired number of compute states not found. Expected " + desiredCount + ", found " + res.documents.size());
}
use of com.vmware.xenon.common.ServiceDocumentQueryResult in project photon-model by vmware.
the class ProvisioningUtils method queryDocumentsAndAssertExpectedCount.
public static ServiceDocumentQueryResult queryDocumentsAndAssertExpectedCount(VerificationHost host, URI peerURI, int desiredCount, String factoryLink, boolean exactCountFlag) throws Throwable {
URI queryUri = UriUtils.buildExpandLinksQueryUri(createServiceURI(host, peerURI, factoryLink));
// add limit, otherwise the query will not return if there are too many docs or versions
queryUri = UriUtils.extendUriWithQuery(queryUri, UriUtils.URI_PARAM_ODATA_LIMIT, String.valueOf(desiredCount * 2));
ServiceDocumentQueryResult res = host.getFactoryState(queryUri);
if (exactCountFlag) {
if (res.documents.size() == desiredCount) {
return res;
}
} else {
if (res.documents.size() >= desiredCount) {
host.log(Level.INFO, "Documents count in %s is %s, expected at least %s", factoryLink, res.documents.size(), desiredCount);
return res;
}
}
throw new Exception("Desired number of documents not found in " + factoryLink + " factory states. Expected " + desiredCount + ", found " + res.documents.size());
}
use of com.vmware.xenon.common.ServiceDocumentQueryResult in project photon-model by vmware.
the class ProvisioningUtils method queryDiskInstances.
public static ServiceDocumentQueryResult queryDiskInstances(VerificationHost host, URI peerURI, int desiredCount) throws Throwable {
Date expiration = host.getTestExpiration();
ServiceDocumentQueryResult res;
do {
res = host.getFactoryState(UriUtils.buildExpandLinksQueryUri(createServiceURI(host, peerURI, DiskService.FACTORY_LINK)));
if (res.documents.size() == desiredCount) {
return res;
}
} while (new Date().before(expiration));
throw new TimeoutException("Desired number of disk states not found. Expected " + desiredCount + ", found " + res.documents.size());
}
Aggregations