2020-05-25 07:37:38 +01:00
|
|
|
from core.emulator.session import Session
|
2020-05-21 06:14:03 +01:00
|
|
|
from core.nodes.base import CoreNode
|
|
|
|
from core.nodes.network import HubNode
|
2019-10-24 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestDistributed:
|
2020-05-25 07:37:38 +01:00
|
|
|
def test_remote_node(self, session: Session):
|
2019-10-24 19:52:25 +01:00
|
|
|
# given
|
|
|
|
server_name = "core2"
|
|
|
|
host = "127.0.0.1"
|
|
|
|
|
|
|
|
# when
|
|
|
|
session.distributed.add_server(server_name, host)
|
2022-05-25 18:51:42 +01:00
|
|
|
node = session.add_node(CoreNode, server=server_name)
|
2020-02-14 21:18:05 +00:00
|
|
|
session.instantiate()
|
2019-10-24 19:52:25 +01:00
|
|
|
|
|
|
|
# then
|
|
|
|
assert node.server is not None
|
|
|
|
assert node.server.name == server_name
|
|
|
|
assert node.server.host == host
|
|
|
|
|
2020-05-25 07:37:38 +01:00
|
|
|
def test_remote_bridge(self, session: Session):
|
2019-10-24 19:52:25 +01:00
|
|
|
# given
|
|
|
|
server_name = "core2"
|
|
|
|
host = "127.0.0.1"
|
|
|
|
session.distributed.address = host
|
|
|
|
|
|
|
|
# when
|
|
|
|
session.distributed.add_server(server_name, host)
|
2022-03-18 19:31:04 +00:00
|
|
|
node1 = session.add_node(HubNode)
|
2022-05-25 18:51:42 +01:00
|
|
|
node2 = session.add_node(HubNode, server=server_name)
|
2022-03-18 19:31:04 +00:00
|
|
|
session.add_link(node1.id, node2.id)
|
2019-10-24 19:52:25 +01:00
|
|
|
session.instantiate()
|
|
|
|
|
|
|
|
# then
|
2022-03-18 19:31:04 +00:00
|
|
|
assert node2.server is not None
|
|
|
|
assert node2.server.name == server_name
|
|
|
|
assert node2.server.host == host
|
|
|
|
assert len(session.distributed.tunnels) == 1
|