summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-13 21:58:19 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2024-01-15 09:27:33 +0100
commit05c6081099d1e25e35ab57efb6c2c42d76cab44c (patch)
tree0a6b5dd16f41d56ba430fedff34c6f4ff3638d9c
parentlib, mgmtd: add ability to set content type in get-data request (diff)
downloadfrr-05c6081099d1e25e35ab57efb6c2c42d76cab44c.tar.xz
frr-05c6081099d1e25e35ab57efb6c2c42d76cab44c.zip
tests: add tests for mgmt get-data with config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--tests/topotests/mgmt_oper/oper.py4
-rw-r--r--tests/topotests/mgmt_oper/r1/frr-simple.conf4
-rw-r--r--tests/topotests/mgmt_oper/simple-results/result-intf-description.json14
-rw-r--r--tests/topotests/mgmt_oper/simple-results/result-intf-eth0-only-config.json10
-rw-r--r--tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json25
-rw-r--r--tests/topotests/mgmt_oper/test_simple.py15
6 files changed, 69 insertions, 3 deletions
diff --git a/tests/topotests/mgmt_oper/oper.py b/tests/topotests/mgmt_oper/oper.py
index e3386067b..0f6c3cdf5 100644
--- a/tests/topotests/mgmt_oper/oper.py
+++ b/tests/topotests/mgmt_oper/oper.py
@@ -66,7 +66,7 @@ def do_oper_test(tgen, query_results):
r1 = tgen.gears["r1"].net
qcmd = (
- r"vtysh -c 'show mgmt get-data {}' "
+ r"vtysh -c 'show mgmt get-data {} {}' "
r"""| sed -e 's/"phy-address": ".*"/"phy-address": "rubout"/'"""
r"""| sed -e 's/"uptime": ".*"/"uptime": "rubout"/'"""
r"""| sed -e 's/"vrf": "[0-9]*"/"vrf": "rubout"/'"""
@@ -81,7 +81,7 @@ def do_oper_test(tgen, query_results):
if doreset:
doreset = False
expected = open(qr[1], encoding="ascii").read()
- output = r1.cmd_nostatus(qcmd.format(qr[0]))
+ output = r1.cmd_nostatus(qcmd.format(qr[0], qr[2] if len(qr) > 2 else ""))
try:
ojson = json.loads(output)
diff --git a/tests/topotests/mgmt_oper/r1/frr-simple.conf b/tests/topotests/mgmt_oper/r1/frr-simple.conf
index cf8ba160f..d262afe35 100644
--- a/tests/topotests/mgmt_oper/r1/frr-simple.conf
+++ b/tests/topotests/mgmt_oper/r1/frr-simple.conf
@@ -14,10 +14,12 @@ debug mgmt client backend
interface r1-eth0
ip address 1.1.1.1/24
+ description r1-eth0-desc
exit
interface r1-eth1 vrf red
ip address 3.3.3.1/24
+ description r1-eth1-desc
exit
ip route 11.11.11.11/32 1.1.1.2
-!ip route 13.13.13.13/32 3.3.3.2 vrf red \ No newline at end of file
+!ip route 13.13.13.13/32 3.3.3.2 vrf red
diff --git a/tests/topotests/mgmt_oper/simple-results/result-intf-description.json b/tests/topotests/mgmt_oper/simple-results/result-intf-description.json
new file mode 100644
index 000000000..8f8092ec1
--- /dev/null
+++ b/tests/topotests/mgmt_oper/simple-results/result-intf-description.json
@@ -0,0 +1,14 @@
+{
+ "frr-interface:lib": {
+ "interface": [
+ {
+ "name": "r1-eth0",
+ "description": "r1-eth0-desc"
+ },
+ {
+ "name": "r1-eth1",
+ "description": "r1-eth1-desc"
+ }
+ ]
+ }
+}
diff --git a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-only-config.json b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-only-config.json
new file mode 100644
index 000000000..adcf99053
--- /dev/null
+++ b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-only-config.json
@@ -0,0 +1,10 @@
+{
+ "frr-interface:lib": {
+ "interface": [
+ {
+ "name": "r1-eth0",
+ "description": "r1-eth0-desc"
+ }
+ ]
+ }
+}
diff --git a/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json
new file mode 100644
index 000000000..47c968625
--- /dev/null
+++ b/tests/topotests/mgmt_oper/simple-results/result-intf-eth0-with-config.json
@@ -0,0 +1,25 @@
+{
+ "frr-interface:lib": {
+ "interface": [
+ {
+ "name": "r1-eth0",
+ "vrf": "default",
+ "description": "r1-eth0-desc",
+ "state": {
+ "if-index": "rubout",
+ "mtu": 1500,
+ "mtu6": 1500,
+ "speed": 10000,
+ "metric": 0,
+ "phy-address": "rubout"
+ },
+ "frr-zebra:zebra": {
+ "state": {
+ "up-count": 0,
+ "down-count": 0
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/tests/topotests/mgmt_oper/test_simple.py b/tests/topotests/mgmt_oper/test_simple.py
index 008733ee7..2f75dfc82 100644
--- a/tests/topotests/mgmt_oper/test_simple.py
+++ b/tests/topotests/mgmt_oper/test_simple.py
@@ -112,6 +112,21 @@ def test_oper_simple(tgen):
'route[prefix="1.1.1.0/24"]/route-entry[protocol="connected"]/metric',
"simple-results/result-singleton-metric.json",
),
+ (
+ '/frr-interface:lib/interface[name="r1-eth0"]',
+ "simple-results/result-intf-eth0-with-config.json",
+ "with-config",
+ ),
+ (
+ '/frr-interface:lib/interface[name="r1-eth0"]',
+ "simple-results/result-intf-eth0-only-config.json",
+ "only-config",
+ ),
+ (
+ "/frr-interface:lib/interface/description",
+ "simple-results/result-intf-description.json",
+ "with-config",
+ ),
# Interface state
(
'/frr-interface:lib/interface[name="r1-eth0"]/state',