Permalink
Browse files

add node.js example

  • Loading branch information...
1 parent aedb24f commit 6b3ee03be8cd8a4b5fd3b09499ca6e79a694a692 @earldouglas earldouglas committed Sep 14, 2012
Showing with 271 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +20 −2 README.md
  3. +16 −0 node.js/api/scamper.js
  4. +42 −0 node.js/app.js
  5. +183 −0 node.js/load-test.jmx
  6. +9 −0 node.js/package.json
View
1 .gitignore
@@ -13,3 +13,4 @@ lib_managed/
*/project/plugins/project/
*/project/plugins/src_managed/
+node_modules/
View
22 README.md
@@ -4,6 +4,14 @@
http://jmeter.apache.org/
+## Install Node.js
+
+```
+brew install nodejs
+npm install -g express
+(cd scamper/node.js ; npm link express)
+```
+
## Install sbt
https://github.com/harrah/xsbt/wiki/Getting-Started-Setup
@@ -80,11 +88,11 @@ jmeter -n -t scamper/play2-mini/load-test.jmx
### [spray-can](https://github.com/spray/spray-can)
```
-(cd scamper/FOOBAR ; sbt run)
+(cd scamper/spray-can ; sbt run)
```
```
-jmeter -n -t scamper/FOOBAR/load-test.jmx
+jmeter -n -t scamper/spray-can/load-test.jmx
```
### Servlet 3.0
@@ -99,3 +107,13 @@ jmeter -n -t scamper/servlet-3.0/async-load-test.jmx
jmeter -n -t scamper/servlet-3.0/scalatra-load-test.jmx
jmeter -n -t scamper/servlet-3.0/scalatra-async-load-test.jmx
```
+
+### Node.js
+
+```
+(cd scamper/node.js ; node app.js)
+```
+
+```
+jmeter -n -t scamper/node.js/load-test.jmx
+```
View
16 node.js/api/scamper.js
@@ -0,0 +1,16 @@
+exports.fast = function(req, res) {
+ res.send('<h1>slept for 0 ms</h1>');
+}
+
+exports.medium = function(req, res) {
+ setTimeout(function () {
+ res.send('<h1>slept for 150 ms</h1>');
+ }, 150);
+}
+
+exports.slow = function(req, res) {
+ setTimeout(function () {
+ res.send('<h1>slept for 300 ms</h1>');
+ }, 300);
+}
+
View
42 node.js/app.js
@@ -0,0 +1,42 @@
+/**
+ * Nodejs Scamper
+ *
+ * @package Application
+ * @author Alex Zelensky
+ */
+
+/**
+ * Require Modules
+ */
+var express = require('express'),
+ http = require('http'),
+ scamper = require('./api/scamper');
+
+/**
+ * Create Application
+ */
+var app = express();
+
+/**
+ * Application Routers
+ */
+//sleep 0ms
+app.get('/fast', scamper.fast);
+
+//sleep 150ms
+app.get('/medium', scamper.medium);
+
+//sleep 300ms
+app.get('/slow', scamper.slow);
+
+/**
+ * Run Node.js Server
+ */
+var server = http.createServer(app).listen(3000, '127.0.0.1', function(){
+ /**
+ * Start Message
+ */
+ console.log("Node.js Web server listening on port 3000");
+});
+
+
View
183 node.js/load-test.jmx
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jmeterTestPlan version="1.2" properties="2.3">
+ <hashTree>
+ <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
+ <stringProp name="TestPlan.comments"></stringProp>
+ <boolProp name="TestPlan.functional_mode">false</boolProp>
+ <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
+ <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="TestPlan.user_define_classpath"></stringProp>
+ </TestPlan>
+ <hashTree>
+ <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments">
+ <elementProp name="loops" elementType="Argument">
+ <stringProp name="Argument.name">loops</stringProp>
+ <stringProp name="Argument.value">10</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="host" elementType="Argument">
+ <stringProp name="Argument.name">host</stringProp>
+ <stringProp name="Argument.value">localhost</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="port" elementType="Argument">
+ <stringProp name="Argument.name">port</stringProp>
+ <stringProp name="Argument.value">3000</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="fastEndpoint" elementType="Argument">
+ <stringProp name="Argument.name">fastEndpoint</stringProp>
+ <stringProp name="Argument.value">/fast</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="mediumEndpoint" elementType="Argument">
+ <stringProp name="Argument.name">mediumEndpoint</stringProp>
+ <stringProp name="Argument.value">/medium</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="slowEndpoint" elementType="Argument">
+ <stringProp name="Argument.name">slowEndpoint</stringProp>
+ <stringProp name="Argument.value">/slow</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="fastThreads" elementType="Argument">
+ <stringProp name="Argument.name">fastThreads</stringProp>
+ <stringProp name="Argument.value">81</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="mediumThreads" elementType="Argument">
+ <stringProp name="Argument.name">mediumThreads</stringProp>
+ <stringProp name="Argument.value">27</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ <elementProp name="slowThreads" elementType="Argument">
+ <stringProp name="Argument.name">slowThreads</stringProp>
+ <stringProp name="Argument.value">9</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ </collectionProp>
+ </Arguments>
+ <hashTree/>
+ <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
+ <boolProp name="LoopController.continue_forever">false</boolProp>
+ <stringProp name="LoopController.loops">${loops}</stringProp>
+ </elementProp>
+ <stringProp name="ThreadGroup.num_threads">${fastThreads}</stringProp>
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+ <longProp name="ThreadGroup.start_time">1347296476000</longProp>
+ <longProp name="ThreadGroup.end_time">1347296476000</longProp>
+ <boolProp name="ThreadGroup.scheduler">false</boolProp>
+ <stringProp name="ThreadGroup.duration"></stringProp>
+ <stringProp name="ThreadGroup.delay"></stringProp>
+ </ThreadGroup>
+ <hashTree>
+ <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${host}:${port}${fastEndpoint}" enabled="true">
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">${host}</stringProp>
+ <stringProp name="HTTPSampler.port">${port}</stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="HTTPSampler.protocol"></stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path">${fastEndpoint}</stringProp>
+ <stringProp name="HTTPSampler.method">GET</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <boolProp name="HTTPSampler.monitor">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ <stringProp name="TestPlan.comments"> </stringProp>
+ </HTTPSamplerProxy>
+ <hashTree/>
+ <Summariser guiclass="SummariserGui" testclass="Summariser" testname="${host}:${port}${fastEndpoint} " enabled="true"/>
+ <hashTree/>
+ </hashTree>
+ <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
+ <boolProp name="LoopController.continue_forever">false</boolProp>
+ <stringProp name="LoopController.loops">${loops}</stringProp>
+ </elementProp>
+ <stringProp name="ThreadGroup.num_threads">${mediumThreads}</stringProp>
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+ <longProp name="ThreadGroup.start_time">1347296476000</longProp>
+ <longProp name="ThreadGroup.end_time">1347296476000</longProp>
+ <boolProp name="ThreadGroup.scheduler">false</boolProp>
+ <stringProp name="ThreadGroup.duration"></stringProp>
+ <stringProp name="ThreadGroup.delay"></stringProp>
+ </ThreadGroup>
+ <hashTree>
+ <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${host}:${port}${mediumEndpoint}" enabled="true">
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">${host}</stringProp>
+ <stringProp name="HTTPSampler.port">${port}</stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="HTTPSampler.protocol"></stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path">${mediumEndpoint}</stringProp>
+ <stringProp name="HTTPSampler.method">GET</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <boolProp name="HTTPSampler.monitor">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ <stringProp name="TestPlan.comments"> </stringProp>
+ </HTTPSamplerProxy>
+ <hashTree/>
+ <Summariser guiclass="SummariserGui" testclass="Summariser" testname="${host}:${port}${mediumEndpoint}" enabled="true"/>
+ <hashTree/>
+ </hashTree>
+ <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
+ <boolProp name="LoopController.continue_forever">false</boolProp>
+ <stringProp name="LoopController.loops">${loops}</stringProp>
+ </elementProp>
+ <stringProp name="ThreadGroup.num_threads">${slowThreads}</stringProp>
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+ <longProp name="ThreadGroup.start_time">1347296476000</longProp>
+ <longProp name="ThreadGroup.end_time">1347296476000</longProp>
+ <boolProp name="ThreadGroup.scheduler">false</boolProp>
+ <stringProp name="ThreadGroup.duration"></stringProp>
+ <stringProp name="ThreadGroup.delay"></stringProp>
+ </ThreadGroup>
+ <hashTree>
+ <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${host}:${port}${slowEndpoint}" enabled="true">
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">${host}</stringProp>
+ <stringProp name="HTTPSampler.port">${port}</stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="HTTPSampler.protocol"></stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path">${slowEndpoint}</stringProp>
+ <stringProp name="HTTPSampler.method">GET</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <boolProp name="HTTPSampler.monitor">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ <stringProp name="TestPlan.comments"> </stringProp>
+ </HTTPSamplerProxy>
+ <hashTree/>
+ <Summariser guiclass="SummariserGui" testclass="Summariser" testname="${host}:${port}${slowEndpoint} " enabled="true"/>
+ <hashTree/>
+ </hashTree>
+ </hashTree>
+ </hashTree>
+</jmeterTestPlan>
View
9 node.js/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "nodejs-scamper"
+ , "version": "0.0.1"
+ , "private": true
+ , "dependencies": {
+ "express": "3.0.0rc1",
+ "jade": "*"
+ }
+}

0 comments on commit 6b3ee03

Please sign in to comment.