diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-09 10:39:27 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-10-12 14:27:53 -0700 |
commit | 627bcf7f275e266d8ec5c42bcedd68c188444ead (patch) | |
tree | 6cd0676db521536cf99888de77c8a2c88588c92d /test/parallel/test-gc-http-client-onerror.js | |
parent | 0ea804aae58568d6bf18e4eee7976ccccdbe6704 (diff) | |
download | android-node-v8-627bcf7f275e266d8ec5c42bcedd68c188444ead.tar.gz android-node-v8-627bcf7f275e266d8ec5c42bcedd68c188444ead.tar.bz2 android-node-v8-627bcf7f275e266d8ec5c42bcedd68c188444ead.zip |
test: move some gc tests back to parallel/, unmark flaky
These should no longer be flaky after the libuv update.
Refs: https://github.com/nodejs/node/pull/23336
PR-URL: https://github.com/nodejs/node/pull/23356
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-gc-http-client-onerror.js')
-rw-r--r-- | test/parallel/test-gc-http-client-onerror.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/parallel/test-gc-http-client-onerror.js b/test/parallel/test-gc-http-client-onerror.js new file mode 100644 index 0000000000..28a8aecd27 --- /dev/null +++ b/test/parallel/test-gc-http-client-onerror.js @@ -0,0 +1,65 @@ +'use strict'; +// Flags: --expose-gc +// just like test-gc-http-client.js, +// but with an on('error') handler that does nothing. + +const common = require('../common'); +const onGC = require('../common/ongc'); + +function serverHandler(req, res) { + req.resume(); + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('Hello World\n'); +} + +const http = require('http'); +const todo = 500; +let done = 0; +let count = 0; +let countGC = 0; + +console.log(`We should do ${todo} requests`); + +const server = http.createServer(serverHandler); +server.listen(0, common.mustCall(() => { + for (let i = 0; i < 10; i++) + getall(); +})); + +function getall() { + if (count >= todo) + return; + + const req = http.get({ + hostname: 'localhost', + pathname: '/', + port: server.address().port + }, cb).on('error', onerror); + + count++; + onGC(req, { ongc }); + + setImmediate(getall); +} + +function cb(res) { + res.resume(); + done += 1; +} + +function onerror(err) { + throw err; +} + +function ongc() { + countGC++; +} + +setInterval(status, 100).unref(); + +function status() { + global.gc(); + console.log('Done: %d/%d', done, todo); + console.log('Collected: %d/%d', countGC, count); + if (countGC === todo) server.close(); +} |