test/case: Add meta/play

Launches an interactive ipython environment, attached to Infix nodes.
This can be used as a playground for developing tests, testing out
NETCONF operations, etc.
This commit is contained in:
Tobias Waldekranz
2023-06-30 15:33:10 +02:00
committed by Joachim Wiberg
parent 6d6acda35d
commit be7b57412e
2 changed files with 22 additions and 0 deletions
+3
View File
@@ -24,5 +24,8 @@ test-run: | ~/.infix-test-venv
test-run-sh:
$(call test-env-run,/bin/sh)
test-run-play:
$(call test-env-run,$(test-dir)/case/meta/play.py)
~/.infix-test-venv:
$(test-dir)/docker/init-venv.sh $(test-dir)/docker/pip-requirements.txt
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env -S ipython3 -i
import json
import infamy
def jq(yangdata):
print(json.dumps(yangdata, indent=True))
env = infamy.Env()
ctrl = env.ptop.get_ctrl()
infixen = env.ptop.get_infixen()
for ix in infixen:
(_, cport), (_, ixport) = env.ptop.get_path(ctrl, ix)
print(f"Attaching to {ix}:{ixport} via {ctrl}:{cport}")
exec(f"{ix} = env.attach(\"{ix}\", \"{ixport}\")")
print("\nGLHF")