Skip to content

Commit 1410fa6

Browse files
committed
adding get set cases
Signed-off-by: selldinesh <[email protected]>
1 parent 9a75130 commit 1410fa6

9 files changed

+2521
-55
lines changed

tests/api/test_acl_counter.py

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
from pprint import pprint
22

3+
import pytest
34

5+
6+
@pytest.fixture(scope="module", autouse=True)
7+
def discovery(npu):
8+
npu.objects_discovery()
9+
10+
11+
@pytest.fixture(scope="module", autouse=True)
12+
def skip_all(testbed_instance):
13+
testbed = testbed_instance
14+
if testbed is not None and len(testbed.npu) != 1:
15+
pytest.skip("invalid for {} testbed".format(testbed.name))
16+
17+
18+
@pytest.mark.npu
419
class TestSaiAclCounter:
520
# object with parent SAI_OBJECT_TYPE_ACL_TABLE
621

@@ -19,23 +34,31 @@ def test_acl_counter_create(self, npu):
1934
'attributes': ['SAI_ACL_COUNTER_ATTR_TABLE_ID', '$acl_table_1'],
2035
},
2136
]
22-
37+
npu.objects_discovery()
2338
results = [*npu.process_commands(commands)]
2439
print('======= SAI commands RETURN values create =======')
2540
pprint(results)
2641

27-
def test_acl_counter_remove(self, npu):
42+
@pytest.mark.dependency(name='test_sai_acl_counter_attr_label_set')
43+
def test_sai_acl_counter_attr_label_set(self, npu):
2844
commands = [
2945
{
3046
'name': 'acl_counter_1',
31-
'op': 'remove',
32-
},
33-
{
34-
'name': 'acl_table_1',
35-
'op': 'remove',
36-
},
47+
'op': 'set',
48+
'attributes': ['SAI_ACL_COUNTER_ATTR_LABEL', '""'],
49+
}
3750
]
51+
npu.objects_discovery()
52+
results = [*npu.process_commands(commands)]
53+
print('======= SAI commands RETURN values get =======')
54+
pprint(results)
3855

56+
def test_acl_counter_remove(self, npu):
57+
commands = [
58+
{'name': 'acl_counter_1', 'op': 'remove'},
59+
{'name': 'acl_table_1', 'op': 'remove'},
60+
]
61+
npu.objects_discovery()
3962
results = [*npu.process_commands(commands)]
4063
print('======= SAI commands RETURN values remove =======')
4164
pprint(results)

tests/api/test_hostif_trap_group.py

+73-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
from pprint import pprint
22

3+
import pytest
4+
5+
6+
@pytest.fixture(scope="module", autouse=True)
7+
def discovery(npu):
8+
npu.objects_discovery()
9+
10+
11+
@pytest.fixture(scope="module", autouse=True)
12+
def skip_all(testbed_instance):
13+
testbed = testbed_instance
14+
if testbed is not None and len(testbed.npu) != 1:
15+
pytest.skip("invalid for {} testbed".format(testbed.name))
16+
317

418
class TestSaiHostifTrapGroup:
519
# object with no attributes
@@ -18,13 +32,70 @@ def test_hostif_trap_group_create(self, npu):
1832
print('======= SAI commands RETURN values create =======')
1933
pprint(results)
2034

