Skip to content

Commit 6ca8e85

Browse files
liuh-80preetham-singh
authored andcommitted
Fix vrf UT failed issue (sonic-net#2309)
#### 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)
1 parent 1df95e8 commit 6ca8e85

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/ip_config_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ def test_remove_interface_case_sensitive_mock_ipv6_w_apply_patch(self):
221221
print(result.exit_code, result.output)
222222
assert "converted ipv6 address to lowercase fc00::1~1126 with prefix /INTERFACE/Ethernet12| in value: /INTERFACE/Ethernet12|FC00::1~1126" in result.output
223223

224+
def test_intf_vrf_bind_unbind(self):
225+
runner = CliRunner()
226+
db = Db()
227+
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}
228+
229+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj)
230+
print(result.exit_code, result.output)
231+
assert result.exit_code == 0
232+
233+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj)
234+
print(result.exit_code, result.output)
235+
assert result.exit_code == 0
224236

225237
@classmethod
226238
def teardown_class(cls):

tests/mock_tables/dbconnector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def connect_SonicV2Connector(self, db_name, retry_on=True):
6060
def _subscribe_keyspace_notification(self, db_name, client):
6161
pass
6262

63+
def mock_close(self, db_name):
64+
pass
6365

6466
def config_set(self, *args):
6567
pass
@@ -201,6 +203,7 @@ def get(self, counter, name):
201203

202204

203205
swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
206+
swsssdk.interface.DBInterface.close = mock_close
204207
mockredis.MockRedis.config_set = config_set
205208
redis.StrictRedis = SwssSyncClient
206209
SonicV2Connector.connect = connect_SonicV2Connector

0 commit comments

Comments
 (0)