osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38065?usp=email )


Change subject: testenv: support obtaining talloc reports
......................................................................

testenv: support obtaining talloc reports

Allow setting vty_port= and vty_host= (default: 127.0.0.1) for SUT
components in testenv.cfg. Pass the values as OSMO_SUT_PORT and
OSMO_SUT_HOST to the testsuite, so ttcn3-tcpdump-stop.sh generates
talloc reports after running test cases.

The next patch will add vty_port/vty_host to existing testenv.cfg files.

I have considered enabling the talloc report only conditionally (e.g.
with a --talloc-report parameter). But previous behavior in
docker-playground was also that we created them unconditionally where
OSMO_SUT_PORT/HOST was set, and they are generated almost instantly so
it did not seem necessary to make this conditionally.

Related: OS#6552
Change-Id: I50a7035f072668ca2ab65de1bc1f194da8b18610
---
M _testenv/README.md
M _testenv/testenv/testenv_cfg.py
M _testenv/testenv/testsuite.py
3 files changed, 40 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/65/38065/1

diff --git a/_testenv/README.md b/_testenv/README.md
index 4886786..8562063 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -37,6 +37,7 @@
 make=osmo-mgw
 package=osmo-mgw
 copy=osmo-mgw.cfg
+vty_port=4243
 ```

 ### Keys
@@ -90,6 +91,13 @@
   below for `PATH`. A `TESTENV_CLEAN_REASON` env var is set to `prepare`,
   `crashed` or `finished` depending on when the script runs.

+* `vty_port`: optionally set the VTY port for the SUT component to obtain a
+  talloc report after each test case has been executed. If this is not set, no
+  talloc reports will be obtained.
+
+* `vty_host`: optionally set the VTY host for the SUT component to be used when
+  obtaining a talloc report. If this is not set, `127.0.0.1` is used.
+
 ### PATH

 Executables mentioned in `program=`, `prepare=`, `setup=` and `clean=` run
diff --git a/_testenv/testenv/testenv_cfg.py b/_testenv/testenv/testenv_cfg.py
index 64f2423..9642ae8 100644
--- a/_testenv/testenv/testenv_cfg.py
+++ b/_testenv/testenv/testenv_cfg.py
@@ -49,6 +49,27 @@
             del cfg[section][key]


+def get_vty_host_port(cfg, path=None):
+    host = "127.0.0.1"
+    port = None
+
+    for section in cfg:
+        if "vty_port" in cfg[section]:
+            if port:
+                logging.error(f"Error in {path}, section {section}:")
+                logging.error("  Found vty_port in multiple sections. This is 
not supported.")
+                sys.exit(1)
+            port = cfg[section]["vty_port"]
+        if "vty_host" in cfg[section]:
+            if not port:
+                logging.error(f"Error in {path}, section {section}:")
+                logging.error("  Found vty_host in section without vty_port.")
+                sys.exit(1)
+            host = cfg[section]["vty_host"]
+
+    return host, port
+
+
 def verify(cfg, path):
     keys_valid_testsuite = [
         "clean",
@@ -64,6 +85,8 @@
         "prepare",
         "program",
         "setup",
+        "vty_host",
+        "vty_port",
     ]
     keys_invalid = {
         "configs": "config",
@@ -108,6 +131,8 @@
             logging.error("If this is on purpose, set make=no.")
             exit_error_readme()

+    get_vty_host_port(cfg, path)
+

 def raise_error_config_arg(glob_result):
     valid = []
diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py
index a46d5a9..d14d36f 100644
--- a/_testenv/testenv/testsuite.py
+++ b/_testenv/testenv/testsuite.py
@@ -165,6 +165,13 @@
     env = {
         "TTCN3_PCAP_PATH": os.path.join(testenv.testdir.testdir, "testsuite"),
     }
+
+    # Let ttcn3-tcpdump-stop.sh retrieve talloc reports
+    host, port = testenv.testenv_cfg.get_vty_host_port(cfg)
+    if port:
+        env["OSMO_SUT_HOST"] = host
+        env["OSMO_SUT_PORT"] = port
+
     env = testenv.cmd.generate_env(env, testenv.args.podman)

     cmd = [start_testsuite, suite, section_data["config"]]

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38065?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I50a7035f072668ca2ab65de1bc1f194da8b18610
Gerrit-Change-Number: 38065
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to