Add possibility to trace UEs
This commit is contained in:
@@ -17,3 +17,18 @@ test-fail:
|
||||
NetworkScript: ip a show dev TESTDEVICEDOESNOTEXIST
|
||||
IF: TESTDEVICEDOESNOTEXIST
|
||||
MTU: 123
|
||||
|
||||
test-trace:
|
||||
Host: localhost
|
||||
InitScript: ""
|
||||
TermScript: ""
|
||||
AttachScript: "true"
|
||||
DetachScript: "true"
|
||||
Tracing:
|
||||
# tttf: temp-trace-test-file
|
||||
Start: "rm -f /tmp/tttf; for i in {1..8}; do echo $i >> /tmp/tttf; sleep 1; done &"
|
||||
Stop: "while [[ $(wc -l /tmp/tttf) < 4 ]]; do sleep 1; done"
|
||||
Collect: "cp /tmp/tttf %%log_dir%%"
|
||||
NetworkScript: ip a show dev lo
|
||||
IF: lo
|
||||
MTU: 65536
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import logging
|
||||
import tempfile
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
stream=sys.stdout,
|
||||
@@ -16,6 +17,7 @@ import cls_cmd
|
||||
class TestModule(unittest.TestCase):
|
||||
def test_simple_module(self):
|
||||
c = cls_module.Module_UE("test", filename="tests/config/test_module_infra.yaml")
|
||||
self.assertFalse(c.trace)
|
||||
success = c.initialize()
|
||||
self.assertTrue(success)
|
||||
ip = c.attach()
|
||||
@@ -37,5 +39,20 @@ class TestModule(unittest.TestCase):
|
||||
logs = c.terminate()
|
||||
self.assertEqual(logs, None) # no tracing
|
||||
|
||||
def test_simple_trace(self):
|
||||
c = cls_module.Module_UE("test-trace", filename="tests/config/test_module_infra.yaml")
|
||||
self.assertTrue(c.trace)
|
||||
success = c.initialize()
|
||||
self.assertTrue(success)
|
||||
ip = c.attach()
|
||||
self.assertEqual(ip, "127.0.0.1")
|
||||
self.assertTrue(c.checkMTU())
|
||||
c.detach()
|
||||
tmp = tempfile.mkdtemp()
|
||||
log_file = c.terminate(log_dir=tmp)
|
||||
with cls_cmd.LocalCmd() as c:
|
||||
c.run(f'rm -rf {tmp}')
|
||||
self.assertEqual(log_file, [f"{tmp}/tttf"]) # matches test-trace UE collection file
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user