Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Mar 26, 2020
1 parent c86a723 commit 8bc3796
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 50 deletions.
2 changes: 1 addition & 1 deletion include/broker/endpoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public:

// --- forwarding events -----------------------------------------------------

/// Forward remote events for given filter even if no local subscribers exist.
[[deprecated("this legacy function has no effect")]]
void forward(filter_type filter);

// --- subscribing data ------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/broker-node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ int main(int argc, char** argv) {
for (auto& topic_name : topic_names)
topics.emplace_back(std::move(topic_name));
}
ep.forward(topics);
// Enable verbose output if demanded by user.
actor verbose_logger;
if (get_or(ep, "verbose", false)) {
Expand Down
59 changes: 11 additions & 48 deletions tests/python/forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,58 +40,21 @@ def test_two_hops(self):

x = s4.get()
self.assertEqual(x, ('/test/foo', 'Foo!'))
x = s1.get()
self.assertEqual(x, ('/test/bar', 'Bar!'))

def test_two_hops_with_forward(self):
# Two hops that are not subscribed, but configured to forward.
((ep1, ep2, ep3, ep4), (s1, s2, s3, s4)) = setup_peers(create_s2=False, create_s3=False)

ep2.forward("/test/");
ep3.forward("/test/");
time.sleep(1) # give time to take effect.

ep1.publish("/test/foo", "Foo!")
ep4.publish("/test/bar", "Bar!")

x = s4.get()
self.assertEqual(x, ('/test/foo', 'Foo!'))
x = s1.get()
self.assertEqual(x, ('/test/bar', 'Bar!'))

def test_two_hops_forwarding_disabled(self):
# Two hops that are subscribed, so they would forward but we disable.
no_forward = broker.BrokerOptions()
no_forward.forward = False

((ep1, ep2, ep3, ep4), (s1, s2, s3, s4)) = setup_peers(opts2=no_forward)

ep1.publish("/test/foo", "Foo!") # Shouldn't arrive
x = s4.get(1.0)
self.assertEqual(x, None)

def test_two_hops_without_forward(self):
# Two hops that are not subscribed, and hence don't forward.
((ep1, ep2, ep3, ep4), (s1, s2, s3, s4)) = setup_peers(create_s2=False, create_s3=False)

ep1.publish("/test/foo", "Foo!")
x = s4.get(1.0)
self.assertEqual(x, None)

def test_two_hops_ttl(self):
ttl1 = broker.BrokerOptions()
ttl1.ttl = 2
((ep1, ep2, ep3, ep4), (s1, s2, s3, s4)) = setup_peers(opts1=ttl1)

ep1.publish("/test/foo", "Foo!")

x = s2.get(1.0)
self.assertEqual(x, ('/test/foo', 'Foo!'))
x = s3.get(1.0)
self.assertEqual(x, ('/test/foo', 'Foo!'))
x = s4.get(1.0)
self.assertEqual(x, None) # Doesn't get here anymore.
# def test_two_hops_with_forward(self):
# # Two hops that are not subscribed, but configured to forward.
# ((ep1, ep2, ep3, ep4), (s1, s2, s3, s4)) = setup_peers(create_s2=False, create_s3=False)
#
# ep1.publish("/test/foo", "Foo!")
# ep4.publish("/test/bar", "Bar!")
#
# x = s4.get()
# self.assertEqual(x, ('/test/foo', 'Foo!'))
# x = s1.get()
# self.assertEqual(x, ('/test/bar', 'Bar!'))

if __name__ == '__main__':
#TestCommunication().test_two_hops()
unittest.main(verbosity=3)

0 comments on commit 8bc3796

Please sign in to comment.