456be1fa253d1429b545bbc9ddd993b696fa30fa
[csit.git] / tests / dmm / dmm_scripts / run_dmm.sh
1 #!/bin/bash
2
3 set -x
4
5 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
6 ROOTDIR=/tmp/DMM-testing
7 PWDDIR=$(pwd)
8 APP_DIR=${ROOTDIR}/dmm/release/bin/
9 LIB_PATH=${APP_DIR}/../lib64
10 dut1_ip=$1
11 dut2_ip=$2
12 proc_name=$3
13 #proc_name => 0 = server, 1= client
14
15 # Try to kill the vs_epoll
16 sudo killall vs_epoll
17
18 sudo pgrep vs_epoll
19 if [ $? -eq "0" ]; then
20     success=false
21     sudo pkill vs_epoll
22     echo "RC = $?"
23     for attempt in {1..5}; do
24         echo "Checking if vs_epoll is still alive, attempt nr ${attempt}"
25         sudo pgrep vs_epoll
26         if [ $? -eq "1" ]; then
27             echo "vs_epoll is dead"
28             success=true
29             break
30         fi
31         echo "vs_epoll is still alive, waiting 1 second"
32         sleep 1
33     done
34     if [ "$success" = false ]; then
35         echo "The command sudo pkill vs_epoll failed"
36         sudo pkill -9 vs_epoll
37         echo "RC = $?"
38         exit 1
39     fi
40 else
41     echo "vs_epoll is not running"
42 fi
43
44 sleep 2
45
46 cat /proc/meminfo
47
48 cd ${LIB_PATH}
49 chmod 777 *
50 ls -l
51
52 cd ${APP_DIR}
53 cp -r ${LIB_PATH}/* .
54 cp -r ../configure/* .
55 chmod 777 *
56
57 if [ "$OS_ID" == "ubuntu" ]; then
58         ifaddress1=$(ifconfig eth1 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
59         echo $ifaddress1
60         ifaddress2=$(ifconfig eth2 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
61         echo $ifaddress2
62 elif [ "$OS_ID" == "centos" ]; then
63         ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
64         echo $ifaddress1
65         ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
66         echo $ifaddress2
67 fi
68
69 echo '{
70         "default_stack_name": "kernel",
71         "module_list": [
72         {
73                 "stack_name": "kernel",
74                 "function_name": "kernel_stack_register",
75                 "libname": "./",
76                 "loadtype": "static",
77                 "deploytype": "1",
78                 "maxfd": "1024",
79                 "minfd": "0",
80                 "priorty": "1",
81                 "stackid": "0",
82     },
83   ]
84 }' | tee module_config.json
85
86 echo '{
87         "ip_route": [
88         {
89                 "subnet": "'$ifaddress1'/24",
90                 "type": "nstack-kernel",
91         },
92         {
93                 "subnet": "'$ifaddress2'/24",
94                 "type": "nstack-kernel",
95         },
96         ],
97         "prot_route": [
98         {
99                 "proto_type": "1",
100                 "type": "nstack-kernel",
101         },
102         {
103                 "proto_type": "2",
104                 "type": "nstack-kernel",
105         }
106         ],
107 }' | tee rd_config.json
108
109 ls -l
110
111 #only for kernal stack
112 if [ ${proc_name} -eq 0 ]; then
113 sudo LD_LIBRARY_PATH=${LIB_PATH} ./vs_epoll -p 20000 -d ${dut2_ip} -a 10000 -s ${dut1_ip} -l 200 -t 50000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
114 else
115 sudo LD_LIBRARY_PATH=${LIB_PATH} ./vc_common -p 20000 -d ${dut1_ip} -a 10000 -s ${dut2_ip} -l 200 -t 50000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
116 fi
117
118 cd ${PWDDIR}
119
120 ps -elf | grep vs_epoll
121
122 sleep 10