From 1fe75d1f0d8022295501b0eac3613010034dddef Mon Sep 17 00:00:00 2001
From: Raphael Defosseux <raphael.defosseux@eurecom.fr>
Date: Mon, 3 Sep 2018 18:08:55 +0200
Subject: [PATCH] CI: little fixes to TDD scenario

Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr>
---
 ci-scripts/reportTestLocally.sh              | 56 +++++++++++---------
 ci-scripts/xml_files/enb_usrpb210_band40.xml | 14 ++---
 2 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh
index 113fc1e1e5c..55e8ff34122 100755
--- a/ci-scripts/reportTestLocally.sh
+++ b/ci-scripts/reportTestLocally.sh
@@ -363,28 +363,34 @@ then
         echo "        <td>$NAME</td>" >> ./test_simulator_results.html
         CMD=`egrep "COMMAND IS" $IPERF_CASE | sed -e "s#COMMAND IS: ##"`
         echo "        <td>$CMD</td>" >> ./test_simulator_results.html
+        REQ_BITRATE=`echo $CMD | sed -e "s#^.*-b ##" -e "s#-i 1.*##"`
+        if [[ $REQ_BITRATE =~ .*K.* ]]
+        then
+            REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#K##"`
+            FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000.0" | bc -l`
+        fi
+        if [[ $REQ_BITRATE =~ .*M.* ]]
+        then
+            REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#M##"`
+            FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000000.0" | bc -l`
+        fi
+        if [[ $REQ_BITRATE =~ .*G.* ]]
+        then
+            REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#G##"`
+            FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000000000.0" | bc -l`
+        fi
         FILE_COMPLETE=`egrep -c "Server Report" $IPERF_CASE`
         if [ $FILE_COMPLETE -eq 0 ]
         then
             echo "        <td bgcolor = \"red\" >KO</td>" >> ./test_simulator_results.html
-            echo "        <td>N/A</td>" >> ./test_simulator_results.html
+            SERVER_FILE=`echo $IPERF_CASE | sed -e "s#client#server#"`
+            FLOAT_EFF_BITRATE=`grep --color=never sec $SERVER_FILE | sed -e "s#^.*Bytes *##" -e "s#sec *.*#sec#" | awk 'BEGIN{s=0;n=0}{n++;if ($2 ~/Mbits/){a = $1 * 1000000}; s=s+a}END{br=s/n; printf "%.0f", br}'`
+            EFFECTIVE_BITRATE=`grep --color=never sec $SERVER_FILE | sed -e "s#^.*Bytes *##" -e "s#sec *.*#sec#" | awk 'BEGIN{s=0;n=0}{n++;if ($2 ~/Mbits/){a = $1 * 1000000}; s=s+a}END{br=s/n; if(br>1000000){printf "%.2f MBits/sec", br/1000000}}'`
+            PERF=`echo "100 * $FLOAT_EFF_BITRATE / $FLOAT_REQ_BITRATE" | bc -l | awk '{printf "%.2f", $0}'`
+            JITTER=`grep --color=never sec $SERVER_FILE | sed -e "s#^.*/sec *##" -e "s# *ms.*##" | awk 'BEGIN{s=0;n=0}{n++;s+=$1}END{jitter=s/n; printf "%.3f ms", jitter}'`
+            PACKETLOSS_NOSIGN=`grep --color=never sec $SERVER_FILE | sed -e "s#^.*(##" -e "s#%.*##" | awk 'BEGIN{s=0;n=0}{n++;s+=$1}END{per=s/n; printf "%.1f", per}'`
+            PACKETLOSS=`echo "${PACKETLOSS_NOSIGN}%"`
         else
-            REQ_BITRATE=`echo $CMD | sed -e "s#^.*-b ##" -e "s#-i 1.*##"`
-            if [[ $REQ_BITRATE =~ .*K.* ]]
-            then
-                REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#K##"`
-                FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000.0" | bc -l`
-            fi
-            if [[ $REQ_BITRATE =~ .*M.* ]]
-            then
-                REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#M##"`
-                FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000000.0" | bc -l`
-            fi
-            if [[ $REQ_BITRATE =~ .*G.* ]]
-            then
-                REQ_BITRATE=`echo $REQ_BITRATE | sed -e "s#G##"`
-                FLOAT_REQ_BITRATE=`echo "$REQ_BITRATE * 1000000000.0" | bc -l`
-            fi
             EFFECTIVE_BITRATE=`tail -n3 $IPERF_CASE | egrep "Mbits/sec" | sed -e "s#^.*MBytes *##" -e "s#sec.*#sec#"`
             if [[ $EFFECTIVE_BITRATE =~ .*Kbits/sec.* ]]
             then
@@ -409,18 +415,18 @@ then
             else
                 echo "        <td bgcolor = \"green\" >OK</td>" >> ./test_simulator_results.html
             fi
