Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test][SAI-PTF][mlnx]Enable saiserver test container on mlnx container #13312

29 changes: 10 additions & 19 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ jobs:
rm target/sonic-vs.img
fi
else
if [ $(GROUP_NAME) == mellanox ]; then
make $BUILD_OPTIONS SAITHRIFT_V2=y ENABLE_SYNCD_RPC=y target/docker-saiserverv2-mlnx.gz
fi
if [ $(GROUP_NAME) == marvell-armhf ]; then
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y PLATFORM_ARCH=armhf target/docker-saiserverv2-mrvl.gz
fi
if [ $(dbg_image) == yes ]; then
make $BUILD_OPTIONS INSTALL_DEBUG_TOOLS=y target/sonic-$(GROUP_NAME).bin
mv target/sonic-$(GROUP_NAME).bin target/sonic-$(GROUP_NAME)-dbg.bin
Expand All @@ -148,35 +154,20 @@ jobs:
if [ $(raw_image) == yes ]; then
make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).raw
fi
if [ $(GROUP_NAME) == marvell-armhf ]; then
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y PLATFORM_ARCH=armhf target/docker-saiserverv2-mrvl.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
fi
if [ $(docker_syncd_rpc_image) == yes ]; then
# workaround for issue in rules/sairedis.dep, git ls-files will list un-exist files for cache
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y target/docker-syncd-$(platform_rpc)-rpc.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
if [ $(GROUP_NAME) == broadcom ]; then
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y target/docker-syncd-$(platform_rpc)-dnx-rpc.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y target/docker-saiserverv2-brcm.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
fi
if [ $(GROUP_NAME) == marvell-armhf ]; then
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y PLATFORM_ARCH=armhf target/docker-saiserverv2-mrvl.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
fi
fi
if [ $(GROUP_NAME) == mellanox ]; then
make $BUILD_OPTIONS SAITHRIFT_V2=y ENABLE_SYNCD_RPC=y target/docker-saiserverv2-mlnx.gz
fi
fi
if [ $(syncd_rpc_image) == yes ]; then
make $BUILD_OPTIONS ENABLE_SYNCD_RPC=y target/sonic-$(GROUP_NAME).bin
mv target/sonic-mellanox.bin target/sonic-$(GROUP_NAME)-rpc.bin
Expand Down
7 changes: 1 addition & 6 deletions .azure-pipelines/azure-pipelines-repd-build-variables.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
variables:
${{ if eq(variables['Build.Reason'],'PullRequest') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=$([ "$(System.PullRequest.TargetBranch)" != "master" ] && echo deb,py2,py3,web,git,docker)'
${{ elseif ne(variables['Build.SourceBranch'],'master') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
${{ else }}:
VERSION_CONTROL_OPTIONS: ''
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=none'
19 changes: 9 additions & 10 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ jobs:

make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) target/docker-sonic-vs.gz target/sonic-vs.img.gz target/docker-ptf.gz
else
if [ ${{ parameters.platform }} == mellanox ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) SAITHRIFT_V2=y ENABLE_SYNCD_RPC=y target/docker-saiserverv2-mlnx.gz
fi
if [ $(GROUP_NAME) == marvell-armhf ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y PLATFORM_ARCH=armhf target/docker-saiserverv2-mrvl.gz
fi
if [ ${{ parameters.dbg_image }} == true ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) INSTALL_DEBUG_TOOLS=y target/sonic-${{ parameters.platform }}.bin && \
mv target/sonic-${{ parameters.platform }}.bin target/sonic-${{ parameters.platform }}-dbg.bin
Expand All @@ -105,21 +111,14 @@ jobs:
fi
if [ ${{ parameters.sync_rpc_image }} == true ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y target/docker-syncd-${{ parameters.platform_short }}-rpc.gz
# workaround for issue in rules/sairedis.dep, git ls-files will list un-exist files for cache
pushd ./src/sonic-sairedis/SAI
git stash
popd
if [ ${{ parameters.platform }} == broadcom ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y target/docker-saiserverv2-brcm.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
fi
if [ $(GROUP_NAME) == marvell-armhf ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) ENABLE_SYNCD_RPC=y SAITHRIFT_V2=y PLATFORM_ARCH=armhf target/docker-saiserverv2-mrvl.gz
pushd ./src/sonic-sairedis/SAI
git stash
popd
fi
if [ ${{ parameters.platform }} == mellanox ]; then
make USERNAME=admin $CACHE_OPTIONS SONIC_BUILD_JOBS=$(nproc) SAITHRIFT_V2=y ENABLE_SYNCD_RPC=y target/docker-saiserverv2-mlnx.gz
fi
fi

Expand Down
3 changes: 0 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ stages:
parameters:
buildOptions: 'USERNAME=admin SONIC_BUILD_JOBS=$(nproc) ${{ variables.VERSION_CONTROL_OPTIONS }}'
jobGroups:
- name: broadcom
variables:
swi_image: yes
- name: mellanox
- name: marvell-armhf
pool: sonicbld-armhf
Expand Down
21 changes: 20 additions & 1 deletion platform/mellanox/docker-saiserver-mlnx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,26 @@

DOCKER_SAISERVER_MLNX = docker-saiserver$(SAITHRIFT_VER)-mlnx.gz
$(DOCKER_SAISERVER_MLNX)_PATH = $(PLATFORM_PATH)/docker-saiserver-mlnx
$(DOCKER_SAISERVER_MLNX)_DEPENDS += $(SAISERVER) $(PYTHON_SDK_API)
$(DOCKER_SAISERVER_MLNX)_DEPENDS += $(SAISERVER)

$(DOCKER_SAISERVER_MLNX)_DEPENDS += $(PYTHON_SDK_API) $(MFT)

ifeq ($(ENABLE_ASAN), y)
$(DOCKER_SAISERVER_MLNX)_DEPENDS += $(SAISERVER_DBG)
endif

$(DOCKER_SAISERVER_MLNX)_FILES += $(ISSU_VERSION_FILE)

ifeq ($(SDK_FROM_SRC), y)
$(DOCKER_SAISERVER_MLNX)_DBG_DEPENDS += $(MLNX_SDK_DBG_DEBS) $(MLNX_SAI_DBGSYM)
endif

# Use syncd_init_common.sh to init hardware platform
SYNCD_INIT_COMMON_SCRIPT = syncd_init_common.sh
$(SYNCD_INIT_COMMON_SCRIPT)_PATH = $(SRC_PATH)/sonic-sairedis/syncd/scripts
SONIC_COPY_FILES += $(SYNCD_INIT_COMMON_SCRIPT)

$(DOCKER_SAISERVER_MLNX)_FILES += $(SYNCD_INIT_COMMON_SCRIPT)
$(DOCKER_SAISERVER_MLNX)_PYTHON_DEBS += $(MLNX_SFPD)
$(DOCKER_SAISERVER_MLNX)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE)
SONIC_DOCKER_IMAGES += $(DOCKER_SAISERVER_MLNX)
Expand Down
72 changes: 57 additions & 15 deletions platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,84 @@
## See the License for the specific language governing permissions and
## limitations under the License.
##
{% from "dockers/dockerfile-macros.j2" import install_debian_packages %}
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

#Install syncd dependences
RUN mkdir -p /var/run/sx_sdk

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
libxml2 \
python3-pip \
python3-dev \
python-is-python3 \
{%- if ENABLE_ASAN == "y" %}
libasan6 \
{%- endif %}
python3-setuptools

RUN pip3 install --upgrade pip
RUN apt-get purge -y python-pip

#install syncd_rpc dependences
## Pre-install the fundamental packages
RUN apt-get update \
&& apt-get -y install \
gdb \
net-tools \
python-setuptools \
build-essential \
libssl-dev \
libffi-dev \
python-dev \
wget \
cmake \
libqt5core5a \
libqt5network5 \
libboost-atomic1.74.0

COPY \
{% for deb in docker_saiserver_mlnx_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/
# Build and install python-scapy
RUN curl http://ftp.us.debian.org/debian/pool/main/s/scapy/python-scapy_2.4.0-2_all.deb --output python-scapy_2.4.0-2_all.deb \
&& dpkg -i python-scapy_2.4.0-2_all.deb \
&& apt install -f

COPY \
{% for deb in docker_saiserver_mlnx_pydebs.split(' ') -%}
python-debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/

RUN apt-get install -y --no-install-recommends libxml2 iptables libbsd0 protobuf-c-compiler protobuf-compiler python3-protobuf libprotobuf-c1 python3-future python3-ipaddr libnet1 pkg-config asciidoc xmlto
{% if docker_saiserver_mlnx_debs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("debs/", docker_saiserver_mlnx_debs.split(' '), "/debs/") }}

# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_saiserver_mlnx_debs.split(' ')) }}
{% endif %}

COPY ["start.sh", "/usr/bin/"]
{% if docker_saiserver_mlnx_pydebs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("python-debs/", docker_saiserver_mlnx_pydebs.split(' '), "/debs/") }}

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_saiserver_mlnx_pydebs.split(' ')) }}
{% endif %}


RUN apt-get install -y --no-install-recommends libxml2 iptables libbsd0 protobuf-c-compiler protobuf-compiler python3-protobuf libprotobuf-c1 python3-future python3-ipaddr libnet1 pkg-config asciidoc xmlto

COPY ["start.sh", "/usr/bin/"]
COPY ["old_start.sh", "/usr/bin/"]
COPY ["saiserver_start.sh", "/usr/bin/"]
COPY ["files/syncd_init_common.sh", "/usr/bin/"]
RUN chmod +x /usr/bin/saiserver_start.sh /usr/bin/syncd_init_common.sh /usr/bin/old_start.sh
COPY ["profile.ini", "portmap.ini", "/etc/sai/"]
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]

