From 859deb3cc4a7f756f876db9d79da68d4c5b32a3a Mon Sep 17 00:00:00 2001 From: Mingzhi Leng Date: Mon, 27 Feb 2023 11:30:21 -0800 Subject: [PATCH] update unit test cases --- .../tests/fine-grained-ecmp.json | 44 +++- .../tests_config/fine_grained_ecmp.json | 207 ++++++++++++++++-- 2 files changed, 224 insertions(+), 27 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json index caeda39992eb..b502fb5dc5b6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json @@ -1,5 +1,43 @@ { - "VALID_FINE_GRAINED_ECMP": { - "desc": "VALID_FINE_GRAINED_ECMP no failure." + "FG_NHG_TEST": { + "desc": "Fine-grained ECMP next-hop group configuration in FG_NHG_LIST table." + }, + "FG_NHG_PREFIX_TEST": { + "desc": "Fine-grained ECMP prefix configuration in FG_NHG_PREFIX_LIST table." + }, + "FG_NHG_MEMBER_TEST": { + "desc": "Fine-grained ECMP next-hop member configuration in FG_NHG_MEMBER_LIST table." + }, + "FG_NHG_MEMBER_TEST_INVALID_IP": { + "desc": "Fine-grained ECMP next-hop member configuration with invalid IP value in FG_NHG_MEMBER_LIST table.", + "eStr": "Invalid value" + }, + "FG_NHG_PREFIX_TEST_INVALID_PREFIX":{ + "desc": "Fine-grained ECMP prefix configuration with invalid prefix value in FG_NHG_PREFIX_LIST table.", + "eStr": "Invalid value" + }, + "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { + "desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.", + "eStr": "Missing reference" + }, + "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { + "desc": "Fine-grained ECMP prefix configuration with missing FG_NHG reference in FG_NHG_PREFIX_LIST table.", + "eStr": "Missing reference" + }, + "FG_NHG_MEMBER_TEST_MISSING_BANK": { + "desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.", + "eStr": "Mandatory leaf 'bank' missing" + }, + "FG_NHG_TEST_DUPLICATE_ENTRY": { + "desc": "Fine-grained ECMP next-hop group configuration with duplicate entry in FG_NHG_LIST table.", + "eStr": "Duplicate entry" + }, + "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { + "desc": "Fine-grained ECMP prefix configuration with duplicate entry in FG_NHG_PREFIX_LIST table.", + "eStr": "Duplicate entry" + }, + "FG_NHG_MEMBER_TEST_DUPLICATE_MEMBER": { + "desc": "Fine-grained ECMP next-hop member configuration with duplicate member in FG_NHG_MEMBER_LIST table.", + "eStr": "Duplicate member" } -} \ No newline at end of file +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json index 27ae645734c9..67494e18ff9f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fine_grained_ecmp.json @@ -1,41 +1,200 @@ { - "VALID_FINE_GRAINED_ECMP":{ - "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp":{ - "sonic-fine-grained-ecmp:FG_NHG":{ - "FG_NHG_LIST":[ + "FG_NHG_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ { - "name":"fgnhg_v4", - "bucket_size": "120", + "name": "group1", + "bucket_size": 10, "match_mode": "nexthop-based" }, { - "name":"fgnhg_v6", - "bucket_size": "120", + "name": "group2", + "bucket_size": 20, + "match_mode": "route-based" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group1" + }, + { + "ip_prefix": "10.1.0.0/24", + "FG_NHG": "group2" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" + }, + { + "next_hop_ip": "10.0.0.2", + "FG_NHG": "group1", + "bank": 2, + "link": "Ethernet2" + }, + { + "next_hop_ip": "10.1.0.1", + "FG_NHG": "group2", + "bank": 3, + "link": "PortChannel1" + } + ] + } + } + }, + "FG_NHG_TEST_DUPLICATE_NAME": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 10, "match_mode": "nexthop-based" + }, + { + "name": "group1", + "bucket_size": 20, + "match_mode": "route-based" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_INVALID_IP": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "invalid_ip", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" } - ], - "FG_NHG_PREFIX_LIST":[ + ] + } + } + }, + "FG_NHG_PREFIX_TEST_INVALID_PREFIX": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ { - "ip_prefix":"100.50.25.12/32", - "FG_NHG": "fgnhg_v4" + "ip_prefix": "invalid_prefix", + "FG_NHG": "group1" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "bank": 1, + "link": "Ethernet1" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24" + } + ] + } + } + }, + "FG_NHG_MEMBER_TEST_MISSING_BANK": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "link": "Ethernet1" + } + ] + } + } + }, + "FG_NHG_TEST_DUPLICATE_ENTRY": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG": { + "FG_NHG_LIST": [ + { + "name": "group1", + "bucket_size": 16, + "match_mode": "nexthop-based" + }, + { + "name": "group1", + "bucket_size": 8, + "match_mode": "nexthop-based" + } + ] + } + } + }, + "FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_PREFIX": { + "FG_NHG_PREFIX_LIST": [ + { + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group1" }, { - "ip_prefix":"fc:05::/128", - "FG_NHG": "fgnhg_v6" + "ip_prefix": "10.0.0.0/24", + "FG_NHG": "group2" } - ], - "FG_NHG_MEMBER_LIST":[ + ] + } + } + }, + "FG_NHG_MEMBER_TEST_DUPLICATE_MEMBER": { + "sonic-fine-grained-ecmp:sonic-fine-grained-ecmp": { + "sonic-fine-grained-ecmp:FG_NHG_MEMBER": { + "FG_NHG_MEMBER_LIST": [ + { + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 1, + "link": "Ethernet1" + }, { - "next_hop_ip":"200.200.200.4", - "FG_NHG": "fgnhg_v4", - "bank": "0", - "link": "Ethernet8" + "next_hop_ip": "10.0.0.2", + "FG_NHG": "group1", + "bank": 2, + "link": "Ethernet2" }, { - "next_hop_ip":"200.200.200.5", - "FG_NHG": "fgnhg_v4", - "bank": "1", - "link": "Ethernet12" + "next_hop_ip": "10.0.0.1", + "FG_NHG": "group1", + "bank": 3, + "link": "Ethernet3" } ] }