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

Updated FDB UT #234

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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