use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudProviderTest method testTwoImages.
@Test
public void testTwoImages() {
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 image1Name = "IMAGE" + (int) (Math.random() * 10000);
Map<String, String> imageProperties = new HashMap<>();
String img1PropValue = "VALUE" + (int) (Math.random() * 10000);
imageProperties.put(CID_PROPERTY_TEST_TAG, img1PropValue);
CloudImageDescription cid1 = new CloudImageDescription(image1Name, imageProperties);
cp.addCloudImage(cid1);
String image2Name = "IMAGE" + (int) (Math.random() * 10000);
imageProperties = new HashMap<>();
String img2PropValue = "VALUE" + (int) (Math.random() * 10000);
imageProperties.put(CID_PROPERTY_TEST_TAG, img2PropValue);
CloudImageDescription cid2 = new CloudImageDescription(image2Name, imageProperties);
cp.addCloudImage(cid2);
Set<String> imageNames = cp.getAllImageNames();
int contains = 0;
if (imageNames.contains(image1Name)) {
contains++;
}
if (imageNames.contains(image2Name)) {
contains++;
}
switch(contains) {
case 0:
fail("Cloud Provider is not storing properly the Images. Cannot find any image name on the two images scenario.");
break;
case 1:
fail("Cloud Provider is not storing properly the Images. Cannot find one image name on the two images scenario.");
break;
default:
}
if (imageNames.size() != 2) {
fail("Cloud Provider is not storing properly the Images. only two images are supposed to be in the group.");
}
CloudImageDescription retrieved1 = cp.getImage(image1Name);
try {
checkRetrievedImage(retrieved1, image1Name, img1PropValue);
} catch (Exception e) {
fail("Cloud Provider is not storing properly the Images. The provider " + e.getMessage() + " on the two images scenario.");
}
CloudImageDescription retrieved2 = cp.getImage(image2Name);
try {
checkRetrievedImage(retrieved2, image2Name, img2PropValue);
} catch (Exception e) {
fail("Cloud Provider is not storing properly the Images. " + e.getMessage() + " on the two images scenario.");
}
}
use of es.bsc.compss.types.resources.description.CloudImageDescription 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.CloudImageDescription 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.CloudImageDescription 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.CloudImageDescription in project compss by bsc-wdc.
the class Converter method getSoftwareDescription.
/**
* Returns the software description
*
* @param cmrd
* @return
*/
public static SoftwareDescription getSoftwareDescription(CloudMethodResourceDescription cmrd) {
String osType = cmrd.getOperatingSystemType();
String osDist = cmrd.getOperatingSystemDistribution();
String osVersion = cmrd.getOperatingSystemVersion();
List<String> apps = cmrd.getAppSoftware();
CloudImageDescription cid = cmrd.getImage();
MethodConfiguration mc = cid.getConfig();
InstallationDescription installDesc = getInstallationDescription(mc);
return new SoftwareDescription(osType, osDist, osVersion, apps, installDesc);
}
Aggregations