)
-def init(ctx: Test) -> Tinc:
- """Initialize a node."""
-
- node = ctx.node()
- stdin = f"""
- init {node}
- set Port 0
- set Address localhost
- set DeviceType dummy
- """
- node.cmd(stdin=stdin)
- return node
-
-
def try_dot(src: str) -> None:
"""Try passing graph source through the dot binary, if it's present."""
try:
check.equals(node, bar.name)
-def run_unconnected_tests(foo: Tinc) -> None:
+def run_unconnected_tests(foo: Tinc, bar: Tinc) -> None:
"""Run online tests with unconnected nodes."""
log.info("dump invalid type")
check.lines(out, 1)
check.is_in("<control>", out)
- log.info("dump unconnected nodes")
- for arg in (("nodes",), ("reachable", "nodes")):
- out, _ = foo.cmd("dump", *arg)
- check.lines(out, 1)
- check.is_in(f"{foo} id ", out)
+ log.info("%s knows about %s", foo, bar)
+ out, _ = foo.cmd("dump", "nodes")
+ check.lines(out, 2)
+ check.is_in(f"{foo} id ", out)
+ check.is_in(f"{bar} id ", out)
+
+ log.info("%s can only reach itself", foo)
+ out, _ = foo.cmd("dump", "reachable", "nodes")
+ check.lines(out, 1)
+ check.is_in(f"{foo} id ", out)
def run_connected_tests(foo: Tinc, bar: Tinc) -> None:
def run_tests(ctx: Test) -> None:
"""Run all tests."""
- foo = init(ctx)
- bar = ctx.node()
+ foo, bar = ctx.node(init=True), ctx.node()
log.info("set %s subnets", foo)
for sub in SUBNETS_FOO:
for sub in SUBNETS_BAR:
bar.cmd("add", "Subnet", sub)
- run_unconnected_tests(foo)
+ run_unconnected_tests(foo, bar)
log.info("start %s", bar)
foo.add_script(bar.script_up)