diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-05 16:57:23 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-05 16:57:23 +0200 |
commit | f66eb7244e76523b96c625ce6675b1aba2c48fb7 (patch) | |
tree | c15011322ad2bdbc2e772930701765b464823817 /src | |
parent | bcb0c70668243672a63dc6f4bba3ce417b05abb2 (diff) | |
download | twister-f66eb7244e76523b96c625ce6675b1aba2c48fb7.tar.gz twister-f66eb7244e76523b96c625ce6675b1aba2c48fb7.tar.bz2 twister-f66eb7244e76523b96c625ce6675b1aba2c48fb7.zip |
Testing chaos probability.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_chaos.conf | 27 | ||||
-rwxr-xr-x | src/test/test_chaos.sh | 69 |
2 files changed, 96 insertions, 0 deletions
diff --git a/src/test/test_chaos.conf b/src/test/test_chaos.conf new file mode 100644 index 0000000..f24b65f --- /dev/null +++ b/src/test/test_chaos.conf @@ -0,0 +1,27 @@ +[twister] +# HTTP listen port for twister +HTTP_PORT = 8888 + +# HTTP Destination for twister. The test-Webserver needs +# to listen on the port used here. +# Note: no trailing '/'! +DESTINATION_BASE_URL = http://localhost:8080 + +# Control port for TCP +# PORT = 8889 +HOSTNAME = localhost +ACCEPT_FROM = 127.0.0.1; +ACCEPT_FROM6 = ::1; + +# Control port for UNIX +UNIXPATH = /tmp/taler-service-twister.sock +UNIX_MATCH_UID = NO +UNIX_MATCH_GID = YES + +# 3% probability. +CHAOS_RATE = 3 + +# Launching of twister by ARM +# BINARY = taler-service-twister +# AUTOSTART = NO +# FORCESTART = NO diff --git a/src/test/test_chaos.sh b/src/test/test_chaos.sh new file mode 100755 index 0000000..b5c8770 --- /dev/null +++ b/src/test/test_chaos.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +# This file is part of GNUnet. +# Copyright (C) 2018 Taler Systems SA +# +# Twister is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version +# 3, or (at your option) any later version. +# +# Twister is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with Twister; see the file COPYING. If not, +# write to the Free Software Foundation, Inc., 51 Franklin +# Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# @author Marcello Stanisci +# @author Christian Grothoff +# +# @file test_twister.sh +# +# @brief Twister testcases, with a 5% chaos probability (#5737). + + +if ! which curl > /dev/null +then + echo "curl not found"; + exit 77 +fi + +TWISTER_URL_V4="http://localhost:8888/" +TWISTER_URL="http://[::1]:8888/" + +# Launch the Web server. +./test_twister_webserver & +web_server_pid=$! + +echo Webserver launched. + +# Launch the Twister. +taler-twister-service -c ./test_chaos.conf & +twister_service_pid=$! + +echo "Twister chaos'd launched (${twister_service_pid})." + +# We give 100 rounds to match a 5% probability. +for i in $(seq 1 100); do + status_code=$(curl -s ${TWISTER_URL_V4} -o /dev/null \ + -w "%{http_code}") + + # check status code was hacked + if test 503 = $status_code; then + echo "$i-th round: found 'Service Unavailable'; success." + kill $web_server_pid + kill $twister_service_pid + exit 0 + fi +done + +echo Could not find 'Service Unavailable response; fail!' +# shutdown twister and webserver +kill $web_server_pid +kill $twister_service_pid + +exit 1 |