Skip to content

Commit

Permalink
Merge branch 'opencomputeproject:main' into pr_phase4_new_cases
Browse files Browse the repository at this point in the history
  • Loading branch information
selldinesh authored Oct 5, 2023
2 parents a3262f2 + 3840d2d commit 9ffd0b4
Show file tree
Hide file tree
Showing 11 changed files with 641 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common/sai_client/sai_redis_client/sai_redis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def cleanup(self):
'''
self.assert_process_running(self.port, self.server_ip, "Redis server has not started yet...")
self.r.flushall()
self.loglevel_db.hmset('syncd:syncd', {'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
self.loglevel_db.hset('syncd:syncd', mapping={'LOGLEVEL':self.loglevel, 'LOGOUTPUT':'SYSLOG'})
self.r.shutdown()
time.sleep(1)
self.assert_process_running(self.port, self.server_ip, "Redis server has not restarted yet...")
Expand Down
9 changes: 7 additions & 2 deletions common/sai_dataplane/ptf/sai_ptf_dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import copy
import sys
import imp
import importlib
import random
import time
import signal
Expand Down Expand Up @@ -146,6 +146,11 @@ def __logging_setup(config):

ptf.open_logfile('main')

@staticmethod
def __import_module(root_path, module_name):
module_specs = importlib.util.find_spec(module_name, [root_path])
return module_specs.loader.load_module()

def init(self):
global ptf
ptf.config.update(config_default)
Expand Down Expand Up @@ -178,7 +183,7 @@ def init(self):

platform_mod = None
try:
platform_mod = imp.load_module(platform_name, *imp.find_module(platform_name, [config["platform_dir"]]))
platform_mod = self.__import_module(config["platform_dir"], platform_name)
except:
logging.warn("Failed to import " + platform_name + " platform module")
raise
Expand Down
13 changes: 9 additions & 4 deletions common/sai_testbed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import imp
import importlib
import os
import json
import glob
Expand Down Expand Up @@ -108,6 +108,11 @@ def __init__(self, base_dir, name, with_traffic, skip_dataplane=False):
self.with_traffic = with_traffic
self.skip_dataplane = skip_dataplane

@staticmethod
def __import_module(root_path, module_name):
module_specs = importlib.util.find_spec(module_name, [root_path])
return module_specs.loader.load_module()

@staticmethod
def spawn_asic(base_dir, cfg, asic_type="npu"):
params = cfg.copy()
Expand All @@ -118,13 +123,13 @@ def spawn_asic(base_dir, cfg, asic_type="npu"):
asic_mod = None
module_name = f"sai_{asic_type}"
try:
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir]))
asic_mod = self.__import_module(asic_dir, module_name)
except:
logging.info("No {} specific module defined..".format(params["asic"]))
try:
asic_mod = imp.load_module(module_name, *imp.find_module(module_name, [asic_dir + "/../"]))
asic_mod = self.__import_module(asic_dir + "/../", module_name)
except:
logging.warn("No NPU specific module defined.")
logging.warning("No NPU specific module defined.")

asic = None
if asic_mod is not None:
Expand Down
3 changes: 3 additions & 0 deletions dockerfiles/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ RUN apt-get install -y nlohmann-json3-dev
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
RUN apt-get install -y python3-paramiko

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Deploy SAI Challenger
COPY common /sai-challenger/common
COPY cli /sai-challenger/cli
Expand Down
3 changes: 3 additions & 0 deletions dockerfiles/bullseye/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ RUN if [ "$NOSNAPPI" != "y" ]; then \
pip3 install snappi==0.11.14 snappi_ixnetwork==0.9.1 ; \
fi

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Install PTF dependencies
RUN pip3 install scapy dpkt

Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
supervisor

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

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

# Install sonic-swss-common & sonic-sairedis building dependencies
RUN apt-get install -y \
Expand Down
3 changes: 1 addition & 2 deletions dockerfiles/buster/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
build-essential \
python3 \
python3-pip \
python3-redis \
iproute2 \
rsyslog \
supervisor \
Expand Down Expand Up @@ -64,7 +63,7 @@ RUN git clone https://github.com/opencomputeproject/SAI.git \
&& rm -rf /sai/SAI

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

ARG NOSNAPPI
RUN if [ "$NOSNAPPI" != "y" ]; then \
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/buster/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
supervisor

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

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

# Install sonic-swss-common & sonic-sairedis building dependencies
RUN apt-get install -y \
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
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)

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)
Loading

0 comments on commit 9ffd0b4

Please sign in to comment.