Search in sources :

Example 6 with CloudImageDescription

use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.

the class CloudProviderTest method testTwoImages.

@Test
public void testTwoImages() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    String image1Name = "IMAGE" + (int) (Math.random() * 10000);
    Map<String, String> imageProperties = new HashMap<>();
    String img1PropValue = "VALUE" + (int) (Math.random() * 10000);
    imageProperties.put(CID_PROPERTY_TEST_TAG, img1PropValue);
    CloudImageDescription cid1 = new CloudImageDescription(image1Name, imageProperties);
    cp.addCloudImage(cid1);
    String image2Name = "IMAGE" + (int) (Math.random() * 10000);
    imageProperties = new HashMap<>();
    String img2PropValue = "VALUE" + (int) (Math.random() * 10000);
    imageProperties.put(CID_PROPERTY_TEST_TAG, img2PropValue);
    CloudImageDescription cid2 = new CloudImageDescription(image2Name, imageProperties);
    cp.addCloudImage(cid2);
    Set<String> imageNames = cp.getAllImageNames();
    int contains = 0;
    if (imageNames.contains(image1Name)) {
        contains++;
    }
    if (imageNames.contains(image2Name)) {
        contains++;
    }
    switch(contains) {
        case 0:
            fail("Cloud Provider is not storing properly the Images. Cannot find any image name on the two images scenario.");
            break;
        case 1:
            fail("Cloud Provider is not storing properly the Images. Cannot find one image name on the two images scenario.");
            break;
        default:
    }
    if (imageNames.size() != 2) {
        fail("Cloud Provider is not storing properly the Images. only two images are supposed to be in the group.");
    }
    CloudImageDescription retrieved1 = cp.getImage(image1Name);
    try {
        checkRetrievedImage(retrieved1, image1Name, img1PropValue);
    } catch (Exception e) {
        fail("Cloud Provider is not storing properly the Images. The provider " + e.getMessage() + " on the two images scenario.");
    }
    CloudImageDescription retrieved2 = cp.getImage(image2Name);
    try {
        checkRetrievedImage(retrieved2, image2Name, img2PropValue);
    } catch (Exception e) {
        fail("Cloud Provider is not storing properly the Images. " + e.getMessage() + " on the two images scenario.");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) Test(org.junit.Test)

Example 7 with CloudImageDescription

use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.

the class CloudProviderTest method testRefusedOneTurnOn.

@Test
public void testRefusedOneTurnOn() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly intialized the number of requested VMs should be 0");
    }
    String imageName = "IMAGE" + (int) (Math.random() * 10000);
    CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
    cp.addCloudImage(cid);
    String typeName = "TYPE" + (int) (Math.random() * 10000);
    float type1Memory = (float) Math.random() * 5;
    MethodResourceDescription mrd1 = new MethodResourceDescription();
    mrd1.setMemorySize(type1Memory);
    CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
    cp.addInstanceType(citd);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    if (!FakeConnector.getProcessedRequests().contains(crc)) {
        fail("Turn on has not reached the connector");
    }
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
    if (!pendingRequests.contains(crc)) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (pendingRequests.size() != 1) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    cp.refusedCreation(crc);
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    pendingRequests = cp.getPendingRequests();
    if (!pendingRequests.isEmpty()) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Example 8 with CloudImageDescription

use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.

the class CloudProviderTest method testCreateOneVMOneResourceSameDescription.

@Test
public void testCreateOneVMOneResourceSameDescription() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    String imageName = "IMAGE" + (int) (Math.random() * 10000);
    CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
    cp.addCloudImage(cid);
    String typeName = "TYPE" + (int) (Math.random() * 10000);
    float type1Memory = (float) Math.random() * 5;
    MethodResourceDescription mrd1 = new MethodResourceDescription();
    mrd1.setMemorySize(type1Memory);
    CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
    cp.addInstanceType(citd);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
    Set<CloudMethodWorker> workers = cp.getHostedWorkers();
    if (!pendingRequests.contains(crc)) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (pendingRequests.size() != 1) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (!workers.isEmpty()) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    String vmName = "VM" + (int) (Math.random() * 1000);
    CloudMethodWorker cmw = new CloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, 0, 0, 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc, cmw, granted);
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    pendingRequests = cp.getPendingRequests();
    workers = cp.getHostedWorkers();
    if (!pendingRequests.isEmpty()) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (workers.size() != 1) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    if (!workers.contains(cmw)) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) FakeNode(es.bsc.compss.types.fake.FakeNode) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Example 9 with CloudImageDescription

use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.

the class CloudManagerTest method createResourceDescriptionFromProvider.

private CloudMethodResourceDescription createResourceDescriptionFromProvider(CloudProvider cp1) {
    CloudImageDescription cid = null;
    CloudInstanceTypeDescription citd = null;
    for (String imageName : cp1.getAllImageNames()) {
        cid = cp1.getImage(imageName);
        break;
    }
    for (String instanceType : cp1.getAllInstanceTypeNames()) {
        citd = cp1.getInstanceType(instanceType);
        break;
    }
    return new CloudMethodResourceDescription(citd, cid);
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 10 with CloudImageDescription

use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.

the class Converter method getSoftwareDescription.

/**
 * Returns the software description
 *
 * @param cmrd
 * @return
 */
public static SoftwareDescription getSoftwareDescription(CloudMethodResourceDescription cmrd) {
    String osType = cmrd.getOperatingSystemType();
    String osDist = cmrd.getOperatingSystemDistribution();
    String osVersion = cmrd.getOperatingSystemVersion();
    List<String> apps = cmrd.getAppSoftware();
    CloudImageDescription cid = cmrd.getImage();
    MethodConfiguration mc = cid.getConfig();
    InstallationDescription installDesc = getInstallationDescription(mc);
    return new SoftwareDescription(osType, osDist, osVersion, apps, installDesc);
}
Also used : MethodConfiguration(es.bsc.compss.types.resources.configuration.MethodConfiguration) InstallationDescription(es.bsc.conn.types.InstallationDescription) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) SoftwareDescription(es.bsc.conn.types.SoftwareDescription)

Aggregations

CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)31 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)23 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)22 HashMap (java.util.HashMap)15 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)12 Test (org.junit.Test)12 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)9 FakeNode (es.bsc.compss.types.fake.FakeNode)7 CloudProvider (es.bsc.compss.types.CloudProvider)6 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)3 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)2 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)2 LinkedList (java.util.LinkedList)2 ConnectorException (es.bsc.compss.connectors.ConnectorException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)1 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)1 Implementation (es.bsc.compss.types.implementations.Implementation)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 ShutdownListener (es.bsc.compss.types.resources.ShutdownListener)1