diff --git a/spytest/bin/env b/spytest/bin/env index ef17d261633..b72d0810ab3 100755 --- a/spytest/bin/env +++ b/spytest/bin/env @@ -22,7 +22,10 @@ else export SCID_PYTHON_BIN=$SCID/tools/ActivPython/current/bin fi -export SCID_TGEN_PATH=$SCID/tgen +if [ -z "$SCID_TGEN_PATH=" ]; then + export SCID_TGEN_PATH=$SCID/tgen +fi + if [ -z "$SPYTEST_PYTHON" ]; then export SPYTEST_PYTHON=$SCID_PYTHON_BIN/python fi diff --git a/spytest/bin/tools_install.sh b/spytest/bin/tools_install.sh index f750e519ddb..f759066f327 100755 --- a/spytest/bin/tools_install.sh +++ b/spytest/bin/tools_install.sh @@ -14,7 +14,7 @@ dir=$(dirname $0) dir=$(cd $dir;pwd -P) scid=$(cd $dir/..;pwd -P) -# sourde environment +# source environment . $dir/env if [ -f $dir/.tools_env ]; then diff --git a/spytest/containers/README.md b/spytest/containers/README.md new file mode 100644 index 00000000000..04627ca5c93 --- /dev/null +++ b/spytest/containers/README.md @@ -0,0 +1,23 @@ +# host setup +https://github.com/Azure/sonic-mgmt/blob/master/docs/testbed/README.testbed.Setup.md + - do the steps in "Prepare Testbed Server" section + +# build container +``` +git clone https://github.com/Azure/sonic-mgmt +docker build --no-cache --tag spytest/keysight-u18:latest ./sonic-mgmt/spytest/containers/keysight-ubuntu18 +docker tag spytest/keysight-u18:latest spytest/keysight-u18:1.0.0 +``` + +http://downloads.ixiacom.com/support/downloads_and_updates/public/ixnetwork/9.10/IxNetworkAPI9.10.2007.7Linux64.bin.tgz + +# run tests +``` +https://github.com/Azure/sonic-mgmt/blob/master/spytest/Doc/intro.md + - do the steps in "Testbed" section + - copy and edit the file testbed_file.yaml ./testbeds/ + +docker run --network host -v $PWD:/data --mount src=/etc/localtime,target=/etc/localtime,type=bind,readonly -it spytest/keysight-u18 bash +cd /data/sonic-mgmt/spytest +./bin/spytest --testbed-file ./testbeds/testbed_file.yaml --logs-path ./logs --log-level debug --test-suite community-legacy +``` diff --git a/spytest/containers/keysight-ubuntu18/Dockerfile b/spytest/containers/keysight-ubuntu18/Dockerfile new file mode 100644 index 00000000000..5a9078d5e1a --- /dev/null +++ b/spytest/containers/keysight-ubuntu18/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:bionic + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=US/Pacific + +RUN apt -y update +RUN apt -y upgrade + +RUN apt -y install build-essential +RUN apt -y install git +RUN apt -y install wget + +RUN apt -y install python +RUN apt -y install python-setuptools +RUN apt -y install python-pip +RUN apt -y install python-tk +RUN apt -y install tk +RUN apt -y install tcl +RUN apt -y install tclx8.4 +RUN apt -y install tcllib +RUN apt -y install tcl-tls + + +RUN apt -y install iputils-ping +RUN apt -y install snmp +RUN apt -y install snmptrapd + +COPY . /keysight +WORKDIR /keysight + +RUN pip install -r ./spytest.txt + +# https://downloads.ixiacom.com/support/downloads_and_updates/public/ixnetwork/9.10/IxNetworkAPI9.10.2007.7Linux64.bin.tgz +RUN bash ./IxNetworkAPI9.10.2007.7Linux64.bin -i silent + +RUN pip install -r /opt/ixia/ixnetwork/9.10.2007.7/lib/PythonApi/requirements.txt + +ENV SCID_TGEN_PATH=/opt +ENV SCID_TCL85_BIN=/opt +ENV IXNETWORK_VERSION=9.10.2007.7 +ENV HLAPI_VERSION=9.10.2007.43 + +LABEL author="Mircea Dan Gheorghe" +LABEL version="1.0" +LABEL description="SpyTest with Keysight traffic generator" \ No newline at end of file diff --git a/spytest/containers/keysight-ubuntu18/spytest.txt b/spytest/containers/keysight-ubuntu18/spytest.txt new file mode 100644 index 00000000000..bc2ddadff40 --- /dev/null +++ b/spytest/containers/keysight-ubuntu18/spytest.txt @@ -0,0 +1,35 @@ +ansible +autoflake +autopep8 +cryptography >= 2.5 +flake8 +future>=0.16.0 +gitpython +jinja2 +jira +jsonpatch +mmh3 +natsort +netaddr +netmiko==2.4.2 +prettytable +protobuf +psutil +pyang +pycryptodome +pyfiglet +pyflakes +pylint==1.8.1 +Pyro4 +pysnmp +pytest>=4.4.1,<=4.6.5 +pytest-timeout +pytest-xdist==1.28.0 +python-jenkins +redis +requests +rpyc +scapy==2.4.3rc1 +sphinx +tabulate +textfsm diff --git a/spytest/spytest/tgen/init.py b/spytest/spytest/tgen/init.py index a58a749d3b4..7ff5f97c10e 100644 --- a/spytest/spytest/tgen/init.py +++ b/spytest/spytest/tgen/init.py @@ -122,16 +122,18 @@ def tg_ixia_load(version, logger, logs_path=None): tcl_path = os.getenv("SCID_TCL85_BIN", def_tcl_path) tcl_lib_path = os.path.join(tcl_path, "..", "lib") ixia_root = os.path.join(tgen_path, "ixia", "all", "ixia-" + py_version) + + ixnetwork_version = os.getenv("IXNETWORK_VERSION", version_string) + hltapi_version = os.getenv("HLAPI_VERSION", version_string) + if not os.path.exists(ixia_root): - ixia_root = os.path.join(tgen_path, "ixia", "all", "ixia") - hlt_api = os.path.join(ixia_root, "hlapi", version_string) + ixia_root = os.path.join(tgen_path, "ixia") + hlt_api = os.path.join(ixia_root, "hlapi", hltapi_version) ngpf_api = os.path.join(hlt_api, "library", "common", "ixiangpf", "python") - ixn_py_api = os.path.join(ixia_root, "ixnetwork", version_string, - "lib", "PythonApi") - ixn_tcl_api_1 = os.path.join(ixia_root, "ixnetwork", version_string, - "lib", "IxTclNetwork") - ixn_tcl_api_2 = os.path.join(ixia_root, "ixnetwork", version_string, - "lib", "TclApi", "IxTclNetwork") + ixn_py_api = os.path.join(ixia_root, "ixnetwork", ixnetwork_version,"lib", "PythonApi") + ixn_tcl_api_1 = os.path.join(ixia_root, "ixnetwork", ixnetwork_version,"lib", "IxTclNetwork") + ixn_tcl_api_2 = os.path.join(ixia_root, "ixnetwork", ixnetwork_version,"lib", "TclApi", "IxTclNetwork") + os.environ["IXIA_VERSION"] = ixia_hltapi_map[version_string] os.environ["TCLLIBPATH"] = " ".join([hlt_api, ixn_tcl_api_1, ixn_tcl_api_2, tcl_lib_path]) sys.path.append(ngpf_api) diff --git a/spytest/spytest/tgen/tg.py b/spytest/spytest/tgen/tg.py index 20f2857fce4..82e01dc6650 100644 --- a/spytest/spytest/tgen/tg.py +++ b/spytest/spytest/tgen/tg.py @@ -2264,10 +2264,10 @@ def get_tgen(port, name=None): def is_soft_tgen(name=None): tg = get_chassis(name) - return (tg.tg_type == "scapy") + return (tg and tg.tg_type == "scapy") if __name__ == "__main__": - tg_ixia_load("8.42", None, None) + tg_ixia_load("9.10", None, None) code = \ "from ixiatcl import IxiaTcl \n" + \ "from ixiahlt import IxiaHlt \n" + \ diff --git a/spytest/spytest/tgen_api.py b/spytest/spytest/tgen_api.py index a2b512c1dd2..87661a5e3b3 100644 --- a/spytest/spytest/tgen_api.py +++ b/spytest/spytest/tgen_api.py @@ -50,7 +50,7 @@ def get_chassis(vars=None, index=0): def is_soft_tgen(vars=None): tg = get_chassis(vars) - return (tg.tg_type == "scapy") + return (tg and tg.tg_type == "scapy") def get_handles(vars, tg_port_list=list()): """