Skip to content

Commit 65dde59

Browse files
committed
sonic-yang-models: Update test cases in preparation for libyang3
This mostly simplifies the existing test cases and standardizes behavior where they may be incompatible with libyang3. The main goal is to have this in place before the migration to libyang3 to make it easier to evaluate the actual code review for porting aspects for libyang3. Convert some yang model test cases that use `eStr` for failure matching to use `eStrKey` instead to standardize expected failure matching so when messsages change they can be updated in one place instead of all over. Also, split out some new `eStrKey` values that are needed for libyang3 due to different messages, and document the libyang3 values needed once upgraded but keep libyang1 values for now. Finally, some tests were using both `eStr` and `eStrKey` and the `eStr` portion is not needed to perform a meaningful validation, plus the `eStr` in these cases are not valid for libyang3.
1 parent cfb4e3d commit 65dde59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+143
-152
lines changed

src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,27 @@ class Test_yang_models:
3939
def initTest(self):
4040
self.defaultYANGFailure = {
4141
'Must': ['Must condition', 'not satisfied'],
42-
'InvalidValue': ['Invalid value'],
43-
'LeafRef': ['Leafref', 'non-existing'],
42+
'InvalidValue': ['Invalid value'], # libyang3: ['Invalid', 'value', 'Data path']
43+
'LeafRef': ['Leafref', 'non-existing'], #libyang3: ['Invalid leafref', 'no target instance']
4444
'When': ['When condition', 'not satisfied'],
45-
'Pattern': ['pattern', 'does not satisfy'],
46-
'Mandatory': ['required element', 'Missing'],
45+
'Pattern': ['pattern', 'does not satisfy'], #libyang3: ['pattern', 'Unsatisfied pattern']
46+
'Mandatory': ['required element', 'Missing'], #libyang3: ['Mandatory node', 'does not exist']
4747
'Verify': ['verified'],
48-
'Range': ['does not satisfy', 'range'],
48+
'Range': ['does not satisfy', 'range'], #libyang3: ['Unsatisfied range']
4949
'MinElements': ['Too few'],
5050
'MaxElements': ['Too many'],
5151
'UnknownElement': ['Unknown element'],
52-
'None': []
52+
'None': [],
53+
# New keys are needed for libyang3's messages which are different. Go
54+
# ahead and add them now with the libyang1 values (which are duplicates
55+
# of the above). This will make migrating to libyang3 easier with less
56+
# code review.
57+
'Length': ['does not satisfy', 'range'], # libyang3: ['Unsatisfied length']
58+
'DecimalFractionExceed': ['Invalid value'], # libyang3: ['Value', 'exceeds defined number', 'fraction digits']
59+
'Bounds': ['Invalid value'], #libyang3 ['Value', 'out of type', 'min/max bounds'],
60+
'ListKey': ['Missing required element'], #libyang3 ['List instance is missing its key']
61+
'DateTime': ['pattern', 'does not satisfy'], #libyang3: ['Invalid date-and-time']
62+
'IPv4': ['pattern', 'does not satisfy'], #libyang3 ['Failed to convert IPv4 address'],
5363
}
5464

5565
self.ExceptionTests = { }

