From 3156b530afe14c8d14b82b9cb4fde9d7921c4e32 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Mon, 11 Nov 2013 13:40:33 +0200 Subject: [PATCH] Allow test programs use custom port using environment variable or command-line argument --- tests/basic.py | 6 +++--- tests/bench.sh | 8 ++++++-- tests/limits.py | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/basic.py b/tests/basic.py index 87c8dc6..89d664e 100755 --- a/tests/basic.py +++ b/tests/basic.py @@ -6,9 +6,9 @@ try: except: msgpack = None - -host = '127.0.0.1' -port = 7379 +import os +host = os.getenv('WEBDIS_HOST', '127.0.0.1') +port = int(os.getenv('WEBDIS_PORT', 7379)) class TestWebdis(unittest.TestCase): diff --git a/tests/bench.sh b/tests/bench.sh index b7e8c01..0761696 100755 --- a/tests/bench.sh +++ b/tests/bench.sh @@ -1,8 +1,12 @@ #!/bin/bash CLIENTS=100 REQUESTS=100000 -HOST=127.0.0.1 -PORT=7379 + +HOST=$WEBDIS_HOST +PORT=$WEBDIS_PORT + +[ -n $HOST ] && HOST=127.0.0.1 +[ -n $PORT ] && PORT=7379 info() { echo "Testing on $HOST:$PORT with $CLIENTS clients in parallel, for a total of $REQUESTS requests per benchmark." diff --git a/tests/limits.py b/tests/limits.py index 0e7adff..1fdecc8 100755 --- a/tests/limits.py +++ b/tests/limits.py @@ -2,8 +2,9 @@ import socket import unittest -HOST = "127.0.0.1" -PORT = 7379 +import os +HOST = os.getenv('WEBDIS_HOST', '127.0.0.1') +PORT = int(os.getenv('WEBDIS_PORT', 7379)) class BlockingSocket: