core-extra/daemon/tests/test_distributed.py

42 lines
1.3 KiB
Python

from core.emulator.data import NodeOptions
from core.emulator.session import Session
from core.nodes.base import CoreNode
from core.nodes.network import HubNode
class TestDistributed:
def test_remote_node(self, session: Session):
# given
server_name = "core2"
host = "127.0.0.1"
# when
session.distributed.add_server(server_name, host)
options = NodeOptions(server=server_name)
node = session.add_node(CoreNode, options=options)
session.instantiate()
# then
assert node.server is not None
assert node.server.name == server_name
assert node.server.host == host
def test_remote_bridge(self, session: Session):
# given
server_name = "core2"
host = "127.0.0.1"
session.distributed.address = host
# when
session.distributed.add_server(server_name, host)
node1 = session.add_node(HubNode)
options = NodeOptions(server=server_name)
node2 = session.add_node(HubNode, options=options)
session.add_link(node1.id, node2.id)
session.instantiate()
# then
assert node2.server is not None
assert node2.server.name == server_name
assert node2.server.host == host
assert len(session.distributed.tunnels) == 1