Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: extended timeout interval for OS operations #1306

Merged
merged 1 commit into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/tap/dateFileAppender-test.js
Expand Up @@ -8,6 +8,8 @@ const format = require('date-format');
const sandbox = require('@log4js-node/sandboxed-module');
const log4js = require('../../lib/log4js');

const osDelay = process.platform === 'win32' ? 400 : 200;

function removeFile(filename) {
try {
fs.unlinkSync(path.join(__dirname, filename));
Expand Down Expand Up @@ -40,7 +42,7 @@ test('../../lib/appenders/dateFile', (batch) => {
);
t.end();
});
}, 100);
}, osDelay);
});

batch.test('configure with dateFileAppender', (t) => {
Expand Down
8 changes: 5 additions & 3 deletions test/tap/file-descriptor-leak-test.js
Expand Up @@ -3,6 +3,8 @@ const fs = require('fs');
const path = require('path');
const log4js = require('../../lib/log4js');

const osDelay = process.platform === 'win32' ? 400 : 200;

const removeFiles = async (filenames) => {
if (!Array.isArray(filenames)) filenames = [filenames];
const promises = filenames.map((filename) => fs.promises.unlink(filename));
Expand Down Expand Up @@ -46,7 +48,7 @@ if (process.platform !== 'win32') {
`file descriptor count should increase by ${numOfAppenders} after 1st configure() call`
);
t.end();
}, 250);
}, osDelay);
}
);

Expand All @@ -65,7 +67,7 @@ if (process.platform !== 'win32') {
`file descriptor count should be identical after repeated configure() calls`
);
t.end();
}, 250);
}, osDelay);
}
);

Expand All @@ -82,7 +84,7 @@ if (process.platform !== 'win32') {
`file descriptor count should be back to initial`
);
t.end();
}, 250);
}, osDelay);
}
);

Expand Down
4 changes: 3 additions & 1 deletion test/tap/file-sighup-test.js
Expand Up @@ -3,6 +3,8 @@ const path = require('path');
const fs = require('fs');
const sandbox = require('@log4js-node/sandboxed-module');

const osDelay = process.platform === 'win32' ? 400 : 200;

const removeFiles = async (filenames) => {
if (!Array.isArray(filenames)) filenames = [filenames];
const promises = filenames.map((filename) => fs.promises.unlink(filename));
Expand Down Expand Up @@ -129,7 +131,7 @@ test('file appender SIGHUP', (t) => {
t.equal(openCalled, 2, 'open should be called twice');
t.equal(closeCalled, 1, 'close should be called once');
t.end();
}, 100);
}, osDelay);
});

test('file appender SIGHUP handler leak', (t) => {
Expand Down
14 changes: 8 additions & 6 deletions test/tap/fileAppender-test.js
Expand Up @@ -7,6 +7,8 @@ const sandbox = require('@log4js-node/sandboxed-module');
const zlib = require('zlib');
const util = require('util');

const osDelay = process.platform === 'win32' ? 400 : 200;

const sleep = util.promisify(setTimeout);
const gunzip = util.promisify(zlib.gunzip);
const EOL = require('os').EOL || '\n';
Expand Down Expand Up @@ -40,7 +42,7 @@ test('log4js fileAppender', (batch) => {

logger.info('This should be in the file.');

await sleep(250);
await sleep(osDelay);
const fileContents = await fs.readFile(testFile, 'utf8');
t.match(fileContents, `This should be in the file.${EOL}`);
t.match(
Expand Down Expand Up @@ -151,7 +153,7 @@ test('log4js fileAppender', (batch) => {
logger.info('This is an intermediate log message.');
logger.info('This is the second log message.');
// wait for the file system to catch up
await sleep(250);
await sleep(osDelay * 2);
const fileContents = await fs.readFile(testFile, 'utf8');
t.match(fileContents, 'This is the second log message.');
t.equal(fileContents.indexOf('This is the first log message.'), -1);
Expand Down Expand Up @@ -219,7 +221,7 @@ test('log4js fileAppender', (batch) => {
logger.info('This is the second log message.');

// wait for the file system to catch up
await sleep(250);
await sleep(osDelay);
const fileContents = await fs.readFile(testFile, 'utf8');
t.match(fileContents, 'This is the second log message.');
t.notMatch(fileContents, 'These are the log messages for the first file.');
Expand Down Expand Up @@ -272,7 +274,7 @@ test('log4js fileAppender', (batch) => {
logger.info('This is the third log message.');
logger.info('This is the fourth log message.');
// give the system a chance to open the stream
await sleep(250);
await sleep(osDelay);
const files = await fs.readdir(__dirname);
const logFiles = files
.sort()
Expand Down Expand Up @@ -334,7 +336,7 @@ test('log4js fileAppender', (batch) => {
logger.info('This is the third log message.');
logger.info('This is the fourth log message.');
// give the system a chance to open the stream
await sleep(250);
await sleep(osDelay);
const files = await fs.readdir(__dirname);
const logFiles = files
.sort()
Expand Down Expand Up @@ -503,7 +505,7 @@ test('log4js fileAppender', (batch) => {
[]
);

await sleep(250);
await sleep(osDelay);
let fileContents = await fs.readFile(testFilePlain, 'utf8');
t.match(
fileContents,
Expand Down
4 changes: 3 additions & 1 deletion test/tap/logLevelFilter-test.js
Expand Up @@ -4,6 +4,8 @@ const os = require('os');

const EOL = os.EOL || '\n';

const osDelay = process.platform === 'win32' ? 400 : 200;

function remove(filename) {
try {
fs.unlinkSync(filename);
Expand Down Expand Up @@ -155,7 +157,7 @@ test('log4js logLevelFilter', (batch) => {
}
);
t.end();
}, 500);
}, osDelay);
});

batch.end();
Expand Down
2 changes: 1 addition & 1 deletion test/tap/multi-file-appender-test.js
Expand Up @@ -226,7 +226,7 @@ test('multiFile appender', (batch) => {
debug.enable(originalNamespace);
});

const timeoutMs = 100;
const timeoutMs = 200;
log4js.configure({
appenders: {
multi: {
Expand Down