src/sonic-yang-models/tests/yang_model_tests/tests/asic-sensors.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"ASIC_SENSORS_INVALID_POLLER_INTERVAL": {
66
"desc": "Configure an invalid ASIC Sensors polling interval",
7-
"eStrKey" : "Pattern"
7+
"eStrKey" : "Range"
88
},
99
"ASIC_SENSORS_INVALID_POLLER_ADMIN_STATUS": {
1010
"desc": "Configure an invalid ASIC Sensors polling admin status",

src/sonic-yang-models/tests/yang_model_tests/tests/auto_techsupport.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
},
1313
"AUTO_TECHSUPPORT_OUT_OF_RANGE_DECIMAL": {
1414
"desc" : "Configure a value for core-uage outside the range [0, 100)",
15-
"eStr": "Value \"100.00\" does not satisfy the constraint \"0..99.99\" (range, length, or pattern)."
15+
"eStrKey": "Range"
1616
},
1717
"AUTO_TECHSUPPORT_VALID_DECIMAL_VALUE": {
1818
"desc" : "Configure a value for max_techsupport_size inside the range [0, 100)"
1919
},
2020
"AUTO_TECHSUPPORT_INVALID_FRACTION_DIGITS": {
2121
"desc" : "Configure a value for max_techsupport_size inside the range [0, 100) but with 3 fractional digits",
22-
"eStrKey": "InvalidValue"
22+
"eStrKey": "DecimalFractionExceed"
2323
},
2424
"AUTO_TECHSUPPORT_RATE_LIMIT_INTERVAL_TEST": {
2525
"desc" : "Configure and test the valid configuration"
@@ -29,13 +29,13 @@
2929
},
3030
"AUTO_TECHSUPPORT_INVALID_AVAILABLE_MEM_THRESHOLD": {
3131
"desc" : "Configure a value for available_mem_threshold inside the range [0, 100) but with 3 fractional digits",
32-
"eStrKey": "InvalidValue"
32+
"eStrKey": "DecimalFractionExceed"
3333
},
3434
"AUTO_TECHSUPPORT_GLOBAL_MEM_THRESHOLD_VALID": {
3535
"desc" : "Configure and test the valid configuration"
3636
},
3737
"AUTO_TECHSUPPORT_GLOBAL_MEM_THRESHOLD_INVALID_THRESHOLD": {
3838
"desc" : "Configure a value for available_mem_threshold inside the range [0, 100) but with 3 fractional digits",
39-
"eStrKey": "InvalidValue"
39+
"eStrKey": "DecimalFractionExceed"
4040
}
4141
}

