core test cleanup, conslidating network creation for link modification testing
This commit is contained in:
parent
14cb7dc251
commit
8f45e5c4da
3 changed files with 17 additions and 52 deletions
|
@ -88,27 +88,34 @@ class SimpleLxcNode(PyCoreNode):
|
||||||
self.up = True
|
self.up = True
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
# nothing to do if node is not up
|
||||||
if not self.up:
|
if not self.up:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# unmount all targets
|
||||||
while self._mounts:
|
while self._mounts:
|
||||||
source, target = self._mounts.pop(-1)
|
source, target = self._mounts.pop(-1)
|
||||||
self.umount(target)
|
self.umount(target)
|
||||||
|
|
||||||
|
# shutdown all interfaces
|
||||||
for netif in self.netifs():
|
for netif in self.netifs():
|
||||||
netif.shutdown()
|
netif.shutdown()
|
||||||
|
|
||||||
|
# attempt to kill node process and wait for termination of children
|
||||||
try:
|
try:
|
||||||
os.kill(self.pid, signal.SIGTERM)
|
os.kill(self.pid, signal.SIGTERM)
|
||||||
os.waitpid(self.pid, 0)
|
os.waitpid(self.pid, 0)
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.exception("error killing process")
|
logger.exception("error killing process")
|
||||||
|
|
||||||
|
# remove node directory if present
|
||||||
try:
|
try:
|
||||||
os.unlink(self.ctrlchnlname)
|
if os.path.exists(self.ctrlchnlname):
|
||||||
|
os.unlink(self.ctrlchnlname)
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.exception("error removing file")
|
logger.exception("error removing file")
|
||||||
|
|
||||||
|
# clear interface data, close client, and mark self and not up
|
||||||
self._netif.clear()
|
self._netif.clear()
|
||||||
self.vnodeclient.close()
|
self.vnodeclient.close()
|
||||||
self.up = False
|
self.up = False
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""
|
"""
|
||||||
Unit test fixture module.
|
Unit test fixture module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Unit tests for testing with a CORE switch.
|
Unit tests for testing with a CORE switch.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
from core.mobility import BasicRangeModel
|
from core.mobility import BasicRangeModel
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
|
@ -161,7 +164,6 @@ class TestCore:
|
||||||
core.assert_nodes()
|
core.assert_nodes()
|
||||||
|
|
||||||
# ping n2 from n1 and assert failure
|
# ping n2 from n1 and assert failure
|
||||||
import time
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
status = core.ping("n1", "n2")
|
status = core.ping("n1", "n2")
|
||||||
assert status
|
assert status
|
||||||
|
@ -173,22 +175,8 @@ class TestCore:
|
||||||
:param conftest.Core core: core fixture to test with
|
:param conftest.Core core: core fixture to test with
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# create switch
|
# create link network
|
||||||
ptp_node = core.session.add_object(cls=nodes.PtpNet)
|
ptp_node, interface_one, interface_two = core.create_link_network()
|
||||||
|
|
||||||
# create nodes
|
|
||||||
core.create_node("n1")
|
|
||||||
core.create_node("n2")
|
|
||||||
|
|
||||||
# add interfaces
|
|
||||||
interface_one = core.add_interface(ptp_node, "n1")
|
|
||||||
interface_two = core.add_interface(ptp_node, "n2")
|
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
|
||||||
core.assert_nodes()
|
|
||||||
|
|
||||||
# output csv index
|
# output csv index
|
||||||
bandwidth_index = 8
|
bandwidth_index = 8
|
||||||
|
@ -197,7 +185,6 @@ class TestCore:
|
||||||
stdout = core.iperf("n1", "n2")
|
stdout = core.iperf("n1", "n2")
|
||||||
assert stdout
|
assert stdout
|
||||||
value = int(stdout.split(',')[bandwidth_index])
|
value = int(stdout.split(',')[bandwidth_index])
|
||||||
print "bandwidth before: %s" % value
|
|
||||||
assert 900000 <= value <= 1100000
|
assert 900000 <= value <= 1100000
|
||||||
|
|
||||||
# change bandwidth in bits per second
|
# change bandwidth in bits per second
|
||||||
|
@ -219,22 +206,8 @@ class TestCore:
|
||||||
:param conftest.Core core: core fixture to test with
|
:param conftest.Core core: core fixture to test with
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# create switch
|
# create link network
|
||||||
ptp_node = core.session.add_object(cls=nodes.PtpNet)
|
ptp_node, interface_one, interface_two = core.create_link_network()
|
||||||
|
|
||||||
# create nodes
|
|
||||||
core.create_node("n1")
|
|
||||||
core.create_node("n2")
|
|
||||||
|
|
||||||
# add interfaces
|
|
||||||
interface_one = core.add_interface(ptp_node, "n1")
|
|
||||||
interface_two = core.add_interface(ptp_node, "n2")
|
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
|
||||||
core.assert_nodes()
|
|
||||||
|
|
||||||
# output csv index
|
# output csv index
|
||||||
loss_index = -2
|
loss_index = -2
|
||||||
|
@ -264,22 +237,8 @@ class TestCore:
|
||||||
:param conftest.Core core: core fixture to test with
|
:param conftest.Core core: core fixture to test with
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# create switch
|
# create link network
|
||||||
ptp_node = core.session.add_object(cls=nodes.PtpNet)
|
ptp_node, interface_one, interface_two = core.create_link_network()
|
||||||
|
|
||||||
# create nodes
|
|
||||||
core.create_node("n1")
|
|
||||||
core.create_node("n2")
|
|
||||||
|
|
||||||
# add interfaces
|
|
||||||
interface_one = core.add_interface(ptp_node, "n1")
|
|
||||||
interface_two = core.add_interface(ptp_node, "n2")
|
|
||||||
|
|
||||||
# instantiate session
|
|
||||||
core.session.instantiate()
|
|
||||||
|
|
||||||
# assert node directories created
|
|
||||||
core.assert_nodes()
|
|
||||||
|
|
||||||
# run ping for delay information
|
# run ping for delay information
|
||||||
stdout = core.ping_output("n1", "n2")
|
stdout = core.ping_output("n1", "n2")
|
||||||
|
|
Loading…
Add table
Reference in a new issue