Skip to content

Commit

Permalink
Fix UT failed cause by change pycommon to use swsscommon (sonic-net#2085
Browse files Browse the repository at this point in the history
)

Fix UT failed cause by change sonic_py_common to use swss_common

#### Description
    Fix UT failed cause by change sonic_py_common to use swss_common, here is UT failed message:

          2022-02-28T09:26:11.4706067Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
          2022-02-28T09:26:11.4706457Z scripts/route_check.py:556: in main
          2022-02-28T09:26:11.4706805Z     ret, res= check_routes()
          2022-02-28T09:26:11.4707152Z scripts/route_check.py:491: in check_routes
          2022-02-28T09:26:11.4707567Z     rt_appl_miss = filter_out_local_interfaces(rt_appl_miss)
          2022-02-28T09:26:11.4708035Z scripts/route_check.py:352: in filter_out_local_interfaces
          2022-02-28T09:26:11.4708494Z     chassis_local_intfs = chassis.get_chassis_local_interfaces()
          2022-02-28T09:26:11.4708981Z utilities_common/chassis.py:7: in get_chassis_local_interfaces
          2022-02-28T09:26:11.4709703Z     chassisdb_conf=os.path.join('/usr/share/sonic/device/', platform, "chassisdb.conf")
          2022-02-28T09:26:11.4710280Z /usr/lib/python3.7/posixpath.py:94: in join
          2022-02-28T09:26:11.4710838Z     genericpath._check_arg_types('join', a, *p)
          2022-02-28T09:26:11.4711261Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    The UT failed because device_info.get_platform() return null, to fix this issue, add mock method for device_info.get_platform().

#### Motivation and Context
    pyswss will be deprecate, so sonic_py_common will changed to use swss_common.
    Some UT in this project failed because this change.

#### How Has This Been Tested?
    Pass all UT and sonic-buildimage E2E test.
  • Loading branch information
liuh-80 authored and vivekrnv committed Jun 23, 2022
1 parent b82dad1 commit 9e37ad6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import syslog
import time
from sonic_py_common import device_info
from unittest.mock import MagicMock, patch

import pytest
Expand Down Expand Up @@ -525,6 +526,7 @@ def test_server(self, mock_subs, mock_sel, mock_table, mock_conn):
self.init()
ret = 0

device_info.get_platform = MagicMock(return_value='unittest')
set_mock(mock_table, mock_conn, mock_sel, mock_subs)
for (i, ct_data) in test_data.items():
do_start_test("route_test", i, ct_data)
Expand Down

0 comments on commit 9e37ad6

Please sign in to comment.