Skip to content

Commit

Permalink
Tests on common port.
Browse files Browse the repository at this point in the history
  • Loading branch information
arlolra authored and ry committed Feb 26, 2010
1 parent b299582 commit 724ccf1
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 59 deletions.
1 change: 1 addition & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var path = require("path");
exports.testDir = path.dirname(__filename);
exports.fixturesDir = path.join(exports.testDir, "fixtures");
exports.libDir = path.join(exports.testDir, "../lib");
exports.PORT = 12346;

require.paths.unshift(exports.libDir);

Expand Down
1 change: 0 additions & 1 deletion test/disabled/test-cat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common.js"));
http = require("/http.js");
PORT = 8888;

puts("hello world");

Expand Down
2 changes: 1 addition & 1 deletion test/disabled/test-dns.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
process.mixin(require("./common"));
process.mixin(require("../common"));

var dns = require("dns"),
sys = require("sys");
Expand Down
2 changes: 1 addition & 1 deletion test/disabled/test-eio-race3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* XXX Can this test be modified to not call the now-removed wait()? */

process.mixin(require("./common"));
process.mixin(require("../common"));


puts('first stat ...');
Expand Down
3 changes: 1 addition & 2 deletions test/disabled/test-fs-sendfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
process.mixin(require("./common"));
process.mixin(require("../common"));

tcp = require("tcp");
sys = require("sys");
PORT = 23123;
var x = path.join(fixturesDir, "x.txt");
var expected = "xyz";

Expand Down
1 change: 0 additions & 1 deletion test/disabled/test-http-stress.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require('../common.js'));

var PORT = 8003;
var request_count = 1000;
var response_body = '{"ok": true}';

Expand Down
2 changes: 0 additions & 2 deletions test/pummel/test-http-client-reconnect-bug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ var tcp = require("tcp"),
sys = require("sys"),
http = require("http");

var PORT = 2143;

var errorCount = 0;
var eofCount = 0;

Expand Down
1 change: 0 additions & 1 deletion test/pummel/test-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
process.mixin(require("../common"));
http = require("http");
sys = require("sys");
PORT = 8891;

