use of es.bsc.compss.types.fake.FakeNode in project compss by bsc-wdc.
the class CloudProviderTest method testCreateTwoVMOneResource.
@Test
public void testCreateTwoVMOneResource() {
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);
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() != 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, cmw, 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() != 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.fake.FakeNode in project compss by bsc-wdc.
the class CloudProviderTest method testDestroyOneVMOneResource.
@Test
public void testDestroyOneVMOneResource() {
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);
ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
cp.confirmedCreation(crc, cmw, granted);
CloudMethodResourceDescription 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");
}
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.isEmpty()) {
fail("Cloud Provider is not properly registering the hosted workers");
}
}
use of es.bsc.compss.types.fake.FakeNode 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.fake.FakeNode 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.fake.FakeNode 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");
}
}
Aggregations