21-
def test_hostif_trap_group_remove(self, npu):
35+
@pytest.mark.dependency(name='test_sai_hostif_trap_group_attr_admin_state_set')
36+
def test_sai_hostif_trap_group_attr_admin_state_set(self, npu):
37+
commands = [
38+
{
39+
'name': 'hostif_trap_group_1',
40+
'op': 'set',
41+
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_ADMIN_STATE', 'true'],
42+
}
43+
]
44+
results = [*npu.process_commands(commands)]
45+
print('======= SAI commands RETURN values get =======')
46+
pprint(results)
47+
48+
@pytest.mark.dependency(depends=['test_sai_hostif_trap_group_attr_admin_state_set'])
49+
def test_sai_hostif_trap_group_attr_admin_state_get(self, npu):
50+
commands = [
51+
{
52+
'name': 'hostif_trap_group_1',
53+
'op': 'get',
54+
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_ADMIN_STATE'],
55+
}
56+
]
57+
results = [*npu.process_commands(commands)]
58+
print('======= SAI commands RETURN values get =======')
59+
for command in results:
60+
for attribute in command:
61+
pprint(attribute.raw())
62+
r_value = results[0][0].value()
63+
print(r_value)
64+
assert r_value == 'true', 'Get error, expected true but got %s' % r_value
65+
66+
@pytest.mark.dependency(name='test_sai_hostif_trap_group_attr_queue_set')
67+
def test_sai_hostif_trap_group_attr_queue_set(self, npu):
68+
commands = [
69+
{
70+
'name': 'hostif_trap_group_1',
71+
'op': 'set',
72+
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_QUEUE', '0'],
73+
}
74+
]
75+
results = [*npu.process_commands(commands)]
76+
print('======= SAI commands RETURN values get =======')
77+
pprint(results)
78+
79+
@pytest.mark.dependency(depends=['test_sai_hostif_trap_group_attr_queue_set'])
80+
def test_sai_hostif_trap_group_attr_queue_get(self, npu):
2281
commands = [
2382
{
2483
'name': 'hostif_trap_group_1',
25-
'op': 'remove',
84+
'op': 'get',
85+
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_QUEUE'],
2686
}
2787
]
88+
results = [*npu.process_commands(commands)]
89+
print('======= SAI commands RETURN values get =======')
90+
for command in results:
91+
for attribute in command:
92+
pprint(attribute.raw())
93+
r_value = results[0][0].value()
94+
print(r_value)
95+
assert r_value == '0', 'Get error, expected 0 but got %s' % r_value
96+
97+
def test_hostif_trap_group_remove(self, npu):
98+
commands = [{'name': 'hostif_trap_group_1', 'op': 'remove'}]
2899

29100
results = [*npu.process_commands(commands)]
30101
print('======= SAI commands RETURN values remove =======')

tests/api/test_next_hop_group.py

+53-12
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,75 @@
1+
12
from pprint import pprint
23

4+
import pytest
5+
6+
7+
@pytest.fixture(scope="module", autouse=True)
8+
def discovery(npu):
9+
npu.objects_discovery()
10+
311

12+
@pytest.fixture(scope="module", autouse=True)
13+
def skip_all(testbed_instance):
14+
testbed = testbed_instance
15+
if testbed is not None and len(testbed.npu) != 1:
16+
pytest.skip("invalid for {} testbed".format(testbed.name))
17+
18+
19+
@pytest.mark.npu
420
class TestSaiNextHopGroup:
521
# object with no parents
622

723
def test_next_hop_group_create(self, npu):
24+
25+
commands = [{'name': 'next_hop_group_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP', 'attributes': ['SAI_NEXT_HOP_GROUP_ATTR_TYPE', 'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP']}]
26+
27+
results = [*npu.process_commands(commands)]
28+
print('======= SAI commands RETURN values create =======')
29+
pprint(results)
30+
31+
32+
@pytest.mark.dependency(name="test_sai_next_hop_group_attr_set_switchover_set")
33+
def test_sai_next_hop_group_attr_set_switchover_set(self, npu):
34+
835
commands = [
936
{
10-
'name': 'next_hop_group_1',
11-
'op': 'create',
12-
'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP',
13-
'attributes': [
14-
'SAI_NEXT_HOP_GROUP_ATTR_TYPE',
15-
'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP',
16-
],
37+
"name": "next_hop_group_1",
38+
"op": "set",
39+
"attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER", 'false']
1740
}
1841
]
19-
2042
results = [*npu.process_commands(commands)]
21-
print('======= SAI commands RETURN values create =======')
43+
print("======= SAI commands RETURN values set =======")
2244
pprint(results)
2345

24-
def test_next_hop_group_remove(self, npu):
46+
47+
48+
@pytest.mark.dependency(depends=["test_sai_next_hop_group_attr_set_switchover_set"])
49+
def test_sai_next_hop_group_attr_set_switchover_get(self, npu):
50+
2551
commands = [
2652
{
27-
'name': 'next_hop_group_1',
28-
'op': 'remove',
53+
"name": "next_hop_group_1",
54+
"op": "get",
55+
"attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER"]
2956
}
3057
]
58+
results = [*npu.process_commands(commands)]
59+
print("======= SAI commands RETURN values get =======")
60+
for command in results:
61+
for attribute in command:
62+
pprint(attribute.raw())
63+
r_value = results[0][0].value()
64+
print(r_value)
65+
assert r_value == 'false', 'Get error, expected false but got %s' % r_value
66+
67+
68+
def test_next_hop_group_remove(self, npu):
69+
70+
commands = [{'name': 'next_hop_group_1', 'op': 'remove'}]
3171

3272
results = [*npu.process_commands(commands)]
3373
print('======= SAI commands RETURN values remove =======')
3474
pprint(results)
75+

0 commit comments

Comments
 (0)