From 47119e285dfb4f2486a471f9b8c8714952acefea Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 31 Aug 2020 15:04:16 +0300 Subject: stress_test.sh: move to test/ --- .ci/.gitattributes | 1 - .ci/stress_test.sh | 75 ----------------------------------------------------- .gitattributes | 2 ++ .travis.yml | 2 +- test/stress_test.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 77 deletions(-) delete mode 100644 .ci/.gitattributes delete mode 100755 .ci/stress_test.sh create mode 100755 test/stress_test.sh diff --git a/.ci/.gitattributes b/.ci/.gitattributes deleted file mode 100644 index dfdb8b7..0000000 --- a/.ci/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.sh text eol=lf diff --git a/.ci/stress_test.sh b/.ci/stress_test.sh deleted file mode 100755 index eba52d2..0000000 --- a/.ci/stress_test.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2020 Egor Tensin -# This file is part of the "math-server" project. -# For details, see https://github.com/egor-tensin/math-server. -# Distributed under the MIT License. - -set -o errexit -o nounset -o pipefail - -script_name="$( basename -- "${BASH_SOURCE[0]}" )" -readonly script_name -script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" -script_dir="$( cd -- "$script_dir" && pwd )" -readonly script_dir - -install_dir="$HOME/install" -readonly server_path='bin/math-server' -readonly client_path='bin/math-client' -readonly stress_test_path="$script_dir/../test/stress_test.py" -readonly server_port=16666 -server_pid= - -dump() { - local msg - for msg; do - echo "$script_name: $msg" - done -} - -kill_server() { - dump "Killing the server with PID $server_pid..." - kill "$server_pid" - dump "Waiting for the server to terminate..." - wait "$server_pid" - dump "Done" -} - -run_server() { - dump "Running the server..." - "$install_dir/$server_path" --port "$server_port" & - server_pid="$!" - dump "It's PID is $server_pid" - trap kill_server EXIT -} - -run_stress_test() { - dump "Running stress_test.py..." - "$stress_test_path" \ - --client "$install_dir/$client_path" \ - --port "$server_port" \ - --processes 4 \ - --expressions 1000 -} - -script_usage() { - echo "usage: $script_name [INSTALL_DIR]" -} - -parse_args() { - if [ "$#" -gt 1 ]; then - script_usage >&2 - return 1 - fi - if [ "$#" -gt 0 ]; then - install_dir="$1" - fi -} - -main() { - parse_args "$@" - run_server - run_stress_test -} - -main "$@" diff --git a/.gitattributes b/.gitattributes index 176a458..d76765e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ * text=auto + +*.sh text eol=lf diff --git a/.travis.yml b/.travis.yml index 163a334..da019f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ script: - "$HOME/install/bin/math-server-unit-tests" - "$HOME/install/bin/math-server-benchmarks" - - ../.ci/stress_test.sh + - ../test/stress_test.sh jobs: fast_finish: true diff --git a/test/stress_test.sh b/test/stress_test.sh new file mode 100755 index 0000000..ceac401 --- /dev/null +++ b/test/stress_test.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright (c) 2020 Egor Tensin +# This file is part of the "math-server" project. +# For details, see https://github.com/egor-tensin/math-server. +# Distributed under the MIT License. + +set -o errexit -o nounset -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name +script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" +script_dir="$( cd -- "$script_dir" && pwd )" +readonly script_dir + +install_dir="$HOME/install" +readonly server_path='bin/math-server' +readonly client_path='bin/math-client' +readonly stress_test_path="$script_dir/stress_test.py" +readonly server_port=16666 +server_pid= + +dump() { + local msg + for msg; do + echo "$script_name: $msg" + done +} + +kill_server() { + dump "Killing the server with PID $server_pid..." + kill "$server_pid" + dump "Waiting for the server to terminate..." + wait "$server_pid" + dump "Done" +} + +run_server() { + dump "Running the server..." + "$install_dir/$server_path" --port "$server_port" & + server_pid="$!" + dump "It's PID is $server_pid" + trap kill_server EXIT +} + +run_stress_test() { + dump "Running stress_test.py..." + "$stress_test_path" \ + --client "$install_dir/$client_path" \ + --port "$server_port" \ + --processes 4 \ + --expressions 1000 +} + +script_usage() { + echo "usage: $script_name [INSTALL_DIR]" +} + +parse_args() { + if [ "$#" -gt 1 ]; then + script_usage >&2 + return 1 + fi + if [ "$#" -gt 0 ]; then + install_dir="$1" + fi +} + +main() { + parse_args "$@" + run_server + run_stress_test +} + +main "$@" -- cgit v1.2.3