diff --git a/Tests/Stress/README.md b/Tests/Stress/README.md new file mode 100644 index 000000000..53f65e324 --- /dev/null +++ b/Tests/Stress/README.md @@ -0,0 +1,41 @@ +# SOGo Stress Tests + +### Requirements + + apt-get install parallel curl + +### Stragegy + +- set the concurrency level to the number of sogod workers you have +- use as many test users that you have sogod workers. For example, if + you have 10 sogod works, have 10 test users +- test users MUST be named 'sogoX' and MUST have a password set to 'sogo'. If you + have 3 test users, you should have sogo1, sogo2 and sogo3 as test + users. Make sure you delete those users when you are done with + stress-testing. Make also sure you delete the associated mailboxes + as emails sent during tests will NOT be deleted +- ensure memcached is running - you can also test without memcache and + see the performance impacts on SOGo. + +### Running tests + +- define your mail domain + +export SOGO_MAIL_DOMAIN="example.com" + +- define your SOGo server URL. Do NOT put a trailing slash + +export SOGO_SERVER_URL="http://localhost/SOGo/dav" + +- define the identifier of your main authentication source where your + SOGo test users are adefined + +export SOGO_AUTHENTICATION_SOURCE_ID="example.com_public" + +- define your concurrency limit - a minimum of 3 is required: + +export SOGO_CONCURRENCY_LIMIT=3 + +- define the number of test iterations + +export SOGO_TEST_ITERATIONS=100 diff --git a/Tests/Stress/acl.sh b/Tests/Stress/acl.sh new file mode 100755 index 000000000..24e1c7541 --- /dev/null +++ b/Tests/Stress/acl.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +. common_func.sh || error_out + +echo -n "Estimating fork overhead... " +FORK_OVERHEAD=$(calculate_curl_fork_overhead) +echo "done!" + +# +# TEST DEFINITION +# +test_acl() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo1:sogo \ + --request PROPFIND \ + --header "Depth: 0" \ + --header "Content-Type:text/xml" \ + --data @- \ + $SOGO_SERVER_URL/sogo1/Calendar/personal < + + + + + + + +EOF + done; +} +export -f test_acl + +# +# TEST EXECUTION +# +echo "Starting ACL test..." +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_acl {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second." diff --git a/Tests/Stress/authentication.sh b/Tests/Stress/authentication.sh new file mode 100755 index 000000000..beb044163 --- /dev/null +++ b/Tests/Stress/authentication.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +. common_func.sh || error_out + +echo -n "Estimating fork overhead... " +FORK_OVERHEAD=$(calculate_curl_fork_overhead) +echo "done!" + +# +# TEST DEFINITION +# +test_authentication() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request PROPFIND \ + --header "Depth:1" \ + --header "Content-Type:text/xml" \ + --data @- \ + $SOGO_SERVER_URL/sogo$1 < + + + + + + + + + + +EOF + done; +} +export -f test_authentication + +# +# TEST EXECUTION +# +echo -n "Starting authentication test... " +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_authentication {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second." diff --git a/Tests/Stress/changes.sh b/Tests/Stress/changes.sh new file mode 100755 index 000000000..e3e4857d3 --- /dev/null +++ b/Tests/Stress/changes.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +echo $SOGO_CONCURRENCY_LIMIT +echo $SOGO_TEST_ITERATIONS +echo $SOGO_SERVER_URL + +test_changes() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + ctag=$(date +%s) + curl -s -o /dev/null --basic --user sogo1:sogo \ + --request REPORT \ + --header "Depth:1" \ + --header "Content-Type:text/xml" \ + --data @- \ + $SOGO_SERVER_URL/sogo1/Calendar/personal < + + $ctag + 10 + 1 + + + + + +EOF + done; +} + +export -f test_changes + +echo "Starting changes test..." +START=$(date +%s) + +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_changes {} + +END=$(date +%s) +DIFF=$(( $END - $START )) +echo "Completed!" +echo "It took $DIFF seconds" diff --git a/Tests/Stress/common_func.sh b/Tests/Stress/common_func.sh new file mode 100644 index 000000000..b24b270f1 --- /dev/null +++ b/Tests/Stress/common_func.sh @@ -0,0 +1,8 @@ +calculate_curl_fork_overhead() { + local c_start=$(date +%s%N); + for n in $(seq $(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) ); do + curl -s 2>&1 /dev/null + done; + local c_end=$(date +%s%N); + echo "scale=2; $(( $c_end - $c_start )) / 1000000000" | bc -l +} diff --git a/Tests/Stress/insert.sh b/Tests/Stress/insert.sh new file mode 100755 index 000000000..9eab755fc --- /dev/null +++ b/Tests/Stress/insert.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +. common_func.sh || error_out + +echo -n "Estimating fork overhead... " +FORK_OVERHEAD=$(calculate_curl_fork_overhead) +echo "done!" + +# +# TEST DEFINITION +# +test_events_insert() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + start_date=$(/bin/date -d "today +$(($n-1)) hour" "+%Y%m%dT%H%M%S") + end_date=$(/bin/date -d "today +$n hour" "+%Y%m%dT%H%M%S") + calendar_data=$(cat < + + + + + + + sogo + + + +EOF + done; +} + +export -f test_gal_search + +# +# TEST EXECUTION +# +echo "Starting GAL search test..." +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_gal_search {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second." + + +# +# TEST DEFINITION +# +test_contacts_search() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request REPORT \ + --header "Depth:1" \ + --header "Content-Type:text/xml" \ + --data @- \ + $SOGO_SERVER_URL/sogo$1/Contacts/personal/ < + + + + + + + john$n + + + +EOF + done; +} + +export -f test_contacts_search + +# +# TEST EXECUTION +# +echo "Starting contacts search test..." +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_contacts_search {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second." + + +# +# TEST DEFINITION +# +test_calendar_search() { + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request REPORT \ + --header "Depth:1" \ + --header "Content-Type:text/xml" \ + --data @- \ + $SOGO_SERVER_URL/sogo$1/Calendar/personal/ < + + + + + + + + + + + + +EOF + done; +} + +export -f test_calendar_search + +# +# TEST EXECUTION +# +echo "Starting calendar search test..." +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_calendar_search {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second." diff --git a/Tests/Stress/teardown.sh b/Tests/Stress/teardown.sh new file mode 100755 index 000000000..bc976ffac --- /dev/null +++ b/Tests/Stress/teardown.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +. common_func.sh || error_out + +echo -n "Estimating fork overhead... " +FORK_OVERHEAD=$(calculate_curl_fork_overhead) +echo "done!" + +# +# TEST DEFINITION +# +test_teardown() { + # Cleanup calendar test data + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request DELETE \ + --header "Content-Type: text/xml" \ + $SOGO_SERVER_URL/sogo$1/Calendar/personal/$n.ics + done; + + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request DELETE \ + --header "Content-Type: text/xml" \ + $SOGO_SERVER_URL/sogo$1/Calendar/personal/sogo$1-$n.ics + done; + + # Cleanup address book test data + for n in $(seq $SOGO_TEST_ITERATIONS); do + curl -s -o /dev/null --basic --user sogo$1:sogo \ + --request DELETE \ + --header "Content-Type: text/xml" \ + $SOGO_SERVER_URL/sogo$1/Contacts/personal/$n.ics + done; +} + +export -f test_teardown + +# +# TEST EXECUTION +# +echo "Starting teardown test..." +START=$(date +%s%N) +seq $SOGO_CONCURRENCY_LIMIT | parallel -j0 test_teardown {} +END=$(date +%s%N) + +# +# TEST RESULTS +# +DIFF=$(echo "scale=2; $(( $END - $START)) / 1000000000" | bc -l) +TOTAL=$(( $SOGO_CONCURRENCY_LIMIT * $SOGO_TEST_ITERATIONS )) +DIFF_WITHOUT_FORK=$(echo "scale=2; $DIFF - $FORK_OVERHEAD" | bc -l) +THROUGHPUT=$(echo "scale=2; $TOTAL / $DIFF_WITHOUT_FORK" | bc -l) +echo "completed!" +echo "It took $DIFF seconds to run the test with the fork overhead of $FORK_OVERHEAD seconds." +echo "The real execution time for the test is $DIFF_WITHOUT_FORK seconds." +echo "Throughput achieved is $THROUGHPUT requests per second."