Commit 6af1a126 authored by Eduardo Falcão's avatar Eduardo Falcão
Browse files

initiating test for sla migration

parent 98145c41
......@@ -231,7 +231,7 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
* Get hosts in which the SLA are delivered with no performance degradation.
* @return a set of hosts
*/
private List<Host> getHostsWithTightSla(Datacenter dc){
protected List<Host> getHostsWithTightSla(Datacenter dc){
return getHostsFromSlaExploitationPolicy(dc, TIGHT);
}
......@@ -240,7 +240,7 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
* (may have (or not) performance degradation)
* @return a set of hosts
*/
private List<Host> getHostsWithLooseSla(Datacenter dc){
protected List<Host> getHostsWithLooseSla(Datacenter dc){
return getHostsFromSlaExploitationPolicy(dc, LOOSE);
}
......@@ -250,7 +250,7 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
* @param policyType type scenario of the host SlaExplotation
* @return a set of hosts
*/
private List<Host> getHostsFromSlaExploitationPolicy(Datacenter dc, String policyType) {
protected List<Host> getHostsFromSlaExploitationPolicy(Datacenter dc, String policyType) {
List<Host> exploitationHosts = new ArrayList<Host>();
for (Host host : dc.getHostList()) {
if (policyType.toUpperCase().equals(LOOSE) &&
......
......@@ -793,7 +793,7 @@ public class HostSimple implements Host {
@Override
public List<ResourceManageable> getResources() {
if(simulation.isRunning() && resources.isEmpty()){
resources = Arrays.asList(ramProvisioner.getResource(), bwProvisioner.getResource());
resources = Arrays.asList(ramProvisioner.getResource(), bwProvisioner.getResource(), iopsProvisioner.getResource());
}
return Collections.unmodifiableList(resources);
}
......@@ -801,7 +801,7 @@ public class HostSimple implements Host {
@Override
public ResourceProvisioner getProvisioner(final Class<? extends ResourceManageable> resourceClass) {
if(simulation.isRunning() && provisioners.isEmpty()){
provisioners = Arrays.asList(ramProvisioner, bwProvisioner);
provisioners = Arrays.asList(ramProvisioner, bwProvisioner, iopsProvisioner);
}
return provisioners
......
package org.cloudbus.cloudsim.allocationpolicies;
package org.cloudbus.cloudsim.allocationpolicies.migration;
import static org.junit.Assert.assertEquals;
......@@ -10,9 +10,13 @@ import org.apache.commons.lang3.NotImplementedException;
import org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigrationSla;
import org.cloudbus.cloudsim.datacenters.Datacenter;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.provisioners.ResourceProvisioner;
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerShared;
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple;
import org.cloudbus.cloudsim.resources.Bandwidth;
import org.cloudbus.cloudsim.resources.Iops;
import org.cloudbus.cloudsim.resources.Ram;
import org.cloudbus.cloudsim.resources.ResourceManageable;
import org.cloudbus.cloudsim.vms.Vm;
import org.cloudbus.cloudsim.vms.VmWithMetadata;
import org.cloudbus.cloudsim.vms.VmWithMetadata.VmData;
......@@ -80,7 +84,7 @@ public class VmAllocationPolicyMigrationSlaTest {
return vm;
}
private Host createMockedHost(int id, int pesNumber, Vm vm) {
private Host createMockedHost(int id, int pesNumber, Vm vm, ResourceProvisioner provisioner) {
Host host = EasyMock.createMock(Host.class);
EasyMock.expect(host.getId()).andReturn(id).anyTimes();
......@@ -90,6 +94,7 @@ public class VmAllocationPolicyMigrationSlaTest {
EasyMock.expect(host.getIops()).andReturn(new Iops(HOST_IOPS)).anyTimes();
EasyMock.expect(host.getBw()).andReturn(new Bandwidth(HOST_BW)).anyTimes();
EasyMock.expect(host.getNumberOfWorkingPes()).andReturn((long) 2).anyTimes();
EasyMock.expect(host.getIopsProvisioner()).andReturn(provisioner).anyTimes();
List<Vm> vms = new ArrayList<Vm>();
vms.add(vm);
......@@ -108,4 +113,19 @@ public class VmAllocationPolicyMigrationSlaTest {
return datacenter;
}
@Test
public void getHostsWithTightSla_test(){
List<Host> hosts = new ArrayList<Host>();
final int NUM_HEAVEN_HOSTS = 50;
for(int i = 0; i < NUM_HEAVEN_HOSTS; i++)
hosts.add(createMockedHost(i, 0, null, new ResourceProvisionerSimple()));
final int NUM_HELL_HOSTS = 50;
for(int i = NUM_HEAVEN_HOSTS; i < NUM_HELL_HOSTS; i++)
hosts.add(createMockedHost(i, 0, null, new ResourceProvisionerShared()));
Datacenter dc = createMockedDatacenter(hosts);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment