Skip to content

Commit bc236d7

Browse files
committed
[tests] Added a test case for run all the examples
* I changed all the ports across examples to be different and can run at same time
1 parent c82ff2c commit bc236d7

19 files changed

+144
-72
lines changed

Diff for: examples/balancer/simple-balancer-with-websockets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ server.on('upgrade', function (req, socket, head) {
8080
nextProxy().ws(req, socket, head);
8181
});
8282

83-
server.listen(8080);
83+
server.listen(8001);
8484

Diff for: examples/balancer/simple-balancer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ http.createServer(function (req, res) {
5959
// ...and then the server you just used becomes the last item in the list.
6060
//
6161
addresses.push(target);
62-
}).listen(8000);
62+
}).listen(8021);
6363

6464
// Rinse; repeat; enjoy.

Diff for: examples/http/basic-proxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ util.puts(welcome.rainbow.bold);
4444
// Basic Http Proxy Server
4545
//
4646
httpProxy.createServer({
47-
target:'http://localhost:9000'
48-
}).listen(8000);
47+
target:'http://localhost:9003'
48+
}).listen(8003);
4949

5050
//
5151
// Target Http Server
@@ -54,7 +54,7 @@ http.createServer(function (req, res) {
5454
res.writeHead(200, { 'Content-Type': 'text/plain' });
5555
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
5656
res.end();
57-
}).listen(9000);
57+
}).listen(9003);
5858

59-
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
60-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
59+
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow);
60+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow);

Diff for: examples/http/concurrent-proxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ var util = require('util'),
3333
// Basic Http Proxy Server
3434
//
3535
httpProxy.createServer({
36-
target:'http://localhost:9000'
37-
}).listen(8000);
36+
target:'http://localhost:9004'
37+
}).listen(8004);
3838

3939
//
4040
// Target Http Server
@@ -62,7 +62,7 @@ http.createServer(function (req, res) {
6262
connections.shift()();
6363
}
6464
}
65-
}).listen(9000);
65+
}).listen(9004);
6666

67-
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
68-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
67+
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8004'.yellow);
68+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9004 '.yellow);

Diff for: examples/http/custom-proxy-error.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ var util = require('util'),
3333
// Http Proxy Server with bad target
3434
//
3535
var proxy = httpProxy.createServer({
36-
target:'http://localhost:9000'
36+
target:'http://localhost:9005'
3737
});
3838

3939
//
4040
// Tell the proxy to listen on port 8000
4141
//
42-
proxy.listen(8000);
42+
proxy.listen(8005);
4343

4444
//
4545
// Listen for the `error` event on `proxy`.
@@ -52,4 +52,4 @@ proxy.on('error', function (err, req, res) {
5252
});
5353

5454

55-
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow + 'with custom error message'.magenta.underline);
55+
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8005 '.yellow + 'with custom error message'.magenta.underline);

Diff for: examples/http/forward-and-target-proxy.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ var util = require('util'),
3434
//
3535
httpProxy.createServer({
3636
target: {
37-
port: 9000,
37+
port: 9006,
3838
host: 'localhost'
3939
},
4040
forward: {
41-
port: 9001,
41+
port: 9007,
4242
host: 'localhost'
4343
}
44-
}).listen(8000);
44+
}).listen(8006);
4545

4646
//
4747
// Target Http Server
@@ -50,7 +50,7 @@ http.createServer(function (req, res) {
5050
res.writeHead(200, { 'Content-Type': 'text/plain' });
5151
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
5252
res.end();
53-
}).listen(9000);
53+
}).listen(9006);
5454

5555
//
5656
// Target Http Forwarding Server
@@ -60,8 +60,8 @@ http.createServer(function (req, res) {
6060
res.writeHead(200, { 'Content-Type': 'text/plain' });
6161
res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
6262
res.end();
63-
}).listen(9001);
63+
}).listen(9007);
6464

65-
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow + 'with forward proxy'.magenta.underline);
66-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
67-
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9001 '.yellow);
65+
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8006 '.yellow + 'with forward proxy'.magenta.underline);
66+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9006 '.yellow);
67+
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9007 '.yellow);

Diff for: examples/http/forward-proxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var util = require('util'),
3434
//
3535
httpProxy.createServer({
3636
forward: {
37-
port: 9000,
37+
port: 9019,
3838
host: 'localhost'
3939
}
40-
}).listen(8000);
40+
}).listen(8019);
4141

4242
//
4343
// Target Http Forwarding Server
@@ -47,7 +47,7 @@ http.createServer(function (req, res) {
4747
res.writeHead(200, { 'Content-Type': 'text/plain' });
4848
res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
4949
res.end();
50-
}).listen(9000);
50+
}).listen(9019);
5151

52-
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow + 'with forward proxy'.magenta.underline);
53-
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
52+
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8019 '.yellow + 'with forward proxy'.magenta.underline);
53+
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9019 '.yellow);

Diff for: examples/http/latent-proxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ var proxy = httpProxy.createProxyServer();
3636
http.createServer(function (req, res) {
3737
setTimeout(function () {
3838
proxy.web(req, res, {
39-
target: 'http://localhost:9000'
39+
target: 'http://localhost:9008'
4040
});
4141
}, 500);
42-
}).listen(8000);
42+
}).listen(8008);
4343

4444
//
4545
// Target Http Server
@@ -48,7 +48,7 @@ http.createServer(function (req, res) {
4848
res.writeHead(200, { 'Content-Type': 'text/plain' });
4949
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
5050
res.end();
51-
}).listen(9000);
51+
}).listen(9008);
5252

53-
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow + 'with latency'.magenta.underline);
54-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
53+
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8008 '.yellow + 'with latency'.magenta.underline);
54+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9008 '.yellow);

Diff for: examples/http/proxy-http-to-https.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ httpProxy.createProxyServer({
4141
headers: {
4242
host: 'google.com'
4343
}
44-
}).listen(8000);
44+
}).listen(8011);
4545

46-
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
46+
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8011'.yellow);

Diff for: examples/http/proxy-https-to-http.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ http.createServer(function (req, res) {
4040
res.writeHead(200, { 'Content-Type': 'text/plain' });
4141
res.write('hello http over https\n');
4242
res.end();
43-
}).listen(9000);
43+
}).listen(9009);
4444

4545
//
4646
// Create the HTTPS proxy server listening on port 8000
4747
//
4848
httpProxy.createServer({
4949
target: {
5050
host: 'localhost',
51-
port: 9000
51+
port: 9009
5252
},
5353
ssl: {
5454
key: fs.readFileSync(path.join(fixturesDir, 'agent2-key.pem'), 'utf8'),
5555
cert: fs.readFileSync(path.join(fixturesDir, 'agent2-cert.pem'), 'utf8')
5656
}
57-
}).listen(8000);
57+
}).listen(8009);
5858

59-
util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
60-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
59+
util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow);
60+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow);

Diff for: examples/http/proxy-https-to-https.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ https.createServer(httpsOpts, function (req, res) {
4444
res.writeHead(200, { 'Content-Type': 'text/plain' });
4545
res.write('hello https\n');
4646
res.end();
47-
}).listen(9000);
47+
}).listen(9010);
4848

4949
//
5050
// Create the proxy server listening on port 443
5151
//
5252
httpProxy.createServer({
5353
ssl: httpsOpts,
54-
target: 'https://localhost:9000',
54+
target: 'https://localhost:9010',
5555
secure: false
56-
}).listen(8000);
56+
}).listen(8010);
5757

58-
util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
59-
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
58+
util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8010'.yellow);
59+
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '9010 '.yellow);

Diff for: examples/http/standalone-proxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ var proxy = new httpProxy.createProxyServer();
3636
http.createServer(function (req, res) {
3737
setTimeout(function () {
3838
proxy.web(req, res, {
39-
target: 'http://localhost:9000'
39+
target: 'http://localhost:9002'
4040
});
4141
}, 200);
42-
}).listen(8000);
42+
}).listen(8002);
4343

4444
//
4545
// Target Http Server
@@ -48,7 +48,7 @@ http.createServer(function (req, res) {
4848
res.writeHead(200, { 'Content-Type': 'text/plain' });
4949
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
5050
res.end();
51-
}).listen(9000);
51+
}).listen(9002);
5252

53-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8000 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta);
54-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
53+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta);
54+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9001 '.yellow);

Diff for: examples/middleware/gzip-middleware.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ connect.createServer(
4343
function (req, res) {
4444
proxy.web(req, res);
4545
}
46-
).listen(8000);
46+
).listen(8012);
4747

4848
//
4949
// Basic Http Proxy Server
5050
//
5151
var proxy = httpProxy.createProxyServer({
52-
target: 'http://localhost:9000'
52+
target: 'http://localhost:9012'
5353
});
5454

5555
//
@@ -59,7 +59,7 @@ http.createServer(function (req, res) {
5959
res.writeHead(200, { 'Content-Type': 'text/plain' });
6060
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
6161
res.end();
62-
}).listen(9000);
62+
}).listen(9012);
6363

64-
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
65-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
64+
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8012'.yellow);
65+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9012 '.yellow);

Diff for: examples/middleware/modifyResponse-middleware.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ connect.createServer(
4545
function (req, res) {
4646
proxy.web(req, res);
4747
}
48-
).listen(8000);
48+
).listen(8013);
4949

5050
//
5151
// Basic Http Proxy Server
5252
//
5353
var proxy = httpProxy.createProxyServer({
54-
target: 'http://localhost:9000'
54+
target: 'http://localhost:9013'
5555
});
5656

5757
//
@@ -60,8 +60,8 @@ var proxy = httpProxy.createProxyServer({
6060
http.createServer(function (req, res) {
6161
res.writeHead(200, { 'Content-Type': 'text/plain' });
6262
res.end('Hello, I know Ruby\n');
63-
}).listen(9000);
63+
}).listen(9013);
6464

65-
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
66-
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
65+
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow);
66+
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9013 '.yellow);
6767

Diff for: examples/websocket/latent-websocket-proxy.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ catch (ex) {
4343
// Create the target HTTP server and setup
4444
// socket.io on it.
4545
//
46-
var server = io.listen(9000);
46+
var server = io.listen(9016);
4747
server.sockets.on('connection', function (client) {
4848
util.debug('Got websocket connection');
4949

@@ -60,7 +60,7 @@ server.sockets.on('connection', function (client) {
6060
var proxy = new httpProxy.createProxyServer({
6161
target: {
6262
host: 'localhost',
63-
port: 9000
63+
port: 9016
6464
}
6565
});
6666

@@ -78,12 +78,12 @@ proxyServer.on('upgrade', function (req, socket, head) {
7878
}, 1000);
7979
});
8080

81-
proxyServer.listen(8000);
81+
proxyServer.listen(8016);
8282

8383
//
8484
// Setup the socket.io client against our proxy
8585
//
86-
var ws = client.connect('ws://localhost:8000');
86+
var ws = client.connect('ws://localhost:8016');
8787

8888
ws.on('message', function (msg) {
8989
util.debug('Got message: ' + msg);

Diff for: examples/websocket/standalone-websocket-proxy.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ catch (ex) {
4343
// Create the target HTTP server and setup
4444
// socket.io on it.
4545
//
46-
var server = io.listen(9000);
46+
var server = io.listen(9015);
4747
server.sockets.on('connection', function (client) {
4848
util.debug('Got websocket connection');
4949

@@ -60,7 +60,7 @@ server.sockets.on('connection', function (client) {
6060
var proxy = new httpProxy.createProxyServer({
6161
target: {
6262
host: 'localhost',
63-
port: 9000
63+
port: 9015
6464
}
6565
});
6666
var proxyServer = http.createServer(function (req, res) {
@@ -75,12 +75,12 @@ proxyServer.on('upgrade', function (req, socket, head) {
7575
proxy.ws(req, socket, head);
7676
});
7777

78-
proxyServer.listen(8000);
78+
proxyServer.listen(8015);
7979

8080
//
8181
// Setup the socket.io client against our proxy
8282
//
83-
var ws = client.connect('ws://localhost:8000');
83+
var ws = client.connect('ws://localhost:8015');
8484

8585
ws.on('message', function (msg) {
8686
util.debug('Got message: ' + msg);

0 commit comments

Comments
 (0)