Skip to content

Commit

Permalink
[GCU] Adding unit-test where path and ref paths are under the same YA…
Browse files Browse the repository at this point in the history
…NG container (#2047)

#### What I did
Did a debug session with Ping Mao and found this case is failing in her PR: sonic-net/sonic-buildimage#9545 I think it is an interesting case and I added it explicitly to GCU.

Adding unit-test where path and ref paths are under the same YANG container

[sonic-loopback-interface.yang](https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang) has:
```yang
    container sonic-loopback-interface {
        container LOOPBACK_INTERFACE {
            list LOOPBACK_INTERFACE_LIST {
                ...
                leaf name{
                    type string;
                }
                ...
            list LOOPBACK_INTERFACE_IPPREFIX_LIST {
                leaf name{
                    ...
                    type leafref {
                        path "../../LOOPBACK_INTERFACE_LIST/name";
                    }
                }
               ...
```

#### How I did it
Unit-test added

#### How to verify it
unit-test

#### Previous command output (if the output of a command-line utility has changed)

#### New command output (if the output of a command-line utility has changed)
  • Loading branch information
ghooo authored Feb 18, 2022
1 parent 37225a4 commit 15670bf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/generic_config_updater/gu_common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,20 @@ def test_find_ref_paths__whole_config_path__returns_all_refs(self):
# Assert
self.assertEqual(expected, actual)

def test_find_ref_paths__path_and_ref_paths_are_under_same_yang_container__returns_ref_paths(self):
# Arrange
path = "/LOOPBACK_INTERFACE/Loopback0"
expected = [
self.path_addressing.create_path(["LOOPBACK_INTERFACE", "Loopback0|10.1.0.32/32"]),
self.path_addressing.create_path(["LOOPBACK_INTERFACE", "Loopback0|1100:1::32/128"]),
]

# Act
actual = self.path_addressing.find_ref_paths(path, Files.CONFIG_DB_WITH_LOOPBACK_INTERFACES)

# Assert
self.assertEqual(expected, actual)

def test_find_ref_paths__does_not_remove_tables_without_yang(self):
# Arrange
config = Files.CONFIG_DB_AS_JSON # This has a table without yang named 'TABLE_WITHOUT_YANG'
Expand Down

0 comments on commit 15670bf

Please sign in to comment.