From 8d65628052feaad8a60f84dc69ac4efb274164f7 Mon Sep 17 00:00:00 2001
From: hardy <remi.hardy@openairinterface.org>
Date: Thu, 22 Oct 2020 17:58:00 +0200
Subject: [PATCH] re-enabling RA test

---
 ci-scripts/reportTestLocally.sh | 90 +++++++++++++++------------------
 ci-scripts/runTestOnVM.sh       | 66 +++---------------------
 2 files changed, 49 insertions(+), 107 deletions(-)

diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh
index 03cda20542..64c5d74975 100755
--- a/ci-scripts/reportTestLocally.sh
+++ b/ci-scripts/reportTestLocally.sh
@@ -768,55 +768,47 @@ function report_test {
 
                 #RA test (--do-ra option)
 
-# Currently disabled
-#                #build log files names
-#                RA_ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb_ra_test.log
-#                RA_UE_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_ue_ra_test.log
-#                if [ -f $RA_ENB_LOG ] && [ -f $RA_UE_LOG ]
-#                then
-#                    #get rid of full path
-#                    NAME_ENB=`echo $RA_ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"`
-#                    NAME_UE=`echo $RA_UE_LOG | sed -e "s#$ARCHIVES_LOC/##"`
-#                    echo "      <tr>" >> ./test_simulator_results.html
-#                    echo "        <td>$NAME_ENB --- $NAME_UE</td>" >> ./test_simulator_results.html
-#                    echo "        <td>Check if RA proc succeeded</td>" >> ./test_simulator_results.html
-#
-#                    #gNB RA check
-#                    GNB_RECEIVED=`egrep -c "received correctly" $RA_ENB_LOG`
-#                    GNB_CONNECTED=`egrep -c "now 5G connected" $RA_ENB_LOG`
-#                    #UE RA check
-#                    UE_RA_PROC_OK=`egrep -c "RA procedure succeeded" $RA_UE_LOG`
-#
-#
-#                    if [ $GNB_RECEIVED -gt 0 ] && [ $GNB_CONNECTED -gt 0 ] && [ $UE_RA_PROC_OK -gt 0 ]
-#                    then
-#                        echo "        <td bgcolor = \"green\" >OK</td>" >> ./test_simulator_results.html
-#                    else
-#                        echo "        <td bgcolor = \"red\" >KO</td>" >> ./test_simulator_results.html
-#                    fi
-#
-#                    echo "        <td><pre>" >> ./test_simulator_results.html
-#                    if [ $GNB_RECEIVED -gt 0 ]
-#                    then
-#                        echo "<font color = \"blue\">- gNB --> RA received</font>" >> ./test_simulator_results.html
-#                    else
-#                        echo "<font color = \"red\"><b>- gNB RA NOT RECEIVED</b></font>" >> ./test_simulator_results.html
-#                    fi
-#                    if [ $GNB_CONNECTED -gt 0 ]
-#                    then
-#                        echo "<font color = \"blue\">- gNB --> 5G connected</font>" >> ./test_simulator_results.html
-#                    else
-#                        echo "<font color = \"red\"><b>- gNB NOT 5G CONNECTED</b></font>" >> ./test_simulator_results.html
-#                    fi
-#                    if [ $UE_RA_PROC_OK -gt 0 ]
-#                    then
-#                        echo "<font color = \"blue\">- NR UE  --> RA procedure succeded</font>" >> ./test_simulator_results.html
-#                    else
-#                        echo "<font color = \"red\"><b>- NR UE RA procedure failed</b></font>" >> ./test_simulator_results.html
-#                    fi
-#                    echo "        </pre></td>" >> ./test_simulator_results.html
-#                    echo "      </tr>" >> ./test_simulator_results.html
-#                fi
+                #build log files names
+                RA_ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb_ra_test.log
+                RA_UE_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_ue_ra_test.log
+                if [ -f $RA_ENB_LOG ] && [ -f $RA_UE_LOG ]
+                then
+                    #get rid of full path
+                    NAME_ENB=`echo $RA_ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+                    NAME_UE=`echo $RA_UE_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+                    echo "      <tr>" >> ./test_simulator_results.html
+                    echo "        <td>$NAME_ENB --- $NAME_UE</td>" >> ./test_simulator_results.html
+                    echo "        <td>Check if RA proc succeeded</td>" >> ./test_simulator_results.html
+
+                    #gNB RA check
+                    GNB_RECEIVED=`egrep -c "\[RAPROC\] PUSCH with TC_RNTI (.+) received correctly and UE_id (.+) is now 5G connected" $RA_ENB_LOG`
+                    #UE RA check
+                    UE_RA_PROC_OK=`egrep -c "RA procedure succeeded" $RA_UE_LOG`
+
+
+                    if [ $GNB_RECEIVED -gt 0 ] && [ $UE_RA_PROC_OK -gt 0 ]
+                    then
+                        echo "        <td bgcolor = \"green\" >OK</td>" >> ./test_simulator_results.html
+                    else
+                        echo "        <td bgcolor = \"red\" >KO</td>" >> ./test_simulator_results.html
+                    fi
+
+                    echo "        <td><pre>" >> ./test_simulator_results.html
+                    if [ $GNB_RECEIVED -gt 0 ]
+                    then
+                        echo "<font color = \"blue\">- gNB --> RA received</font>" >> ./test_simulator_results.html
+                    else
+                        echo "<font color = \"red\"><b>- gNB RA NOT RECEIVED</b></font>" >> ./test_simulator_results.html
+                    fi
+                    if [ $UE_RA_PROC_OK -gt 0 ]
+                    then
+                        echo "<font color = \"blue\">- NR UE  --> RA procedure succeded</font>" >> ./test_simulator_results.html
+                    else
+                        echo "<font color = \"red\"><b>- NR UE RA procedure failed</b></font>" >> ./test_simulator_results.html
+                    fi
+                    echo "        </pre></td>" >> ./test_simulator_results.html
+                    echo "      </tr>" >> ./test_simulator_results.html
+                fi
 
                 #SYNC test
                 ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb.log
diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh
index 734001040c..f1f4945b9b 100755
--- a/ci-scripts/runTestOnVM.sh
+++ b/ci-scripts/runTestOnVM.sh
@@ -283,8 +283,8 @@ function check_ra_result {
 
     #gNB RA test
     echo "Checking gNB Log for RA success"
-    egrep "received correctly" $1 
-    egrep "now 5G connected" $1 
+    egrep "\[RAPROC\] PUSCH with TC_RNTI (.+) received correctly and UE_id (.+) is now 5G connected" $1 
+ 
  
     #UE RA test
     echo 'Checking UE Log for RA success'
@@ -2241,71 +2241,21 @@ function run_test_on_vm {
             echo "############################################################"
 
             # Proper check to be done when RA test is working!
-            #check_ra_result $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE
+            check_ra_result $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE
 
             try_cnt=$[$try_cnt+1]
 
-        ########### end RA test
         done
-        sleep 10
-        try_cnt="0"
+        ########### end RA test
+        
+        sleep 30
+
 
         ######### start of PHY TEST loop
+        try_cnt="0"
         while [ $try_cnt -lt 4 ]
         do
 
-            #start RA test
-            SYNC_STATUS=0
-            PING_STATUS=0
-            IPERF_STATUS=0
-
-            echo "############################################################"
-            echo "${CN_CONFIG} : Starting the gNB"
-            echo "############################################################"
-            CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb.log
-            #last argument = 1 is to enable --do-ra for RA test
-            start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 1
-
-            echo "############################################################"
-            echo "${CN_CONFIG} : Starting the NR-UE"
-            echo "############################################################"
-            CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue.log
-            #last argument = 1 is to enable --do-ra for RA test
-            start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 1
-            if [ $NR_UE_SYNC -eq 0 ]
-            then
-                echo "Problem w/ gNB and NR-UE not syncing"
-                terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2
-                terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1
-                scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC
-                scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC
-                SYNC_STATUS=-1
-                try_cnt=$[$try_cnt+1]
-                continue
-            fi
-
-            echo "############################################################"
-            echo "${CN_CONFIG} : Terminate gNB/NR-UE simulators"
-            echo "############################################################"
-            sleep 20
-            terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2
-            terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1
-            scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC
-            scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC
-
-            #check RA markers in gNB and NR UE log files
-            echo "############################################################"
-            echo "${CN_CONFIG} : Checking RA on gNB / NR-UE"
-            echo "############################################################"
-
-            mv $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE
-            mv $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE  $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE
-            # Proper check to be done when RA test is working!
-            #check_ra_result $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE
-
-
-            #end RA test
-            sleep 30
 
             SYNC_STATUS=0
             PING_STATUS=0
-- 
2.26.2