summaryrefslogtreecommitdiff
path: root/test/sequential/test-https-server-keep-alive-timeout.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-11-04 20:49:27 -0700
committerRich Trott <rtrott@gmail.com>2017-11-17 21:04:53 -0800
commit780c2d3917ccffd9d71d484b089f74af18355314 (patch)
tree49ba34e459109f41e32213c2c2093218e9885de2 /test/sequential/test-https-server-keep-alive-timeout.js
parent02590b4cfa2cefc512cdee4244490a09676a58b2 (diff)
downloadandroid-node-v8-780c2d3917ccffd9d71d484b089f74af18355314.tar.gz
android-node-v8-780c2d3917ccffd9d71d484b089f74af18355314.tar.bz2
android-node-v8-780c2d3917ccffd9d71d484b089f74af18355314.zip
test: move timing-sensitive test to sequential
test-https-server-keep-alive-timeout relies on server timeouts and whatnot that will be inherently unreliable on a busy host. The test fails when run with a high `-j` value and higher `--repeat` value passed to `tools/test.py`. Move the test to `sequential`. PR-URL: https://github.com/nodejs/node/pull/16775 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential/test-https-server-keep-alive-timeout.js')
-rw-r--r--test/sequential/test-https-server-keep-alive-timeout.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/sequential/test-https-server-keep-alive-timeout.js b/test/sequential/test-https-server-keep-alive-timeout.js
new file mode 100644
index 0000000000..3c18d325c1
--- /dev/null
+++ b/test/sequential/test-https-server-keep-alive-timeout.js
@@ -0,0 +1,79 @@
+'use strict';
+
+const common = require('../common');
+
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+
+const fixtures = require('../common/fixtures');
+const https = require('https');
+const tls = require('tls');
+
+const tests = [];
+
+const serverOptions = {
+ key: fixtures.readKey('agent1-key.pem'),
+ cert: fixtures.readKey('agent1-cert.pem')
+};
+
+function test(fn) {
+ if (!tests.length) {
+ process.nextTick(run);
+ }
+ tests.push(fn);
+}
+
+function run() {
+ const fn = tests.shift();
+ if (fn) fn(run);
+}
+
+test(function serverKeepAliveTimeoutWithPipeline(cb) {
+ const server = https.createServer(
+ serverOptions,
+ common.mustCall((req, res) => {
+ res.end();
+ }, 3));
+ server.setTimeout(500, common.mustCall((socket) => {
+ // End this test and call `run()` for the next test (if any).
+ socket.destroy();
+ server.close();
+ cb();
+ }));
+ server.keepAliveTimeout = 50;
+ server.listen(0, common.mustCall(() => {
+ const options = {
+ port: server.address().port,
+ allowHalfOpen: true,
+ rejectUnauthorized: false
+ };
+ const c = tls.connect(options, () => {
+ c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ });
+ }));
+});
+
+test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
+ const server = https.createServer(serverOptions, common.mustCall(3));
+ server.setTimeout(500, common.mustCall((socket) => {
+ // End this test and call `run()` for the next test (if any).
+ socket.destroy();
+ server.close();
+ cb();
+ }));
+ server.keepAliveTimeout = 50;
+ server.listen(0, common.mustCall(() => {
+ const options = {
+ port: server.address().port,
+ allowHalfOpen: true,
+ rejectUnauthorized: false
+ };
+ const c = tls.connect(options, () => {
+ c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
+ });
+ }));
+});