src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
},
5252
"BGP_NEIGHBOR_NEG_INVALID_NAME": {
5353
"desc": "Incorrect neighbor name.",
54-
"eStrKey": "InvalidValue",
55-
"eStr": ["neighbor"]
54+
"eStrKey": "InvalidValue"
5655
},
5756
"BGP_NEIGHBOR_NEG_INVALID_ASN": {
5857
"desc": "Invalid local AS number.",
@@ -78,7 +77,7 @@
7877
},
7978
"BGP_NEIGHBOR_AF_NEG_INVALID_MAXTHRESHOLD": {
8079
"desc": "Invalid maximum prefix warning threshold in neighbor AF.",
81-
"eStrKey" : "Pattern"
80+
"eStrKey" : "Range"
8281
},
8382
"BGP_NEIGHBOR_AF_NEG_INVALID_SOFT_RECFG_IN": {
8483
"desc": "Invalid boolean value for soft reconfiguration-in in neighbor AF.",
@@ -118,11 +117,11 @@
118117
},
119118
"BGP_PEERGROUP_INVALID_HOPS": {
120119
"desc": "Invalid TTL hops for peergroup.",
121-
"eStrKey" : "Pattern"
120+
"eStrKey" : "Range"
122121
},
123122
"BGP_PEERGROUP_AF_INVALID_MAXTHRESHOLD": {
124123
"desc": "Invalid maximum prefix warning threshold in peergroup AF.",
125-
"eStrKey" : "Pattern"
124+
"eStrKey" : "Range"
126125
},
127126
"BGP_PEERGROUP_AF_INVALID_SOFT_RECFG_IN": {
128127
"desc": "Invalid boolean value for soft reconfiguration-in in peergroup AF.",
@@ -157,7 +156,7 @@
157156
},
158157
"BGP_NEIGHBOR_NEG_INVALID_HOPS": {
159158
"desc": "Invalid TTL hops for unnumbered interface neigbhor.",
160-
"eStrKey" : "Pattern"
159+
"eStrKey" : "Range"
161160
},
162161
"BGP_MONITORS_ALL_VALID": {
163162
"desc": "Configure BGP monitor table."

src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pool.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE": {
5050
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE pattern failure.",
51-
"eStr": "Invalid value"
51+
"eStrKey": "Bounds"
5252
},
5353
"BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE": {
5454
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE pattern failure.",

src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"DEVICE_METADATA_INCORRECT_BUFFER_MODEL_PATTERN": {
8282
"desc": "DEVICE_METADATA wrong value for BUFFER_MODEL field.",
83-
"eStr": ["pattern", "does not satisfy"]
83+
"eStrKey": "Pattern"
8484
},
8585
"DEVICE_METADATA_FRR_MGMT_FWK_CONFIG": {
8686
"desc": "Verifying FRR MGMT framework configuration."
@@ -118,7 +118,7 @@
118118
},
119119
"DEVICE_METADATA_INVALID_PEER_SWITCH": {
120120
"desc": "Verifying test fails with hostname that is too long",
121-
"eStrKey": "Range"
121+
"eStrKey": "Length"
122122
},
123123
"DEVICE_METADATA_VALID_STORAGE_DEVICE": {
124124
"desc": "Verifying valid storage device value"
@@ -169,7 +169,7 @@
169169
},
170170
"DEVICE_METADATA_INVALID_TIMEZONE": {
171171
"desc": "Verifying invalid timezone value",
172-
"eStrKey": "Range"
172+
"eStrKey": "Length"
173173
},
174174
"DEVICE_METADATA_VALID_CREATE_ONLY_CONFIG_DB_BUFFERS": {
175175
"desc": "Verifying the create_only_config_db_buffers value"

src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"DHCP_SERVER_IPV4_INCORRECT_NETMASK": {
1414
"desc": "Add netmask which is not in correct ip-prefix format.",
15-
"eStrKey": "Pattern"
15+
"eStrKey": "IPv4"
1616
},
1717
"DHCP_SERVER_IPV4_STATE_WRONG_VALUE": {
1818
"desc": "Configure wrong value for state.",

src/sonic-yang-models/tests/yang_model_tests/tests/fine-grained-ecmp.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
},
3939
"FG_NHG_MEMBER_TEST_MISSING_FG_NHG_REF": {
4040
"desc": "Fine-grained ECMP next-hop member configuration with missing FG_NHG reference in FG_NHG_MEMBER_LIST table.",
41-
"eStr": "Missing required element \"FG_NHG\" in \"FG_NHG_MEMBER_LIST\". "
41+
"eStrKey": "Mandatory"
4242
},
4343
"FG_NHG_PREFIX_TEST_MISSING_FG_NHG_REF": {
4444
"desc": "Fine-grained ECMP prefix configuration with missing FG_NHG reference in FG_NHG_PREFIX_LIST table.",
45-
"eStr": "Missing required element \"FG_NHG\" in \"FG_NHG_PREFIX_LIST\". "
45+
"eStrKey": "Mandatory"
4646
},
4747
"FG_NHG_MEMBER_TEST_MISSING_BANK": {
4848
"desc": "Fine-grained ECMP next-hop member configuration with missing bank in FG_NHG_MEMBER_LIST table.",
49-
"eStr": "Missing required element \"bank\""
49+
"eStrKey": "Mandatory"
5050
},
5151
"FG_NHG_PREFIX_TEST_DUPLICATE_ENTRY": {
5252
"desc": "Fine-grained ECMP prefix configuration with duplicate entry in FG_NHG_PREFIX_LIST table.",
@@ -56,4 +56,4 @@
5656
"desc": "Fine-grained ECMP next-hop member configuration with duplicate member in FG_NHG_MEMBER_LIST table.",
5757
"eStr": "Duplicated instance of \"FG_NHG_MEMBER_LIST\" list."
5858
}
59-
}
59+
}

src/sonic-yang-models/tests/yang_model_tests/tests/flex_counter.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
},
55
"FLEX_COUNTER_TABLE_WITH_INVALID_POLL_INTERVAL": {
66
"desc": "Out of range poll interval.",
7-
"eStrKey": "Range",
8-
"eStr": "100..4294967295"
7+
"eStrKey": "Range"
98
},
109
"FLEX_COUNTER_TABLE_WITH_VALID_BULK_CHUNK_SIZE": {
1110
"desc": "FLEX_COUNTER_TABLE_WITH_VALID_BULK_CHUNK_SIZE no failure."
1211
},
1312
"FLEX_COUNTER_TABLE_WITH_INVALID_BULK_CHUNK_SIZE": {
1413
"desc": "Out of range bulk chunk size.",
15-
"eStrKey": "Range",
16-
"eStr": "1..4294967295"
14+
"eStrKey": "Range"
1715
},
1816
"FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_VRF": {
1917
"desc": "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_VRF no failure."
@@ -23,7 +21,6 @@
2321
},
2422
"FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_INVALID_MAX_MATCH_COUNT": {
2523
"desc": "Out of range max_match_count.",
26-
"eStrKey": "Range",
27-
"eStr": "1..50"
24+
"eStrKey": "Range"
2825
}
2926
}

