Skip to content

Commit

Permalink
test: fix the termination timeout during in terminate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 14, 2024
1 parent 4459339 commit 3d54dba
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
docker: node:18-alpine
docker_cmd:
apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake
musl-dev && npm i -g pnpm && pnpm install && pnpm run build.prebuild
musl-dev && npm i -g pnpm && pnpm install && pnpm run
build.prebuild
node_version: 18
node_arch: x64
ARCH: x64
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
"build": "run-s build.js build.native",
"build.debug": "run-s build.js build.native.debug",
"test.deps": "cd test && pnpm install && cd ..",
"test": "run-s clean.temp test.deps build && mocha --exit",
"test.skip_gc_tests": "run-s clean.temp test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
"test": "run-s clean.temp test.deps build && mocha",
"test.skip_gc_tests": "run-s clean.temp test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha",
"test.electron.main": "run-s clean.temp test.deps build && electron-mocha",
"format": "prettier --write .",
"test.electron.renderer": "run-s build && electron-mocha --renderer",
Expand Down
2 changes: 1 addition & 1 deletion script/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"moduleResolution": "node"
},
"include": ["./**/*.mts"],
"exclude": []
Expand Down
12 changes: 7 additions & 5 deletions test/unit/proxy-router-dealer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import {testProtos, uniqAddress} from "./helpers"

for (const proto of testProtos("tcp", "ipc", "inproc")) {
describe(`proxy with ${proto} router/dealer`, function () {
/* ZMQ < 4.0.5 has no steerable proxy support. */
if (semver.satisfies(zmq.version, "< 4.0.5")) {
return
}

let proxy: zmq.Proxy

let frontAddress: string
Expand All @@ -15,11 +20,6 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
let rep: zmq.Reply

beforeEach(async function () {
/* ZMQ < 4.0.5 has no steerable proxy support. */
if (semver.satisfies(zmq.version, "< 4.0.5")) {
this.skip()
}

proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer())

frontAddress = uniqAddress(proto)
Expand Down Expand Up @@ -89,6 +89,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
rep.close()
}

console.log("waiting for messages")

await Promise.all([echo(), send()])
assert.deepEqual(received, messages)

Expand Down
19 changes: 10 additions & 9 deletions test/unit/proxy-terminate-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {isFullError} from "../../src/errors"

for (const proto of testProtos("tcp", "ipc", "inproc")) {
describe(`proxy with ${proto} terminate`, function () {
/* ZMQ < 4.0.5 has no steerable proxy support. */
if (semver.satisfies(zmq.version, "< 4.0.5")) {
return
}

let proxy: zmq.Proxy

beforeEach(async function () {
/* ZMQ < 4.0.5 has no steerable proxy support. */
if (semver.satisfies(zmq.version, "< 4.0.5")) {
this.skip()
}

proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer())
})

Expand All @@ -28,12 +28,13 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
await proxy.frontEnd.bind(uniqAddress(proto))
await proxy.backEnd.bind(uniqAddress(proto))

try {
const timer = setTimeout(() => proxy.terminate(), 50)
await proxy.run()
const sleep_ms = 50

setTimeout(() => proxy.terminate(), sleep_ms)
await proxy.run()

try {
await proxy.terminate()
timer.unref()
assert.ok(false)
} catch (err) {
if (!isFullError(err)) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/typings-compatibility-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
readFile,
writeFile,
} from "fs-extra"
import * as which from "which"
import which from "which"

import {assert} from "chai"

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"noUnusedParameters": false,
"incremental": true,
"sourceMap": true,
"esModuleInterop": true,
"lib": ["ES2020", "dom"]
}
}

0 comments on commit 3d54dba

Please sign in to comment.