body = "hello world\n";
server = http.createServer(function (req, res) {
Expand Down
1 change: 0 additions & 1 deletion test/pummel/test-multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ process.mixin(require("../common"));
var http = require("http"),
multipart = require("multipart"),
sys = require("sys"),
PORT = 8222,
fixture = require("../fixtures/multipart"),
events = require("events"),
testPart = function (expect, part) {
Expand Down
7 changes: 3 additions & 4 deletions test/pummel/test-tcp-many-clients.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
tcp = require("tcp");
// settings
var port = 20743;
var bytes = 1024*40;
var concurrency = 100;
var connections_per_client = 5;
Expand All @@ -22,10 +21,10 @@ var server = tcp.createServer(function (c) {
c.close();
});
});
server.listen(port);
server.listen(PORT);

function runClient (callback) {
var client = tcp.createConnection(port);
var client = tcp.createConnection(PORT);
client.connections = 0;
client.setEncoding("utf8");

Expand All @@ -48,7 +47,7 @@ function runClient (callback) {
assert.equal(false, had_error);
assert.equal(bytes, client.recved.length);
if (this.connections < connections_per_client) {
this.connect(port);
this.connect(PORT);
} else {
callback();
}
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-tcp-pingpong-delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function pingPongTest (port, host, on_complete) {
});
}

pingPongTest(21988);
pingPongTest(PORT);

process.addListener("exit", function () {
assert.equal(1, tests_run);
Expand Down
7 changes: 3 additions & 4 deletions test/pummel/test-tcp-pingpong.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
tcp = require("tcp");


var tests_run = 0;

function pingPongTest (port, host, on_complete) {
Expand Down Expand Up @@ -81,9 +80,9 @@ function pingPongTest (port, host, on_complete) {
}

/* All are run at once, so run on different ports */
pingPongTest(20989, "localhost");
pingPongTest(20988, null);
pingPongTest(20997, "::1");
pingPongTest(PORT, "localhost");
pingPongTest(PORT+1, null);
pingPongTest(PORT+2, "::1");

process.addListener("exit", function () {
assert.equal(3, tests_run);
Expand Down
1 change: 0 additions & 1 deletion test/pummel/test-tcp-throttle-kernel-buffer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
tcp = require("tcp");
PORT = 20444;
N = 30*1024; // 500kb

puts("build big string");
Expand Down
1 change: 0 additions & 1 deletion test/pummel/test-tcp-throttle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
tcp = require("tcp");
PORT = 20443;
N = 200;

server = tcp.createServer(function (connection) {
Expand Down
7 changes: 3 additions & 4 deletions test/pummel/test-tcp-timeout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
tcp = require("tcp");
port = 9992;
exchanges = 0;
starttime = null;
timeouttime = null;
Expand All @@ -25,10 +24,10 @@ var echo_server = tcp.createServer(function (socket) {
});
});

echo_server.listen(port);
puts("server listening at " + port);
echo_server.listen(PORT);
puts("server listening at " + PORT);

var client = tcp.createConnection(port);
var client = tcp.createConnection(PORT);
client.setEncoding("UTF8");
client.setTimeout(0); // disable the timeout for client
client.addListener("connect", function () {
Expand Down
4 changes: 2 additions & 2 deletions test/pummel/test-tcp-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ if (have_tls) {
var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem");

/* All are run at once, so run on different ports */
tlsTest(20443, "localhost", caPem, keyPem, certPem);
tlsTest(21443, null, caPem, keyPem, certPem);
tlsTest(PORT, "localhost", caPem, keyPem, certPem);
tlsTest(PORT+1, null, caPem, keyPem, certPem);

process.addListener("exit", function () {
assert.equal(2, tests_run);
Expand Down
6 changes: 2 additions & 4 deletions test/simple/test-http-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ process.mixin(require("../common"));
tcp = require("tcp");
http = require("http");

var port = 7333;

var body = "hello world\n";
var server_response = "";
var client_got_eof = false;
Expand All @@ -13,9 +11,9 @@ var server = http.createServer(function (req, res) {
res.write(body);
res.close();
})
server.listen(port);
server.listen(PORT);

var c = tcp.createConnection(port);
var c = tcp.createConnection(PORT);

c.setEncoding("utf8");

Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http-cat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
http = require("http");
PORT = 8888;

var body = "exports.A = function() { return 'A';}";
var server = http.createServer(function (req, res) {
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http-chunked.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
var http = require("http");
var PORT = 8888;

var UTF8_STRING = "Il était tué";

Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http-client-race.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
http = require("http");
url = require("url");
PORT = 8888;

var body1_s = "1111111111111111";
var body2_s = "22222";
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http-client-upload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
http = require("http");
var PORT = 18032;

var sent_body = "";
var server_req_complete = false;
Expand Down
5 changes: 2 additions & 3 deletions test/simple/test-http-eof-on-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ http = require("http");
// This is a regression test for http://github.com/ry/node/issues/#issue/44
// It is separate from test-http-malformed-request.js because it is only
// reproduceable on the first packet on the first connection to a server.
port = 9999;

server = http.createServer(function (req, res) {});
server.listen(port);
server.listen(PORT);

tcp.createConnection(port).addListener("connect", function () {
tcp.createConnection(PORT).addListener("connect", function () {
this.close();
}).addListener("close", function () {
server.close();
Expand Down
5 changes: 2 additions & 3 deletions test/simple/test-http-malformed-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ url = require("url");

// Make sure no exceptions are thrown when receiving malformed HTTP
// requests.
port = 9999;

nrequests_completed = 0;
nrequests_expected = 1;
Expand All @@ -19,9 +18,9 @@ var s = http.createServer(function (req, res) {

if (++nrequests_completed == nrequests_expected) s.close();
});
s.listen(port);
s.listen(PORT);

var c = tcp.createConnection(port);
var c = tcp.createConnection(PORT);
c.addListener("connect", function () {
c.write("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n");
c.close();
Expand Down
4 changes: 2 additions & 2 deletions test/simple/test-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ process.mixin(require("../common"));
http = require("http");
url = require("url");

var PROXY_PORT = 8869;
var BACKEND_PORT = 8870;
var PROXY_PORT = PORT;
var BACKEND_PORT = PORT+1;

var backend = http.createServer(function (req, res) {
// debug("backend");
Expand Down
6 changes: 2 additions & 4 deletions test/simple/test-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ http = require("http");
url = require("url");
qs = require("querystring");

var port = 8222;

var request_number = 0;
var requests_sent = 0;
var server_response = "";
Expand Down Expand Up @@ -43,9 +41,9 @@ http.createServer(function (req, res) {
res.close();
}, 1);

}).listen(port);
}).listen(PORT);

var c = tcp.createConnection(port);
var c = tcp.createConnection(PORT);

c.setEncoding("utf8");

Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http-tls.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
http = require("http");
url = require("url");
PORT = 8888;

HOST = "localhost";

Expand Down
6 changes: 2 additions & 4 deletions test/simple/test-http-wget.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ http = require("http");
// content-length is not provided, that the connection is in fact
// closed.

var port = 7333;

var server_response = "";
var client_got_eof = false;
var connection_was_closed = false;
Expand All @@ -29,9 +27,9 @@ var server = http.createServer(function (req, res) {
res.write("world\n");
res.close();
})
server.listen(port);
server.listen(PORT);

var c = tcp.createConnection(port);
var c = tcp.createConnection(PORT);

c.setEncoding("utf8");

Expand Down
1 change: 0 additions & 1 deletion test/simple/test-http.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
http = require("http");
url = require("url");
PORT = 8888;

var responses_sent = 0;
var responses_recvd = 0;
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-remote-module-loading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));

var PORT = 8889;
var http = require('http');
var sys = require('sys');
var url = require("url");
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-tcp-binary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
process.mixin(require("../common"));
tcp = require("tcp");
PORT = 23123;

binaryString = "";
for (var i = 255; i >= 0; i--) {
Expand Down
7 changes: 3 additions & 4 deletions test/simple/test-tcp-reconnect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
process.mixin(require("../common"));
tcp = require("tcp");
var N = 50;
var port = 8921;

var c = 0;
var client_recv_count = 0;
Expand All @@ -21,9 +20,9 @@ var server = tcp.createServer(function (socket) {
assert.equal(false, had_error);
});
});
server.listen(port);
server.listen(PORT);

var client = tcp.createConnection(port);
var client = tcp.createConnection(PORT);

client.setEncoding("UTF8");

Expand All @@ -42,7 +41,7 @@ client.addListener("close", function (had_error) {
puts("disconnect");
assert.equal(false, had_error);
if (disconnect_count++ < N)
client.connect(port); // reconnect
client.connect(PORT); // reconnect
else
server.close();
});
Expand Down

0 comments on commit 724ccf1

Please sign in to comment.