speed up more unit tests (#149712) (#155576)

* undo change to split up tests

* faster node.js disk i/o tests

* skip slow one
This commit is contained in:
Benjamin Pasero 2022-07-19 14:17:20 +02:00 committed by GitHub
parent 54694499a0
commit aba7e6c58b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 126 deletions

View file

@ -21,18 +21,13 @@ flakySuite('PFS', function () {
let testDir: string;
setup(() => {
configureFlushOnWrite(true); // but enable flushing for the purpose of these tests
testDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs');
return Promises.mkdir(testDir, { recursive: true });
});
teardown(async () => {
try {
await Promises.rm(testDir);
} finally {
configureFlushOnWrite(false);
}
teardown(() => {
return Promises.rm(testDir);
});
test('writeFile', async () => {
@ -375,24 +370,36 @@ flakySuite('PFS', function () {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
return testWriteFileAndFlush(smallData, smallData, bigData, bigData);
return testWriteFile(smallData, smallData, bigData, bigData);
});
test('writeFile (string) - flush on write', async () => {
configureFlushOnWrite(true);
try {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
return await testWriteFile(smallData, smallData, bigData, bigData);
} finally {
configureFlushOnWrite(false);
}
});
test('writeFile (Buffer)', async () => {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
return testWriteFileAndFlush(Buffer.from(smallData), smallData, Buffer.from(bigData), bigData);
return testWriteFile(Buffer.from(smallData), smallData, Buffer.from(bigData), bigData);
});
test('writeFile (UInt8Array)', async () => {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
return testWriteFileAndFlush(VSBuffer.fromString(smallData).buffer, smallData, VSBuffer.fromString(bigData).buffer, bigData);
return testWriteFile(VSBuffer.fromString(smallData).buffer, smallData, VSBuffer.fromString(bigData).buffer, bigData);
});
async function testWriteFileAndFlush(
async function testWriteFile(
smallData: string | Buffer | Uint8Array,
smallDataValue: string,
bigData: string | Buffer | Uint8Array,

View file

@ -140,16 +140,13 @@ flakySuite('BackupMainService', () => {
return pfs.Promises.rm(testDir);
});
test('service validates backup workspaces on startup and cleans up (folder workspaces) (1)', async function () {
test('service validates backup workspaces on startup and cleans up (folder workspaces)', async function () {
// 1) backup workspace path does not exist
service.registerFolderBackupSync(toFolderBackupInfo(fooFile));
service.registerFolderBackupSync(toFolderBackupInfo(barFile));
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('service validates backup workspaces on startup and cleans up (folder workspaces) (2)', async function () {
// 2) backup workspace path exists with empty contents within
fs.mkdirSync(service.toBackupPath(fooFile));
@ -160,9 +157,6 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
});
test('service validates backup workspaces on startup and cleans up (folder workspaces) (3)', async function () {
// 3) backup workspace path exists with empty folders within
fs.mkdirSync(service.toBackupPath(fooFile));
@ -175,9 +169,6 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
});
test('service validates backup workspaces on startup and cleans up (folder workspaces) (4)', async function () {
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
@ -194,16 +185,13 @@ flakySuite('BackupMainService', () => {
assert.strictEqual(service.getEmptyWindowBackupPaths().length, 1);
});
test('service validates backup workspaces on startup and cleans up (root workspaces) (1)', async function () {
test('service validates backup workspaces on startup and cleans up (root workspaces)', async function () {
// 1) backup workspace path does not exist
service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath));
service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(barFile.fsPath));
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('service validates backup workspaces on startup and cleans up (root workspaces) (2)', async function () {
// 2) backup workspace path exists with empty contents within
fs.mkdirSync(service.toBackupPath(fooFile));
@ -214,9 +202,6 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
});
test('service validates backup workspaces on startup and cleans up (root workspaces) (3)', async function () {
// 3) backup workspace path exists with empty folders within
fs.mkdirSync(service.toBackupPath(fooFile));
@ -229,9 +214,6 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
});
test('service validates backup workspaces on startup and cleans up (root workspaces) (4)', async function () {
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
@ -291,19 +273,13 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
@ -315,37 +291,22 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (1)', async () => {
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": ["bar"]}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": []}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": "bar"}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":"foo"}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":1}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
@ -372,19 +333,13 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
@ -396,73 +351,43 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (1)', async () => {
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (1)', async () => {
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
@ -482,19 +407,13 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
@ -506,37 +425,22 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (1)', async function () {
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (2)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (3)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (4)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (5)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (6)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);

View file

@ -142,8 +142,6 @@ flakySuite('Disk File Service', function () {
const disposables = new DisposableStore();
setup(async () => {
DiskFileSystemProvider.configureFlushOnWrite(true); // but enable flushing for the purpose of these tests
const logService = new NullLogService();
service = new FileService(logService);
@ -164,14 +162,10 @@ flakySuite('Disk File Service', function () {
await Promises.copy(sourceDir, testDir, { preserveSymlinks: false });
});
teardown(async () => {
try {
disposables.clear();
teardown(() => {
disposables.clear();
await Promises.rm(testDir);
} finally {
DiskFileSystemProvider.configureFlushOnWrite(false);
}
return Promises.rm(testDir);
});
test('createFolder', async () => {
@ -1802,6 +1796,15 @@ flakySuite('Disk File Service', function () {
return testWriteFile();
});
test('writeFile - flush on write', async () => {
DiskFileSystemProvider.configureFlushOnWrite(true);
try {
return await testWriteFile();
} finally {
DiskFileSystemProvider.configureFlushOnWrite(false);
}
});
test('writeFile - buffered', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);

View file

@ -89,7 +89,7 @@ flakySuite('StorageService (browser specific)', () => {
disposables.clear();
});
test('clear', () => {
test.skip('clear', () => { // slow test and also only ever being used as a developer action
return runWithFakedTimers({ useFakeTimers: true }, async () => {
storageService.store('bar', 'foo', StorageScope.APPLICATION, StorageTarget.MACHINE);
storageService.store('bar', 3, StorageScope.APPLICATION, StorageTarget.USER);