Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libyang: upgrade to v3 step 2 -- port sonic-yang-models test cases #21719

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bradh352
Copy link
Contributor

@bradh352 bradh352 commented Feb 12, 2025

Why I did it

libyang3 porting.

Port of sonic-yang-model test cases

NOTE: this PR actually includes (as a squashed commits) PR #21679. Please review the individual commits (skipping the squashed commit) otherwise this may seem too large/confusing.

Depends PR #21679

Work item tracking

How I did it

Ported code

How to verify it

See test cases succeed in CI/CD

Which release branch to backport (provide reason below if selected)

N/A

Description for the changelog

libyang: upgrade to v3 step 2 - port sonic-yang-models test cases

Link to config_db schema for YANG module changes

N/A

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Brad House (@bradh352)

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 12, 2025
@bradh352 bradh352 changed the title libyang: upgrade to v3 step 2 - port sonic-yang-models test cases libyang: upgrade to v3 step 2 -- port sonic-yang-models test cases Feb 12, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 13, 2025
@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from bc318a9 to d7b6de2 Compare February 13, 2025 16:15
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 13, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 13, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 13, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 13, 2025
@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from d7b6de2 to 652397b Compare February 16, 2025 18:16
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from 652397b to 7d41fcd Compare February 16, 2025 18:23
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 16, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 16, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 16, 2025
@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from 7d41fcd to 395469b Compare February 17, 2025 19:39
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 17, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 17, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Feb 19, 2025
@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from 395469b to 97a95e4 Compare February 20, 2025 00:13
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from 97a95e4 to 2a00938 Compare February 20, 2025 13:54
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

It looks like there is a behavior difference between libyang1 and
libyang3 where a default value of 0 was actually treated the same
as not set, so now the `POLICER_PIR_WITHOUT_CIR` test case is
failing with:
```
ERROR    YANG-TEST:test_yang_model.py:303 POLICER_PIR_WITHOUT_CIR: Mismatch ["pir can't be configured without cir."] and failed to parse data tree: cbs can't be configured without cir.: Data path: /sonic-policer:sonic-policer/POLICER/POLICER_LIST[name='e3policer']/cbs
```

Get rid of this bogus default.
RFC 7950 defines an ordered-by clause when a list needs to maintain
its order:
https://datatracker.ietf.org/doc/html/rfc7950#section-7.7.7

The default ordering is "system", which means the user specified
order doesn't need to be preserved.  Prior to this libyang commit
there was no difference between system and user ordering:
CESNET/libyang@6cf1d16

Since SONiC depends on list ordering being maintained, either explicitly
due to the order actually mattering, or implicitly due to the reverse
translation performed during config valiation, we need to tag all
leaf-list references as `ordered-by user`.
For some reason after upgrading to libyang3, tests started throwing
these errors:
```
------------------- Test 247: DEVICE_METADATA DEFAULT VALUE FOR BGP_STATUS FIELD.---------------------
INFO     YANG-TEST:test_yang_model.py:193 Verify xpath: /sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname
INFO     YANG-TEST:test_yang_model.py:197 Verify dnode: /sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname
INFO     YANG-TEST:test_yang_model.py:200 Verify path value sonic-device_metadata:default_bgp_status is up in {'sonic-device_metadata:hostname': 'DUT-ASW', 'sonic-device_metadata:platform': 'Stone-DX010', 'sonic-device_metadata:default_pfcwd_status': 'disable', 'sonic-device_metadata:bgp_asn': 65000, 'sonic-device_metadata:frr_mgmt_framework_config': False, 'sonic-device_metadata:synchronous_mode': 'enable', 'sonic-device_metadata:yang_config_validation': 'disable', 'sonic-device_metadata:suppress-fib-pending': 'disabled', 'sonic-device_metadata:timezone': 'UTC', 'sonic-device_metadata:nexthop_group': 'disabled'}
ERROR    YANG-TEST:test_yang_model.py:29  Exception >assert 'sonic-device_metadata:default_bgp_status' in {'sonic-device_metadata:bgp_asn': 65000, 'sonic-device_metadata:default_pfcwd_status': 'disable', 'sonic-device_metadata:frr_mgmt_framework_config': False, 'sonic-device_metadata:hostname': 'DUT-ASW', ...}< in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:201
ERROR    YANG-TEST:test_yang_model.py:29  Exception >DEVICE_METADATA_DEFAULT_BGP_STATUS: Mismatch ['verified'] and < in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:234
INFO     YANG-TEST:test_yang_model.py:238 DEVICE_METADATA DEFAULT VALUE FOR BGP_STATUS FIELD. Failed

INFO     YANG-TEST:test_yang_model.py:159
------------------- Test 248: DEVICE_METADATA DEFAULT VALUE FOR DOCKER_ROUTING_CONFIG_MODE FIELD.---------------------
INFO     YANG-TEST:test_yang_model.py:193 Verify xpath: /sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname
INFO     YANG-TEST:test_yang_model.py:197 Verify dnode: /sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname
INFO     YANG-TEST:test_yang_model.py:200 Verify path value sonic-device_metadata:docker_routing_config_mode is unified in {'sonic-device_metadata:hostname': 'DUT-CSW', 'sonic-device_metadata:platform': 'Stone-DX010', 'sonic-device_metadata:default_pfcwd_status': 'disable', 'sonic-device_metadata:bgp_asn': 65001, 'sonic-device_metadata:frr_mgmt_framework_config': False, 'sonic-device_metadata:synchronous_mode': 'enable', 'sonic-device_metadata:yang_config_validation': 'disable', 'sonic-device_metadata:suppress-fib-pending': 'disabled', 'sonic-device_metadata:timezone': 'UTC', 'sonic-device_metadata:nexthop_group': 'disabled'}
ERROR    YANG-TEST:test_yang_model.py:29  Exception >assert 'sonic-device_metadata:docker_routing_config_mode' in {'sonic-device_metadata:bgp_asn': 65001, 'sonic-device_metadata:default_pfcwd_status': 'disable', 'sonic-device_metadata:frr_mgmt_framework_config': False, 'sonic-device_metadata:hostname': 'DUT-CSW', ...}< in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:201
ERROR    YANG-TEST:test_yang_model.py:29  Exception >DEVICE_METADATA_DEFAULT_DOCKER_ROUTING_CONFIG_MODE: Mismatch ['verified'] and < in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:234
INFO     YANG-TEST:test_yang_model.py:238 DEVICE_METADATA DEFAULT VALUE FOR DOCKER_ROUTING_CONFIG_MODE FIELD. Failed

INFO     YANG-TEST:test_yang_model.py:159
```

The "fix" is to simply mov those 2 leaf nodes lower in the schema and it
fixes the issue.

This probably needs to be reported to libyang as the schema appears
valid.
@bradh352 bradh352 force-pushed the bradh352/libyang3-pr1 branch from 2a00938 to f09dbeb Compare February 21, 2025 01:56
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants