]> git.stg.codes - stg.git/blobdiff - functest/test_services.sh
More std::jthread
[stg.git] / functest / test_services.sh
index 3447c22ffb91ae3f6d1a78ee96a6d4521e828810..97c3c7440a757ad4af9070962fd3c877129a8c78 100755 (executable)
 #!/bin/sh
 
 #!/bin/sh
 
+source `dirname $0`/functions
+
 BASEPATH=$1
 
 BASEPATH=$1
 
-SGCONFPATH="$BASEPATH/stg/projects/sgconf"
+SGCONFPATH="$BASEPATH/stg/build/projects/sgconf"
+
+printf "Check initial service list... "
 
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
 
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
+    printf "Error.\n"
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
-printf "Got services list:\n"
-
-NAMES=""
-OLDIFS=$IFS
-IFS=$(printf "\n")
-for LINE in $RES
-do
-    printf -- "$LINE\n"
-    NAME=`printf "$LINE" | grep name`
-    if [ "$?" == "0" ]
-    then
-        NAMES="$NAMES\n"`printf "$NAME" | cut -d: -f2 | sed -e 's/^ *//' -e 's/ *$//'`
-    fi
-done
-IFS=$OLDIFS
-
-printf "Names:\n$NAMES\n"
+NAMES=`getFields "name" "$RES"`
 
 
-NUM=`printf "$NAMES" | wc -l`
-
-printf -- "--------\n$NUM\n\n"
+NUM=`count "$NAMES"`
 
 if [ "$NUM" != "0" ]
 then
 
 if [ "$NUM" != "0" ]
 then
+    printf "Failed.\n"
     printf "Services list should be empty.\n"
     printf "Services list should be empty.\n"
+    printf "Names:\n$NAMES\n"
+    printf -- "--------\n$NUM\n\n"
     exit 0
 fi
 
     exit 0
 fi
 
+printf "Ok.\nCheck adding services... "
+
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --add-service test`
 
 if [ "$?" != "0" ]
 then
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --add-service test`
 
 if [ "$?" != "0" ]
 then
+    printf "Error.\n"
     printf "Failed to add new service. Result:\n$RES\n"
     exit 0
 fi
 
     printf "Failed to add new service. Result:\n$RES\n"
     exit 0
 fi
 
+printf "Ok.\nCheck new service list... "
+
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
+    printf "Error.\n"
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
-printf "Got services list:\n"
-
-NAMES=""
-OLDIFS=$IFS
-IFS=$(printf "\n")
-for LINE in $RES
-do
-    printf -- "$LINE\n"
-    NAME=`printf "$LINE" | grep name`
-    if [ "$?" == "0" ]
-    then
-        NAMES="$NAMES\n"`printf "$NAME" | cut -d: -f2 | sed -e 's/^ *//' -e 's/ *$//'`
-    fi
-done
-IFS=$OLDIFS
+NAMES=`getFields "name" "$RES"`
 
 
-printf "Names:\n$NAMES\n"
-
-NUM=`printf "$NAMES" | wc -l`
-
-printf -- "--------\n$NUM\n\n"
+NUM=`count "$NAMES"`
 
 if [ "$NUM" != "1" ]
 then
 
 if [ "$NUM" != "1" ]
 then
+    printf "Failed.\n"
     printf "Services list should have exactly one entry.\n"
     printf "Services list should have exactly one entry.\n"
+    printf "Names:\n$NAMES\n"
+    printf -- "--------\n$NUM\n\n"
     exit 0
 fi
 
     exit 0
 fi
 
+printf "Ok.\nCheck deletion exisiting service... "
+
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --del-service test`
 
 if [ "$?" != "0" ]
 then
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --del-service test`
 
 if [ "$?" != "0" ]
 then
+    printf "Error.\n"
     printf "Failed to delete a service. Result:\n$RES\n"
     exit 0
 fi
 
     printf "Failed to delete a service. Result:\n$RES\n"
     exit 0
 fi
 
+printf "Ok.\nCheck new service list... "
+
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
 
 if [ "$?" != "0" ]
 then
+    printf "Error.\n"
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
     printf "Failed to get services list. Result:\n$RES\n"
     exit 0
 fi
 
-printf "Got services list:\n"
+NAMES=`getFields "name" "$RES"`
 
 
-NAMES=""
-OLDIFS=$IFS
-IFS=$(printf "\n")
-for LINE in $RES
-do
-    printf -- "$LINE\n"
-    NAME=`printf "$LINE" | grep name`
-    if [ "$?" == "0" ]
-    then
-        NAMES="$NAMES\n"`printf "$NAME" | cut -d: -f2 | sed -e 's/^ *//' -e 's/ *$//'`
-    fi
-done
-IFS=$OLDIFS
-
-printf "Names:\n$NAMES\n"
-
-NUM=`printf "$NAMES" | wc -l`
-
-printf -- "--------\n$NUM\n\n"
+NUM=`count "$NAMES"`
 
 if [ "$NUM" != "0" ]
 then
 
 if [ "$NUM" != "0" ]
 then
+    printf "Failed.\n"
     printf "Services list should be empty.\n"
     printf "Services list should be empty.\n"
+    printf "Names:\n$NAMES\n"
+    printf -- "--------\n$NUM\n\n"
     exit 0
 fi
     exit 0
 fi
+
+printf "Ok.\n"