From 0953e404e7dacbe397cc60d8715af72bd59b8c1c Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sat, 11 Jan 2020 20:12:34 +0100 Subject: Start implementing gossip cleanup --- .../cloudatlas/agent/modules/GossipGirlTest.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java index a812e61..fb3c5f7 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java @@ -15,6 +15,7 @@ import java.util.Set; import pl.edu.mimuw.cloudatlas.agent.MockExecutor; import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; import pl.edu.mimuw.cloudatlas.agent.messages.AttributesMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.CleanOldGossipsMessage; import pl.edu.mimuw.cloudatlas.agent.messages.HejkaMessage; import pl.edu.mimuw.cloudatlas.agent.messages.GetStateMessage; import pl.edu.mimuw.cloudatlas.agent.messages.GossipGirlMessage; @@ -409,6 +410,28 @@ public class GossipGirlTest { gossipGirl.handleTyped(queryMessage2); } + @Test + public void cleanupOldGossips() throws Exception { + gossipGirl.handleTyped(hejkaMessage); + executor.messagesToPass.take(); + gossipGirl.handleTyped(stateMessage); + executor.messagesToPass.take(); + + gossipGirl.handleTyped(attributesMessage1); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + + CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, TestUtil.addToTime(ValueUtils.currentTime(), 10)); + gossipGirl.handleTyped(message); + gossipGirl.handleTyped(attributesMessage2); + + assertEquals(0, executor.messagesToPass.size()); + } + private void assertQueryMessage(AgentMessage message, String recipientPath, String name, String query) throws Exception { assertUDUPMessage( message, -- cgit v1.2.3 From 3ebdb1ce162e13c5accf7f3e65a35863504026dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 12 Jan 2020 15:10:27 +0100 Subject: Reduce sleeps --- .../pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java | 4 ++-- .../java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java | 6 +++--- src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java index e2c12d6..9028026 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentIntegrationTest.java @@ -48,9 +48,9 @@ public class AgentIntegrationTest { @BeforeClass public static void bindApi() throws Exception { registryProcess = Runtime.getRuntime().exec("./scripts/registry"); - Thread.sleep(10000); + Thread.sleep(5000); agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost -DfreshnessPeriod=10000000 -DqueryPeriod=100"); - Thread.sleep(10000); + Thread.sleep(5000); registry = LocateRegistry.getRegistry("localhost"); api = (Api) registry.lookup("Api"); diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java index 4a9eb87..99051ff 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java @@ -60,7 +60,7 @@ public class SchedulerTest { } })); - Thread.sleep(1000); + Thread.sleep(300); } @Test @@ -92,7 +92,7 @@ public class SchedulerTest { })); - Thread.sleep(1000); + Thread.sleep(300); } @Test @@ -129,6 +129,6 @@ public class SchedulerTest { } })); - Thread.sleep(1000); + Thread.sleep(300); } } diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java index ac2c587..f731706 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java @@ -30,7 +30,7 @@ public class UDUPTest { UDUPServer server2 = null; UDUPMessage msg1 = null; boolean testSuccess = true; - int timeout = 5000; + int timeout = 500; try { System.out.println("Starting udp1"); @@ -72,7 +72,7 @@ public class UDUPTest { udpThread2.start(); try { - Thread.sleep(500); + Thread.sleep(100); if (udp1 == null | udp2 == null) { testSuccess = false; } else { @@ -102,7 +102,7 @@ public class UDUPTest { UDUPServer server2 = null; UDUPMessage msg1 = null; boolean testSuccess = true; - int timeout = 3000; + int timeout = 1000; try { System.out.println("Starting udp1"); @@ -144,7 +144,7 @@ public class UDUPTest { udpThread2.start(); try { - Thread.sleep(500); + Thread.sleep(100); if (udp1 == null | udp2 == null) { testSuccess = false; } else { @@ -177,7 +177,7 @@ public class UDUPTest { UDUPMessage msg2 = null; UDUPMessage msg3 = null; boolean testSuccess = true; - int timeout = 3000; + int timeout = 1000; try { System.out.println("Starting udp1"); @@ -231,7 +231,7 @@ public class UDUPTest { udpThread2.start(); try { - Thread.sleep(500); + Thread.sleep(100); if (udp1 == null | udp2 == null) { testSuccess = false; } else { -- cgit v1.2.3 From a91ffb770782450b0dd23f0510cd80ec531f7339 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 16:12:08 +0100 Subject: Add log --- src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java index 2d7b15f..720a7e3 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java @@ -429,7 +429,6 @@ public class GossipGirlTest { CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, TestUtil.addToTime(ValueUtils.currentTime(), 10)); gossipGirl.handleTyped(message); gossipGirl.handleTyped(attributesMessage2); - assertEquals(0, executor.messagesToPass.size()); } -- cgit v1.2.3 From 37f413d69d8f60e327c564d2b9a604739f80080b Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 16:20:01 +0100 Subject: Add test for live gossip --- .../cloudatlas/agent/modules/GossipGirlTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java index 720a7e3..e35274b 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java @@ -432,6 +432,27 @@ public class GossipGirlTest { assertEquals(0, executor.messagesToPass.size()); } + @Test + public void dontCleanFreshGossips() throws Exception { + gossipGirl.handleTyped(hejkaMessage); + executor.messagesToPass.take(); + gossipGirl.handleTyped(stateMessage); + executor.messagesToPass.take(); + + gossipGirl.handleTyped(attributesMessage1); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + executor.messagesToPass.take(); + + CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, TestUtil.addToTime(testTime, -10)); + gossipGirl.handleTyped(message); + gossipGirl.handleTyped(attributesMessage2); + assertEquals(1, executor.messagesToPass.size()); + } + private void assertQueryMessage(AgentMessage message, String recipientPath, String name, String query) throws Exception { assertUDUPMessage( message, -- cgit v1.2.3 From edec7f92b20f1f873083bdf3198283fa822e0f64 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 16:36:42 +0100 Subject: Start removing old gossips --- .../mimuw/cloudatlas/agent/modules/GossipGirlTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java index e35274b..d443fad 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java @@ -84,7 +84,7 @@ public class GossipGirlTest { Map otherZoneTimestamps = makeOtherZoneTimestamps(); Map otherQueryTimestamps = makeOtherQueryTimestamps(); - noCoTamMessage = new NoCoTamMessage("", 0, 42, 0, otherZoneTimestamps, otherQueryTimestamps, TestUtil.addToTime(testTime, 10), TestUtil.addToTime(testTime, 22)); + noCoTamMessage = new NoCoTamMessage("", 0, 42, 0, otherZoneTimestamps, otherQueryTimestamps, ValueUtils.addToTime(testTime, 10), ValueUtils.addToTime(testTime, 22)); attributesMessage1 = makeAttributesMessage("/son/bro", makeAttributes1()); attributesMessage2 = makeAttributesMessage("/son/whodis", makeAttributes2()); @@ -93,7 +93,7 @@ public class GossipGirlTest { hejkaMessage = new HejkaMessage("", 0, 123, new PathName("/son/bro"), new PathName("/son/grand"), otherZoneTimestamps, otherQueryTimestamps); hejkaMessage.setSentTimestamp(testTime); - hejkaMessage.setReceivedTimestamp(TestUtil.addToTime(testTime, 15)); + hejkaMessage.setReceivedTimestamp(ValueUtils.addToTime(testTime, 15)); hejkaMessage.setSenderAddress(theirContact.getAddress()); } @@ -114,7 +114,7 @@ public class GossipGirlTest { public AttributesMap makeAttributes2() { AttributesMap attributes = new AttributesMap(); attributes.add("name", new ValueString("whodis")); - attributes.add("timestamp", TestUtil.addToTime(testTime, -300)); + attributes.add("timestamp", ValueUtils.addToTime(testTime, -300)); attributes.add("foo", new ValueInt(61l)); attributes.add("bar", new ValueString("nice")); return attributes; @@ -142,11 +142,11 @@ public class GossipGirlTest { } public void addOtherQueryTimestamp(Map timestamps, String name, long offset) { - timestamps.put(new Attribute(name), TestUtil.addToTime(testTime, offset)); + timestamps.put(new Attribute(name), ValueUtils.addToTime(testTime, offset)); } public void addOtherZoneTimestamp(Map timestamps, String path, long offset) { - timestamps.put(new PathName(path), TestUtil.addToTime(testTime, offset)); + timestamps.put(new PathName(path), ValueUtils.addToTime(testTime, offset)); } public void setupHierarchy() { @@ -290,7 +290,7 @@ public class GossipGirlTest { new SimpleImmutableEntry( new ValueQuery("SELECT 3 AS one"), // TODO: this should be modified by GTP - TestUtil.addToTime(testTime, 10) + ValueUtils.addToTime(testTime, 10) ) ); @@ -403,7 +403,7 @@ public class GossipGirlTest { new SimpleImmutableEntry( new ValueQuery("SELECT 3 AS one"), // TODO: this should be modified by GTP - TestUtil.addToTime(testTime, 10) + ValueUtils.addToTime(testTime, 10) ) ); @@ -426,7 +426,7 @@ public class GossipGirlTest { executor.messagesToPass.take(); executor.messagesToPass.take(); - CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, TestUtil.addToTime(ValueUtils.currentTime(), 10)); + CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, ValueUtils.addToTime(ValueUtils.currentTime(), 10)); gossipGirl.handleTyped(message); gossipGirl.handleTyped(attributesMessage2); assertEquals(0, executor.messagesToPass.size()); @@ -447,7 +447,7 @@ public class GossipGirlTest { executor.messagesToPass.take(); executor.messagesToPass.take(); - CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, TestUtil.addToTime(testTime, -10)); + CleanOldGossipsMessage message = new CleanOldGossipsMessage("", 0, ValueUtils.addToTime(testTime, -10)); gossipGirl.handleTyped(message); gossipGirl.handleTyped(attributesMessage2); assertEquals(1, executor.messagesToPass.size()); -- cgit v1.2.3