RUN mkdir -p /etc/supervisor/conf.d/
RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2

COPY ["sai_2700.xml", "/usr/share/"]

Expand Down
13 changes: 13 additions & 0 deletions platform/mellanox/docker-saiserver-mlnx/old_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
start_mlnx()
{
[ -e /dev/sxdevs/sxcdev ] || ( mkdir -p /dev/sxdevs && mknod /dev/sxdevs/sxcdev c 231 193 )
}


rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

start_mlnx

supervisorctl start saiserver
32 changes: 32 additions & 0 deletions platform/mellanox/docker-saiserver-mlnx/saiserver_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Copy from src/sonic-sairedis/syncd/scripts/syncd_start.sh
# Re-use the structure for syncd setup
# Use it to start saiserver
# Script to start syncd using supervisord
#

# Source the file that holds common code for systemd and supervisord
. /usr/bin/syncd_init_common.sh

get_saiserver_param()
{
IFS=' ' read -r -a array <<< "$CMD_ARGS"
for index in "${!array[@]}"
do
#echo "$index ${array[index]}"
if [[ "${array[index]}" == *"-p"* ]]; then
SAI_PROFILE="${array[index+1]}"
fi
if [[ "${array[index]}" == *"-m"* ]]; then
PORT_CONFIG="${array[index+1]}"
fi
done
}

