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