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

Adding new Test Scripts for create set and remove on the api attributes #195

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion common/sai_client/sai_thrift_client/sai_thrift_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def object_id(oid):
"16" => 16
"oid:0x10" => 16
"""
if oid == None or oid == 'null':
if oid == None or oid == 'null' or oid == 'SAI_NULL_OBJECT_ID':
return 0
if isinstance(oid, str) and oid.startswith('oid:0x'):
return int(oid[4:], 16)
Expand Down
11 changes: 7 additions & 4 deletions common/sai_npu.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ def set_sku_mode(self, sku):
# Remove existing ports
num_ports = len(self.dot1q_bp_oids)
for idx in range(num_ports):
self.remove_vlan_member(self.default_vlan_oid, self.dot1q_bp_oids[idx])
self.remove(self.dot1q_bp_oids[idx])
oid = self.get(self.port_oids[idx], ["SAI_PORT_ATTR_PORT_SERDES_ID"]).oid()
if oid != "oid:0x0":
oid = self.get_vlan_member(self.default_vlan_oid, self.dot1q_bp_oids[idx])
if oid:
self.remove(oid)
self.remove(self.dot1q_bp_oids[idx])
status, data = self.get(self.port_oids[idx], ["SAI_PORT_ATTR_PORT_SERDES_ID"], do_assert=False)
serdes_oid = data.oid()
if status == "SAI_STATUS_SUCCESS" and serdes_oid != "oid:0x0":
self.remove(serdes_oid)
self.remove(self.port_oids[idx])
self.port_oids.clear()
self.dot1q_bp_oids.clear()
Expand Down
56 changes: 56 additions & 0 deletions tests/api/test_dash_acl_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

from pprint import pprint

import pytest

@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
testbed = testbed_instance
if testbed is not None and len(testbed.dpu) != 1:
pytest.skip("invalid for \"{}\" testbed".format(testbed.name))

@pytest.mark.dpu
vikumarks marked this conversation as resolved.
Show resolved Hide resolved
class TestSaiDashAclGroup:
# object with no attributes

def test_dash_acl_group_create(self, dpu):
#Attribs are not marked mandatory but if we dont gives it throws an error
commands = [
{
'name': 'dash_acl_group_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP',
'attributes': ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY","SAI_IP_ADDR_FAMILY_IPV4"]
}
]

results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)



@pytest.mark.dependency(name="test_sai_dash_acl_group_attr_ip_addr_family_set")
def test_sai_dash_acl_group_attr_ip_addr_family_set(self, dpu):

commands = [
{
"name": "dash_acl_group_1",
"op": "set",
"attributes": ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY", 'SAI_IP_ADDR_FAMILY_IPV4']
}
]
results = [*dpu.process_commands(commands)]
print("======= SAI commands RETURN values get =======")
pprint(results)



def test_dash_acl_group_remove(self, dpu):

commands = [{'name': 'dash_acl_group_1', 'op': 'remove'}]

results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)

54 changes: 54 additions & 0 deletions tests/api/test_direction_lookup_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

from pprint import pprint

import pytest

@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
testbed = testbed_instance
if testbed is not None and len(testbed.dpu) != 1:
pytest.skip("invalid for \"{}\" testbed".format(testbed.name))

@pytest.mark.dpu
class TestSaiDirectionLookupEntry:
# object with no attributes

def test_direction_lookup_entry_create(self, dpu):
commands = [
{
'name': 'direction_lookup_entry_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_DIRECTION_LOOKUP_ENTRY',
'attributes': [],
'key': {'switch_id': '$SWITCH_ID', 'vni': "2000"}
}
]
results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)



@pytest.mark.dependency(name="test_sai_direction_lookup_entry_attr_action_set")
def test_sai_direction_lookup_entry_attr_action_set(self, dpu):

commands = [
{
"name": "direction_lookup_entry_1",
"op": "set",
"attributes": ["SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION", 'SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION']
}
]
results = [*dpu.process_commands(commands)]
print("======= SAI commands RETURN values get =======")
pprint(results)


def test_direction_lookup_entry_remove(self, dpu):

commands = [{'name': 'direction_lookup_entry_1', 'key': {'switch_id': '$SWITCH_ID', 'vni': '2000'}, 'op': 'remove'}]

results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)

Loading