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

[sonic-utilities] Unit test failed when building sonic-utilities #1761

Closed
Junchao-Mellanox opened this issue Aug 16, 2021 · 8 comments
Closed

Comments

@Junchao-Mellanox
Copy link
Collaborator

Junchao-Mellanox commented Aug 16, 2021

Description

I suppose this issue is introduced by commit: 920bb87 . And when I checkout the previous commit, no issue.

See unit test failure:

=================================== FAILURES ===================================
___ TestPathAddressing.test_find_ref_paths__path_is_table__returns_ref_paths ___

self = <tests.generic_config_updater.gu_common_test.TestPathAddressing testMethod=test_find_ref_paths__path_is_table__returns_ref_paths>

    def test_find_ref_paths__path_is_table__returns_ref_paths(self):
        # Arrange
        path = "/PORT"
        expected = [
            "/ACL_TABLE/DATAACL/ports/0",
            "/ACL_TABLE/EVERFLOW/ports/0",
            "/ACL_TABLE/EVERFLOWV6/ports/0",
            "/ACL_TABLE/EVERFLOWV6/ports/1",
            "/ACL_TABLE/NO-NSW-PACL-V4/ports/0",
            "/VLAN_MEMBER/Vlan1000|Ethernet0",
            "/VLAN_MEMBER/Vlan1000|Ethernet4",
            "/VLAN_MEMBER/Vlan1000|Ethernet8",
        ]

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

        # Assert
>       self.assertCountEqual(expected, actual)
E       AssertionError: Element counts were not equal:
E       First has 1, Second has 0:  '/ACL_TABLE/DATAACL/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOW/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOWV6/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOWV6/ports/1'
E       First has 1, Second has 0:  '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'

tests/generic_config_updater/gu_common_test.py:502: AssertionError
 TestPathAddressing.test_find_ref_paths__ref_is_in_leafref_union__returns_ref_paths

self = <tests.generic_config_updater.gu_common_test.TestPathAddressing testMethod=test_find_ref_paths__ref_is_in_leafref_union__returns_ref_paths>

    def test_find_ref_paths__ref_is_in_leafref_union__returns_ref_paths(self):
        # Arrange
        path = "/PORTCHANNEL/PortChannel0001"
        expected = [
            "/ACL_TABLE/NO-NSW-PACL-V4/ports/1",
        ]

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

        # Assert
>       self.assertCountEqual(expected, actual)
E       AssertionError: Element counts were not equal:
E       First has 1, Second has 0:  '/ACL_TABLE/NO-NSW-PACL-V4/ports/1'

tests/generic_config_updater/gu_common_test.py:482: AssertionError
 TestPathAddressing.test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths

self = <tests.generic_config_updater.gu_common_test.TestPathAddressing testMethod=test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths>

    def test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths(self):
        # Arrange
        path = "/PORT/Ethernet0"
        expected = [
            "/ACL_TABLE/NO-NSW-PACL-V4/ports/0",
            "/VLAN_MEMBER/Vlan1000|Ethernet0",
        ]

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

        # Assert
>       self.assertCountEqual(expected, actual)
E       AssertionError: Element counts were not equal:
E       First has 1, Second has 0:  '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'

tests/generic_config_updater/gu_common_test.py:440: AssertionError
_ TestPathAddressing.test_find_ref_paths__whole_config_path__returns_all_refs __

self = <tests.generic_config_updater.gu_common_test.TestPathAddressing testMethod=test_find_ref_paths__whole_config_path__returns_all_refs>

    def test_find_ref_paths__whole_config_path__returns_all_refs(self):
        # Arrange
        path = ""
        expected = [
            "/ACL_TABLE/DATAACL/ports/0",
            "/ACL_TABLE/EVERFLOW/ports/0",
            "/ACL_TABLE/EVERFLOWV6/ports/0",
            "/ACL_TABLE/EVERFLOWV6/ports/1",
            "/ACL_TABLE/NO-NSW-PACL-V4/ports/0",
            "/VLAN_MEMBER/Vlan1000|Ethernet0",
            "/VLAN_MEMBER/Vlan1000|Ethernet4",
            "/VLAN_MEMBER/Vlan1000|Ethernet8",
        ]

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

        # Assert
>       self.assertCountEqual(expected, actual)
E       AssertionError: Element counts were not equal:
E       First has 1, Second has 0:  '/ACL_TABLE/DATAACL/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOW/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOWV6/ports/0'
E       First has 1, Second has 0:  '/ACL_TABLE/EVERFLOWV6/ports/1'
E       First has 1, Second has 0:  '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'

tests/generic_config_updater/gu_common_test.py:522: AssertionError
 TestNoDependencyMoveValidator.test_validate__replace_whole_config_item_added_ref_added__failure

self = <tests.generic_config_updater.patch_sorter_test.TestNoDependencyMoveValidator testMethod=test_validate__replace_whole_config_item_added_ref_added__failure>

    def test_validate__replace_whole_config_item_added_ref_added__failure(self):
        # Arrange
        target_config = Files.SIMPLE_CONFIG_DB_INC_DEPS
        # prepare current config by removing an item and its ref from target config
        current_config = self.prepare_config(target_config, jsonpatch.JsonPatch([
            {"op": "replace", "path":"/ACL_TABLE/EVERFLOW/ports/0", "value":""},
            {"op": "remove", "path":"/PORT/Ethernet0"}
        ]))

        diff = ps.Diff(current_config, target_config)
        move = ps.JsonMove(diff, OperationType.REPLACE, [], [])

        # Act and assert
>       self.assertFalse(self.validator.validate(move, diff))
E       AssertionError: True is not false

tests/generic_config_updater/patch_sorter_test.py:951: AssertionError
 TestNoDependencyMoveValidator.test_validate__replace_whole_config_item_removed_ref_removed__false

self = <tests.generic_config_updater.patch_sorter_test.TestNoDependencyMoveValidator testMethod=test_validate__replace_whole_config_item_removed_ref_removed__false>

    def test_validate__replace_whole_config_item_removed_ref_removed__false(self):
        # Arrange
        current_config = Files.SIMPLE_CONFIG_DB_INC_DEPS
        # prepare target config by removing an item and its ref from current config
        target_config = self.prepare_config(current_config, jsonpatch.JsonPatch([
            {"op": "replace", "path":"/ACL_TABLE/EVERFLOW/ports/0", "value":""},
            {"op": "remove", "path":"/PORT/Ethernet0"}
        ]))

        diff = ps.Diff(current_config, target_config)
        move = ps.JsonMove(diff, OperationType.REPLACE, [], [])

        # Act and assert
>       self.assertFalse(self.validator.validate(move, diff))
E       AssertionError: True is not false

tests/generic_config_updater/patch_sorter_test.py:966: AssertionError
__ DeleteRefsMoveExtender.test_extend__path_with_direct_refs__extended_moves ___

self = <tests.generic_config_updater.patch_sorter_test.DeleteRefsMoveExtender testMethod=test_extend__path_with_direct_refs__extended_moves>

    def test_extend__path_with_direct_refs__extended_moves(self):
        self.verify(OperationType.REMOVE,
                    ["PORT", "Ethernet0"],
                    tc_ops=[{'op':'remove', 'path':'/PORT/Ethernet0'}],
                    ex_ops=[{'op': 'remove', 'path': '/VLAN_MEMBER/Vlan1000|Ethernet0'},
>                           {'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'}])

tests/generic_config_updater/patch_sorter_test.py:1513:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/generic_config_updater/patch_sorter_test.py:1544: in verify
    self.verify_moves(ex_ops, moves)
tests/generic_config_updater/patch_sorter_test.py:1548: in verify_moves
    self.assertCountEqual(ex_ops, moves_ops)
E   AssertionError: Element counts were not equal:
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'}
 DeleteRefsMoveExtender.test_extend__path_with_refs_to_children__extended_moves

