Skip to content

Commit 9ba9def

Browse files
author
Bibhuprasad Singh
committed
Adding script to execute sonic-framework/tests
1 parent 14eb980 commit 9ba9def

File tree

4 files changed

+222
-0
lines changed

4 files changed

+222
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Steps to run tests_script.sh
2+
3+
1. Build the workspace, incase the workspace is not built using following commands.
4+
5+
cd /sonic-buildiamge
6+
7+
make init
8+
9+
NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 NOBULLSEYE=1 SONIC_BUILD_JOBS=12 make configure PLATFORM=vs
10+
11+
NOJESSIE=1 NOSTRETCH=1 NOBUSTER=1 NOBULLSEYE=1 SONIC_BUILD_JOBS=12 make target/sonic-vs.img.gz
12+
13+
14+
2. Create a virtual environment using following steps.
15+
16+
Run create_virtualenv.sh script to create a virtual environment.
17+
18+
sh create_virtualenv.sh ./
19+
20+
21+
3. Run test_script.sh inside the virtual envirment to execute the UT test cases
22+
23+
sh test_script.sh ./
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# read virtual environment name
4+
read -p "Enter the name of the virtual environment: " venv
5+
6+
# Install virtual env
7+
sudo apt-get install python3-pip
8+
9+
sudo apt-get install virtualenv
10+
11+
# Create a virtual environment
12+
virtualenv $venv
13+
echo
14+
echo
15+
echo "To activate the virtualenv, run:"
16+
17+
echo " source $venv/bin/activate"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"INSTANCES": {
3+
"redis": {
4+
"hostname": "127.0.0.1",
5+
"port": 6379,
6+
"unix_socket_path": "/var/run/redis/redis.sock"
7+
},
8+
"redis_chassis": {
9+
"hostname": "redis_chassis.server",
10+
"port": 6380,
11+
"unix_socket_path": "/var/run/redis/redis_chassis.sock"
12+
}
13+
},
14+
"DATABASES": {
15+
"APPL_DB": {
16+
"id": 0,
17+
"separator": ":",
18+
"instance": "redis"
19+
},
20+
"ASIC_DB": {
21+
"id": 1,
22+
"separator": ":",
23+
"instance": "redis"
24+
},
25+
"COUNTERS_DB": {
26+
"id": 2,
27+
"separator": ":",
28+
"instance": "redis"
29+
},
30+
"LOGLEVEL_DB": {
31+
"id": 3,
32+
"separator": ":",
33+
"instance": "redis"
34+
},
35+
"CONFIG_DB": {
36+
"id": 4,
37+
"separator": "|",
38+
"instance": "redis"
39+
},
40+
"PFC_WD_DB": {
41+
"id": 5,
42+
"separator": ":",
43+
"instance": "redis"
44+
},
45+
"FLEX_COUNTER_DB": {
46+
"id": 5,
47+
"separator": ":",
48+
"instance": "redis"
49+
},
50+
"STATE_DB": {
51+
"id": 6,
52+
"separator": "|",
53+
"instance": "redis"
54+
},
55+
"SNMP_OVERLAY_DB": {
56+
"id": 7,
57+
"separator": "|",
58+
"instance": "redis"
59+
},
60+
"RESTAPI_DB": {
61+
"id": 8,
62+
"separator": "|",
63+
"instance": "redis"
64+
},
65+
"GB_ASIC_DB": {
66+
"id": 9,
67+
"separator": ":",
68+
"instance": "redis"
69+
},
70+
"GB_COUNTERS_DB": {
71+
"id": 10,
72+
"separator": ":",
73+
"instance": "redis"
74+
},
75+
"GB_FLEX_COUNTER_DB": {
76+
"id": 11,
77+
"separator": ":",
78+
"instance": "redis"
79+
},
80+
"CHASSIS_APP_DB": {
81+
"id": 12,
82+
"separator": "|",
83+
"instance": "redis_chassis"
84+
},
85+
"CHASSIS_STATE_DB": {
86+
"id": 13,
87+
"separator": "|",
88+
"instance": "redis_chassis"
89+
},
90+
"APPL_STATE_DB": {
91+
"id": 14,
92+
"separator": ":",
93+
"instance": "redis"
94+
}
95+
},
96+
"VERSION": "1.0"
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# execute all the steps inside virtual Environment.
4+
# From /sonic-buildimage path.
5+
#
6+
# Creating a new folder inside /tmp and
7+
# Downloading libhiredis packages to /tmp/new path.
8+
mkdir /tmp/new
9+
cd /tmp/new
10+
curl -O https://ftp.debian.org/debian/pool/main/h/hiredis/libhiredis0.14_0.14.1-3_amd64.deb
11+
curl -O https://ftp.debian.org/debian/pool/main/h/hiredis/libhiredis-dev_0.14.1-3_amd64.deb
12+
13+
# Install all the dependencies/pkgs
14+
# which are present in target/debs/bookworm path.
15+
cd -
16+
cd ../../../../target/debs/bookworm
17+
sudo dpkg -r libhiredis-dev
18+
sudo apt remove libhiredis0.14
19+
sudo dpkg -r libhiredis1.1.0
20+
sudo dpkg -i /tmp/new/libhiredis0.14_0.14.1-3_amd64.deb
21+
sudo dpkg -i /tmp/new/libhiredis-dev_0.14.1-3_amd64.deb
22+
sudo dpkg -i libnl-3-200_*.deb
23+
sudo dpkg -i libnl-3-dev_*.deb
24+
sudo dpkg -i libnl-genl-3-200_*.deb
25+
sudo dpkg -i libnl-genl-3-dev_*.deb
26+
sudo dpkg -i libnl-route-3-200_*.deb
27+
sudo dpkg -i libnl-route-3-dev_*.deb
28+
sudo dpkg -i libnl-nf-3-200_*.deb
29+
sudo dpkg -i libnl-nf-3-dev_*.deb
30+
sudo dpkg -i libnl-cli-3-200_*.deb
31+
sudo dpkg -i libnl-cli-3-dev_*.deb
32+
sudo dpkg -i libyang_*.deb
33+
sudo dpkg -i libyang-*.deb
34+
sudo dpkg -i libswsscommon_1.0.0_amd64.deb
35+
sudo dpkg -i libswsscommon-dev_1.0.0_amd64.deb
36+
37+
# Install pip and add base-tooling-requirement.text
38+
sudo apt-get update
39+
sudo pip install --upgrade pip
40+
41+
touch base-tooling-requirements.txt
42+
sudo echo "Pympler ==0.8 --hash=sha256:f74cd2982c5cd92ded55561191945616f2bb904a0ae5cdacdb566c6696bdb922" >>base-tooling-requirements.txt
43+
44+
pip install --require-hashes -r base-tooling-requirements.txt
45+
46+
# Install redis-tools inside virtualenv
47+
sudo apt install redis-server redis-tools
48+
sudo sed -i 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf
49+
sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf
50+
sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf
51+
sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf
52+
53+
# Start redis-server :
54+
sudo service redis-server restart &
55+
56+
# Install gtest and gmock
57+
sudo apt-get install -y libgtest-dev
58+
sudo apt-get install -y libgmock-dev
59+
60+
# Install dependencies need to execute tests
61+
sudo apt-get install libjansson-dev
62+
sudo apt install protobuf-compiler
63+
sudo apt install libdbus-c++-bin
64+
sudo apt install libdbus-c++-dev
65+
66+
# Create /var/run/redis/sonic-db folder.
67+
# copy the database_config.json file to /var/run/redis/sonic-db path.
68+
sudo mkdir -p /var/run/redis/sonic-db
69+
sudo cp ../../../src/sonic-framework/tests/test_scripts/database_config.json /var/run/redis/sonic-db/
70+
71+
#Build the sonic-fraework/tests.
72+
cd ../../../src/sonic-framework/
73+
./autogen.sh
74+
./configure
75+
make
76+
77+
cd tests
78+
make
79+
80+
#execure the sonic-framework tests.
81+
./tests
82+
./tests_asan
83+
./tests_tsan
84+
./tests_usan

0 commit comments

Comments
 (0)