Search in sources :

Example 6 with CloudProvider

use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.

the class CloudManagerTest method testAddProviders.

@Test
public void testAddProviders() {
    CloudManager cm = new CloudManager();
    CloudProvider cp = createProvider(cm);
    if (!cm.isUseCloud()) {
        fail("Cloud Manager does not notice that Cloud is enabled when a provider is added.");
    }
    if ((cm.getProviders().size()) != 1) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (!cm.getProviders().contains(cp)) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (cm.getProvider(cp.getName()) != cp) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    CloudProvider cp2 = createProvider(cm);
    if ((cm.getProviders().size()) != 2) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (!cm.getProviders().contains(cp)) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (!cm.getProviders().contains(cp2)) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (cm.getProvider(cp.getName()) != cp) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
    if (cm.getProvider(cp2.getName()) != cp2) {
        fail("Cloud Manager does not properly register Cloud Providers.");
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) Test(org.junit.Test)

Example 7 with CloudProvider

use of es.bsc.compss.types.CloudProvider 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)

Example 8 with CloudProvider

use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.

the class CloudManagerTest method testVMsManagement.

@Test
public void testVMsManagement() {
    CloudManager cm = new CloudManager();
    CloudProvider cp1 = createProvider(cm);
    CloudProvider cp2 = createProvider(cm);
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    if (rcr1 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 1) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 1) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd2);
    if (rcr2 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 2) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    CloudMethodResourceDescription cmrd3 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr3 = cp1.requestResourceCreation(cmrd3);
    if (rcr3 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 3) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 3) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr3)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    cp1.refusedCreation(rcr3);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().size() != 2) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr3)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    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);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().size() != 1) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    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 (!cm.getPendingRequests().isEmpty()) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the 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");
    }
    CloudMethodResourceDescription reduction2 = new CloudMethodResourceDescription(cmrd2);
    cmw2.getDescription().reduce(reduction2);
    cp2.requestResourceReduction(cmw2, reduction2);
    if (cm.getCurrentVMCount() != 1) {
        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");
    }
    if (!cmw2.isTerminated()) {
        fail("Cloud Manager did not called the connector to terminate the resource");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    cmw1.getDescription().reduce(reduction1);
    cp1.requestResourceReduction(cmw1, reduction1);
    if (cm.getCurrentVMCount() != 0) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cmw1.isTerminated()) {
        fail("Cloud Manager did not called the connector to terminate the resource");
    }
}
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)

Example 9 with CloudProvider

use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.

the class ResourceManagerTest method testCloudConfiguration.

@Test
public void testCloudConfiguration() {
    if (ResourceManager.useCloud()) {
        fail("ResourceManager has cloud enabled by default");
    }
    ResourceManager.setCloudVMsBoundaries(3, 5, 8);
    if (ResourceManager.getMinCloudVMs() != 3) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getInitialCloudVMs() != 5) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getMaxCloudVMs() != 8) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    ResourceManager.setCloudVMsBoundaries(9, 5, 8);
    if (ResourceManager.getMinCloudVMs() != 9) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getInitialCloudVMs() != 9) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getMaxCloudVMs() != 9) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    ResourceManager.setCloudVMsBoundaries(3, null, null);
    if (ResourceManager.getMinCloudVMs() != 3) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getInitialCloudVMs() != 5) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    if (ResourceManager.getMaxCloudVMs() != 8) {
        fail("ResourceManager does not properly configure the cloud boundaries");
    }
    CloudProvider cp1 = addProvider();
    if (ResourceManager.getAvailableCloudProviders().size() != 1 || !ResourceManager.getAvailableCloudProviders().contains(cp1)) {
        fail("ResourceManager does not properly register cloud providers");
    }
    if (!ResourceManager.useCloud()) {
        fail("ResourceManager does not detect that the cloud has been enabled");
    }
    CloudProvider cp2 = addProvider();
    if (ResourceManager.getAvailableCloudProviders().size() != 2 || !ResourceManager.getAvailableCloudProviders().contains(cp1) || !ResourceManager.getAvailableCloudProviders().contains(cp2)) {
        fail("ResourceManager does not properly register cloud providers");
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) Test(org.junit.Test)

Example 10 with CloudProvider

use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.

the class ResourceManagerTest method testOneCloudWorkersOperations.

@Test
public void testOneCloudWorkersOperations() {
    ResourceManager.setCloudVMsBoundaries(3, 5, 8);
    CloudProvider cp1 = addProvider();
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || !ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr1, cmw1, cmrd1);
    if (!ResourceManager.getPendingCreationRequests().isEmpty() || ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != cmw1 || ResourceManager.getWorker(vmName1) != cmw1) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    ResourceManager.reduceResource(cmw1, new PendingReduction<>(reduction1));
    ResourceManager.terminateCloudResource(cmw1, reduction1);
    if (!ResourceManager.getDynamicResources().isEmpty() || !ResourceManager.getAllWorkers().isEmpty() || ResourceManager.getDynamicResource(vmName1) != null || ResourceManager.getWorker(vmName1) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw1.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
}
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

CloudProvider (es.bsc.compss.types.CloudProvider)22 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)11 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)9 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)6 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 FakeNode (es.bsc.compss.types.fake.FakeNode)4 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)4 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)2 PerformedIncrease (es.bsc.compss.types.resources.updates.PerformedIncrease)2 Map (java.util.Map)2 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)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 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)1 Resource (es.bsc.compss.types.resources.Resource)1