From 95edf36d124f098d04b9f3ed984fe404959c9662 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sun, 26 Nov 2023 11:56:24 +0200 Subject: [PATCH] Updated FDB UT (#234) Signed-off-by: Andriy Kokhan --- tests/ut/test_fdb_ut.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/ut/test_fdb_ut.py b/tests/ut/test_fdb_ut.py index af9a4305..0faad360 100644 --- a/tests/ut/test_fdb_ut.py +++ b/tests/ut/test_fdb_ut.py @@ -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): @@ -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): @@ -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: