Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a shell script for stress testing #11

Merged
merged 5 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
.externalNativeBuild
.idea
modified-key-92e6.json
config.py
config.py
__pycache__/
7 changes: 4 additions & 3 deletions RunTestSuite.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import subprocess, smtplib, ssl, sys, time
from email.message import EmailMessage
import re, config
Expand Down Expand Up @@ -29,9 +31,8 @@ def getTestResults(output):


def runAndroidTest():
subprocess.call("gradle clean", shell=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to remove this because this would cause the different stress test processes to interfere with each other by changing the build output.

subprocess.call("gradle build -x lint", shell=True)
cmdExe = "gradlew test"
subprocess.call("./gradlew build -x lint", shell=True)
cmdExe = "./gradlew test"
process = subprocess.Popen(cmdExe, stdout=subprocess.PIPE, shell=True)
output = process.communicate()[0]
output = str(output)
Expand Down
43 changes: 43 additions & 0 deletions StressTestApp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/zsh
trap "exit" INT TERM
trap "kill 0" EXIT

if [ "$#" -ne 2 ]; then
echo "Usage: StressTestApp.sh <number of iterations> <number of background processes>"
exit -1
fi

NUM_ITERATIONS=$1
NUM_BACKGROUND_PROCESSES=$2

# Run once before to do any necessary compilation once
echo "Pre-compiling tests"
./RunTestSuite.py 1 > /dev/null 2>&1
START_TIME=$(date)
START_SECONDS=$SECONDS

PID_ARRAY=()
for ((i=0;i<$NUM_BACKGROUND_PROCESSES;i++))
do
./RunTestSuite.py $NUM_ITERATIONS > /dev/null 2>&1 &
PID_ARRAY+=($!)
echo "Started background process $((i+1)) with PID $!"
done

echo "Created ${#PID_ARRAY[@]} background processes"
for PID in "${PID_ARRAY[@]}"
do
echo "Waiting for background process with ID $PID"
wait $PID
done

COMPLETED_TIME=$(date)
ELAPSED_SECONDS=$(($SECONDS - $START_SECONDS))

echo "
Finished executing stress test with parameters:
Number of background processes: $NUM_BACKGROUND_PROCESSES
Number of iterations: $NUM_ITERATIONS
Start time: $START_TIME
End time: $COMPLETED_TIME
Elapsed seconds: $ELAPSED_SECONDS"