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

Lines changed: 144 additions & 72 deletions

examples/balancer/simple-balancer-with-websockets.js

Lines changed: 1 addition & 1 deletion
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

examples/balancer/simple-balancer.js

Lines changed: 1 addition & 1 deletion
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.

examples/http/basic-proxy.js

Lines changed: 5 additions & 5 deletions
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);

examples/http/concurrent-proxy.js

Lines changed: 5 additions & 5 deletions
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);

examples/http/custom-proxy-error.js

Lines changed: 3 additions & 3 deletions
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);

examples/http/forward-and-target-proxy.js

Lines changed: 8 additions & 8 deletions
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);

examples/http/forward-proxy.js

Lines changed: 5 additions & 5 deletions
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);

examples/http/latent-proxy.js

Lines changed: 5 additions & 5 deletions
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);

examples/http/proxy-http-to-https.js

Lines changed: 2 additions & 2 deletions
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);

examples/http/proxy-https-to-http.js

Lines changed: 5 additions & 5 deletions
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);

0 commit comments

Comments
 (0)