Skip to content

Commit

Permalink
Adding new Test Scripts for create set and remove on the api attribut…
Browse files Browse the repository at this point in the history
…es 2nd set

Signed-off-by: Vinod Kumar <[email protected]>
  • Loading branch information
vikumarks committed Sep 15, 2023
1 parent 89eb340 commit 077adae
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/api/test_dash_acl_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 TestSaiDashAclRule:
# object with parent SAI_OBJECT_TYPE_DASH_ACL_GROUP

def test_dash_acl_rule_create(self, dpu):
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',],
},
{
'name': 'dash_acl_rule_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_DASH_ACL_RULE',
'attributes': [
'SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID','$dash_acl_group_1',
'SAI_DASH_ACL_RULE_ATTR_DIP','1.1.1.1',
'SAI_DASH_ACL_RULE_ATTR_SIP','2.2.2.2',
'SAI_DASH_ACL_RULE_ATTR_PROTOCOL','17',
'SAI_DASH_ACL_RULE_ATTR_SRC_PORT','5678',
'SAI_DASH_ACL_RULE_ATTR_DST_PORT','8765',
'SAI_DASH_ACL_RULE_ATTR_PRIORITY','10',
],
},
]

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

@pytest.mark.dependency(name='test_sai_dash_acl_rule_attr_action_set')
def test_sai_dash_acl_rule_attr_action_set(self, dpu):
commands = [
{
'name': 'dash_acl_rule_1',
'op': 'set',
'attributes': [
'SAI_DASH_ACL_RULE_ATTR_ACTION',
'SAI_DASH_ACL_RULE_ACTION_PERMIT',
],
}
]
results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values set =======')
pprint(results)


def test_dash_acl_rule_remove(self, dpu):
commands = [
{'name': 'dash_acl_rule_1', 'op': 'remove'},
{'name': 'dash_acl_group_1', 'op': 'remove'},
]

results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
71 changes: 71 additions & 0 deletions tests/api/test_eni_ether_address_map_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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 TestSaiEniEtherAddressMapEntry:
# object with no attributes

def test_eni_ether_address_map_entry_create(self, dpu):
commands = [
{"name": "vnet","op": "create","type": "SAI_OBJECT_TYPE_VNET","attributes": ["SAI_VNET_ATTR_VNI","2000"]},
{
"name": "eni_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_ENI",
"attributes": [
"SAI_ENI_ATTR_ADMIN_STATE","True",
"SAI_ENI_ATTR_VM_UNDERLAY_DIP","10.10.1.10",
"SAI_ENI_ATTR_VM_VNI","2000",
"SAI_ENI_ATTR_VNET_ID","$vnet",
]
},
{
'name': 'eni_ether_address_map_entry_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ENI_ETHER_ADDRESS_MAP_ENTRY',
'attributes': ["SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID","$eni_1"],
'key': {'switch_id': '$SWITCH_ID', 'address': '00:AA:AA:AA:AB:00'},
}
]

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

@pytest.mark.dependency(name='test_sai_eni_ether_address_map_entry_attr_eni_id_set')
def test_sai_eni_ether_address_map_entry_attr_eni_id_set(self, dpu):
commands = [
{
'name': 'eni_ether_address_map_entry_1',
'op': 'set',
'attributes': ['SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID', 'null'],
}
]
results = [*dpu.process_commands(commands)]
print('\n======= SAI commands RETURN values set =======\n')
pprint(results)


def test_eni_ether_address_map_entry_remove(self, dpu):
commands = [

{
'name': 'eni_ether_address_map_entry_1',
'key': {'switch_id': '$SWITCH_ID', 'address': '00:AA:AA:AA:AB:00'},
'op': 'remove',
},
{'name': 'eni_1', 'op': 'remove'},
{"name": "vnet","op": "remove"},
]

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

132 changes: 132 additions & 0 deletions tests/api/test_outbound_routing_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
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 TestSaiOutboundRoutingEntry:
# object with no attributes

def test_outbound_routing_entry_create(self, dpu):
commands = [
{"name": "vnet","op": "create","type": "SAI_OBJECT_TYPE_VNET","attributes": ["SAI_VNET_ATTR_VNI","2000"]},
{
"name": "eni_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_ENI",
"attributes": [
"SAI_ENI_ATTR_ADMIN_STATE","True",
"SAI_ENI_ATTR_VM_UNDERLAY_DIP","10.10.1.10",
"SAI_ENI_ATTR_VM_VNI","2000",
"SAI_ENI_ATTR_VNET_ID","$vnet",
]
},
{
'name': 'outbound_routing_entry_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY',
'attributes': ["SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION", "SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET","SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet"],
'key': {
'switch_id': '$SWITCH_ID',
'eni_id': '$eni_1',
'destination': '10.1.0.0/16',
},
}
]

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

@pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_action_set')
def test_sai_outbound_routing_entry_attr_action_set(self, dpu):
commands = [
{
'name': 'outbound_routing_entry_1',
'op': 'set',
'attributes': [
'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION',
'SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET',
"SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet"
],
}
]
results = [*dpu.process_commands(commands)]
print('\n======= SAI commands RETURN values set =======\n')
pprint(results)


@pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_dst_vnet_id_set')
def test_sai_outbound_routing_entry_attr_dst_vnet_id_set(self, dpu):
commands = [
{
'name': 'outbound_routing_entry_1',
'op': 'set',
'attributes': [
'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION',
'SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET',
"SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet"
],
}
]
results = [*dpu.process_commands(commands)]
print('\n======= SAI commands RETURN values set =======\n')
pprint(results)




@pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_overlay_ip_set')
def test_sai_outbound_routing_entry_attr_overlay_ip_set(self, dpu):
commands = [
{
'name': 'outbound_routing_entry_1',
'op': 'set',
'attributes': ['SAI_OUTBOUND_ROUTING_ENTRY_ATTR_OVERLAY_IP', '0.0.0.0'],
}
]
results = [*dpu.process_commands(commands)]
print('\n======= SAI commands RETURN values set =======\n')
pprint(results)


@pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_counter_id_set')
def test_sai_outbound_routing_entry_attr_counter_id_set(self, dpu):
commands = [
{
'name': 'outbound_routing_entry_1',
'op': 'set',
'attributes': ['SAI_OUTBOUND_ROUTING_ENTRY_ATTR_COUNTER_ID', 'null'],
}
]
results = [*dpu.process_commands(commands)]
print('\n======= SAI commands RETURN values set =======\n')
pprint(results)



def test_outbound_routing_entry_remove(self, dpu):
commands = [
{
'name': 'outbound_routing_entry_1',
'key': {
'switch_id': '$SWITCH_ID',
'eni_id': '$eni_1',
'destination': '10.1.0.0/16',
},
'op': 'remove',
},
{'name': 'eni_1', 'op': 'remove'},
{"name": "vnet","op": "remove"},

]

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

0 comments on commit 077adae

Please sign in to comment.