src/sonic-yang-models/tests/yang_model_tests/tests/kdump.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
},
1111
"KDUMP_WITH_INVALID_NUM_DUMPS": {
1212
"desc": "Configuring kdump config with a invalid number of allowed kdumps.",
13-
"eStr": ["pattern", "does not satisfy"]
13+
"eStrKey": "Range"
1414
},
1515
"KDUMP_WITH_INVALID_MEMORY": {
1616
"desc": "Configuring kdump config with invalid memory config.",
17-
"eStr": ["pattern", "does not satisfy"]
17+
"eStrKey": "Pattern"
1818
},
1919
"KDUMP_WITH_VALID_REMOTE_VALUES": {
2020
"desc": "Configuring the kdump with valid remote ssh values."

src/sonic-yang-models/tests/yang_model_tests/tests/kubernetes_master.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"KUBERNETES_MASTER_INVALID_PORT": {
1414
"desc": "Configure invalid PORT in kubernetes_master.",
15-
"eStrKey": "InvalidValue"
15+
"eStrKey": "Bounds"
1616
},
1717
"KUBERNETES_MASTER_INVALID_IP" : {
1818
"desc": "Configure invalid IP in kubernetes_master.",

src/sonic-yang-models/tests/yang_model_tests/tests/memory_statistics.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
},
55
"MEMORY_STATISTICS_WITH_INVALID_SAMPLING_INTERVAL": {
66
"desc": "Configuring memory statistics with an invalid sampling_interval ( out of acceptable range).",
7-
"eStrKey": "Range",
8-
"eStr": "3..15"
7+
"eStrKey": "Range"
98
},
109
"MEMORY_STATISTICS_WITH_INVALID_RETENTION_PERIOD": {
1110
"desc": "Configuring memory statistics with an invalid retention_period (out of acceptable range).",
12-
"eStrKey": "Range",
13-
"eStr": "1..30"
11+
"eStrKey": "Range"
1412
},
1513
"MEMORY_STATISTICS_WITH_ENABLE_FEATURE": {
1614
"desc": "Enabling memory statistics feature with valid values."
1715
}
18-
}
16+
}

