use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudProviderTest method testOneImage.
@Test
public void testOneImage() {
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);
Set<String> imageNames = cp.getAllImageNames();
if (!imageNames.contains(image1Name)) {
fail("Cloud Provider is not storing properly the Images. Cannot find the Image name on the one single image scenario.");
}
if (imageNames.size() != 1) {
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 one single image scenario.");
}
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class CloudProviderTest method testDestroyTwoVMOneResource.
@Test
public void testDestroyTwoVMOneResource() {
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);
CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
String vmName = "VM" + (int) (Math.random() * 1000);
ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc, cmw, granted);
granted = new CloudMethodResourceDescription(citd, cid);
cmw.getDescription().increase(granted);
cp.confirmedCreation(crc2, cmw, granted);
CloudMethodResourceDescription reduction = new CloudMethodResourceDescription(citd, cid);
cmw.getDescription().reduce(reduction);
cp.requestResourceReduction(cmw, reduction);
if (cp.getCurrentVMCount() != 1) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
Set<CloudMethodWorker> workers = cp.getHostedWorkers();
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");
}
reduction = new CloudMethodResourceDescription(citd, cid);
cmw.getDescription().reduce(reduction);
cp.requestResourceReduction(cmw, reduction);
if (cp.getCurrentVMCount() != 0) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
workers = cp.getHostedWorkers();
if (!workers.isEmpty()) {
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 CloudProviderTest method testCreateOneVMOneResourceDifferentDescription.
@Test
public void testCreateOneVMOneResourceDifferentDescription() {
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);
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);
granted.addInstance(citd);
cp.confirmedCreation(crc, cmw, granted);
if (cp.getCurrentVMCount() != 2) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
Set<CloudMethodWorker> 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 CloudProviderTest method testDestroyTwoVMTwoResources.
@Test
public void testDestroyTwoVMTwoResources() {
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);
CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
String vmName = "VM" + (int) (Math.random() * 1000);
ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
String vmName2 = "VM" + (int) (Math.random() * 1000);
ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName, cp, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc, cmw, granted);
granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc2, cmw2, granted);
CloudMethodResourceDescription reduction = new CloudMethodResourceDescription(citd, cid);
cmw.getDescription().reduce(reduction);
cp.requestResourceReduction(cmw, reduction);
if (cp.getCurrentVMCount() != 1) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
Set<CloudMethodWorker> workers = cp.getHostedWorkers();
if (workers.size() != 1) {
fail("Cloud Provider is not properly registering the hosted workers");
}
if (!workers.contains(cmw2)) {
fail("Cloud Provider is not properly registering the hosted workers");
}
reduction = new CloudMethodResourceDescription(citd, cid);
cmw2.getDescription().reduce(reduction);
cp.requestResourceReduction(cmw2, reduction);
if (cp.getCurrentVMCount() != 0) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
workers = cp.getHostedWorkers();
if (!workers.isEmpty()) {
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 CloudProviderTest method testCreateTwoVMTwoResources.
@Test
public void testCreateTwoVMTwoResources() {
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);
CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
if (cp.getCurrentVMCount() != 2) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
String vmName = "VM" + (int) (Math.random() * 1000);
CloudMethodWorker cmw = new CloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, 0, 0, 0, new HashMap<>());
String vmName2 = "VM" + (int) (Math.random() * 1000);
CloudMethodWorker cmw2 = new CloudMethodWorker(vmName2, cp, cmrd, new FakeNode(vmName2), 0, 0, 0, 0, new HashMap<>());
CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc, cmw, granted);
if (cp.getCurrentVMCount() != 2) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
Set<CloudMethodWorker> workers = cp.getHostedWorkers();
if (pendingRequests.size() != 1) {
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");
}
granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc2, cmw2, granted);
if (cp.getCurrentVMCount() != 2) {
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() != 2) {
fail("Cloud Provider is not properly registering the hosted workers");
}
if (!workers.contains(cmw)) {
fail("Cloud Provider is not properly registering the hosted workers");
}
if (!workers.contains(cmw2)) {
fail("Cloud Provider is not properly registering the hosted workers");
}
}
Aggregations