Search in sources :

Example 1 with VirtualMachineSizeInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner in project photon-model by vmware.

the class AzureInstanceTypeServiceTest method testGetInstanceTypes.

@Test
public void testGetInstanceTypes() throws Throwable {
    Assume.assumeFalse(this.isMock);
    TestContext ctx = getHost().testCreate(1);
    URI uri = buildUri(getHost(), AzureInstanceTypeService.SELF_LINK, buildUriQuery("endpoint", this.endpointState.documentSelfLink));
    send(Operation.createGet(uri).setCompletion((op, t) -> {
        try {
            if (t != null) {
                ctx.failIteration(t);
                return;
            }
            assertEquals(Operation.STATUS_CODE_OK, op.getStatusCode());
            InstanceTypeList instanceTypesList = op.getBody(InstanceTypeList.class);
            assertNotNull("Tenant links should ne set.", instanceTypesList.tenantLinks);
            assertEquals("Tenant links size equal to endpoint tenant links size is " + "expected.", this.endpointState.tenantLinks.size(), instanceTypesList.tenantLinks.size());
            assertNotNull("Instance types should not be null.", instanceTypesList.instanceTypes);
            InstanceType instanceTypeBasicA0 = instanceTypesList.instanceTypes.stream().filter(instanceType -> VirtualMachineSizeTypes.BASIC_A0.toString().equals(instanceType.name)).findFirst().get();
            assertNotNull("BASIC_A0 Instance type should not be null.", instanceTypeBasicA0);
            final String regionId = this.endpointState.endpointProperties.get(EndpointConfigRequest.REGION_KEY);
            final List<VirtualMachineSizeInner> azureSizes = getAzureSdkClients().getComputeManager().inner().virtualMachineSizes().list(regionId);
            assertEquals(azureSizes.size(), instanceTypesList.instanceTypes.size());
            VirtualMachineSizeInner azureSizeBasicA0 = azureSizes.stream().filter(azureSize -> VirtualMachineSizeTypes.BASIC_A0.toString().equals(azureSize.name())).findFirst().get();
            assertEquals("Invalid cpuCount", azureSizeBasicA0.numberOfCores(), instanceTypeBasicA0.cpuCount);
            assertEquals("Invalid dataDiskMaxCount", azureSizeBasicA0.maxDataDiskCount(), instanceTypeBasicA0.dataDiskMaxCount);
            assertEquals("Invalid dataDiskSizeInMB", azureSizeBasicA0.resourceDiskSizeInMB(), instanceTypeBasicA0.dataDiskSizeInMB);
            assertEquals("Invalid bootDiskSizeInMB", azureSizeBasicA0.osDiskSizeInMB(), instanceTypeBasicA0.bootDiskSizeInMB);
            assertEquals("Invalid memoryInMB", azureSizeBasicA0.memoryInMB(), instanceTypeBasicA0.memoryInMB);
            ctx.completeIteration();
        } catch (AssertionError err) {
            ctx.failIteration(err);
        }
    }));
    testWait(ctx);
}
Also used : Assert.assertNotNull(org.junit.Assert.assertNotNull) Operation(com.vmware.xenon.common.Operation) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Test(org.junit.Test) VirtualMachineSizeTypes(com.microsoft.azure.management.compute.VirtualMachineSizeTypes) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) VirtualMachineSizeInner(com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner) InstanceType(com.vmware.photon.controller.model.support.InstanceTypeList.InstanceType) List(java.util.List) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) TestContext(com.vmware.xenon.common.test.TestContext) EndpointService(com.vmware.photon.controller.model.resources.EndpointService) UriUtils(com.vmware.xenon.common.UriUtils) UriUtils.buildUri(com.vmware.xenon.common.UriUtils.buildUri) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) Assume(org.junit.Assume) URI(java.net.URI) UriUtils.buildUriQuery(com.vmware.xenon.common.UriUtils.buildUriQuery) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) TestContext(com.vmware.xenon.common.test.TestContext) List(java.util.List) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) InstanceType(com.vmware.photon.controller.model.support.InstanceTypeList.InstanceType) URI(java.net.URI) VirtualMachineSizeInner(com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) Test(org.junit.Test) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)

Aggregations

VirtualMachineSizeTypes (com.microsoft.azure.management.compute.VirtualMachineSizeTypes)1 VirtualMachineSizeInner (com.microsoft.azure.management.compute.implementation.VirtualMachineSizeInner)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 AzureBaseTest (com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)1 EndpointService (com.vmware.photon.controller.model.resources.EndpointService)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 InstanceTypeList (com.vmware.photon.controller.model.support.InstanceTypeList)1 InstanceType (com.vmware.photon.controller.model.support.InstanceTypeList.InstanceType)1 TestUtils (com.vmware.photon.controller.model.tasks.TestUtils)1 Operation (com.vmware.xenon.common.Operation)1 ServiceDocument (com.vmware.xenon.common.ServiceDocument)1 UriUtils (com.vmware.xenon.common.UriUtils)1 UriUtils.buildUri (com.vmware.xenon.common.UriUtils.buildUri)1 UriUtils.buildUriQuery (com.vmware.xenon.common.UriUtils.buildUriQuery)1 TestContext (com.vmware.xenon.common.test.TestContext)1 URI (java.net.URI)1 Collections (java.util.Collections)1 List (java.util.List)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1