Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan authored Mar 22, 2024
2 parents aa094a0 + 04912ad commit 6e99f94
Show file tree
Hide file tree
Showing 80 changed files with 3,301 additions and 895 deletions.
3 changes: 3 additions & 0 deletions .artifactignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
**/*
!*.deb
!coverage.info
!coverage.xml
!build.info
9 changes: 7 additions & 2 deletions .azure-pipelines/build-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ jobs:
find $(Build.ArtifactStagingDirectory)/download/sairedis -name '*.deb' -exec cp "{}" .azure-pipelines/docker-sonic-vs/debs \;
cp -v $(Build.ArtifactStagingDirectory)/download/*.deb .azure-pipelines/docker-sonic-vs/debs
if [ -f $(Build.ArtifactStagingDirectory)/download/coverage.info ]; then
cp -v $(Build.ArtifactStagingDirectory)/download/coverage.info $(Build.ArtifactStagingDirectory)/
cp -v $(Build.ArtifactStagingDirectory)/download/coverage.xml $(Build.ArtifactStagingDirectory)/
fi
pushd .azure-pipelines
build_args=""
build_dir=$(grep BUILD_DIR $(Build.ArtifactStagingDirectory)/download/build.info | cut -d= -f2)
build_args="--build-arg build_dir=$build_dir"
if [ '${{ parameters.asan }}' == True ]; then
build_args="--build-arg need_dbg=y"
build_args="$build_args --build-arg need_dbg=y"
fi
docker build $build_args --no-cache -t docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber).asan-${{ parameters.asan }} docker-sonic-vs
Expand Down
4 changes: 4 additions & 0 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
swig4.0 \
libdbus-1-dev \
libteam-dev
sudo pip3 install lcov_cobertura
displayName: "Install dependencies"
- task: DownloadPipelineArtifact@2
inputs:
Expand All @@ -114,6 +115,7 @@ jobs:
artifact: ${{ parameters.swss_common_artifact_name }}
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/${{ parameters.swss_common_branch }}'
allowPartiallySucceededBuilds: true
path: $(Build.ArtifactStagingDirectory)/download/swsscommon
patterns: |
libswsscommon_1.0.0_${{ parameters.arch }}.deb
Expand All @@ -127,6 +129,7 @@ jobs:
artifact: ${{ parameters.sairedis_artifact_name }}
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/${{ parameters.sairedis_artifact_branch }}'
allowPartiallySucceededBuilds: true
path: $(Build.ArtifactStagingDirectory)/download/sairedis
patterns: |
${{ parameters.sairedis_artifact_pattern }}/libsaivs_*.deb
Expand Down Expand Up @@ -191,6 +194,7 @@ jobs:
cp -r pytest.tgz $(Build.ArtifactStagingDirectory)/
if [ '${{ parameters.archive_gcov }}' == True ]; then
export ENABLE_GCOV=y
echo BUILD_DIR=$(pwd) > build.info
fi
if [ '${{ parameters.asan }}' == True ]; then
export ENABLE_ASAN=y
Expand Down
12 changes: 11 additions & 1 deletion .azure-pipelines/docker-sonic-vs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM docker-sonic-vs

ARG docker_container_name
ARG need_dbg
ARG build_dir
ENV BUILD_DIR=$build_dir

COPY ["debs", "/debs"]

Expand All @@ -24,4 +26,12 @@ RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/swss-dbg_1.0.0_amd64.deb ; fi

RUN apt-get update

RUN apt-get -y install lcov
RUN apt-get -y install software-properties-common libdatetime-perl libcapture-tiny-perl build-essential libcpanel-json-xs-perl git

RUN git clone -b v2.0 --single-branch --depth 1 https://github.com/linux-test-project/lcov && cd lcov && make install

RUN lcov --version

RUN pip3 install lcov_cobertura

RUN if [ -n "$BUILD_DIR" ]; then mkdir -p $BUILD_DIR && tar -xf /tmp/gcov/gcov-source.tar -C $BUILD_DIR; fi
86 changes: 43 additions & 43 deletions .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ jobs:
- job:
displayName: vstest
timeoutInMinutes: ${{ parameters.timeout }}
${{ if parameters.archive_gcov }}:
variables:
DIFF_COVER_CHECK_THRESHOLD: 80
DIFF_COVER_ENABLE: 'true'
DIFF_COVER_COVERAGE_FILES: Cobertura.xml

pool: sonic-common
pool: sonic-common-test

steps:
- script: |
ip a show dev eth0 || true
ls -A1 | xargs -I{} sudo rm -rf {}
displayName: "Clean workspace"
- checkout: self
Expand Down Expand Up @@ -78,6 +84,16 @@ jobs:
path: $(Build.ArtifactStagingDirectory)/download
displayName: "Download sonic buildimage ubuntu20.04 deb packages"

- script: |
set -ex
# Install .NET CORE
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-add-repository https://packages.microsoft.com/ubuntu/20.04/prod
sudo apt-get update
sudo apt-get install -y dotnet-sdk-7.0
sudo dotnet tool install dotnet-reportgenerator-globaltool --tool-path /usr/bin
displayName: "Install .NET CORE"
- script: |
set -ex
sudo .azure-pipelines/build_and_install_module.sh
Expand All @@ -92,6 +108,7 @@ jobs:
sudo apt-get install -y net-tools bridge-utils vlan
sudo apt-get install -y python3-pip
sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker>=4.4.1 redis==3.3.4 flaky==3.7.0
sudo pip3 install lcov_cobertura
displayName: "Install dependencies"
- script: |
Expand All @@ -106,7 +123,9 @@ jobs:
params=""
if [ '${{ parameters.archive_gcov }}' == True ]; then
params=" ${params} --keeptb "
cp $(Build.ArtifactStagingDirectory)/download/coverage.info ./
cp $(Build.ArtifactStagingDirectory)/download/coverage.xml ./
params=" ${params} --enable-coverage --force-recreate-dvs "
fi
if [ '${{ parameters.asan }}' == True ]; then
params=" ${params} --graceful-stop "
Expand All @@ -115,44 +134,37 @@ jobs:
params=" ${params} --num-ports=${{ parameters.num_ports }} "
fi
all_tests=$(ls test_*.py)
all_tests=$(ls test_*.py | xargs)
all_tests="${all_tests} p4rt"
if [ -n '${{ parameters.run_tests_pattern }}' ]; then
all_tests=" $(ls ${{ parameters.run_tests_pattern }}) "
fi
test_set=()
# Run 20 tests as a set.
for test in ${all_tests}; do
test_set+=("${test}")
if [ ${#test_set[@]} -ge 20 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" $params --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber).asan-${{ parameters.asan }}
container_count=$(docker ps -q -a | wc -l)
if [ '${{ parameters.archive_gcov }}' == True ] && [ ${container_count} -gt 0 ]; then
./gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
test_set=()
fi
done
if [ ${#test_set[@]} -gt 0 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v $params --force-flaky --junitxml="${test_name}_tr.xml" $params --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber).asan-${{ parameters.asan }}
container_count=$(docker ps -q -a | wc -l)
if [ '${{ parameters.archive_gcov }}' == True ] && [ ${container_count} -gt 0 ]; then
./gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
all_tests=" $(ls ${{ parameters.run_tests_pattern }} | xargs) "
fi
# Run the tests in parallel and retry
retry=3
IMAGE_NAME=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber).asan-${{ parameters.asan }}
echo $all_tests | xargs -n 1 | xargs -P 8 -I TEST_MODULE sudo ./run-tests.sh "$IMAGE_NAME" "$params" "TEST_MODULE" 3
rm -rf $(Build.ArtifactStagingDirectory)/download
displayName: "Run vs tests"
continueOnError: ${{ parameters.asan }}
- script: |
set -ex
reportgenerator -reporttypes:Cobertura -reports:tests/*coverage.xml -targetdir:.
mkdir $(Build.ArtifactStagingDirectory)/gcov
cp Cobertura.xml tests/*coverage.xml $(Build.ArtifactStagingDirectory)/gcov/
cp tests/*coverage.info $(Build.ArtifactStagingDirectory)/gcov/
condition: ${{ parameters.archive_gcov }}
displayName: "Generate coverage.xml"
- task: PublishCodeCoverageResults@1
condition: ${{ parameters.archive_gcov }}
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/Cobertura.xml'
displayName: 'Publish test coverage'

- task: PublishTestResults@2
inputs:
testResultsFiles: '**/*_tr.xml'
Expand All @@ -165,21 +177,9 @@ jobs:
if [ '${{ parameters.asan }}' == True ]; then
cp -vr tests/log/*/log/asan $(Build.ArtifactStagingDirectory)/
fi
if [ '${{ parameters.archive_gcov }}' == True ]; then
sudo apt-get install -y lcov
cd $(Build.ArtifactStagingDirectory)/gcov_tmp/
tar -zcvf sonic-gcov.tar.gz sonic-gcov/
rm -rf sonic-gcov
fi
displayName: "Collect logs"
condition: always()
- publish: $(Build.ArtifactStagingDirectory)/gcov_tmp
artifact: ${{ parameters.gcov_artifact_name }}
displayName: "Publish gcov output"
condition: and(succeeded(), eq('${{ parameters.archive_gcov }}', true))

- publish: $(Build.ArtifactStagingDirectory)/
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
displayName: "Publish logs"
Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ stages:
- template: .azure-pipelines/build-template.yml
parameters:
arch: amd64
pool: sonicbld
sonic_slave: sonic-slave-bullseye
common_lib_artifact_name: common-lib
swss_common_artifact_name: sonic-swss-common
Expand All @@ -55,6 +56,7 @@ stages:
- template: .azure-pipelines/build-template.yml
parameters:
arch: amd64
pool: sonicbld
sonic_slave: sonic-slave-bullseye
common_lib_artifact_name: common-lib
swss_common_artifact_name: sonic-swss-common
Expand Down Expand Up @@ -137,8 +139,8 @@ stages:
asan: true

- stage: Gcov
condition: false
dependsOn: Test
condition: in(dependencies.Test.result, 'Succeeded', 'SucceededWithIssues')
jobs:
- template: .azure-pipelines/gcov.yml
parameters:
Expand Down
28 changes: 14 additions & 14 deletions cfgmgr/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ macsecmgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI) $(
macsecmgrd_LDADD = $(LDFLAGS_ASAN) $(COMMON_LIBS) $(SAIMETA_LIBS)

if GCOV_ENABLED
vlanmgrd_LDADD += -lgcovpreload
teammgrd_LDADD += -lgcovpreload
portmgrd_LDADD += -lgcovpreload
intfmgrd_LDADD+= -lgcovpreload
buffermgrd_LDADD += -lgcovpreload
vrfmgrd_LDADD += -lgcovpreload
nbrmgrd_LDADD += -lgcovpreload
vxlanmgrd_LDADD += -lgcovpreload
sflowmgrd_LDADD += -lgcovpreload
natmgrd_LDADD += -lgcovpreload
coppmgrd_LDADD += -lgcovpreload
tunnelmgrd_LDADD += -lgcovpreload
macsecmgrd_LDADD += -lgcovpreload
fabricmgrd_LDADD += -lgcovpreload
vlanmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
teammgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
portmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
fabricmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
intfmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
buffermgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
vrfmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
nbrmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
vxlanmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
sflowmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
natmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
coppmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
tunnelmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
macsecmgrd_SOURCES += ../gcovpreload/gcovpreload.cpp
endif

if ASAN_ENABLED
Expand Down
19 changes: 15 additions & 4 deletions cfgmgr/buffer_pool_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ local function iterate_profile_list(all_items)
return 0
end

local function fetch_buffer_pool_size_from_appldb()
local function fetch_buffer_pool_size_from_appldb(shp_enabled)
local buffer_pools = {}
redis.call('SELECT', config_db)
local buffer_pool_keys = redis.call('KEYS', 'BUFFER_POOL|*')
Expand All @@ -158,7 +158,18 @@ local function fetch_buffer_pool_size_from_appldb()
end
xoff = redis.call('HGET', 'BUFFER_POOL_TABLE:' .. buffer_pools[i], 'xoff')
if not xoff then
table.insert(result, buffer_pools[i] .. ':' .. size)
if shp_enabled and size == "0" and buffer_pools[i] == "ingress_lossless_pool" then
-- During initialization, if SHP is enabled
-- 1. the buffer pool sizes, xoff have initialized to 0, which means the shared headroom pool is disabled
-- 2. but the buffer profiles already indicate the shared headroom pool is enabled
-- 3. later on the buffer pool sizes are updated with xoff being non-zero
-- In case the orchagent starts handling buffer configuration between 2 and 3,
-- It is inconsistent between buffer pools and profiles, which fails Mellanox SAI sanity check
-- To avoid it, it indicates the shared headroom pool is enabled by setting a very small buffer pool and shared headroom pool sizes
table.insert(result, buffer_pools[i] .. ':2048:1024')
else
table.insert(result, buffer_pools[i] .. ':' .. size)
end
else
table.insert(result, buffer_pools[i] .. ':' .. size .. ':' .. xoff)
end
Expand Down Expand Up @@ -295,7 +306,7 @@ local fail_count = 0
fail_count = fail_count + iterate_all_items(all_pgs, true)
fail_count = fail_count + iterate_all_items(all_tcs, false)
if fail_count > 0 then
fetch_buffer_pool_size_from_appldb()
fetch_buffer_pool_size_from_appldb(shp_enabled)
return result
end

Expand All @@ -305,7 +316,7 @@ local all_egress_profile_lists = redis.call('KEYS', 'BUFFER_PORT_EGRESS_PROFILE_
fail_count = fail_count + iterate_profile_list(all_ingress_profile_lists)
fail_count = fail_count + iterate_profile_list(all_egress_profile_lists)
if fail_count > 0 then
fetch_buffer_pool_size_from_appldb()
fetch_buffer_pool_size_from_appldb(shp_enabled)
return result
end

Expand Down
4 changes: 2 additions & 2 deletions cfgmgr/fabricmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ bool FabricMgr::writeConfigToAppDb(const std::string &key, const std::string &fi
if (key == "FABRIC_MONITOR_DATA")
{
m_appFabricMonitorTable.set(key, fvs);
SWSS_LOG_NOTICE("Write FABRIC_MONITOR:%s %s to %s", key.c_str(), field.c_str(), value.c_str());
SWSS_LOG_INFO("Write FABRIC_MONITOR:%s %s to %s", key.c_str(), field.c_str(), value.c_str());
}
else
{
m_appFabricPortTable.set(key, fvs);
SWSS_LOG_NOTICE("Write FABRIC_PORT:%s %s to %s", key.c_str(), field.c_str(), value.c_str());
SWSS_LOG_INFO("Write FABRIC_PORT:%s %s to %s", key.c_str(), field.c_str(), value.c_str());
}

return true;
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ if test "x$asan_enabled" = "xtrue"; then
CFLAGS_ASAN+=" -fsanitize=address"
CFLAGS_ASAN+=" -DASAN_ENABLED"
CFLAGS_ASAN+=" -ggdb -fno-omit-frame-pointer -U_FORTIFY_SOURCE"
CFLAGS_ASAN+=" -Wno-maybe-uninitialized"
AC_SUBST(CFLAGS_ASAN)

LDFLAGS_ASAN+=" -lasan"
Expand Down
7 changes: 4 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ifeq ($(ENABLE_ASAN), y)
endif

ifeq ($(ENABLE_GCOV), y)
configure_opts += --enable-gcov CFLAGS="-g -O0" CXXFLAGS="-g -O0"
configure_opts += --enable-gcov --enable-code-coverage CFLAGS="-g -O0" CXXFLAGS="-g -O0"
endif

override_dh_auto_configure:
Expand All @@ -43,9 +43,10 @@ override_dh_auto_install:
dh_auto_install --destdir=debian/swss
ifeq ($(ENABLE_GCOV), y)
mkdir -p debian/swss/tmp/gcov
sh ./tests/gcov_support.sh collect swss
lcov -c --directory . --no-external --exclude "$(shell pwd)/tests/*" --exclude "$(shell pwd)/**/tests/*" --output-file coverage.info
lcov_cobertura coverage.info -o coverage.xml
find ./ -type f -regex '.*\.\(h\|cpp\|gcno\|info\)' | tar -cf debian/swss/tmp/gcov/gcov-source.tar -T -
endif

override_dh_strip:
dh_strip --dbg-package=swss-dbg

2 changes: 1 addition & 1 deletion fdbsyncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fdbsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(COV_CFLAGS) $(CF
fdbsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon $(COV_LDFLAGS)

if GCOV_ENABLED
fdbsyncd_LDADD += -lgcovpreload
fdbsyncd_SOURCES += ../gcovpreload/gcovpreload.cpp
endif

if ASAN_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion fpmsyncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fpmsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_ASAN)
fpmsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon

if GCOV_ENABLED
fpmsyncd_LDADD += -lgcovpreload
fpmsyncd_SOURCES += ../gcovpreload/gcovpreload.cpp
endif

if ASAN_ENABLED
Expand Down
Loading

0 comments on commit 6e99f94

Please sign in to comment.