Skip to content

Commit

Permalink
Fix vrf UT failed issue (#2309)
Browse files Browse the repository at this point in the history
#### What I did
    Fix VRF bind/unbind UT failed issue.

#### How I did it
    Mock DBInterface.close() method.

#### How to verify it
    Add new UT.
    Pass all UT.

#### 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
liuh-80 authored and yxieca committed Sep 1, 2022
1 parent ec4b09f commit 1542e7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ip_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ def test_remove_interface_case_sensitive_mock_ipv6_w_apply_patch(self):
print(result.exit_code, result.output)
assert "converted ipv6 address to lowercase fc00::1~1126 with prefix /INTERFACE/Ethernet12| in value: /INTERFACE/Ethernet12|FC00::1~1126" in result.output

def test_intf_vrf_bind_unbind(self):
runner = CliRunner()
db = Db()
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

@classmethod
def teardown_class(cls):
Expand Down
3 changes: 3 additions & 0 deletions tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def connect_SonicV2Connector(self, db_name, retry_on=True):
def _subscribe_keyspace_notification(self, db_name, client):
pass

def mock_close(self, db_name):
pass

def config_set(self, *args):
pass
Expand Down Expand Up @@ -183,6 +185,7 @@ def keys(self, pattern='*'):


swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
swsssdk.interface.DBInterface.close = mock_close
mockredis.MockRedis.config_set = config_set
redis.StrictRedis = SwssSyncClient
SonicV2Connector.connect = connect_SonicV2Connector
Expand Down

0 comments on commit 1542e7a

Please sign in to comment.