use of es.bsc.compss.types.ExtendedCloudMethodWorker 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");
}
}
use of es.bsc.compss.types.ExtendedCloudMethodWorker 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");
}
}
use of es.bsc.compss.types.ExtendedCloudMethodWorker 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");
}
}
use of es.bsc.compss.types.ExtendedCloudMethodWorker in project compss by bsc-wdc.
the class ResourceManagerTest method testMultipleCloudWorkersOperations.
@Test
public void testMultipleCloudWorkersOperations() {
ResourceManager.setCloudVMsBoundaries(3, 5, 8);
CloudProvider cp1 = addProvider();
CloudProvider cp2 = addProvider();
CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd1);
CloudMethodResourceDescription cmrd3 = createResourceDescriptionFromProvider(cp1);
ResourceCreationRequest rcr3 = cp1.requestResourceCreation(cmrd3);
if (ResourceManager.getPendingCreationRequests().size() != 3 || !ResourceManager.getPendingCreationRequests().contains(rcr1) || !ResourceManager.getPendingCreationRequests().contains(rcr2) || !ResourceManager.getPendingCreationRequests().contains(rcr3)) {
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().size() != 2 || 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");
}
String vmName2 = "VM" + (int) (Math.random() * 1000);
ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
ResourceManager.addCloudWorker(rcr2, cmw2, cmrd2);
if (ResourceManager.getPendingCreationRequests().size() != 1 || ResourceManager.getPendingCreationRequests().contains(rcr2)) {
fail("ResourceManager is not properly registering the pending resouce creations");
}
if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName2) != cmw2 || ResourceManager.getWorker(vmName2) != cmw2) {
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.getPendingCreationRequests().size() != 1) {
fail("ResourceManager is not properly registering the pending resouce creations");
}
if (ResourceManager.getCurrentVMCount() != 2) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || 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");
}
String vmName3 = "VM" + (int) (Math.random() * 1000);
ExtendedCloudMethodWorker cmw3 = new ExtendedCloudMethodWorker(vmName3, cp1, cmrd3, new FakeNode(vmName3), 0, new HashMap<>());
ResourceManager.addCloudWorker(rcr3, cmw3, cmrd3);
if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
fail("ResourceManager is not properly registering the pending resouce creations");
}
if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
fail("ResourceManager is not properly adding the new cloud resources");
}
CloudMethodResourceDescription reduction2 = new CloudMethodResourceDescription(cmrd2);
ResourceManager.reduceResource(cmw2, new PendingReduction<>(reduction2));
ResourceManager.terminateCloudResource(cmw2, reduction2);
if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName2) != null || ResourceManager.getWorker(vmName2) != null) {
fail("ResourceManager is not properly removing the new cloud resources");
}
if (!cmw2.isTerminated()) {
fail("ResourceManager is not properly requesting the resource shutdown");
}
if (ResourceManager.getCurrentVMCount() != 1) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
CloudMethodResourceDescription cmrd4 = createResourceDescriptionFromProvider(cp1);
ResourceCreationRequest rcr4 = cp1.requestResourceCreation(cmrd4);
if (ResourceManager.getPendingCreationRequests().size() != 1 || !ResourceManager.getPendingCreationRequests().contains(rcr4)) {
fail("ResourceManager is not properly registering the pending resouce creations");
}
if (ResourceManager.getCurrentVMCount() != 2) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
if (entry.getValue()[0] != 1) {
fail("ResourceManager is not properly keeping track of the amount of instances of each type");
}
}
ResourceManager.increasedCloudWorker(rcr4, cmw3, cmrd4);
if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
fail("ResourceManager is not properly registering the pending resouce creations");
}
if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
fail("ResourceManager is not properly removing the new cloud resources");
}
if (ResourceManager.getCurrentVMCount() != 2) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
if (entry.getValue()[0] != 2) {
fail("ResourceManager is not properly keeping track of the amount of instances of each type");
}
}
CloudMethodResourceDescription reduction4 = new CloudMethodResourceDescription(cmrd4);
ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction4));
ResourceManager.terminateCloudResource(cmw3, reduction4);
if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
fail("ResourceManager is not properly removing the new cloud resources");
}
if (ResourceManager.getCurrentVMCount() != 1) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
if (entry.getValue()[0] != 1) {
fail("ResourceManager is not properly keeping track of the amount of instances of each type");
}
}
CloudMethodResourceDescription reduction3 = new CloudMethodResourceDescription(cmrd3);
ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction3));
ResourceManager.terminateCloudResource(cmw3, reduction3);
if (!ResourceManager.getDynamicResources().isEmpty() || !ResourceManager.getAllWorkers().isEmpty() || ResourceManager.getDynamicResource(vmName3) != null || ResourceManager.getWorker(vmName3) != null) {
fail("ResourceManager is not properly removing the new cloud resources");
}
if (ResourceManager.getCurrentVMCount() != 0) {
fail("ResourceManager is not properly keeping track of the created VMs");
}
for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
if (entry.getValue()[0] != 0) {
fail("ResourceManager is not properly keeping track of the amount of instances of each type");
}
}
}
Aggregations