Skip to content

Commit

Permalink
54435: Add load test results to microservices ui autoLoadTest.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Bobbitt committed Feb 12, 2016
1 parent 3bf03c3 commit 06c0e5c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
26 changes: 24 additions & 2 deletions autoLoadTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,40 @@
}
});
}
function updateResults() {
$.ajax({
type: "GET",
contentType: "text/plain",
url: "/autoLoadTest.php?action=results",
success: function(result_log) {
var results = document.getElementById("results");
results.innerText = result_log;
setTimeout(updateResults, 1000);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var status = document.getElementById("results");
results.innerText = "Error: " + XMLHttpRequest.statusText;
setTimeout(updateResults, 1000);
}
});
}
function onLoad() {
callLoad("status");
updateResults();
}
</script>
</head>

<body onload=callLoad("status");>
<body onload=onLoad();>
Test count per burst:
<input type="number" id="countText" value="100"></input>
Delay between bursts (s):
<input type="number" id="delayText" value="0"></input>
<button type="button" id="startButton" style="position:static;" onclick="start()">Start</button>
<button type="button" id="stopButton" style="position:static;" disabled="true" onclick="stop()">Stop</button>
<span id="status"></span>
<table id="resultsTable"></table>
</br>
<div id="results"></div>
</body>

</html>
2 changes: 2 additions & 0 deletions autoLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function echoStatus($running, $message) {
//Turn off load test
exec("rm -f $RUNNING_FILE");
echoStatus(false, 'Load test stopped.');
} else if ($_GET['action'] == 'results') {
echo file_get_contents("results.log");
} else if ($_GET['action'] == 'start') {
//If already running, user needs to issue a stop first. We could get fancier and kill
//the running script and update with the new params but for now let's just...
Expand Down
16 changes: 10 additions & 6 deletions load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ fi
#echo "Delay: $DELAY";

#Check for RUNNING file to determine if load should be generated
if [ ! -f "RUNNING" ] ; then
if [ ! -f RUNNING ] ; then
echo "Load test not running. Exiting...";
exit 0;
fi

#Clean up the results log file if it exists
if [ -f results.log ] ; then
echo "Cleaning up old results.log"
rm -f results.log
#Create an empty results log file if it does not exist
if [ ! -f results.log ] ; then
echo "Creating results.log"
touch results.log
fi

#TODO: Get fancier to prevent someone from stopping and starting the load during sleep interval
Expand All @@ -52,7 +52,11 @@ echo "Starting load to $URL";

while [ -f RUNNING ] ;
do
curl -s $URL -w "\n" >> results.log;
#Use temp file to add result to top of the log
echo "`date -u` `curl -s $URL -w \"\\n\"`" | cat - results.log > results.log.tmp
#Use temp file to truncate the log... sed inline is inconsistent between mac and linux
sed '30,$ d' results.log.tmp > results.log

sleep $DELAY;
done

Expand Down

0 comments on commit 06c0e5c

Please sign in to comment.