Skip to content

Commit

Permalink
chore: test tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jun 4, 2023
1 parent aff600b commit 578b1fd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export class OPCUACertificateManager extends CertificateManager implements ICert

const location = options.rootFolder || paths.config;
if (!fs.existsSync(location)) {
mkdirp.sync(location);
try {
mkdirp.sync(location);
} catch (err) {
console.log(" cannot create folder ", location , fs.existsSync(location));
}
}

const _options: CertificateManagerOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
/* */
this._handleDisconnectionWhileConnecting(err, callback);
} else {
console.log("REMOVE ME", err.stack);
err = new Error("The connection may have been rejected by server,\n" + "Err = (" + err.message + ")");
this._handleUnrecoverableConnectionFailure(err, callback);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/node-opcua-date-time/test/test_clock_performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ describe("testing clock getCurrentClock", function () {
for (let i = 1; i < 10000; i++) {
const d = new Date();
const c = getCurrentClock();
// let's allow for a 20 millisecond drift max
(c.timestamp.getTime() + 20).should.be.greaterThanOrEqual(d.getTime());
// let's allow for a 100 millisecond drift max
// (this could happen in some containerize environment)
(c.timestamp.getTime() + 100).should.be.greaterThanOrEqual(d.getTime());
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"use strict";
import { Socket } from "net";
import * as fs from "fs";
import * as os from "os";
import should from "should";
import * as async from "async";
import {
Expand All @@ -23,6 +24,7 @@ import {
ConnectionStrategyOptions
} from "node-opcua";
import chalk from "chalk";
import "mocha";

import { readCertificate } from "node-opcua-crypto";

Expand Down Expand Up @@ -168,15 +170,15 @@ describe("KJH1 testing basic Client-Server communication", function (this: Mocha
(client as any).protocolVersion = 0;

const unused_port = 8909;
const bad_endpointUrl = "opc.tcp://" + "localhost" + ":" + unused_port;
const bad_endpointUrl = "opc.tcp://" + os.hostname()+ ":" + unused_port;

let _err: Error | undefined = undefined;
try {
await client.connect(bad_endpointUrl);
} catch (err) {
_err = err as Error;
}
_err!.message.should.match(/connect ECONNREFUSED/);
_err!.message.should.match(/connect ECONNREFUSED|The connection may have been rejected by server/);

await client.connect(endpointUrl);
await client.disconnect();
Expand Down Expand Up @@ -1014,7 +1016,7 @@ describe("KJH2 testing ability for client to reconnect when server close connect
// the client with indefinitely try to connect, causing the callback function
// passed to the client#connect method not to be called.
let connect_done = false;
let connect_err = null;
let connect_err: Error | undefined = undefined;
(async () => {
client.connect(endpointUrl, function (err) {
connect_err = err;
Expand Down

0 comments on commit 578b1fd

Please sign in to comment.