diff --git a/Demos/apps/loadtest/WebServicePkg/Code/server.js b/Demos/apps/loadtest/WebServicePkg/Code/server.js index 456dd1c..43d5cd7 100644 --- a/Demos/apps/loadtest/WebServicePkg/Code/server.js +++ b/Demos/apps/loadtest/WebServicePkg/Code/server.js @@ -3,8 +3,21 @@ var http = require('http'); const PORT = process.env.NODE_PORT || 3000; const RESPONSE = process.env.RES_STRING || "Hello World" +/** + * Returns a random integer between min (inclusive) and max (inclusive) + * Using Math.round() will give you a non-uniform distribution! + */ +function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; +} + + var server = http.createServer(function (req, res) { - var body = RESPONSE; + if (req.url.includes('large')) { + var body = JSON.stringify(new Array(getRandomInt(1000,2000000))); + } else { + var body = RESPONSE; + } var content_length = body.length; res.writeHead(200, { 'Content-Length': content_length, @@ -12,4 +25,6 @@ var server = http.createServer(function (req, res) { res.end(body); }); server.listen(PORT); -console.log('Server is running on port ' + PORT); \ No newline at end of file +console.log('Server is running on port ' + PORT); + + diff --git a/Testing/Cleanup.sh b/Testing/Cleanup.sh old mode 100644 new mode 100755 diff --git a/Testing/Scenario2/Setup.sh b/Testing/Scenario2/Setup.sh index adebb04..89cc46a 100755 --- a/Testing/Scenario2/Setup.sh +++ b/Testing/Scenario2/Setup.sh @@ -1,3 +1,5 @@ +ENDPOINT_TO_TEST=$1 + #Traefik install sfctl application upload --path ./Traefik/ApplicationPackageRoot/ sfctl application provision --application-type-build-path ApplicationPackageRoot @@ -12,5 +14,6 @@ do sfctl application create --app-type NodeAppType --app-version 1.0.0 --parameters "{\"PORT\":\"25$i\", \"RESPONSE\":\"25$i\"}" --app-name fabric:/node25$i ) & done - #Run load test +docker run --rm -it williamyeh/wrk -c 100 -t6 -d15m $ENDPOINT_TO_TEST +docker run --rm -it williamyeh/wrk -c 100 -t6 -d15m $ENDPOINT_TO_TEST/large