Commit 27473f14 authored by Lucas Cavalcante's avatar Lucas Cavalcante
Browse files

Merge branch 'sla-simulation' of...

Merge branch 'sla-simulation' of git.lsd.ufcg.edu.br:lenovo-autonomic/cloudsimplus into sla-simulation
parents 00417e2e 4bc2a775
......@@ -146,10 +146,11 @@ public class VmAllocationPolicyMigrationSlaTest {
Vm vm0 = new VmSimple(0, 0);
vm0.setContract(contract);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm0.setIOPSUtilization(0, MINIMUM_IOPS);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm0.setIOPSUtilization(5, MINIMUM_IOPS);
Host h0 = createMockedHostWithIops(1, 0, vm0, 0, 0, 0, null);
List<Host> hosts = new ArrayList<Host>();
......@@ -161,10 +162,11 @@ public class VmAllocationPolicyMigrationSlaTest {
vm0 = new VmSimple(0, 0);
vm0.setContract(contract);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is MINIMUM_IOPS
vm0.setIOPSUtilization(0, MINIMUM_IOPS - 1);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS - 1, 0, false));
vm0.setIOPSUtilization(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS -1);
h0 = createMockedHostWithIops(1, 0, vm0, 0, 0, 0, null);
hosts.clear();
......@@ -176,11 +178,13 @@ public class VmAllocationPolicyMigrationSlaTest {
vm0 = new VmSimple(0, 0);
vm0.setContract(contract);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is MINIMUM_IOPS
vm0.setIOPSUtilization(0, MINIMUM_IOPS -1);
vm0.addStateHistoryEntry(
new VmStateHistoryEntry(vm0.getMonitor().getMaximumAllowedSlaViolationTime() - policy.getMIGRATION_TIME(),
0, 0, MINIMUM_IOPS, 0, false));
vm0.setIOPSUtilization(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
h0 = createMockedHostWithIops(1, 0, vm0, 0, 0, 0, null);
hosts.clear();
......@@ -392,28 +396,31 @@ public class VmAllocationPolicyMigrationSlaTest {
// VM with enough credit to migrate
Vm vm0 = new VmSimple(0, 0);
vm0.setContract(contract);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm0.setIOPSUtilization(0, MINIMUM_IOPS);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm0.setIOPSUtilization(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm0.setId(0);
// VM about to violate SLA
Vm vm1 = new VmSimple(0, 0);
vm1.setContract(contract);
vm1.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm1.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is MINIMUM_IOPS
vm1.setIOPSUtilization(0, MINIMUM_IOPS);
vm1.addStateHistoryEntry(new VmStateHistoryEntry(vm1.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS - 1, 0, false));
vm1.setIOPSUtilization(vm1.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS -1);
vm1.setId(1);
// VM without enough credit to migrate
Vm vm2 = new VmSimple(0, 0);
vm2.setContract(contract);
vm2.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm2.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS - 1, 0, false)); // allocatedIops is MINIMUM_IOPS
vm2.setIOPSUtilization(0, MINIMUM_IOPS -1);
vm2.addStateHistoryEntry(new VmStateHistoryEntry(vm2.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS - 1, 0, false));
vm2.setIOPSUtilization(vm1.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS -1);
vm2.setId(2);
// heaven host
......@@ -642,91 +649,101 @@ public class VmAllocationPolicyMigrationSlaTest {
// VM with enough credit to migrate
Vm vm0 = new VmSimple(1000, 1);
vm0.setContract(contract);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm0.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm0.setIOPSUtilization(0, MINIMUM_IOPS -1);
vm0.addStateHistoryEntry(new VmStateHistoryEntry(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm0.setIOPSUtilization(vm0.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS -1);
vm0.setId(0);
// VM about to violate SLA
Vm vm1 = new VmSimple(1000, 1);
vm1.setContract(contract);
vm1.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm1.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm1.setIOPSUtilization(0, MINIMUM_IOPS);
vm1.addStateHistoryEntry(new VmStateHistoryEntry(vm1.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm1.setIOPSUtilization(vm1.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm1.setId(1);
// VM without enough credit to migrate
Vm vm2 = new VmSimple(1000, 1);
vm2.setContract(contract);
vm2.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm2.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm2.setIOPSUtilization(0, MINIMUM_IOPS);
vm2.addStateHistoryEntry(new VmStateHistoryEntry(vm2.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm2.setIOPSUtilization(vm2.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm2.setId(2);
// VM about to violate SLA
Vm vm3 = new VmSimple(1000, 1);
vm3.setContract(contract);
vm3.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm3.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm3.setIOPSUtilization(0, MINIMUM_IOPS);
vm3.addStateHistoryEntry(new VmStateHistoryEntry(vm3.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm3.setIOPSUtilization(vm3.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm3.setId(3);
// VM about to violate SLA
Vm vm4 = new VmSimple(1000, 1);
vm4.setContract(contract);
vm4.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm4.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm4.setIOPSUtilization(0, MINIMUM_IOPS);
vm4.addStateHistoryEntry(new VmStateHistoryEntry(vm4.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm4.setIOPSUtilization(vm4.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm4.setId(4);
// VM about to violate SLA
Vm vm5 = new VmSimple(1000, 1);
vm5.setContract(contract);
vm5.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm5.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm5.setIOPSUtilization(0, MINIMUM_IOPS);
vm5.addStateHistoryEntry(new VmStateHistoryEntry(vm5.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm5.setIOPSUtilization(vm5.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm5.setId(5);
// VM about to violate SLA
Vm vm6 = new VmSimple(1000, 1);
vm6.setContract(contract);
vm6.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm6.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm6.setIOPSUtilization(0, MINIMUM_IOPS);
vm6.addStateHistoryEntry(new VmStateHistoryEntry(vm6.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm6.setIOPSUtilization(vm6.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm6.setId(6);
// VM about to violate SLA
Vm vm7 = new VmSimple(1000, 1);
vm7.setContract(contract);
vm7.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm7.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm7.setIOPSUtilization(0, MINIMUM_IOPS);
vm7.addStateHistoryEntry(new VmStateHistoryEntry(vm7.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm7.setIOPSUtilization(vm7.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm7.setId(7);
// VM about to violate SLA
Vm vm8 = new VmSimple(1000, 1);
vm8.setContract(contract);
vm8.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm8.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm8.setIOPSUtilization(0, MINIMUM_IOPS);
vm8.addStateHistoryEntry(new VmStateHistoryEntry(vm8.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm8.setIOPSUtilization(vm8.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm8.setId(8);
// VM about to violate SLA
Vm vm9 = new VmSimple(1000, 1);
vm9.setContract(contract);
vm9.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is
// MINIMUM_IOPS
vm9.addStateHistoryEntry(new VmStateHistoryEntry(0, 0, 0, MINIMUM_IOPS, 0, false)); // allocatedIops is MINIMUM_IOPS
vm9.setIOPSUtilization(0, MINIMUM_IOPS);
vm9.addStateHistoryEntry(new VmStateHistoryEntry(vm9.getMonitor().getMaximumAllowedSlaViolationTime(), 0, 0,
MINIMUM_IOPS, 0, false));
vm9.setIOPSUtilization(vm9.getMonitor().getMaximumAllowedSlaViolationTime(), MINIMUM_IOPS);
vm9.setId(9);
// heaven hosts
......
......@@ -22,7 +22,7 @@ public class SlaMonitorTest {
private static SlaContract contract;
private static double imprecision = 0.0001;
private static double imprecision = 0.2;
@BeforeClass
public static void setup(){
......@@ -43,14 +43,20 @@ public class SlaMonitorTest {
}
@Test
public void existingTimeSlaMonitor_test() {
public void existingTimeSlaMonitorTest() {
Vm vm = new VmSimple(0, 0);
vm.addStateHistoryEntry(new VmStateHistoryEntry(0,0,0,400,0,false));
vm.setIOPSUtilization(0, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(2,0,0,500,0,false));
vm.setIOPSUtilization(2, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(3,0,0,500,0,false));
vm.setIOPSUtilization(3, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(4,0,0,600,0,false));
vm.setIOPSUtilization(4, 600);
vm.addStateHistoryEntry(new VmStateHistoryEntry(5,0,0,600,0,false));
vm.setIOPSUtilization(5, 600);
vm.setContract(contract);
assertTrue(vm.getMonitor().isTheIopsSlaBeingViolated(0));
......@@ -62,12 +68,16 @@ public class SlaMonitorTest {
}
@Test
public void notExistingTimeSlaMonitor_test() {
public void notExistingTimeSlaMonitorTest() {
Vm vm = new VmSimple(0, 0);
vm.addStateHistoryEntry(new VmStateHistoryEntry(0,0,0,400,0,false));
vm.setIOPSUtilization(0, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(2,0,0,500,0,false));
vm.setIOPSUtilization(2, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(4,0,0,600,0,false));
vm.setIOPSUtilization(4, 600);
vm.addStateHistoryEntry(new VmStateHistoryEntry(5,0,0,600,0,false));
vm.setIOPSUtilization(5, 600);
vm.setContract(contract);
assertTrue(vm.getMonitor().isTheIopsSlaBeingViolated(1));
......@@ -76,7 +86,7 @@ public class SlaMonitorTest {
}
@Test
public void getVmCredit_test() {
public void getVmCreditTest() {
Vm vm = new VmSimple(0, 0);
vm.getUtilizationHistory().enable();
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
......@@ -110,11 +120,14 @@ public class SlaMonitorTest {
@Test
public void getVmCreditAfterOneMonth_test() {
public void getVmCreditAfterOneMonthTest() {
Vm vm = new VmSimple(0, 0);
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(SlaMonitor.SECONDS_OF_A_MONTH,0,0,500,0,false));
vm.setIOPSUtilization(SlaMonitor.SECONDS_OF_A_MONTH, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(SlaMonitor.SECONDS_OF_A_MONTH+5,0,0,400,0,false));
vm.setIOPSUtilization(SlaMonitor.SECONDS_OF_A_MONTH+5, 400);
vm.setContract(contract);
assertEquals(0, vm.getMonitor().getCumulativeCredit(0), imprecision);
......@@ -122,20 +135,25 @@ public class SlaMonitorTest {
assertEquals((-1 * STEP_CREDIT) * (SlaMonitor.SECONDS_OF_A_MONTH -1),vm.getMonitor().getCumulativeCredit((SlaMonitor.SECONDS_OF_A_MONTH -1)), imprecision);
assertEquals((-1 * STEP_CREDIT) * (SlaMonitor.SECONDS_OF_A_MONTH -2),vm.getMonitor().getCumulativeCredit((SlaMonitor.SECONDS_OF_A_MONTH)), imprecision);
assertEquals((-1 * STEP_CREDIT) * (SlaMonitor.SECONDS_OF_A_MONTH -6), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 4), imprecision);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -5), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 5), 0.2);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -15), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 15), 0.2);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -55), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 55), 0.2);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -101), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 101), 0.2);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -5), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 5), imprecision);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -15), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 15), imprecision);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -55), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 55), imprecision);
assertEquals((STEP_CREDIT) * (-1 * SlaMonitor.SECONDS_OF_A_MONTH -101), vm.getMonitor().getCumulativeCredit(SlaMonitor.SECONDS_OF_A_MONTH + 101), imprecision);
}
@Test
public void getVmViolationTime_test() {
public void getVmViolationTimeTest() {
Vm vm = new VmSimple(0, 0);
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(2,0,0,500,0,false));
vm.setIOPSUtilization(2, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(3,0,0,500,0,false));
vm.setIOPSUtilization(3, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(4,0,0,600,0,false));
vm.setIOPSUtilization(4, 600);
vm.addStateHistoryEntry(new VmStateHistoryEntry(5,0,0,450,0,false));
vm.setIOPSUtilization(5, 450);
vm.setContract(contract);
assertEquals(0, vm.getMonitor().getCumulativeVmViolationTime(0));
......@@ -148,11 +166,14 @@ public class SlaMonitorTest {
}
@Test
public void getVmViolationTimeAfterOneMonth_test() {
public void getVmViolationTimeAfterOneMonthTest() {
Vm vm = new VmSimple(0, 0);
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(SlaMonitor.SECONDS_OF_A_MONTH,0,0,500,0,false));
vm.addStateHistoryEntry(new VmStateHistoryEntry(SlaMonitor.SECONDS_OF_A_MONTH+5,0,0,400,0,false));
vm.setIOPSUtilization(SlaMonitor.SECONDS_OF_A_MONTH, 500);
vm.addStateHistoryEntry(new VmStateHistoryEntry(SlaMonitor.SECONDS_OF_A_MONTH+5,0,0,400,0,false));
vm.setIOPSUtilization(SlaMonitor.SECONDS_OF_A_MONTH, 400);
vm.setContract(contract);
assertEquals(0, vm.getMonitor().getCumulativeVmViolationTime(0));
......
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