2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
Unit tests for testing with a CORE switch.
|
|
|
|
"""
|
2017-07-12 17:46:57 +01:00
|
|
|
from conftest import EMANE_SERVICES
|
|
|
|
|
2017-07-12 17:29:36 +01:00
|
|
|
from core.data import ConfigData
|
2017-07-10 17:25:33 +01:00
|
|
|
from core.emane.bypass import EmaneBypassModel
|
|
|
|
from core.emane.commeffect import EmaneCommEffectModel
|
|
|
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
|
|
|
from core.emane.nodes import EmaneNode
|
|
|
|
from core.emane.rfpipe import EmaneRfPipeModel
|
2017-07-10 18:44:10 +01:00
|
|
|
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
class TestGui:
|
2017-07-25 18:16:18 +01:00
|
|
|
def test_80211(self, core):
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
Test emane 80211 model.
|
|
|
|
|
|
|
|
:param conftest.Core core: core fixture to test with
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create emane node for networking the core nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
2017-07-10 17:25:33 +01:00
|
|
|
emane_node.setposition(x=80, y=50)
|
|
|
|
|
|
|
|
# set the emane model
|
2017-07-25 18:16:18 +01:00
|
|
|
core.set_emane_model(emane_node, EmaneIeee80211abgModel)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# create nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
|
|
|
core.create_node("n2", objid=2, position=(300, 150), services=EMANE_SERVICES, model="mdr")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# add interfaces to nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.add_interface(emane_node, "n1")
|
|
|
|
core.add_interface(emane_node, "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# instantiate session
|
2017-07-25 18:16:18 +01:00
|
|
|
core.session.instantiate()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# assert node directories created
|
2017-07-25 18:16:18 +01:00
|
|
|
core.assert_nodes()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# ping n2 from n1 and assert success
|
2017-07-25 18:16:18 +01:00
|
|
|
status = core.ping("n1", "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
assert not status
|
|
|
|
|
2017-07-25 18:16:18 +01:00
|
|
|
def test_rfpipe(self, core):
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
Test emane 80211 model.
|
|
|
|
|
|
|
|
:param conftest.Core core: core fixture to test with
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create emane node for networking the core nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
2017-07-10 17:25:33 +01:00
|
|
|
emane_node.setposition(x=80, y=50)
|
|
|
|
|
|
|
|
# set the emane model
|
2017-07-25 18:16:18 +01:00
|
|
|
core.set_emane_model(emane_node, EmaneRfPipeModel)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# create nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
|
|
|
core.create_node("n2", objid=2, position=(300, 150), services=EMANE_SERVICES, model="mdr")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# add interfaces to nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.add_interface(emane_node, "n1")
|
|
|
|
core.add_interface(emane_node, "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# instantiate session
|
2017-07-25 18:16:18 +01:00
|
|
|
core.session.instantiate()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# assert node directories created
|
2017-07-25 18:16:18 +01:00
|
|
|
core.assert_nodes()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# ping n2 from n1 and assert success
|
2017-07-25 18:16:18 +01:00
|
|
|
status = core.ping("n1", "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
assert not status
|
|
|
|
|
2017-07-25 18:16:18 +01:00
|
|
|
def test_commeffect(self, core):
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
Test emane 80211 model.
|
|
|
|
|
|
|
|
:param conftest.Core core: core fixture to test with
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create emane node for networking the core nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
2017-07-10 17:25:33 +01:00
|
|
|
emane_node.setposition(x=80, y=50)
|
|
|
|
|
|
|
|
# set the emane model
|
2017-07-25 18:16:18 +01:00
|
|
|
core.set_emane_model(emane_node, EmaneCommEffectModel)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
2017-07-12 17:29:36 +01:00
|
|
|
# configure emane to enable default connectivity
|
|
|
|
config_data = ConfigData(
|
|
|
|
node=emane_node.objid,
|
|
|
|
object="emane_commeffect",
|
|
|
|
type=2,
|
|
|
|
data_types=(11,),
|
|
|
|
data_values="defaultconnectivitymode=1"
|
|
|
|
)
|
2017-07-25 18:16:18 +01:00
|
|
|
EmaneCommEffectModel.configure_emane(core.session, config_data)
|
2017-07-12 17:29:36 +01:00
|
|
|
|
2017-07-10 17:25:33 +01:00
|
|
|
# create nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
|
|
|
core.create_node("n2", objid=2, position=(300, 150), services=EMANE_SERVICES, model="mdr")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# add interfaces to nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.add_interface(emane_node, "n1")
|
|
|
|
core.add_interface(emane_node, "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# instantiate session
|
2017-07-25 18:16:18 +01:00
|
|
|
core.session.instantiate()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# assert node directories created
|
2017-07-25 18:16:18 +01:00
|
|
|
core.assert_nodes()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# ping n2 from n1 and assert success
|
2017-07-25 18:16:18 +01:00
|
|
|
status = core.ping("n1", "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
assert not status
|
|
|
|
|
2017-07-25 18:16:18 +01:00
|
|
|
def test_bypass(self, core):
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
Test emane 80211 model.
|
|
|
|
|
|
|
|
:param conftest.Core core: core fixture to test with
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create emane node for networking the core nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
2017-07-10 17:25:33 +01:00
|
|
|
emane_node.setposition(x=80, y=50)
|
|
|
|
|
|
|
|
# set the emane model
|
2017-07-25 18:16:18 +01:00
|
|
|
core.set_emane_model(emane_node, EmaneBypassModel)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# create nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
|
|
|
core.create_node("n2", objid=2, position=(300, 150), services=EMANE_SERVICES, model="mdr")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# add interfaces to nodes
|
2017-07-25 18:16:18 +01:00
|
|
|
core.add_interface(emane_node, "n1")
|
|
|
|
core.add_interface(emane_node, "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# instantiate session
|
2017-07-25 18:16:18 +01:00
|
|
|
core.session.instantiate()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# assert node directories created
|
2017-07-25 18:16:18 +01:00
|
|
|
core.assert_nodes()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# ping n2 from n1 and assert success
|
2017-07-25 18:16:18 +01:00
|
|
|
status = core.ping("n1", "n2")
|
2017-07-10 17:25:33 +01:00
|
|
|
assert not status
|