self = <tests.generic_config_updater.patch_sorter_test.DeleteRefsMoveExtender testMethod=test_extend__path_with_refs_to_children__extended_moves>

    def test_extend__path_with_refs_to_children__extended_moves(self):
        self.verify(OperationType.REMOVE,
                    ["PORT"],
                    tc_ops=[{'op':'remove', 'path':'/PORT/Ethernet0'}],
                    ex_ops=[{'op': 'remove', 'path': '/VLAN_MEMBER/Vlan1000|Ethernet0'},
                            {'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'},
                            {'op': 'remove', 'path': '/VLAN_MEMBER/Vlan1000|Ethernet4'},
                            {'op': 'remove', 'path': '/ACL_TABLE/DATAACL/ports/0'},
                            {'op': 'remove', 'path': '/VLAN_MEMBER/Vlan1000|Ethernet8'},
                            {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOWV6/ports/0'},
                            {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOW/ports/0'},
>                           {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOWV6/ports/1'}])

tests/generic_config_updater/patch_sorter_test.py:1526:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/generic_config_updater/patch_sorter_test.py:1544: in verify
    self.verify_moves(ex_ops, moves)
tests/generic_config_updater/patch_sorter_test.py:1548: in verify_moves
    self.assertCountEqual(ex_ops, moves_ops)
E   AssertionError: Element counts were not equal:
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'}
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/DATAACL/ports/0'}
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOWV6/ports/0'}
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOW/ports/0'}
E   First has 1, Second has 0:  {'op': 'remove', 'path': '/ACL_TABLE/EVERFLOWV6/ports/1'}
_______ TestPatchSorter.test_sort__replacing_create_only_field__success ________

self = <tests.generic_config_updater.patch_sorter_test.TestPatchSorter testMethod=test_sort__replacing_create_only_field__success>

    def test_sort__replacing_create_only_field__success(self):
        # Arrange
        patch = jsonpatch.JsonPatch([{"op":"replace", "path": "/PORT/Ethernet0/lanes", "value":"67"}])

        # Act
>       actual = self.create_patch_sorter(Files.DPB_1_SPLIT_FULL_CONFIG).sort(patch)

tests/generic_config_updater/patch_sorter_test.py:1623:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <generic_config_updater.patch_sorter.PatchSorter object at 0x7feca7933278>
patch = <jsonpatch.JsonPatch object at 0x7feca9a9d080>
algorithm = <Algorithm.DFS: 1>

    def sort(self, patch, algorithm=Algorithm.DFS):
        current_config = self.config_wrapper.get_config_db_as_json()
        target_config = self.patch_wrapper.simulate_patch(patch, current_config)

        diff = Diff(current_config, target_config)

        sort_algorithm = self.sort_algorithm_factory.create(algorithm)
        moves = sort_algorithm.sort(diff)

        if moves is None:
>           raise GenericConfigUpdaterError("There is no possible sorting")
E           generic_config_updater.gu_common.GenericConfigUpdaterError: There is no possible sorting

generic_config_updater/patch_sorter.py:1006: GenericConfigUpdaterError
----------------------------- Captured stdout call -----------------------------
sonic_yang(3):Data Loading Failed:Missing required element "lanes" in "PORT_LIST".
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
sonic_yang(3):Data Loading Failed:Missing required element "lanes" in "PORT_LIST".
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
sonic_yang(3):Data Loading Failed:Missing required element "lanes" in "PORT_LIST".
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
sonic_yang(3):Data Loading Failed:Invalid value "Ethernet0" in "ports" element.
----------------------------- Captured stderr call -----------------------------
libyang[0]: Missing required element "lanes" in "PORT_LIST". (path: /sonic-port:sonic-port/PORT/PORT_LIST[name='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
libyang[0]: Missing required element "lanes" in "PORT_LIST". (path: /sonic-port:sonic-port/PORT/PORT_LIST[name='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
libyang[0]: Missing required element "lanes" in "PORT_LIST". (path: /sonic-port:sonic-port/PORT/PORT_LIST[name='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
libyang[0]: Invalid value "Ethernet0" in "ports" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0'])
------- generated xml file: /sonic/src/sonic-utilities/test-results.xml --------

----------- coverage: platform linux, python 3.7.3-final-0 -----------
Name                                                Stmts   Miss Branch BrPart  Cover
-------------------------------------------------------------------------------------
acl_loader/__init__.py                                  0      0      0      0   100%
acl_loader/main.py                                    585    272    268     34    47%
clear/__init__.py                                       0      0      0      0   100%
clear/bgp_frr_v6.py                                    44     44     12      0     0%
clear/bgp_quagga_v4.py                                 44     44     12      0     0%
clear/bgp_quagga_v6.py                                 44     44     12      0     0%
clear/main.py                                         211    121     48      7    38%
clear/plugins/__init__.py                               0      0      0      0   100%
config/__init__.py                                      0      0      0      0   100%
config/aaa.py                                         345    164    164     24    43%
config/chassis_modules.py                              18      1      2      0    95%
config/config_mgmt.py                                 361    236    124      8    32%
config/console.py                                     110      1     28      0    99%
config/feature.py                                      59      1     22      0    99%
config/kdump.py                                        29     18     10      0    28%
config/kube.py                                         65      2      8      0    97%
config/main.py                                       3439   1545   1435    191    50%
config/mclag.py                                       223     20    108     12    89%
config/muxcable.py                                    546    242    244     55    50%
config/nat.py                                         677    569    344      0    11%
config/plugins/__init__.py                              0      0      0      0   100%
config/plugins/mlnx.py                                131     87     36      1    28%
config/utils.py                                         3      0      0      0   100%
config/vlan.py                                        115     10     52      6    90%
config/vxlan.py                                       202     57    104     46    65%
connect/__init__.py                                     0      0      0      0   100%
connect/main.py                                        56     56     16      0     0%
consutil/__init__.py                                    0      0      0      0   100%
consutil/lib.py                                       232      7     58      2    97%
consutil/main.py                                       75      3     16      1    96%
counterpoll/__init__.py                                 0      0      0      0   100%
counterpoll/main.py                                   197     88     34     12    53%
crm/__init__.py                                         0      0      0      0   100%
crm/main.py                                           390     21    108     25    90%
debug/__init__.py                                       0      0      0      0   100%
debug/main.py                                         153    153     26      0     0%
dump/__init__.py                                        0      0      0      0   100%
dump/helper.py                                         20     12     14      1    26%
dump/match_infra.py                                   197     17     76      4    92%
fdbutil/__init__.py                                     0      0      0      0   100%
fdbutil/filter_fdb_entries.py                          79      7     30      4    88%
fwutil/__init__.py                                      5      5      0      0     0%
fwutil/lib.py                                         469    469    200      0     0%
fwutil/log.py                                          45     45      4      0     0%
fwutil/main.py                                        243    243     68      0     0%
generic_config_updater/__init__.py                      0      0      0      0   100%
generic_config_updater/generic_updater.py             213      3     40      1    98%
generic_config_updater/gu_common.py                   414     20    148     14    93%
generic_config_updater/patch_sorter.py                605     48    296     13    91%
pcieutil/__init__.py                                    0      0      0      0   100%
pcieutil/main.py                                      165     64     54      8    62%
pddf_fanutil/__init__.py                                0      0      0      0   100%
pddf_fanutil/main.py                                  112    112     44      0     0%
pddf_ledutil/__init__.py                                0      0      0      0   100%
pddf_ledutil/main.py                                   43     43     12      0     0%
pddf_psuutil/__init__.py                                0      0      0      0   100%
pddf_psuutil/main.py                                  128    128     50      0     0%
pddf_thermalutil/__init__.py                            0      0      0      0   100%
pddf_thermalutil/main.py                               77     77     32      0     0%
pfc/__init__.py                                         0      0      0      0   100%
pfc/main.py                                            93     93     26      0     0%
pfcwd/__init__.py                                       0      0      0      0   100%
pfcwd/main.py                                         291     79    112     12    67%
psuutil/__init__.py                                     0      0      0      0   100%
psuutil/main.py                                        80     59     14      1    23%
scripts/aclshow                                       127     11     60      2    91%
scripts/db_migrator.py                                369     78    154     36    76%
scripts/decode-syseeprom                              172     81     53     10    48%
scripts/disk_check.py                                  91      6     38      7    90%
scripts/dropconfig                                    219    104    112     15    45%
scripts/dropstat                                      222     21     86     17    88%
scripts/ecnconfig                                     234     58    130     26    70%
scripts/fanshow                                        63     10     18      6    80%
scripts/fast-reboot-dump.py                           250    120     66     10    49%
scripts/fdbshow                                        92      0     38      0   100%
scripts/gearboxutil                                   131     21     44     14    78%
scripts/intfstat                                      195     42     72     13    75%
scripts/intfutil                                      408     20    180     30    91%
scripts/ipintutil                                     173     15     64     10    89%
scripts/lldpshow                                      137     54     50      9    56%
scripts/mellanox_buffer_migrator.py                   250     16    126     14    92%
scripts/mmuconfig                                     119     29     54      7    71%
scripts/neighbor_advertiser                           332    170    114      9    44%
scripts/null_route_helper                             123      4     34      3    96%
scripts/pfcstat                                       157     23     52      8    84%
scripts/pg-drop                                       149     22     46     12    83%
scripts/port2alias                                     32      5     14      1    83%
scripts/portconfig                                    202     30     94     24    80%
scripts/portstat                                      309     54    108     25    79%
scripts/psushow                                        86      8     30      7    87%
scripts/queuestat                                     239     77     88     16    65%
scripts/route_check.py                                269      6    104     17    94%
scripts/sfpshow                                       211     34     56      6    85%
scripts/sonic_sku_create.py                           626    151    234     57    73%
scripts/vnet_route_check.py                           183     17     94     15    87%
scripts/watermarkstat                                 188     30     64     17    81%
setup.py                                                3      3      0      0     0%
sfputil/__init__.py                                     0      0      0      0   100%
sfputil/main.py                                       413    264    140      6    33%
show/__init__.py                                        0      0      0      0   100%
show/acl.py                                            21     11      6      0    37%
show/bgp_common.py                                    275     10    180     11    95%
show/bgp_frr_v4.py                                     58      2     20      1    96%
show/bgp_frr_v6.py                                     57      1     18      1    97%
show/bgp_quagga_v4.py                                  22     22      4      0     0%
show/bgp_quagga_v6.py                                  17     17      0      0     0%
show/chassis_modules.py                                73      7     22      4    88%
show/dropcounters.py                                   25      1      6      0    97%
show/feature.py                                       105      1     40      1    99%
show/fgnhg.py                                         124      1     68      0    99%
show/gearbox.py                                        14      3      0      0    79%
show/interfaces/__init__.py                           366    107    136     21    68%
show/interfaces/portchannel.py                        102      6     36      6    91%
show/kdump.py                                          59     47     28      0    14%
show/kube.py                                           41      2     10      0    96%
show/main.py                                          901    390    239     22    51%
show/muxcable.py                                      673    241    266     60    59%
show/nat.py                                            56     34      4      0    37%
show/platform.py                                       80     35     16      1    52%
show/plugins/__init__.py                                0      0      0      0   100%
show/plugins/mlnx.py                                   85     62     22      0    23%
show/processes.py                                      16      7      0      0    56%
show/reboot_cause.py                                   62      7     18      6    84%
show/sflow.py                                          59      5     18      5    87%
show/system_health.py                                 179     46     88     18    72%
show/vlan.py                                          103      2     40      0    99%
show/vnet.py                                          180    164     56      0     7%
show/vxlan.py                                         225     89     88     18    56%
show/warm_restart.py                                   93     84     34      0     7%
sonic_installer/__init__.py                             0      0      0      0   100%
sonic_installer/bootloader/__init__.py                  9      9      4      0     0%
sonic_installer/bootloader/aboot.py                   178    178     42      0     0%
sonic_installer/bootloader/bootloader.py               37     37      0      0     0%
sonic_installer/bootloader/grub.py                     60     60     10      0     0%
sonic_installer/bootloader/onie.py                     27     27      2      0     0%
sonic_installer/bootloader/uboot.py                    61     61     18      0     0%
sonic_installer/common.py                              25     25      4      0     0%
sonic_installer/exception.py                            2      2      0      0     0%
sonic_installer/main.py                               485    485    156      0     0%
sonic_package_manager/__init__.py                       2      0      0      0   100%
sonic_package_manager/constraint.py                    50      2     16      2    94%
sonic_package_manager/database.py                      86     25     20      1    70%
sonic_package_manager/dockerapi.py                    125     95     30      1    20%
sonic_package_manager/errors.py                        73      5     20      2    92%
sonic_package_manager/logger.py                        11      0      0      0   100%
sonic_package_manager/main.py                         225    104     54      3    47%
sonic_package_manager/manager.py                      439    104    152     24    73%
sonic_package_manager/manifest.py                      96      5     32      1    95%
sonic_package_manager/metadata.py                      77     38     20      3    45%
sonic_package_manager/package.py                       22      0      2      0   100%
sonic_package_manager/progress.py                      21     11      4      0    40%
sonic_package_manager/reference.py                     18      1      4      0    95%
sonic_package_manager/registry.py                      93     56     14      0    38%
sonic_package_manager/service_creator/__init__.py       1      0      0      0   100%
sonic_package_manager/service_creator/creator.py      250     29     84     20    85%
sonic_package_manager/service_creator/feature.py       63     20     20      4    59%
sonic_package_manager/service_creator/sonic_db.py      56     36      6      0    32%
sonic_package_manager/service_creator/utils.py          5      0      0      0   100%
sonic_package_manager/source.py                        62      4      8      1    93%
sonic_package_manager/utils.py                         16      4      4      1    65%
sonic_package_manager/version.py                       11      2      0      0    82%
ssdutil/__init__.py                                     0      0      0      0   100%
ssdutil/main.py                                        50     50      8      0     0%
undebug/__init__.py                                     0      0      0      0   100%
undebug/main.py                                       153    153     26      0     0%
utilities_common/__init__.py                            0      0      0      0   100%
utilities_common/bgp_util.py                          198     58     58      4    65%
utilities_common/cli.py                               335    104    196     24    63%
utilities_common/constants.py                          10      0      0      0   100%
utilities_common/db.py                                 23      2      6      0    93%
utilities_common/general.py                            18      0      6      0   100%
utilities_common/intf_filter.py                        30     18     20      1    34%
utilities_common/multi_asic.py                         97     17     44      3    79%
utilities_common/netstat.py                            37     11     18      6    62%
utilities_common/platform_sfputil_helper.py            46     28     10      1    38%
utilities_common/util_base.py                          49     23      8      1    51%
watchdogutil/__init__.py                                0      0      0      0   100%
watchdogutil/main.py                                   54     54     16      0     0%
-------------------------------------------------------------------------------------
TOTAL                                               26264  10261   9733   1209    58%
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml

=============================== warnings summary ===============================
generic_config_updater/gu_common.py:652
  /sonic/src/sonic-utilities/generic_config_updater/gu_common.py:652: DeprecationWarning: invalid escape sequence \[
    leaf_list_pattern = "^[^\[]+(?:\[\.='([^']*)'\])?$"

generic_config_updater/gu_common.py:666
  /sonic/src/sonic-utilities/generic_config_updater/gu_common.py:666: DeprecationWarning: invalid escape sequence \[
    table_keys_pattern = "^([^\[]+)(.*)$"

generic_config_updater/gu_common.py:675
  /sonic/src/sonic-utilities/generic_config_updater/gu_common.py:675: DeprecationWarning: invalid escape sequence \[
    key_value_pattern = "\[([^=]+)='([^']*)'\]"

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:187
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:187: DeprecationWarning: invalid escape sequence \h

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:401
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:401: DeprecationWarning: invalid escape sequence \[

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:1243
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:1243: DeprecationWarning: invalid escape sequence \e

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:187
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:187: DeprecationWarning: invalid escape sequence \h

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:401
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:401: DeprecationWarning: invalid escape sequence \[

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:1243
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:1243: DeprecationWarning: invalid escape sequence \e

.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:7
  /sonic/src/sonic-utilities/.eggs/tabulate-0.8.2-py3.7.egg/tabulate.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

tests/acl_loader_test.py::TestAclLoader::()::test_valid
  /usr/local/lib/python3.7/dist-packages/pyangbind/lib/yangtypes.py:375: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class TypedList(collections.MutableSequence):

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======= 9 failed, 1283 passed, 3 skipped, 11 warnings in 478.44 seconds ========
[  FAIL LOG END  ] [ target/python-wheels/sonic_utilities-1.2-py3-none-any.whl ]

Steps to reproduce the issue

  1. Checkout sonic-utilities hash 920bb87
  2. Make sonic-utilities

Describe the results you received

See unit test failure

Describe the results you expected

All unit test cases should pass

Additional information you deem important (e.g. issue happens only occasionally)

Output of show version

(paste your output here)
@ghooo
Copy link
Contributor

ghooo commented Aug 16, 2021

I did a dummy change and tested it in the online build, and I see the unit-tests are successful.

image

Maybe you need to sync sonic-buildimage because we had a bug fixed there and the sonic-utilities repo UTs. depend on this fix

@qiluo-msft
Copy link
Contributor

Seems not reproducible. Please check, if still have the issue, please reopen.

@Junchao-Mellanox
Copy link
Collaborator Author

@Junchao-Mellanox
Copy link
Collaborator Author

@qiluo-msft could you please reopen the issue?

@keboliu keboliu reopened this Aug 17, 2021
@Junchao-Mellanox
Copy link
Collaborator Author

@ghooo could you please take a look?

@ghooo
Copy link
Contributor

ghooo commented Aug 18, 2021

@Junchao-Mellanox I see you are building Azure.sonic-buildimage and not Azure.sonic-utilities which is not what I tried. The commit was reverted here, I will check soon why it caused a build failure and update accordingly.

@ghooo
Copy link
Contributor

ghooo commented Aug 27, 2021

I was able to generate the problem locally by setting-up sonic-buildimage and sonic-utilities from scratch, and not relaying on old builds.

The problem is that backlinks of port in sonic-port.yang are not retrieved correctly for ACL_TABLE.

The following unit-test shows the error can be reproduced just from sonic-yang-models and sonic-yang-mgmtand is not related to sonic-utilities:
 

def test_find_leaf_dependencies_acl_table_included(self):
        sy = sonic_yang.SonicYang(gu_common.YANG_DIR)
        sy.loadYangModel()
        sy.loadData(Files.CROPPED_CONFIG_DB_AS_JSON)
        xpath = "/sonic-port:sonic-port/PORT/PORT_LIST[name='Ethernet0']/name"
        expected =["/sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0']",
                   "/sonic-vlan:sonic-vlan/VLAN_MEMBER/VLAN_MEMBER_LIST[name='Vlan1000'][port='Ethernet0']/port"]
        actual = sy.find_data_dependencies(xpath)
        self.assertCountEqual(expected, actual)

Output:

E       AssertionError: Element counts were not equal:
E       First has 1, Second has 0:  "/sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4']/ports[.='Ethernet0']"

find_data_dependencies(xpath) is the function that retrieves the backlinks.

The problem is in sonic-nat.yang specifically these lines:

import sonic-acl {
 prefix sacl;
}

When commenting out these lines the issue is resolved. This issue seems to also have happened before, as someone else commented a similar import https://github.com/Azure/sonic-buildimage/blob/48ba459f9ffcf3c5623927ab893ac3f15063aee2/src/sonic-yang-models/yang-models/sonic-route-map.yang#L21

@ghooo ghooo self-assigned this Aug 27, 2021
qiluo-msft pushed a commit to sonic-net/sonic-buildimage that referenced this issue Sep 1, 2021
#### Why I did it
Fixing issue [[sonic-utilities] Unit test failed when building sonic-utilities #1761](sonic-net/sonic-utilities#1761)

Importing `sonic-acl` caused getting references by `backlinks()` to break, 

#### How I did it
solution is to comment out the importing statement as it is not used anyway.

#### How to verify it
Ran sonic-utilities unit-tests locally after the fix, and all passed.
@ghooo
Copy link
Contributor

ghooo commented Sep 1, 2021

Fix submitted here, and was tested here. This PR puts back the reverted code.

qiluo-msft pushed a commit that referenced this issue Sep 2, 2021
)

#### What I did
Implemented [JSON Patch Ordering using YANG Models Design Doc](https://github.com/Azure/SONiC/blob/master/doc/config-generic-update-rollback/Json_Patch_Ordering_using_YANG_Models_Design.md)

#### How to verify it
Unit-Tests

**NOTE: The code in this PR was [reverted](github.com/Azure/sonic-utilities/commit/0a145e8027380e8d4decb36bdfc647062c722612) before because of some [build issues](#1761). Build issues have been fixed [here](sonic-net/sonic-buildimage#8632). To check the original PR comments please go [here](#1599
@ghooo ghooo closed this as completed Sep 21, 2021
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this issue Apr 18, 2022
* d240291 Update port_rates & rif_rates lua scripts to convert poll_interval to MS (sonic-net#1855)
* a71a5d3 [acl mirror action] Mirror session ref count fix at acl rule attachment (sonic-net#1761)
* 197f427 Fix vs test failure in test_buffer_traditional (sonic-net#1881)
* 8471f42 Revert "[debugcounterorch] check if counter type is supported before querying… (sonic-net#1789)" (sonic-net#1884)

Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
malletvapid23 added a commit to malletvapid23/Sonic-Utility that referenced this issue Aug 3, 2023
…794)

#### What I did
Implemented [JSON Patch Ordering using YANG Models Design Doc](https://github.com/Azure/SONiC/blob/master/doc/config-generic-update-rollback/Json_Patch_Ordering_using_YANG_Models_Design.md)

#### How to verify it
Unit-Tests

**NOTE: The code in this PR was [reverted](github.com/Azure/sonic-utilities/commit/0a145e8027380e8d4decb36bdfc647062c722612) before because of some [build issues](sonic-net/sonic-utilities#1761). Build issues have been fixed [here](sonic-net/sonic-buildimage#8632). To check the original PR comments please go [here](sonic-net/sonic-utilities#1599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants