parameterized emane tests, added tdma test, although it is currently failing

This commit is contained in:
Blake J. Harnden 2017-07-27 14:59:40 -07:00
parent 832f497d47
commit 14a5d11c4e
3 changed files with 40 additions and 112 deletions

View file

@ -21,8 +21,8 @@ from core.xml import xmlsession
_XML_VERSIONS = ["0.0", "1.0"]
_NODE_CLASSES = [nodes.PtpNet, nodes.HubNode, nodes.SwitchNode]
class TestCore:
class TestCore:
@pytest.mark.parametrize("cls", _NODE_CLASSES)
def test_nodes(self, core, cls):
"""

View file

@ -1,6 +1,9 @@
"""
Unit tests for testing with a CORE switch.
"""
import pytest
from conftest import EMANE_SERVICES
from core.data import ConfigData
@ -9,14 +12,39 @@ from core.emane.commeffect import EmaneCommEffectModel
from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emane.nodes import EmaneNode
from core.emane.rfpipe import EmaneRfPipeModel
from core.emane.tdma import EmaneTdmaModel
class TestGui:
def test_80211(self, core):
def setup_commeffect(session, emane_node):
# 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"
)
EmaneCommEffectModel.configure_emane(session, config_data)
_EMANE_MODELS = [
(EmaneIeee80211abgModel, None),
(EmaneRfPipeModel, None),
(EmaneBypassModel, None),
(EmaneCommEffectModel, setup_commeffect),
(EmaneTdmaModel, None),
]
class TestEmane:
@pytest.mark.parametrize("model,setup", _EMANE_MODELS)
def test_models(self, core, model, setup):
"""
Test emane 80211 model.
Test emane models within a basic network.
: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
@ -24,113 +52,11 @@ class TestGui:
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
config_data = ConfigData(
node=emane_node.objid,
object="emane_commeffect",
type=2,
data_types=(11,),
data_values="defaultconnectivitymode=1"
)
EmaneCommEffectModel.configure_emane(core.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
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_bypass(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, EmaneBypassModel)
core.set_emane_model(emane_node, model)
# run setup method, if needed
if setup:
setup(core.session, emane_node)
# create nodes
core.create_node("n1", objid=1, position=(150, 150), services=EMANE_SERVICES, model="mdr")