parameterized emane tests, added tdma test, although it is currently failing
This commit is contained in:
parent
832f497d47
commit
14a5d11c4e
3 changed files with 40 additions and 112 deletions
|
@ -16,6 +16,7 @@ from core.emane.commeffect import EmaneCommEffectModel
|
||||||
from core.emane.emanemodel import EmaneModel
|
from core.emane.emanemodel import EmaneModel
|
||||||
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
||||||
from core.emane.rfpipe import EmaneRfPipeModel
|
from core.emane.rfpipe import EmaneRfPipeModel
|
||||||
|
from core.emane.tdma import EmaneTdmaModel
|
||||||
from core.enumerations import ConfigDataTypes, NodeTypes
|
from core.enumerations import ConfigDataTypes, NodeTypes
|
||||||
from core.enumerations import ConfigFlags
|
from core.enumerations import ConfigFlags
|
||||||
from core.enumerations import ConfigTlvs
|
from core.enumerations import ConfigTlvs
|
||||||
|
@ -48,7 +49,8 @@ EMANE_MODELS = [
|
||||||
EmaneRfPipeModel,
|
EmaneRfPipeModel,
|
||||||
EmaneIeee80211abgModel,
|
EmaneIeee80211abgModel,
|
||||||
EmaneCommEffectModel,
|
EmaneCommEffectModel,
|
||||||
EmaneBypassModel
|
EmaneBypassModel,
|
||||||
|
EmaneTdmaModel
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ from core.xml import xmlsession
|
||||||
_XML_VERSIONS = ["0.0", "1.0"]
|
_XML_VERSIONS = ["0.0", "1.0"]
|
||||||
_NODE_CLASSES = [nodes.PtpNet, nodes.HubNode, nodes.SwitchNode]
|
_NODE_CLASSES = [nodes.PtpNet, nodes.HubNode, nodes.SwitchNode]
|
||||||
|
|
||||||
class TestCore:
|
|
||||||
|
|
||||||
|
class TestCore:
|
||||||
@pytest.mark.parametrize("cls", _NODE_CLASSES)
|
@pytest.mark.parametrize("cls", _NODE_CLASSES)
|
||||||
def test_nodes(self, core, cls):
|
def test_nodes(self, core, cls):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Unit tests for testing with a CORE switch.
|
Unit tests for testing with a CORE switch.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from conftest import EMANE_SERVICES
|
from conftest import EMANE_SERVICES
|
||||||
|
|
||||||
from core.data import ConfigData
|
from core.data import ConfigData
|
||||||
|
@ -9,87 +12,10 @@ from core.emane.commeffect import EmaneCommEffectModel
|
||||||
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
||||||
from core.emane.nodes import EmaneNode
|
from core.emane.nodes import EmaneNode
|
||||||
from core.emane.rfpipe import EmaneRfPipeModel
|
from core.emane.rfpipe import EmaneRfPipeModel
|
||||||
|
from core.emane.tdma import EmaneTdmaModel
|
||||||
|
|
||||||
|
|
||||||
class TestGui:
|
def setup_commeffect(session, emane_node):
|
||||||
def test_80211(self, core):
|
|
||||||
"""
|
|
||||||
Test emane 80211 model.
|
|
||||||
|
|
||||||
:param conftest.Core core: core fixture to test with
|
|
||||||
"""
|
|
||||||
|
|
||||||
# create emane node for networking the core nodes
|
|
||||||
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
|
||||||
emane_node.setposition(x=80, y=50)
|
|
||||||
|
|
||||||
# set the emane model
|
|
||||||
core.set_emane_model(emane_node, EmaneIeee80211abgModel)
|
|
||||||
|
|
||||||
# create nodes
|
|
||||||
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")
|
|
||||||
|
|
||||||
# add interfaces to nodes
|
|
||||||
core.add_interface(emane_node, "n1")
|
|
||||||
core.add_interface(emane_node, "n2")
|
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
|
||||||
core.assert_nodes()
|
|
||||||
|
|
||||||
# ping n2 from n1 and assert success
|
|
||||||
status = core.ping("n1", "n2")
|
|
||||||
assert not status
|
|
||||||
|
|
||||||
def test_rfpipe(self, core):
|
|
||||||
"""
|
|
||||||
Test emane 80211 model.
|
|
||||||
|
|
||||||
:param conftest.Core core: core fixture to test with
|
|
||||||
"""
|
|
||||||
|
|
||||||
# create emane node for networking the core nodes
|
|
||||||
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
|
||||||
emane_node.setposition(x=80, y=50)
|
|
||||||
|
|
||||||
# set the emane model
|
|
||||||
core.set_emane_model(emane_node, EmaneRfPipeModel)
|
|
||||||
|
|
||||||
# create nodes
|
|
||||||
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")
|
|
||||||
|
|
||||||
# add interfaces to nodes
|
|
||||||
core.add_interface(emane_node, "n1")
|
|
||||||
core.add_interface(emane_node, "n2")
|
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
|
||||||
core.assert_nodes()
|
|
||||||
|
|
||||||
# ping n2 from n1 and assert success
|
|
||||||
status = core.ping("n1", "n2")
|
|
||||||
assert not status
|
|
||||||
|
|
||||||
def test_commeffect(self, core):
|
|
||||||
"""
|
|
||||||
Test emane 80211 model.
|
|
||||||
|
|
||||||
:param conftest.Core core: core fixture to test with
|
|
||||||
"""
|
|
||||||
|
|
||||||
# create emane node for networking the core nodes
|
|
||||||
emane_node = core.session.add_object(name="emane", cls=EmaneNode)
|
|
||||||
emane_node.setposition(x=80, y=50)
|
|
||||||
|
|
||||||
# set the emane model
|
|
||||||
core.set_emane_model(emane_node, EmaneCommEffectModel)
|
|
||||||
|
|
||||||
# configure emane to enable default connectivity
|
# configure emane to enable default connectivity
|
||||||
config_data = ConfigData(
|
config_data = ConfigData(
|
||||||
node=emane_node.objid,
|
node=emane_node.objid,
|
||||||
|
@ -98,31 +24,27 @@ class TestGui:
|
||||||
data_types=(11,),
|
data_types=(11,),
|
||||||
data_values="defaultconnectivitymode=1"
|
data_values="defaultconnectivitymode=1"
|
||||||
)
|
)
|
||||||
EmaneCommEffectModel.configure_emane(core.session, config_data)
|
EmaneCommEffectModel.configure_emane(session, config_data)
|
||||||
|
|
||||||
# create nodes
|
|
||||||
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")
|
|
||||||
|
|
||||||
# add interfaces to nodes
|
_EMANE_MODELS = [
|
||||||
core.add_interface(emane_node, "n1")
|
(EmaneIeee80211abgModel, None),
|
||||||
core.add_interface(emane_node, "n2")
|
(EmaneRfPipeModel, None),
|
||||||
|
(EmaneBypassModel, None),
|
||||||
|
(EmaneCommEffectModel, setup_commeffect),
|
||||||
|
(EmaneTdmaModel, None),
|
||||||
|
]
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
class TestEmane:
|
||||||
core.assert_nodes()
|
@pytest.mark.parametrize("model,setup", _EMANE_MODELS)
|
||||||
|
def test_models(self, core, model, setup):
|
||||||
# ping n2 from n1 and assert success
|
|
||||||
status = core.ping("n1", "n2")
|
|
||||||
assert not status
|
|
||||||
|
|
||||||
def test_bypass(self, core):
|
|
||||||
"""
|
"""
|
||||||
Test emane 80211 model.
|
Test emane models within a basic network.
|
||||||
|
|
||||||
:param conftest.Core core: core fixture to test with
|
:param conftest.Core core: core fixture to test with
|
||||||
|
:param model: emane model to test
|
||||||
|
:param func setup: setup function to configure emane node
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# create emane node for networking the core nodes
|
# create emane node for networking the core nodes
|
||||||
|
@ -130,7 +52,11 @@ class TestGui:
|
||||||
emane_node.setposition(x=80, y=50)
|
emane_node.setposition(x=80, y=50)
|
||||||
|
|
||||||
# set the emane model
|
# set the emane model
|
||||||
core.set_emane_model(emane_node, EmaneBypassModel)
|
core.set_emane_model(emane_node, model)
|
||||||
|
|
||||||
|
# run setup method, if needed
|
||||||
|
if setup:
|
||||||
|
setup(core.session, emane_node)
|
||||||
|
|
||||||
# create nodes
|
# create nodes
|
||||||
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")
|
||||||
|
|
Loading…
Reference in a new issue