From 16c2b56ed2c0039484d754e984bffc91b6f5f552 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 17:10:44 +0100 Subject: Ignore UDUP tests --- src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/test') 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 f731706..922ebe2 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/UDUPTest.java @@ -20,6 +20,7 @@ import java.net.UnknownHostException; // TODO add serialization tests that target custom serializers (type collections!) +@Ignore public class UDUPTest { @Test -- cgit v1.2.3 From 84b686eb2e4e2eccde13f7cee1987b4211660729 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 21:00:58 +0100 Subject: Use GTP time protocol for gossiping --- .../cloudatlas/agent/modules/GossipGirlTest.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/test') 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 d443fad..dbacfe5 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 @@ -34,6 +34,7 @@ import pl.edu.mimuw.cloudatlas.model.Attribute; import pl.edu.mimuw.cloudatlas.model.PathName; import pl.edu.mimuw.cloudatlas.model.TestUtil; import pl.edu.mimuw.cloudatlas.model.ValueContact; +import pl.edu.mimuw.cloudatlas.model.ValueDuration; import pl.edu.mimuw.cloudatlas.model.ValueInt; import pl.edu.mimuw.cloudatlas.model.ValueQuery; import pl.edu.mimuw.cloudatlas.model.ValueString; @@ -57,6 +58,7 @@ public class GossipGirlTest { private AttributesMessage attributesMessage2; private QueryMessage queryMessage1; private QueryMessage queryMessage2; + private ValueDuration offset; private HejkaMessage hejkaMessage; @@ -84,7 +86,10 @@ public class GossipGirlTest { Map otherZoneTimestamps = makeOtherZoneTimestamps(); Map otherQueryTimestamps = makeOtherQueryTimestamps(); - noCoTamMessage = new NoCoTamMessage("", 0, 42, 0, otherZoneTimestamps, otherQueryTimestamps, ValueUtils.addToTime(testTime, 10), ValueUtils.addToTime(testTime, 22)); + noCoTamMessage = new NoCoTamMessage("", 0, 42, 0, otherZoneTimestamps, otherQueryTimestamps, ValueUtils.addToTime(testTime, 10), ValueUtils.addToTime(testTime, 30)); + noCoTamMessage.setSentTimestamp(ValueUtils.addToTime(testTime, 35)); + noCoTamMessage.setReceivedTimestamp(ValueUtils.addToTime(testTime, 255)); + offset = new ValueDuration(-100l); attributesMessage1 = makeAttributesMessage("/son/bro", makeAttributes1()); attributesMessage2 = makeAttributesMessage("/son/whodis", makeAttributes2()); @@ -99,7 +104,7 @@ public class GossipGirlTest { public QueryMessage makeQueryMessage(String name, String query) throws Exception { - return new QueryMessage("", 0, new Attribute(name), new ValueQuery(query), 0); + return new QueryMessage("", 0, new Attribute(name), new ValueQuery(query), 0, offset); } public AttributesMap makeAttributes1() { @@ -121,12 +126,12 @@ public class GossipGirlTest { } public AttributesMessage makeAttributesMessage(String path, AttributesMap attributes) { - return new AttributesMessage("", 0, new PathName(path), attributes, 0); + return new AttributesMessage("", 0, new PathName(path), attributes, 0, offset); } public Map makeOtherZoneTimestamps() { Map zoneTimestamps = new HashMap(); - addOtherZoneTimestamp(zoneTimestamps, "/son/sis", -100); + addOtherZoneTimestamp(zoneTimestamps, "/son/sis", -120); addOtherZoneTimestamp(zoneTimestamps, "/son/bro", 0); addOtherZoneTimestamp(zoneTimestamps, "/son/whodis", -300); @@ -272,8 +277,7 @@ public class GossipGirlTest { assertEquals(StanikMessage.Type.UPDATE_ATTRIBUTES, stanikMessage1.getType()); UpdateAttributesMessage updateMessage1 = (UpdateAttributesMessage) stanikMessage1; assertEquals("/son/bro", updateMessage1.getPathName()); - // TODO: this should be modified by GTP - assertEquals(testTime, updateMessage1.getAttributes().getOrNull("timestamp")); + assertEquals(ValueUtils.addToTime(testTime, 100), updateMessage1.getAttributes().getOrNull("timestamp")); assertEquals(new ValueInt(140l), updateMessage1.getAttributes().getOrNull("foo")); assertEquals(new ValueString(":wq"), updateMessage1.getAttributes().getOrNull("bar")); @@ -289,7 +293,6 @@ public class GossipGirlTest { assertEquals(updateMessage2.getQueries().get(new Attribute("&one")), new SimpleImmutableEntry( new ValueQuery("SELECT 3 AS one"), - // TODO: this should be modified by GTP ValueUtils.addToTime(testTime, 10) ) ); @@ -385,8 +388,7 @@ public class GossipGirlTest { assertEquals(StanikMessage.Type.UPDATE_ATTRIBUTES, stanikMessage1.getType()); UpdateAttributesMessage updateMessage1 = (UpdateAttributesMessage) stanikMessage1; assertEquals("/son/bro", updateMessage1.getPathName()); - // TODO: this should be modified by GTP - assertEquals(testTime, updateMessage1.getAttributes().getOrNull("timestamp")); + assertEquals(ValueUtils.addToTime(testTime, -100), updateMessage1.getAttributes().getOrNull("timestamp")); assertEquals(new ValueInt(140l), updateMessage1.getAttributes().getOrNull("foo")); assertEquals(new ValueString(":wq"), updateMessage1.getAttributes().getOrNull("bar")); @@ -402,7 +404,6 @@ public class GossipGirlTest { assertEquals(updateMessage2.getQueries().get(new Attribute("&one")), new SimpleImmutableEntry( new ValueQuery("SELECT 3 AS one"), - // TODO: this should be modified by GTP ValueUtils.addToTime(testTime, 10) ) ); @@ -462,6 +463,7 @@ public class GossipGirlTest { QueryMessage queryMessage = (QueryMessage) ((UDUPMessage) message).getContent(); assertEquals(new Attribute(name), queryMessage.getName()); assertEquals(new ValueQuery(query), queryMessage.getQuery()); + assertEquals(new ValueDuration(-100l), queryMessage.getOffset()); } private void assertAttributeMessage(AgentMessage message, String recipientPath, String zonePath) throws Exception { @@ -472,6 +474,7 @@ public class GossipGirlTest { ); AttributesMessage attributesMessage = (AttributesMessage) ((UDUPMessage) message).getContent(); assertEquals(new PathName(zonePath), attributesMessage.getPath()); + assertEquals(new ValueDuration(-100l), attributesMessage.getOffset()); } private void assertUDUPMessage(AgentMessage message, PathName destinationName, GossipGirlMessage.Type type) throws Exception { -- cgit v1.2.3 From 84df6c11a868e8cd98fa14455456d313e25234db Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 21:52:38 +0100 Subject: Set zone levels --- .../mimuw/cloudatlas/agent/modules/StanikTest.java | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java index f3ea0b0..03a89c6 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java @@ -57,7 +57,8 @@ public class StanikTest { ZMI zmi = stateMessage.getZMI(); assertNull(zmi.getFather()); assertTrue(zmi.getSons().isEmpty()); - assertEquals(1, TestUtil.iterableSize(zmi.getAttributes())); + assertEquals(2, TestUtil.iterableSize(zmi.getAttributes())); + assertEquals(new ValueInt(0l), zmi.getAttributes().getOrNull("level")); Map> queries = stateMessage.getQueries(); assertEquals(0, TestUtil.iterableSize(queries.keySet())); } @@ -111,6 +112,28 @@ public class StanikTest { assertEquals(testTime, actualAttributes.getOrNull("timestamp")); } + @Test + public void newZoneHasNewLevel() throws Exception { + AttributesMap attributes = new AttributesMap(); + attributes.add("foo", new ValueInt(1337l)); + attributes.add("bar", new ValueString("baz")); + attributes.add("name", new ValueString("new")); + attributes.add("timestamp", testTime); + UpdateAttributesMessage message = new UpdateAttributesMessage("test_msg", 0, "/new", attributes); + stanik.handleTyped(message); + GetStateMessage newMessage = new GetStateMessage("test_msg2", 123, ModuleType.TEST, 43); + stanik.handleTyped(newMessage); + + StateMessage newReceivedMessage = (StateMessage) executor.messagesToPass.poll(); + AttributesMap actualAttributes = newReceivedMessage.getZMI().findDescendant("/new").getAttributes(); + assertEquals(5, TestUtil.iterableSize(actualAttributes)); + assertEquals(new ValueInt(1337l), actualAttributes.getOrNull("foo")); + assertEquals(new ValueString("baz"), actualAttributes.getOrNull("bar")); + assertEquals(new ValueString("new"), actualAttributes.getOrNull("name")); + assertEquals(testTime, actualAttributes.getOrNull("timestamp")); + assertEquals(new ValueInt(1l), actualAttributes.getOrNull("level")); + } + @Test public void updateWithRemovedAttributes() throws Exception { AttributesMap attributes = new AttributesMap(); -- cgit v1.2.3 From 411bf8f0dae524d70a0754049b5494182ade4a05 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 22:12:09 +0100 Subject: Set owner of ZMIs on our path --- .../java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java index 03a89c6..d16d917 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java @@ -39,7 +39,7 @@ public class StanikTest { @Before public void setupLocals() { - stanik = new Stanik(freshnessPeriod); + stanik = new Stanik(new PathName("/new"), freshnessPeriod); executor = new MockExecutor(stanik); testTime = ValueUtils.currentTime(); } @@ -57,8 +57,9 @@ public class StanikTest { ZMI zmi = stateMessage.getZMI(); assertNull(zmi.getFather()); assertTrue(zmi.getSons().isEmpty()); - assertEquals(2, TestUtil.iterableSize(zmi.getAttributes())); + assertEquals(3, TestUtil.iterableSize(zmi.getAttributes())); assertEquals(new ValueInt(0l), zmi.getAttributes().getOrNull("level")); + assertEquals(new ValueString("/new"), zmi.getAttributes().getOrNull("owner")); Map> queries = stateMessage.getQueries(); assertEquals(0, TestUtil.iterableSize(queries.keySet())); } @@ -126,10 +127,11 @@ public class StanikTest { StateMessage newReceivedMessage = (StateMessage) executor.messagesToPass.poll(); AttributesMap actualAttributes = newReceivedMessage.getZMI().findDescendant("/new").getAttributes(); - assertEquals(5, TestUtil.iterableSize(actualAttributes)); + assertEquals(6, TestUtil.iterableSize(actualAttributes)); assertEquals(new ValueInt(1337l), actualAttributes.getOrNull("foo")); assertEquals(new ValueString("baz"), actualAttributes.getOrNull("bar")); assertEquals(new ValueString("new"), actualAttributes.getOrNull("name")); + assertEquals(new ValueString("/new"), actualAttributes.getOrNull("owner")); assertEquals(testTime, actualAttributes.getOrNull("timestamp")); assertEquals(new ValueInt(1l), actualAttributes.getOrNull("level")); } -- cgit v1.2.3 From cd247e8d64b2ef0aed7f0afdccd711008cd60fcd Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 12 Jan 2020 22:25:09 +0100 Subject: Add default queries for contacts and cardinality --- .../java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java index d16d917..92ba051 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java @@ -61,7 +61,7 @@ public class StanikTest { assertEquals(new ValueInt(0l), zmi.getAttributes().getOrNull("level")); assertEquals(new ValueString("/new"), zmi.getAttributes().getOrNull("owner")); Map> queries = stateMessage.getQueries(); - assertEquals(0, TestUtil.iterableSize(queries.keySet())); + assertEquals(2, TestUtil.iterableSize(queries.keySet())); } @Test @@ -127,11 +127,12 @@ public class StanikTest { StateMessage newReceivedMessage = (StateMessage) executor.messagesToPass.poll(); AttributesMap actualAttributes = newReceivedMessage.getZMI().findDescendant("/new").getAttributes(); - assertEquals(6, TestUtil.iterableSize(actualAttributes)); + assertEquals(7, TestUtil.iterableSize(actualAttributes)); assertEquals(new ValueInt(1337l), actualAttributes.getOrNull("foo")); assertEquals(new ValueString("baz"), actualAttributes.getOrNull("bar")); assertEquals(new ValueString("new"), actualAttributes.getOrNull("name")); assertEquals(new ValueString("/new"), actualAttributes.getOrNull("owner")); + assertEquals(new ValueInt(1l), actualAttributes.getOrNull("cardinality")); assertEquals(testTime, actualAttributes.getOrNull("timestamp")); assertEquals(new ValueInt(1l), actualAttributes.getOrNull("level")); } @@ -223,7 +224,7 @@ public class StanikTest { stanik.handleTyped(message); HashMap> actualQueries = stanik.getQueries(); - assertEquals(1, TestUtil.iterableSize(actualQueries.keySet())); + assertEquals(3, TestUtil.iterableSize(actualQueries.keySet())); assertTrue(actualQueries.containsKey(new Attribute("&query"))); Entry timestampedQuery = actualQueries.get(new Attribute("&query")); assertEquals(new ValueTime(42l), timestampedQuery.getValue()); @@ -247,7 +248,7 @@ public class StanikTest { stanik.handleTyped(otherMessage); HashMap> actualQueries = stanik.getQueries(); - assertEquals(4, TestUtil.iterableSize(actualQueries.keySet())); + assertEquals(6, TestUtil.iterableSize(actualQueries.keySet())); assertTrue(actualQueries.containsKey(new Attribute("&query1"))); assertTrue(actualQueries.containsKey(new Attribute("&query2"))); assertTrue(actualQueries.containsKey(new Attribute("&query3"))); -- cgit v1.2.3