Skip to content

Commit 0406947

Browse files
authored
Merge branch 'opencomputeproject:main' into pr_phase4_new_cases
2 parents 42a9248 + 3840d2d commit 0406947

File tree

11 files changed

+641
-13
lines changed

11 files changed

+641
-13
lines changed

common/sai_client/sai_redis_client/sai_redis_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def cleanup(self):
5353
'''
5454
self.assert_process_running(self.port, self.server_ip, "Redis server has not started yet...")
5555
self.r.flushall()
56-
self.loglevel_db.hmset('syncd:syncd', {'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
56+
self.loglevel_db.hset('syncd:syncd', mapping={'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
5757
self.r.shutdown()
5858
time.sleep(1)
5959
self.assert_process_running(self.port, self.server_ip, "Redis server has not restarted yet...")

common/sai_dataplane/ptf/sai_ptf_dataplane.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import copy
77
import sys
8-
import imp
8+
import importlib
99
import random
1010
import time
1111
import signal
@@ -146,6 +146,11 @@ def __logging_setup(config):
146146

147147
ptf.open_logfile('main')
148148

149+
@staticmethod
150+
def __import_module(root_path, module_name):
151+
module_specs = importlib.util.find_spec(module_name, [root_path])
152+
return module_specs.loader.load_module()
153+
149154
def init(self):
150155
global ptf
151156
ptf.config.update(config_default)
@@ -178,7 +183,7 @@ def init(self):
178183

179184
platform_mod = None
180185
try:
181-
platform_mod = imp.load_module(platform_name, *imp.find_module(platform_name, [config["platform_dir"]]))
186+
platform_mod = self.__import_module(config["platform_dir"], platform_name)
182187
except:
183188
logging.warn("Failed to import " + platform_name + " platform module")
184189
raise

common/sai_testbed.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import imp
1+
import importlib
22
import os
33
import json
44
import glob
@@ -108,6 +108,11 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False):
108108
self.with_traffic = with_traffic
109109
self.skip_dataplane = skip_dataplane
110110

111+
@staticmethod
112+
def __import_module(root_path, module_name):
113+
module_specs = importlib.util.find_spec(module_name, [root_path])
114+
return module_specs.loader.load_module()
115+
111116
@staticmethod
112117
def spawn_asic(base_dir, cfg, asic_type="npu"):
113118
params = cfg.copy()
@@ -118,13 +123,13 @@ def spawn_asic(base_dir, cfg, asic_type="npu"):
118123
asic_mod = None
119124
module_name = f"sai_{asic_type}"
120125
try:
121-
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir]))
126+
asic_mod = self.__import_module(asic_dir, module_name)
122127
except:
123128
logging.info("No {} specific module defined..".format(params["asic"]))
124129
try:
125-
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir + "/../"]))
130+
asic_mod = self.__import_module(asic_dir + "/../", module_name)
126131
except:
127-
logging.warn("No NPU specific module defined.")
132+
logging.warning("No NPU specific module defined.")
128133

129134
asic = None
130135
if asic_mod is not None:

dockerfiles/bullseye/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ RUN apt-get install -y nlohmann-json3-dev
104104
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
105105
RUN apt-get install -y python3-paramiko
106106

107+
# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
108+
RUN pip3 install --upgrade invoke>=2.2.0
109+
107110
# Deploy SAI Challenger
108111
COPY common /sai-challenger/common
109112
COPY cli /sai-challenger/cli

dockerfiles/bullseye/Dockerfile.client

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ RUN if [ "$NOSNAPPI" != "y" ]; then \
6565
pip3 install snappi==0.11.14 snappi_ixnetwork==0.9.1 ; \
6666
fi
6767

68+
# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
69+
RUN pip3 install --upgrade invoke>=2.2.0
70+
6871
# Install PTF dependencies
6972
RUN pip3 install scapy dpkt
7073

dockerfiles/buster/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
3030
supervisor
3131

3232
# Add support for supervisord to handle startup dependencies
33-
RUN pip3 install supervisord-dependent-startup==1.4.0
33+
RUN pip3 install supervisord-dependent-startup==1.4.0 redis>=3.5.0
3434

3535
# Install dependencies
36-
RUN apt-get install -y redis-server libhiredis0.14 python3-redis libc-ares2
36+
RUN apt-get install -y redis-server libhiredis0.14 libc-ares2
3737

3838
# Install sonic-swss-common & sonic-sairedis building dependencies
3939
RUN apt-get install -y \

dockerfiles/buster/Dockerfile.client

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
1717
build-essential \
1818
python3 \
1919
python3-pip \
20-
python3-redis \
2120
iproute2 \
2221
rsyslog \
2322
supervisor \
@@ -64,7 +63,7 @@ RUN git clone https://github.com/opencomputeproject/SAI.git \
6463
&& rm -rf /sai/SAI
6564

6665
# Install SAI-C dependencies
67-
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
66+
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0 redis>=3.5.0
6867

6968
ARG NOSNAPPI
7069
RUN if [ "$NOSNAPPI" != "y" ]; then \

dockerfiles/buster/Dockerfile.server

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
3030
supervisor
3131

3232
# Add support for supervisord to handle startup dependencies
33-
RUN pip3 install supervisord-dependent-startup==1.4.0
33+
RUN pip3 install supervisord-dependent-startup==1.4.0 redis>=3.5.0
3434

3535
# Install dependencies
36-
RUN apt-get install -y redis-server libhiredis0.14 python3-redis libc-ares2
36+
RUN apt-get install -y redis-server libhiredis0.14 libc-ares2
3737

3838
# Install sonic-swss-common & sonic-sairedis building dependencies
3939
RUN apt-get install -y \

tests/api/test_dash_acl_group.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
from pprint import pprint
3+
4+
import pytest
5+
6+
@pytest.fixture(scope="module", autouse=True)
7+
def skip_all(testbed_instance):
8+
testbed = testbed_instance
9+
if testbed is not None and len(testbed.dpu) != 1:
10+
pytest.skip("invalid for \"{}\" testbed".format(testbed.name))
11+
12+
@pytest.mark.dpu
13+
class TestSaiDashAclGroup:
14+
# object with no attributes
15+
16+
def test_dash_acl_group_create(self, dpu):
17+
#Attribs are not marked mandatory but if we dont gives it throws an error
18+
commands = [
19+
{
20+
'name': 'dash_acl_group_1',
21+
'op': 'create',
22+
'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP',
23+
'attributes': ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY","SAI_IP_ADDR_FAMILY_IPV4"]
24+
}
25+
]
26+
27+
results = [*dpu.process_commands(commands)]
28+
print('======= SAI commands RETURN values create =======')
29+
pprint(results)
30+
31+
32+
33+
@pytest.mark.dependency(name="test_sai_dash_acl_group_attr_ip_addr_family_set")
34+
def test_sai_dash_acl_group_attr_ip_addr_family_set(self, dpu):
35+
36+
commands = [
37+
{
38+
"name": "dash_acl_group_1",
39+
"op": "set",
40+
"attributes": ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY", 'SAI_IP_ADDR_FAMILY_IPV4']
41+
}
42+
]
43+
results = [*dpu.process_commands(commands)]
44+
print("======= SAI commands RETURN values get =======")
45+
pprint(results)
46+
47+
48+
49+
def test_dash_acl_group_remove(self, dpu):
50+
51+
commands = [{'name': 'dash_acl_group_1', 'op': 'remove'}]
52+
53+
results = [*dpu.process_commands(commands)]
54+
print('======= SAI commands RETURN values remove =======')
55+
pprint(results)
56+

tests/api/test_dash_acl_rule.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from pprint import pprint
2+
3+
import pytest
4+
5+
@pytest.fixture(scope="module", autouse=True)
6+
def skip_all(testbed_instance):
7+
testbed = testbed_instance
8+
if testbed is not None and len(testbed.dpu) != 1:
9+
pytest.skip("invalid for \"{}\" testbed".format(testbed.name))
10+
11+
@pytest.mark.dpu
12+
class TestSaiDashAclRule:
13+
# object with parent SAI_OBJECT_TYPE_DASH_ACL_GROUP
14+
15+
def test_dash_acl_rule_create(self, dpu):
16+
commands = [
17+
{
18+
'name': 'dash_acl_group_1',
19+
'op': 'create',
20+
'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP',
21+
'attributes': ['SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY', 'SAI_IP_ADDR_FAMILY_IPV4',],
22+
},
23+
{
24+
'name': 'dash_acl_rule_1',
25+
'op': 'create',
26+
'type': 'SAI_OBJECT_TYPE_DASH_ACL_RULE',
27+
'attributes': [
28+
'SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID','$dash_acl_group_1',
29+
'SAI_DASH_ACL_RULE_ATTR_DIP','1.1.1.1',
30+
'SAI_DASH_ACL_RULE_ATTR_SIP','2.2.2.2',
31+
'SAI_DASH_ACL_RULE_ATTR_PROTOCOL','17',
32+
'SAI_DASH_ACL_RULE_ATTR_SRC_PORT','5678',
33+
'SAI_DASH_ACL_RULE_ATTR_DST_PORT','8765',
34+
'SAI_DASH_ACL_RULE_ATTR_PRIORITY','10',
35+
],
36+
},
37+
]
38+
39+
results = [*dpu.process_commands(commands)]
40+
print('======= SAI commands RETURN values create =======')
41+
pprint(results)
42+
43+
@pytest.mark.dependency(name='test_sai_dash_acl_rule_attr_action_set')
44+
def test_sai_dash_acl_rule_attr_action_set(self, dpu):
45+
commands = [
46+
{
47+
'name': 'dash_acl_rule_1',
48+
'op': 'set',
49+
'attributes': [
50+
'SAI_DASH_ACL_RULE_ATTR_ACTION',
51+
'SAI_DASH_ACL_RULE_ACTION_PERMIT',
52+
],
53+
}
54+
]
55+
results = [*dpu.process_commands(commands)]
56+
print('======= SAI commands RETURN values set =======')
57+
pprint(results)
58+
59+
60+
def test_dash_acl_rule_remove(self, dpu):
61+
commands = [
62+
{'name': 'dash_acl_rule_1', 'op': 'remove'},
63+
{'name': 'dash_acl_group_1', 'op': 'remove'},
64+
]
65+
66+
results = [*dpu.process_commands(commands)]
67+
print('======= SAI commands RETURN values remove =======')
68+
pprint(results)

0 commit comments

Comments
 (0)