Skip to content

Commit

Permalink
Updated FDB UT (#234)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Kokhan <[email protected]>
  • Loading branch information
andriy-kokhan authored Nov 26, 2023
1 parent e4d2ad1 commit 95edf36
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/ut/test_fdb_ut.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest
import json
from saichallenger.common.sai import Sai
from saichallenger.common.sai_data import SaiObjType

fdb_entry_attrs = Sai.get_obj_attrs("SAI_OBJECT_TYPE_FDB_ENTRY")


@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
Expand Down Expand Up @@ -29,15 +32,27 @@ def key(cls, npu, bvid, mac=None):
def test_create_dynamic(self, npu):
npu.create_fdb(npu.default_vlan_oid, TestFdbEntry.mac, npu.dot1q_bp_oids[0], "SAI_FDB_ENTRY_TYPE_DYNAMIC")

@pytest.mark.parametrize(
"attr,attr_type",
fdb_entry_attrs
)
@pytest.mark.dependency(depends=['TestFdbEntry::test_create_dynamic'])
def test_get_attr(self, npu, attr, attr_type):
status, data = npu.get_by_type(TestFdbEntry.key(npu, npu.default_vlan_oid), attr, attr_type, False)
if attr == "SAI_FDB_ENTRY_ATTR_ALLOW_MAC_MOVE":
assert status != "SAI_STATUS_SUCCESS", "Attribute invalid for dynamic MAC entry"
else:
npu.assert_status_success(status)

@pytest.mark.dependency(depends=['TestFdbEntry::test_create_dynamic'])
def test_create_duplicated_dynamic(self, npu):
status, _ = npu.create_fdb(npu.default_vlan_oid, TestFdbEntry.mac, npu.dot1q_bp_oids[0], "SAI_FDB_ENTRY_TYPE_DYNAMIC", do_assert=False)
assert status == "SAI_STATUS_ITEM_ALREADY_EXISTS"
assert status == "SAI_STATUS_ITEM_ALREADY_EXISTS", "Unexpected status returned"

@pytest.mark.dependency(depends=['TestFdbEntry::test_create_dynamic'])
def test_create_duplicated_static(self, npu):
status, _ = npu.create_fdb(npu.default_vlan_oid, TestFdbEntry.mac, npu.dot1q_bp_oids[0], "SAI_FDB_ENTRY_TYPE_STATIC", do_assert=False)
assert status == "SAI_STATUS_ITEM_ALREADY_EXISTS"
assert status == "SAI_STATUS_ITEM_ALREADY_EXISTS", "Unexpected status returned"

@pytest.mark.dependency(depends=['TestFdbEntry::test_create_dynamic'])
def test_change_to_static(self, npu):
Expand Down Expand Up @@ -87,7 +102,7 @@ def test_remove_dynamic(self, npu):
@pytest.mark.dependency(depends=['TestFdbEntry::test_create_dynamic'])
def test_duplicated_remove(self, npu):
status = npu.remove_fdb(npu.default_vlan_oid, TestFdbEntry.mac, do_assert=False)
assert status == "SAI_STATUS_ITEM_NOT_FOUND"
assert status == "SAI_STATUS_ITEM_NOT_FOUND", "Unexpected status returned"


class TestFlushFdbEntries:
Expand Down

0 comments on commit 95edf36

Please sign in to comment.