diff --git a/common/sai_client/sai_redis_client/sai_redis_client.py b/common/sai_client/sai_redis_client/sai_redis_client.py index 2782302e..ab48f5ac 100644 --- a/common/sai_client/sai_redis_client/sai_redis_client.py +++ b/common/sai_client/sai_redis_client/sai_redis_client.py @@ -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...") diff --git a/common/sai_dataplane/ptf/sai_ptf_dataplane.py b/common/sai_dataplane/ptf/sai_ptf_dataplane.py index df6ef2bc..49d8390f 100644 --- a/common/sai_dataplane/ptf/sai_ptf_dataplane.py +++ b/common/sai_dataplane/ptf/sai_ptf_dataplane.py @@ -5,7 +5,7 @@ import os import copy import sys -import imp +import importlib import random import time import signal @@ -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) @@ -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 diff --git a/common/sai_testbed.py b/common/sai_testbed.py index af1a9ceb..e2d27cab 100644 --- a/common/sai_testbed.py +++ b/common/sai_testbed.py @@ -1,4 +1,4 @@ -import imp +import importlib import os import json import glob @@ -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() @@ -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: diff --git a/dockerfiles/bullseye/Dockerfile b/dockerfiles/bullseye/Dockerfile index a862b7f8..a6e83fbf 100644 --- a/dockerfiles/bullseye/Dockerfile +++ b/dockerfiles/bullseye/Dockerfile @@ -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 diff --git a/dockerfiles/bullseye/Dockerfile.client b/dockerfiles/bullseye/Dockerfile.client index 4dae5ddb..91c43c2f 100644 --- a/dockerfiles/bullseye/Dockerfile.client +++ b/dockerfiles/bullseye/Dockerfile.client @@ -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