use of com.vmware.photon.controller.model.resources.ResourceState in project photon-model by vmware.
the class TestAWSEnumerationTask method markFirstResourceStateAsStale.
/**
* From all the particular resource states, gets the first one, and patch it with an id, which
* do not correspond to any actually existing resource
* on the cloud, in order to test that this resource state will be deleted after the next enumeration run.
*/
private String markFirstResourceStateAsStale(VerificationHost host, Class<? extends ResourceState> resourceClass, String serviceFactoryLink) throws Throwable {
// get enumerated resources, and change the id of one of them, so that it is deleted on the
// next enum
Map<String, ? extends ResourceState> statesMap = ProvisioningUtils.getResourceStates(host, serviceFactoryLink, resourceClass);
assertNotNull("There should be resources enumerated.", statesMap);
assertFalse("There should be resources enumerated.", statesMap.isEmpty());
ResourceState existingState = statesMap.values().iterator().next();
existingState.id = existingState.id + "-stale";
existingState = doPatch(host, existingState, resourceClass, UriUtils.buildUri(host, existingState.documentSelfLink));
return existingState.documentSelfLink;
}
use of com.vmware.photon.controller.model.resources.ResourceState in project photon-model by vmware.
the class TestAWSEnumerationTask method validateTagInEntity.
/**
* Validates that the given internal tag is present on the passed in entity.
*/
private void validateTagInEntity(ServiceDocumentQueryResult queryResult, Class<?> documentKind, String internalTagType) {
ServiceDocumentQueryResult tagsResult;
String tagLink;
tagsResult = getInternalTagsByType(this.host, internalTagType);
assertEquals(count1, tagsResult.documentLinks.size());
tagLink = tagsResult.documentLinks.get(0);
for (Map.Entry<String, Object> resourceMap : queryResult.documents.entrySet()) {
if (documentKind == ComputeState.class) {
ComputeState compute = Utils.fromJson(resourceMap.getValue(), ComputeState.class);
if (!compute.type.equals(ComputeType.ZONE) && !compute.type.equals(ComputeType.ENDPOINT_HOST)) {
assertTrue(compute.tagLinks.contains(tagLink));
}
} else {
ResourceState resourceState = Utils.fromJson(resourceMap.getValue(), ResourceState.class);
if (resourceState.tagLinks != null) {
assertTrue(resourceState.tagLinks.contains(tagLink));
}
}
}
}
use of com.vmware.photon.controller.model.resources.ResourceState in project photon-model by vmware.
the class TestAWSEnumerationTask method validateStaleResourceStateDeletion.
private void validateStaleResourceStateDeletion(String... staleResourceSelfLinks) throws Throwable {
for (String selfLink : staleResourceSelfLinks) {
ResourceState resourceState = null;
try {
resourceState = host.getServiceState(null, ResourceState.class, UriUtils.buildUri(this.host, selfLink));
} catch (Throwable e) {
// do nothing, expected is the resource not to be found
}
// the resourceState will be deleted by the groomer task after disassociation
assertTrue("Stale subnet state should have been disassociated.", resourceState.endpointLinks.isEmpty());
}
}
Aggregations