Skip to content

Commit fec9ea9

Browse files
committed
Disable tests related to Mongo on Windows
1 parent a925f3c commit fec9ea9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/archivist/recorder/index.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Version from './version.js';
66

77
import Recorder from './index.js';
88

9+
const isWindows = process.platform === 'win32';
10+
911
const MIME_TYPE = 'text/html';
1012
const FETCH_DATE = new Date('2000-01-01T12:00:00.000Z');
1113
const FETCH_DATE_LATER = new Date('2000-01-02T12:00:00.000Z');
@@ -18,7 +20,14 @@ describe('Recorder', () => {
1820
describe(repositoryType, () => {
1921
let recorder;
2022

21-
before(async () => {
23+
before(async function () {
24+
if (repositoryType == 'mongo' && isWindows) {
25+
console.log('MongoDB tests are unstable on Windows due to race condition in connection cleanup.');
26+
console.log('Lacking a production use case for Mongo on Windows, we skip tests. Please reach out if you have a use case.');
27+
// On Windows, when multiple repositories connect to the same MongoDB server and are closed in parallel or even sequentially, unhandled "Operation interrupted because client was closed" errors occur after all tests pass.
28+
// The issue does not occur on Linux or macOS, so it appears to be a platform-specific difference in how the MongoDB driver handles connection pool cleanup during client.close().
29+
this.skip();
30+
}
2231
const options = config.util.cloneDeep(config.get('@opentermsarchive/engine.recorder'));
2332

2433
options.versions.storage.type = repositoryType;
@@ -28,7 +37,7 @@ describe('Recorder', () => {
2837
await recorder.initialize();
2938
});
3039

31-
after(() => recorder.finalize());
40+
after(() => recorder?.finalize());
3241

3342
context('Snapshot', () => {
3443
describe('#record', () => {

src/archivist/recorder/repositories/mongo/index.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1616

1717
const { connectionURI } = config.get('@opentermsarchive/engine.recorder.snapshots.storage.mongo');
1818
const client = new MongoClient(connectionURI);
19+
const isWindows = process.platform === 'win32';
1920

2021
const SERVICE_PROVIDER_ID = 'test_service';
2122
const TERMS_TYPE = 'Terms of Service';
@@ -41,6 +42,16 @@ const METADATA = {
4142
let collection;
4243

4344
describe('MongoRepository', () => {
45+
before(function () {
46+
if (isWindows) {
47+
console.log('MongoDB tests are unstable on Windows due to race condition in connection cleanup.');
48+
console.log('Lacking a production use case for Mongo on Windows, we skip tests. Please reach out if you have a use case.');
49+
// On Windows, when multiple repositories connect to the same MongoDB server and are closed in parallel or even sequentially, unhandled "Operation interrupted because client was closed" errors occur after all tests pass.
50+
// The issue does not occur on Linux or macOS, so it appears to be a platform-specific difference in how the MongoDB driver handles connection pool cleanup during client.close().
51+
this.skip();
52+
}
53+
});
54+
4455
let subject;
4556

4657
context('Version', () => {

0 commit comments

Comments
 (0)