Search in sources :

Example 6 with ImageEnumerationTaskState

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);
}
Also used : QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) ImageEnumerationTaskState(com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) Test(org.junit.Test)

Example 7 with ImageEnumerationTaskState

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);
}
Also used : ImageEnumerationTaskState(com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState)

Example 8 with ImageEnumerationTaskState

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);
}
Also used : ImageEnumerationTaskState(com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState)

Example 9 with ImageEnumerationTaskState

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);
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) ImageEnumerationTaskState(com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) BaseModelTest(com.vmware.photon.controller.model.helpers.BaseModelTest) Test(org.junit.Test)

Example 10 with ImageEnumerationTaskState

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());
    }
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) ImageEnumerationTaskState(com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState) List(java.util.List) QueryTop(com.vmware.photon.controller.model.query.QueryUtils.QueryTop) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) BaseModelTest(com.vmware.photon.controller.model.helpers.BaseModelTest) Test(org.junit.Test)

Aggregations

ImageEnumerationTaskState (com.vmware.photon.controller.model.tasks.ImageEnumerationTaskService.ImageEnumerationTaskState)10 Test (org.junit.Test)6 AzureBaseTest (com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)4 ImageState (com.vmware.photon.controller.model.resources.ImageService.ImageState)4 QueryByPages (com.vmware.photon.controller.model.query.QueryUtils.QueryByPages)3 BaseModelTest (com.vmware.photon.controller.model.helpers.BaseModelTest)2 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)2 QueryTop (com.vmware.photon.controller.model.query.QueryUtils.QueryTop)1 List (java.util.List)1