use of com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState in project photon-model by vmware.
the class TestAzureImageEnumerationTask method testPublicImageEnumeration_multi.
@Test
public void testPublicImageEnumeration_multi() throws Throwable {
Assume.assumeFalse(this.isMock);
// This test takes about less than 2 mins!
getHost().setTimeoutSeconds((int) TimeUnit.MINUTES.toSeconds(2));
ImageEnumerationTaskState task = kickOffImageEnumeration(this.endpointState, PUBLIC, AZURE_MULTI_IMAGES_FILTER);
// Validate at least 200+ image states are created.
QueryByPages<ImageState> queryAll = new QueryByPages<ImageState>(getHost(), Builder.create().addKindFieldClause(ImageState.class).build(), ImageState.class, task.tenantLinks);
queryAll.setMaxPageSize(QueryUtils.DEFAULT_MAX_RESULT_LIMIT);
Long imagesCount = PhotonModelUtils.waitToComplete(queryAll.collectLinks(Collectors.counting()));
Assert.assertTrue("Expected at least " + 200 + " images, but found only " + imagesCount, imagesCount > 200);
}
use of com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState in project photon-model by vmware.
the class TestAzureImageEnumerationTask method kickOffImageEnumeration.
private ImageEnumerationTaskState kickOffImageEnumeration(EndpointState endpoint, boolean isPublic, String filter) throws Throwable {
ImageEnumerationTaskState taskState = new ImageEnumerationTaskState();
if (isPublic == PUBLIC) {
taskState.endpointType = endpoint.endpointType;
} else {
taskState.endpointLink = endpoint.documentSelfLink;
taskState.tenantLinks = endpoint.tenantLinks;
}
taskState.regionId = ENDPOINT_REGION;
taskState.filter = filter;
taskState.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : EnumSet.noneOf(TaskOption.class);
// Start/Post image-enumeration task
taskState = postServiceSynchronously(ImageEnumerationTaskService.FACTORY_LINK, taskState, ImageEnumerationTaskState.class);
// Wait for image-enumeration task to complete
return getHost().waitForFinishedTask(ImageEnumerationTaskState.class, taskState.documentSelfLink);
}
use of com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState in project photon-model by vmware.
the class TestAWSImageEnumerationTask method kickOffImageEnumeration.
private ImageEnumerationTaskState kickOffImageEnumeration(EndpointState endpointState, boolean isPublic, String filter) throws Throwable {
ImageEnumerationTaskState taskState = new ImageEnumerationTaskState();
if (isPublic == PUBLIC) {
taskState.endpointType = endpointState.endpointType;
} else {
taskState.endpointLink = endpointState.documentSelfLink;
taskState.tenantLinks = endpointState.tenantLinks;
}
taskState.regionId = this.regionId;
taskState.filter = filter;
taskState.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : EnumSet.noneOf(TaskOption.class);
// Start/Post image-enumeration task
taskState = postServiceSynchronously(ImageEnumerationTaskService.FACTORY_LINK, taskState, ImageEnumerationTaskState.class);
// Wait for image-enumeration task to complete
return getHost().waitForFinishedTask(ImageEnumerationTaskState.class, taskState.documentSelfLink);
}
use of com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState in project photon-model by vmware.
the class TestAWSImageEnumerationTask method testPublicImageEnumeration_all.
@Test
public void testPublicImageEnumeration_all() throws Throwable {
Assume.assumeFalse(this.isMock);
Assume.assumeTrue(this.enableLongRunning);
getHost().setTimeoutSeconds((int) TimeUnit.MINUTES.toSeconds(10));
// Important: MUST share same Endpoint between the two enum runs.
final EndpointState endpointState = createEndpointState();
ImageEnumerationTaskState task = kickOffImageEnumeration(endpointState, PUBLIC, AMAZON_PUBLIC_IMAGE_FILTER_ALL);
// Validate at least 10K image states are created
// NOTE: do not use queryDocumentsAndAssertExpectedCount
// since it fails with 'Query returned large number of results'
QueryByPages<ImageState> queryAll = new QueryByPages<ImageState>(getHost(), Builder.create().addKindFieldClause(ImageState.class).build(), ImageState.class, task.tenantLinks);
queryAll.setMaxPageSize(QueryUtils.DEFAULT_MAX_RESULT_LIMIT);
Long imagesCount = waitToComplete(queryAll.collectLinks(Collectors.counting()));
Assert.assertTrue("Expected at least " + AMAZON_PUBLIC_IMAGES_ALL_COUNT + " images, but found only " + imagesCount, imagesCount > AMAZON_PUBLIC_IMAGES_ALL_COUNT);
}
use of com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState in project photon-model by vmware.
the class TestAWSImageEnumerationTask method testPublicImageEnumeration_partitioning.
@Test
public void testPublicImageEnumeration_partitioning() throws Throwable {
Assume.assumeFalse(this.isMock);
// Important: MUST share same Endpoint between the two enum runs.
final EndpointState endpointState = createEndpointState();
// Validate NONE PARAVIRTUAL and HVM images are loaded
{
ImageEnumerationTaskState task = kickOffImageEnumeration(endpointState, PUBLIC, AMAZON_PUBLIC_IMAGE_FILTER_PARTITIONING_NO_MATCH);
QueryTop<ImageState> queryAll = new QueryTop<ImageState>(getHost(), Builder.create().addKindFieldClause(ImageState.class).build(), ImageState.class, task.tenantLinks);
long imagesCount = waitToComplete(queryAll.collectDocuments(Collectors.counting()));
Assert.assertEquals("No images expected", 0, imagesCount);
}
// Validate one PARAVIRTUAL and one HVM image are load
{
ImageEnumerationTaskState task = kickOffImageEnumeration(endpointState, PUBLIC, AMAZON_PUBLIC_IMAGE_FILTER_PARTITIONING);
QueryTop<ImageState> queryAll = new QueryTop<ImageState>(getHost(), Builder.create().addKindFieldClause(ImageState.class).build(), ImageState.class, task.tenantLinks);
List<ImageState> images = waitToComplete(queryAll.collectDocuments(Collectors.toList()));
Assert.assertEquals("Only TWO images expected", 2, images.size());
Assert.assertTrue(AMAZON_PARAVIRTUAL_IMAGE_NAME + " is missing", images.stream().filter(image -> image.name.equals(AMAZON_PARAVIRTUAL_IMAGE_NAME)).findFirst().isPresent());
Assert.assertTrue(AMAZON_HVM_IMAGE_NAME + " is missing", images.stream().filter(image -> image.name.equals(AMAZON_HVM_IMAGE_NAME)).findFirst().isPresent());
}
}
Aggregations