-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
babf7d4
commit f1ea4d6
Showing
9 changed files
with
583 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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.npu) != 1: | ||
pytest.skip('invalid for {} testbed'.format(testbed.name)) | ||
|
||
|
||
@pytest.mark.npu | ||
class TestSaiBufferProfile: | ||
# object with parent SAI_OBJECT_TYPE_BUFFER_POOL | ||
|
||
def test_buffer_profile_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'buffer_pool_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_BUFFER_POOL', | ||
'attributes': [ | ||
'SAI_BUFFER_POOL_ATTR_TYPE', | ||
'SAI_BUFFER_POOL_TYPE_INGRESS', | ||
'SAI_BUFFER_POOL_ATTR_SIZE', | ||
'10', | ||
], | ||
}, | ||
{ | ||
'name': 'buffer_profile_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_BUFFER_PROFILE', | ||
'attributes': [ | ||
'SAI_BUFFER_PROFILE_ATTR_POOL_ID', | ||
'$buffer_pool_1', | ||
'SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE', | ||
'10', | ||
'SAI_BUFFER_PROFILE_ATTR_THRESHOLD_MODE', | ||
'SAI_BUFFER_PROFILE_THRESHOLD_MODE_STATIC', | ||
'SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH', | ||
'1', | ||
'SAI_BUFFER_PROFILE_ATTR_SHARED_STATIC_TH', | ||
'10', | ||
], | ||
}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
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.npu) != 1: | ||
pytest.skip('invalid for {} testbed'.format(testbed.name)) | ||
|
||
|
||
@pytest.mark.npu | ||
class TestSaiHostif: | ||
# object with parent SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_LAG SAI_OBJECT_TYPE_VLAN SAI_OBJECT_TYPE_SYSTEM_PORT | ||
|
||
def test_hostif_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'port_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_PORT', | ||
'attributes': [ | ||
'SAI_PORT_ATTR_HW_LANE_LIST', | ||
'2:10,11', | ||
'SAI_PORT_ATTR_SPEED', | ||
'10', | ||
], | ||
}, | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_HOSTIF', | ||
'attributes': [ | ||
'SAI_HOSTIF_ATTR_TYPE', | ||
'SAI_HOSTIF_TYPE_NETDEV', | ||
'SAI_HOSTIF_ATTR_OBJ_ID', | ||
'$port_1', | ||
'SAI_HOSTIF_ATTR_NAME', | ||
'inbound', | ||
'SAI_HOSTIF_ATTR_GENETLINK_MCGRP_NAME', | ||
'inbound', | ||
], | ||
}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(name='test_sai_hostif_attr_oper_status_set') | ||
def test_sai_hostif_attr_oper_status_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'set', | ||
'attributes': ['SAI_HOSTIF_ATTR_OPER_STATUS', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_hostif_attr_oper_status_set']) | ||
def test_sai_hostif_attr_oper_status_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'get', | ||
'attributes': ['SAI_HOSTIF_ATTR_OPER_STATUS'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values get =======') | ||
for command in results: | ||
for attribute in command: | ||
pprint(attribute.raw()) | ||
r_value = results[0][0].value() | ||
print(r_value) | ||
assert r_value == 'false', 'Get error, expected false but got %s' % r_value | ||
|
||
@pytest.mark.dependency(name='test_sai_hostif_attr_queue_set') | ||
def test_sai_hostif_attr_queue_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'set', | ||
'attributes': ['SAI_HOSTIF_ATTR_QUEUE', '0'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_hostif_attr_queue_set']) | ||
def test_sai_hostif_attr_queue_get(self, npu): | ||
commands = [ | ||
{'name': 'hostif_1', 'op': 'get', 'attributes': ['SAI_HOSTIF_ATTR_QUEUE']} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values get =======') | ||
for command in results: | ||
for attribute in command: | ||
pprint(attribute.raw()) | ||
r_value = results[0][0].value() | ||
print(r_value) | ||
assert r_value == '0', 'Get error, expected 0 but got %s' % r_value | ||
|
||
@pytest.mark.dependency(name='test_sai_hostif_attr_vlan_tag_set') | ||
def test_sai_hostif_attr_vlan_tag_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'set', | ||
'attributes': ['SAI_HOSTIF_ATTR_VLAN_TAG', 'SAI_HOSTIF_VLAN_TAG_STRIP'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_hostif_attr_vlan_tag_set']) | ||
def test_sai_hostif_attr_vlan_tag_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'get', | ||
'attributes': ['SAI_HOSTIF_ATTR_VLAN_TAG'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values get =======') | ||
for command in results: | ||
for attribute in command: | ||
pprint(attribute.raw()) | ||
r_value = results[0][0].value() | ||
print(r_value) | ||
assert r_value == 'SAI_HOSTIF_VLAN_TAG_STRIP', ( | ||
'Get error, expected SAI_HOSTIF_VLAN_TAG_STRIP but got %s' % r_value | ||
) | ||
|
||
def test_hostif_remove(self, npu): | ||
commands = [ | ||
{'name': 'hostif_1', 'op': 'remove'}, | ||
{'name': 'port_1', 'op': 'remove'}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
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.npu) != 1: | ||
pytest.skip('invalid for {} testbed'.format(testbed.name)) | ||
|
||
|
||
@pytest.mark.npu | ||
class TestSaiHostifTableEntry: | ||
# object with parent SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_LAG SAI_OBJECT_TYPE_ROUTER_INTERFACE SAI_OBJECT_TYPE_HOSTIF_TRAP SAI_OBJECT_TYPE_HOSTIF_USER_DEFINED_TRAP SAI_OBJECT_TYPE_HOSTIF | ||
|
||
def test_hostif_table_entry_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'port_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_PORT', | ||
'attributes': [ | ||
'SAI_PORT_ATTR_HW_LANE_LIST', | ||
'2:10,11', | ||
'SAI_PORT_ATTR_SPEED', | ||
'10', | ||
], | ||
}, | ||
{ | ||
'name': 'hostif_trap_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_HOSTIF_TRAP', | ||
'attributes': [ | ||
'SAI_HOSTIF_TRAP_ATTR_TRAP_TYPE', | ||
'SAI_HOSTIF_TRAP_TYPE_STP', | ||
'SAI_HOSTIF_TRAP_ATTR_PACKET_ACTION', | ||
'SAI_PACKET_ACTION_DROP', | ||
], | ||
}, | ||
{ | ||
'name': 'hostif_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_HOSTIF', | ||
'attributes': [ | ||
'SAI_HOSTIF_ATTR_TYPE', | ||
'SAI_HOSTIF_TYPE_NETDEV', | ||
'SAI_HOSTIF_ATTR_OBJ_ID', | ||
'$port_1', | ||
'SAI_HOSTIF_ATTR_NAME', | ||
'inbound', | ||
'SAI_HOSTIF_ATTR_GENETLINK_MCGRP_NAME', | ||
'inbound', | ||
], | ||
}, | ||
{ | ||
'name': 'hostif_table_entry_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_HOSTIF_TABLE_ENTRY', | ||
'attributes': [ | ||
'SAI_HOSTIF_TABLE_ENTRY_ATTR_TYPE', | ||
'SAI_HOSTIF_TABLE_ENTRY_TYPE_PORT', | ||
'SAI_HOSTIF_TABLE_ENTRY_ATTR_OBJ_ID', | ||
'$port_1', | ||
'SAI_HOSTIF_TABLE_ENTRY_ATTR_TRAP_ID', | ||
'$hostif_trap_1', | ||
'SAI_HOSTIF_TABLE_ENTRY_ATTR_CHANNEL_TYPE', | ||
'SAI_HOSTIF_TABLE_ENTRY_CHANNEL_TYPE_CB', | ||
'SAI_HOSTIF_TABLE_ENTRY_ATTR_HOST_IF', | ||
'$hostif_1', | ||
], | ||
}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_hostif_table_entry_remove(self, npu): | ||
commands = [ | ||
{'name': 'hostif_table_entry_1', 'op': 'remove'}, | ||
{'name': 'hostif_1', 'op': 'remove'}, | ||
{'name': 'hostif_trap_1', 'op': 'remove'}, | ||
{'name': 'port_1', 'op': 'remove'}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
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.npu) != 1: | ||
pytest.skip('invalid for {} testbed'.format(testbed.name)) | ||
|
||
|
||
@pytest.mark.npu | ||
class TestSaiLagMember: | ||
# object with parent SAI_OBJECT_TYPE_LAG SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_SYSTEM_PORT | ||
|
||
def test_lag_member_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'lag_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_LAG', | ||
'attributes': [], | ||
}, | ||
{ | ||
'name': 'port_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_PORT', | ||
'attributes': [ | ||
'SAI_PORT_ATTR_HW_LANE_LIST', | ||
'2:10,11', | ||
'SAI_PORT_ATTR_SPEED', | ||
'10', | ||
], | ||
}, | ||
{ | ||
'name': 'lag_member_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_LAG_MEMBER', | ||
'attributes': [ | ||
'SAI_LAG_MEMBER_ATTR_LAG_ID', | ||
'$lag_1', | ||
'SAI_LAG_MEMBER_ATTR_PORT_ID', | ||
'$port_1', | ||
], | ||
}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(name='test_sai_lag_member_attr_egress_disable_set') | ||
def test_sai_lag_member_attr_egress_disable_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'lag_member_1', | ||
'op': 'set', | ||
'attributes': ['SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
|
||
@pytest.mark.dependency(name='test_sai_lag_member_attr_ingress_disable_set') | ||
def test_sai_lag_member_attr_ingress_disable_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'lag_member_1', | ||
'op': 'set', | ||
'attributes': ['SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
|
||
def test_lag_member_remove(self, npu): | ||
commands = [ | ||
{'name': 'lag_member_1', 'op': 'remove'}, | ||
{'name': 'port_1', 'op': 'remove'}, | ||
{'name': 'lag_1', 'op': 'remove'}, | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
Oops, something went wrong.