-            echo "        <td>" >> ./test_simulator_results.html
-            echo "            <pre>" >> ./test_simulator_results.html
             EFFECTIVE_BITRATE=`tail -n3 $IPERF_CASE | egrep "Mbits/sec" | sed -e "s#^.*MBytes *##" -e "s#sec.*#sec#"`
-            echo "Bitrate      : $EFFECTIVE_BITRATE" >> ./test_simulator_results.html
-            echo "Bitrate Perf : $PERF %" >> ./test_simulator_results.html
             JITTER=`tail -n3 $IPERF_CASE | egrep "Mbits/sec" | sed -e "s#^.*Mbits/sec *##" -e "s#ms.*#ms#"`
-            echo "Jitter       : $JITTER" >> ./test_simulator_results.html
             PACKETLOSS=`tail -n3 $IPERF_CASE | egrep "Mbits/sec" | sed -e "s#^.*(##" -e "s#).*##"`
-            echo "Packet Loss  : $PACKETLOSS" >> ./test_simulator_results.html
-            echo "            </pre>" >> ./test_simulator_results.html
-            echo "        </td>" >> ./test_simulator_results.html
         fi
+        echo "        <td>" >> ./test_simulator_results.html
+        echo "            <pre>" >> ./test_simulator_results.html
+        echo "Bitrate      : $EFFECTIVE_BITRATE" >> ./test_simulator_results.html
+        echo "Bitrate Perf : $PERF %" >> ./test_simulator_results.html
+        echo "Jitter       : $JITTER" >> ./test_simulator_results.html
+        echo "Packet Loss  : $PACKETLOSS" >> ./test_simulator_results.html
+        echo "            </pre>" >> ./test_simulator_results.html
+        echo "        </td>" >> ./test_simulator_results.html
         echo "      </tr>" >> ./test_simulator_results.html
     done
 
diff --git a/ci-scripts/xml_files/enb_usrpb210_band40.xml b/ci-scripts/xml_files/enb_usrpb210_band40.xml
index 03eca477e8a..3f51f2d34a9 100644
--- a/ci-scripts/xml_files/enb_usrpb210_band40.xml
+++ b/ci-scripts/xml_files/enb_usrpb210_band40.xml
@@ -21,7 +21,7 @@
 
 -->
 <testCaseList>
-        <TestCaseRequestedList>050101 060101 070101 040101 030105 040301 040501 040602 040601 040401 040201 030201 050201 060201 070201 050101 060101 070101 040101 030104 040301 040501 040702 040701 040401 040201 030201 050201 060201 070201</TestCaseRequestedList>
+        <TestCaseRequestedList>050101 060101 070101 040101 030105 040301 040501 040602 040601 040603 040401 040201 030201 050201 060201 070201 050101 060101 070101 040101 030104 040301 040501 040702 040701 040401 040201 030201 050201 060201 070201</TestCaseRequestedList>
 	<TestCaseExclusionList>010101 </TestCaseExclusionList>
 
 	<testCase id="010101">
@@ -84,24 +84,24 @@
 
         <testCase id="040602">
 		<class>Iperf</class>
-		<desc>iperf (5MHz - DL/13.5Mbps/UDP)(30 sec)(single-ue)</desc>
-		<iperf_args>-u -b 13.5M -t 30 -i 1</iperf_args>
+		<desc>iperf (5MHz - DL/6.5Mbps/UDP)(30 sec)(single-ue)</desc>
+		<iperf_args>-u -b 6.5M -t 30 -i 1</iperf_args>
 		<iperf_packetloss_threshold>50</iperf_packetloss_threshold>
 		<iperf_profile>single-ue</iperf_profile>
         </testCase>
 
         <testCase id="040603">
 		<class>Iperf</class>
-		<desc>iperf (5MHz - DL/15Mbps/UDP)(30 sec)(unbalanced)</desc>
-		<iperf_args>-u -b 15M -t 30 -i 1</iperf_args>
+		<desc>iperf (5MHz - DL/6.5Mbps/UDP)(30 sec)(unbalanced)</desc>
+		<iperf_args>-u -b 6.5M -t 30 -i 1</iperf_args>
 		<iperf_packetloss_threshold>50</iperf_packetloss_threshold>
 		<iperf_profile>unbalanced</iperf_profile>
         </testCase>
 
 	<testCase id="040701">
                 <class>Iperf</class>
-                <desc>iperf (10MHz - DL/6.5Mbps/UDP)(30 sec)(balanced)</desc>
-                <iperf_args>-u -b 6.5M -t 30 -i 1</iperf_args>
+                <desc>iperf (10MHz - DL/13.5Mbps/UDP)(30 sec)(balanced)</desc>
+                <iperf_args>-u -b 13.5M -t 30 -i 1</iperf_args>
                 <iperf_packetloss_threshold>50</iperf_packetloss_threshold>
                 <iperf_profile>balanced</iperf_profile>
         </testCase>
-- 
GitLab