-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding script to execute sonic-framework/tests
- Loading branch information
Bibhuprasad Singh
committed
Jan 10, 2025
1 parent
14eb980
commit 2d6532d
Showing
4 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Script tests_scrip.sh can be used to execute sonic-framework/tests UT test cases. | ||
|
||
|
||
# Steps to run tests_scrip.sh | ||
|
||
|
||
# 1.Build the workspace, incase the workspace is not built using following commands. | ||
|
||
cd /sonic-buildiamge | ||
|
||
make init | ||
|
||
NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 NOBULLSEYE=1 SONIC_BUILD_JOBS=12 make configure PLATFORM=vs | ||
|
||
NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 NOBULLSEYE=1 SONIC_BUILD_JOBS=12 make target/sonic-vs.img.gz | ||
|
||
|
||
# 2. Create a virtual environment using following steps. | ||
|
||
Run create_virtualenv.sh script to create a virtual environment. | ||
|
||
sh create_virtualenv.sh ./ | ||
|
||
|
||
# 3. Copy database_config.json to /tmp directory. | ||
|
||
cp sonic-buildimage/src/sonic-framework/tests/test_scripts/database_config.json /tmp | ||
|
||
|
||
# 4. Run test_script.sh inside the virtual envirment to execute the UT test cases | ||
|
||
sh test_script.sh ./ | ||
|
||
|
||
|
||
|
17 changes: 17 additions & 0 deletions
17
src/sonic-framework/tests/test_scripts/create_virtualenv.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# read virtual environment name | ||
read -p "Enter the name of the virtual environment: " venv | ||
|
||
# Install virtual env | ||
sudo apt-get install python3-pip | ||
|
||
sudo apt-get install virtualenv | ||
|
||
# Create a virtual environment | ||
virtualenv $venv | ||
echo | ||
echo | ||
echo "To activate the virtualenv, run:" | ||
|
||
echo " source $venv/bin/activate" |
99 changes: 99 additions & 0 deletions
99
src/sonic-framework/tests/test_scripts/database_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"INSTANCES": { | ||
"redis":{ | ||
"hostname" : "127.0.0.1", | ||
"port" : 6379, | ||
"unix_socket_path" : "/var/run/redis/redis.sock" | ||
}, | ||
"redis_chassis":{ | ||
"hostname" : "redis_chassis.server", | ||
"port" : 6380, | ||
"unix_socket_path" : "/var/run/redis/redis_chassis.sock" | ||
} | ||
}, | ||
"DATABASES" : { | ||
"APPL_DB" : { | ||
"id" : 0, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"ASIC_DB" : { | ||
"id" : 1, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"COUNTERS_DB" : { | ||
"id" : 2, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"LOGLEVEL_DB" : { | ||
"id" : 3, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"CONFIG_DB" : { | ||
"id" : 4, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"PFC_WD_DB" : { | ||
"id" : 5, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"FLEX_COUNTER_DB" : { | ||
"id" : 5, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"STATE_DB" : { | ||
"id" : 6, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"SNMP_OVERLAY_DB" : { | ||
"id" : 7, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"RESTAPI_DB" : { | ||
"id" : 8, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"GB_ASIC_DB" : { | ||
"id" : 9, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"GB_COUNTERS_DB" : { | ||
"id" : 10, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"GB_FLEX_COUNTER_DB" : { | ||
"id" : 11, | ||
"separator": ":", | ||
"instance" : "redis" | ||
}, | ||
"CHASSIS_APP_DB" : { | ||
"id" : 12, | ||
"separator": "|", | ||
"instance" : "redis_chassis" | ||
}, | ||
"CHASSIS_STATE_DB" : { | ||
"id" : 13, | ||
"separator": "|", | ||
"instance" : "redis_chassis" | ||
}, | ||
"APPL_STATE_DB" : { | ||
"id" : 14, | ||
"separator": ":", | ||
"instance" : "redis" | ||
} | ||
}, | ||
"VERSION" : "1.0" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
# execute all the steps inside virtual Environment. | ||
# From /sonic-buildimage path. | ||
# | ||
# Creating a new folder inside /tmp and | ||
# Downloading libhiredis packages to /tmp/new path. | ||
mkdir /tmp/new | ||
cd /tmp/new | ||
curl -O https://ftp.debian.org/debian/pool/main/h/hiredis/libhiredis0.14_0.14.1-3_amd64.deb | ||
curl -O https://ftp.debian.org/debian/pool/main/h/hiredis/libhiredis-dev_0.14.1-3_amd64.deb | ||
|
||
# Install all the dependencies/pkgs | ||
# which are present in target/debs/bookworm path. | ||
cd - | ||
cd ../../../../target/debs/bookworm | ||
|
||
sudo dpkg -r libhiredis-dev | ||
sudo apt remove libhiredis0.14 | ||
sudo dpkg -r libhiredis1.1.0 | ||
sudo dpkg -i /tmp/new/libhiredis0.14_0.14.1-3_amd64.deb | ||
sudo dpkg -i /tmp/new/libhiredis-dev_0.14.1-3_amd64.deb | ||
sudo dpkg -i libnl-3-200_*.deb | ||
sudo dpkg -i libnl-3-dev_*.deb | ||
sudo dpkg -i libnl-genl-3-200_*.deb | ||
sudo dpkg -i libnl-genl-3-dev_*.deb | ||
sudo dpkg -i libnl-route-3-200_*.deb | ||
sudo dpkg -i libnl-route-3-dev_*.deb | ||
sudo dpkg -i libnl-nf-3-200_*.deb | ||
sudo dpkg -i libnl-nf-3-dev_*.deb | ||
sudo dpkg -i libnl-cli-3-200_*.deb | ||
sudo dpkg -i libnl-cli-3-dev_*.deb | ||
sudo dpkg -i libyang_*.deb | ||
sudo dpkg -i libyang-*.deb | ||
sudo dpkg -i libswsscommon_1.0.0_amd64.deb | ||
sudo dpkg -i libswsscommon-dev_1.0.0_amd64.deb | ||
|
||
# Install pip and add base-tooling-requirement.text | ||
sudo apt-get update | ||
sudo pip install --upgrade pip | ||
|
||
touch base-tooling-requirements.txt | ||
sudo echo "Pympler ==0.8 --hash=sha256:f74cd2982c5cd92ded55561191945616f2bb904a0ae5cdacdb566c6696bdb922" >> base-tooling-requirements.txt | ||
|
||
pip install --require-hashes -r base-tooling-requirements.txt | ||
|
||
|
||
# Install redis-tools inside virtualenv | ||
sudo apt install redis-server redis-tools | ||
sudo sed -i 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf | ||
sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf | ||
sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf | ||
sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf | ||
|
||
# Start redis-server : | ||
sudo service redis-server restart& | ||
|
||
# Install gtest and gmock | ||
sudo apt-get install -y libgtest-dev | ||
sudo apt-get install -y libgmock-dev | ||
|
||
# Install dependencies need to execute tests | ||
sudo apt-get install libjansson-dev | ||
sudo apt install protobuf-compiler | ||
sudo apt install libdbus-c++-bin | ||
sudo apt install libdbus-c++-dev | ||
|
||
# Create /var/run/redis/sonic-db folder. | ||
# copy the database_config.json file to /var/run/redis/sonic-db path. | ||
sudo mkdir -p /var/run/redis/sonic-db | ||
sudo cp /tmp/database_config.json /var/run/redis/sonic-db/ | ||
|
||
|
||
#Build the sonic-fraework/tests. | ||
cd ../../../src/sonic-framework/ | ||
./autogen.sh | ||
./configure | ||
make | ||
|
||
cd tests | ||
make | ||
|
||
#execure the sonic-framework tests. | ||
./tests | ||
./tests_asan | ||
./tests_tsan | ||
./tests_usan | ||
|