src/sonic-yang-models/tests/yang_model_tests/tests/mgmt_port.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
},
1616
"MGMT_PORT_INVALID_SPEED": {
1717
"desc": "INVALID SPEED",
18-
"eStrKey": "Range",
19-
"eStr": ["10|100|1000"]
18+
"eStrKey": "Range"
2019
},
2120
"MGMT_PORT_INVALID_MTU": {
2221
"desc": "INVALID MTU",
23-
"eStrKey": "Range",
24-
"eStr": "1500..9216"
22+
"eStrKey": "Range"
2523
},
2624
"MGMT_PORT_DEFAULT_MTU": {
2725
"desc": "VALIDATE DEFAULT MTU",

src/sonic-yang-models/tests/yang_model_tests/tests/mirror_session.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
},
6161
"MIRROR_ERSPAN_ENTRY_WRONG_TTL": {
6262
"desc": "Configuring ERSPAN entry with invalid ttl",
63-
"eStr": "Invalid ttl value"
63+
"eStrKey": "Bounds"
6464
},
6565
"MIRROR_ERSPAN_ENTRY_WRONG_TTL_TYPE": {
6666
"desc": "Configuring ERSPAN entry with invalid ttl",

src/sonic-yang-models/tests/yang_model_tests/tests/nat.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
},
1414
"STATIC_NAPT_ENTRY_WRONG_GLOBAL_L4_PORT": {
1515
"desc": "Configuring a wrong global l4 port in Static NAPT table.",
16-
"eStrKey": "InvalidValue",
17-
"eStr": ["global_l4_port"]
16+
"eStrKey": "Bounds"
1817
},
1918
"STATIC_NAPT_ENTRY_WITHOUT_LOCAL_IP": {
2019
"desc": "Configuring a Static NAPT table without local ip.",
@@ -26,7 +25,7 @@
2625
},
2726
"STATIC_NAPT_ENTRY_INVALID_TWICE_NAT_ID": {
2827
"desc": "Configuring a invalid twice nat id in Static NAPT table.",
29-
"eStrKey": "InvalidValue"
28+
"eStrKey": "Bounds"
3029
},
3130
"STATIC_NAT_ENTRY_WITH_VALID_VALUES": {
3231
"desc": "Configuring the Static NAT table with valid values."
@@ -41,7 +40,7 @@
4140
},
4241
"STATIC_NAT_ENTRY_INVALID_TWICE_NAT_ID": {
4342
"desc": "Configuring a invalid twice nat id in Static NAT table.",
44-
"eStrKey": "InvalidValue"
43+
"eStrKey": "Bounds"
4544
},
4645
"NAT_GLOBAL_WITH_VALID_VALUES": {
4746
"desc": "Configuring a NAT Global table with valid values."
@@ -92,7 +91,7 @@
9291
},
9392
"NAT_BINDING_WITH_INVALID_TWICE_NAT_ID": {
9493
"desc": "Configuring a invalid twice nat id in NAT Binding table.",
95-
"eStrKey": "InvalidValue"
94+
"eStrKey": "Bounds"
9695
},
9796
"NAT_BINDING_WITHOUT_ACL_TABLE": {
9897
"desc": "Configuring a NAT Binding table without acl."

src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
"NEIGH_MISSING_IP": {
77
"desc": "Load NEIGH missing IP address",
8-
"eStr": ["Invalid JSON data"]
8+
"eStrKey": "ListKey"
99
},
1010

1111
"NEIGH_INVALID_VLAN": {
1212
"desc": "Load NEIGH missing VLAN",
13-
"eStr": ["does not satisfy the constraint"]
13+
"eStrKey": "Pattern"
1414
}
1515
}

src/sonic-yang-models/tests/yang_model_tests/tests/ntp.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
},
123123
"NTP_KEY_ID_INVALID": {
124124
"desc": "NTP authentication keys invalid key id",
125-
"eStrKey": "InvalidValue"
125+
"eStrKey": "Bounds"
126126
},
127127
"NTP_KEY_TRUSTED_INVALID": {
128128
"desc": "NTP authentication keys invalid trustiness",
@@ -134,6 +134,6 @@
134134
},
135135
"NTP_KEY_VALUE_INVALID": {
136136
"desc": "NTP authentication keys bad key value",
137-
"eStrKey": "Range"
137+
"eStrKey": "Length"
138138
}
139139
}

src/sonic-yang-models/tests/yang_model_tests/tests/nvgre.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
"NVGRE_TUNNEL_MAP_INVALID_VLAN_ID": {
1717
"desc": "Invalid VLAN ID",
18-
"eStrKey": "Pattern"
18+
"eStrKey": "Range"
1919
},
2020

2121
"NVGRE_TUNNEL_MAP_INVALID_VSID": {
2222
"desc": "INVALID VSID value for NVGRE_TUNNEL_MAP",
23-
"eStrKey": "Pattern"
23+
"eStrKey": "Range"
2424
}
25-
}
25+
}

src/sonic-yang-models/tests/yang_model_tests/tests/password_hardening.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
},
1616
"PASSWORD_BAD_HISTORY_CNT": {
1717
"desc": "Configure password history_cnt with out of range value",
18-
"eStrKey" : "InvalidValue"
18+
"eStrKey" : "Bounds"
1919
},
2020
"PASSWORD_BAD_LEN_MIN": {
2121
"desc": "Configure password len-min with out of range value",
22-
"eStrKey" : "Pattern"
22+
"eStrKey" : "Range"
2323
},
2424
"PASSWORD_BAD_EXPIRATION": {
2525
"desc": "Configure password expiration with out of range value",
26-
"eStrKey" : "Pattern"
26+
"eStrKey" : "Range"
2727
},
2828
"PASSWORD_BAD_EXPIRATION_WARN": {
2929
"desc": "Configure password expiration-warning with out of range value",
30-
"eStrKey" : "Pattern"
30+
"eStrKey" : "Range"
3131
}
32-
}
32+
}

0 commit comments

Comments
 (0)