twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

test_twister_ipc.sh (1814B)


      1 #!/bin/sh
      2 
      3 # This file is part of GNUnet.
      4 # Copyright (C) 2018 Taler Systems SA
      5 # 
      6 # Twister is free software; you can redistribute it and/or
      7 # modify it under the terms of the GNU General Public License
      8 # as published by the Free Software Foundation; either version
      9 # 3, or (at your option) any later version.
     10 # 
     11 # Twister is distributed in the hope that it will be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty
     13 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     14 # the GNU General Public License for more details.
     15 # 
     16 # You should have received a copy of the GNU General Public
     17 # License along with Twister; see the file COPYING.  If not,
     18 # write to the Free Software Foundation, Inc., 51 Franklin
     19 # Street, Fifth Floor, Boston, MA 02110-1301, USA.
     20 
     21 # @author Marcello Stanisci
     22 # @author Christian Grothoff
     23 # 
     24 # @file test_twister.sh
     25 # 
     26 # @brief Twister testcases.
     27 
     28 
     29 if ! which curl > /dev/null
     30 then
     31     echo "curl not found";
     32     exit 77
     33 fi
     34 
     35 TWISTER_UNIXPATH="/tmp/http-twister.sock"
     36 TWISTER_DUMMY_URL="http://dummyhost/"
     37 
     38 # Launch the Web server.
     39 ./test_twister_webserver &
     40 web_server_pid=$!
     41 
     42 echo Webserver launched.
     43 
     44 # Launch the Twister.
     45 taler-twister-service -c ./test_twister_ipc.conf &
     46 twister_service_pid=$!
     47 
     48 echo Twister launched.
     49 
     50 sleep 1
     51 if ! ps xo pid | grep -q ${twister_service_pid}; then
     52   echo Twister did not start correctly
     53   return 77
     54 fi
     55 
     56 status_code=$(curl -s --unix-socket ${TWISTER_UNIXPATH} \
     57   ${TWISTER_DUMMY_URL} -o /dev/null -w "%{http_code}")
     58 
     59 # check status code was hacked
     60 if ! test 200 = $status_code; then
     61   echo "Could not reach the Twister (${status_code})"
     62   kill $web_server_pid
     63   kill $twister_service_pid
     64   exit 1
     65 fi
     66 
     67 echo "Twister reached via IPC".
     68 
     69 # shutdown twister and webserver
     70 kill $web_server_pid
     71 kill $twister_service_pid
     72 
     73 exit 0