ENABLE_SAITHRIFT=1
config_syncd
get_saiserver_param

echo exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG}
exec /usr/sbin/saiserver -p ${SAI_PROFILE} -f ${PORT_CONFIG}
#exec ${CMD} ${CMD_ARGS}
10 changes: 0 additions & 10 deletions platform/mellanox/docker-saiserver-mlnx/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
# limitations under the License.
#

start_mlnx()
{
[ -e /dev/sxdevs/sxcdev ] || ( mkdir -p /dev/sxdevs && mknod /dev/sxdevs/sxcdev c 231 193 )
}


rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

start_mlnx

supervisorctl start saiserver
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% set asan_extra_options = ':print_suppressions=0' %}
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
Expand All @@ -20,9 +21,12 @@ stdout_logfile=syslog
stderr_logfile=syslog

[program:saiserver]
command=/usr/sbin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini
command=/usr/bin/saiserver_start.sh
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
{% if ENABLE_ASAN == "y" %}
environment=ASAN_OPTIONS="log_path=/var/log/asan/syncd-asan.log{{ asan_extra_options }}"
{% endif %}
10 changes: 9 additions & 1 deletion platform/mellanox/libsaithrift-dev.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ SAI_VER = 0.9.4

LIBSAITHRIFT_DEV = libsaithrift$(SAITHRIFT_VER)-dev_$(SAI_VER)_amd64.deb
$(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI

#Support two different versions of thrift
ifeq ($(SAITHRIFT_V2),y)
$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT_0_14_1) $(LIBTHRIFT_0_14_1_DEV) $(PYTHON3_THRIFT_0_14_1) $(THRIFT_0_14_1_COMPILER)
$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT_0_14_1)
$(LIBSAITHRIFT_DEV)_BUILD_ENV += SAITHRIFTV2=true GEN_SAIRPC_OPTS="--adapter_logger"
else
$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER)
$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT)
$(LIBSAITHRIFT_DEV)_BUILD_ENV = SAITHRIFT_VER=v2 # Workaround to use python3 in build
endif
$(LIBSAITHRIFT_DEV)_BUILD_ENV += SAITHRIFT_VER=v2 # Workaround to use python3 in build
$(LIBSAITHRIFT_DEV)_DEPENDS += $(MLNX_SAI) $(MLNX_SAI_DEV)
$(LIBSAITHRIFT_DEV)_RDEPENDS += $(MLNX_SAI)

Expand Down