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.");
}
}
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");
}
}
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");
}
}
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");
}
}
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");
}
}
Aggregations