-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added docs to the NameServer and added NameServer test
- Loading branch information
Alex Wallar
committed
Sep 17, 2015
1 parent
9910b47
commit 19890a9
Showing
4 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
__all__ = ["Heart"] | ||
__all__ = ["Heart", "NameServer"] | ||
|
||
from heart import Heart | ||
from nameserver import NameServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "../src")) | ||
|
||
import jammi | ||
import rospy | ||
|
||
|
||
def test_start(): | ||
""" | ||
Tests that the NameServer is able to store "alive" masters | ||
""" | ||
|
||
rospy.init_node("jammi_test", anonymous=False) | ||
host, port = "localhost", 5005 | ||
rate = 20 | ||
ns = jammi.NameServer(host, port, 3) | ||
ns.start() | ||
heart = jammi.Heart(host, port, rate) | ||
heart.data["name"] = "test" | ||
heart.start() | ||
r = rospy.Rate(10) | ||
alive_set = set() | ||
for i in xrange(5): | ||
alive_set.update(set(ns.get_alive())) | ||
r.sleep() | ||
assert(list(alive_set)[0] == heart.data["name"]) | ||
heart.kill() | ||
ns.kill() | ||
|
||
|
||
if __name__ == "__main__": | ||
test_start() |