Search in sources :

Example 11 with CloudMethodResourceDescription

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

the class CloudProviderTest method testTurnOn.

@Test
public void testTurnOn() {
    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);
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly intialized the number of requested VMs should be 0");
    }
    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");
    }
    cmrd = new CloudMethodResourceDescription(citd, cid);
    cmrd.addInstance(citd);
    ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd);
    pendingRequests = cp.getPendingRequests();
    if (!pendingRequests.contains(crc)) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (!pendingRequests.contains(crc2)) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (pendingRequests.size() != 2) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (!FakeConnector.getProcessedRequests().contains(crc)) {
        fail("Turn on has not reached the connector");
    }
    if (cp.getCurrentVMCount() != 3) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
}
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 12 with CloudMethodResourceDescription

use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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 13 with CloudMethodResourceDescription

use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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 14 with CloudMethodResourceDescription

use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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 15 with CloudMethodResourceDescription

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

the class CloudManagerTest method testTermianteAll.

@Test
public void testTermianteAll() throws Exception {
    CloudManager cm = new CloudManager();
    CloudProvider cp1 = createProvider(cm);
    CloudProvider cp2 = createProvider(cm);
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    cp1.confirmedCreation(rcr1, cmw1, cmrd1);
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd2);
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    cp2.confirmedCreation(rcr2, cmw2, cmrd2);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (!cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    cm.terminateALL();
    if (cm.getCurrentVMCount() != 0) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) FakeNode(es.bsc.compss.types.fake.FakeNode) Test(org.junit.Test)

Aggregations

CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)45 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)23 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)21 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)16 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)12 FakeNode (es.bsc.compss.types.fake.FakeNode)11 CloudProvider (es.bsc.compss.types.CloudProvider)9 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)7 Implementation (es.bsc.compss.types.implementations.Implementation)5 ConnectorException (es.bsc.compss.connectors.ConnectorException)4 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 Map (java.util.Map)4 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)3 VM (es.bsc.compss.connectors.VM)2 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)2 PerformedIncrease (es.bsc.compss.types.resources.updates.PerformedIncrease)2 VirtualResource (es.bsc.conn.types.VirtualResource)2 LinkedList (java.util.LinkedList)2