Commit 0765b658 authored by aninhacostaribeiro's avatar aninhacostaribeiro
Browse files

Added new test for I am alive info

parent 7f624ee5
......@@ -64,6 +64,10 @@ public class DefaultGreenStrategy implements GreenStrategy {
this.allWakedHosts = hosts;
}
protected void setLostHosts(List<Host> hosts){
this.lostHosts = hosts;
}
protected void setDate(Date date) {
this.lastUpdatedTime = date;
}
......@@ -132,7 +136,10 @@ public class DefaultGreenStrategy implements GreenStrategy {
for (Host host : this.lostHosts) {
if (this.lostHosts.contains(host)) {
this.lostHosts.remove(host);
this.lostHosts.add(host);
LinkedList<Host> aux = new LinkedList<Host>();
aux.addAll(this.allWakedHosts);
aux.add(host);
this.allWakedHosts = aux;
}
}
......
......@@ -44,9 +44,23 @@ public class TestDefaultGreenStrategy {
Assert.assertEquals(1, dgs.getAllWakedHosts().size());
}
@Test
public void testRetrievingHosts() {
Host toBeFound = new Host("found", 0, true, true, 0, 0, 0);
List<Host> hosts = new LinkedList<Host>();
hosts.add(toBeFound);
OpenStackInfoPlugin osip = this.createOpenStackInfoPluginMock(hosts);
DefaultGreenStrategy dgs = new DefaultGreenStrategy(osip, 1800000);
dgs.setLostHosts(hosts);
dgs.receiveIamAliveInfo("found", "test@test.com", "123.456.789",
" A1:B2:C3:D4:E5:67");
Assert.assertEquals(0, dgs.getLostHosts().size());
Assert.assertEquals(1, dgs.getAllWakedHosts().size());
}
@Test
public void testNoLoosingData() {
// Test if green strategy is loosing data while updating the hosts
// It tests if green strategy is loosing data while updating the hosts
Host host1 = new Host("host1", 0, true, true, 0, 0, 0);
Host host2 = new Host("host2", 0, true, true, 0, 0, 0);
List<Host> hosts = new LinkedList<Host>();
......
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