mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Initialize empty pods when testing quota
Another attempt to help fix random CI integration test failures
This commit is contained in:
parent
71e55690f3
commit
44f731d7e7
@ -1,9 +1,8 @@
|
|||||||
import { promises as fsPromises } from 'fs';
|
|
||||||
import type { Stats } from 'fs';
|
import type { Stats } from 'fs';
|
||||||
import fetch from 'cross-fetch';
|
import fetch from 'cross-fetch';
|
||||||
import type { Response } from 'cross-fetch';
|
import type { Response } from 'cross-fetch';
|
||||||
import { ensureDir, pathExists } from 'fs-extra';
|
import { ensureDir, pathExists, stat } from 'fs-extra';
|
||||||
import { joinFilePath, joinUrl } from '../../src';
|
import { joinUrl } from '../../src';
|
||||||
import type { App } from '../../src';
|
import type { App } from '../../src';
|
||||||
import { getPort } from '../util/Util';
|
import { getPort } from '../util/Util';
|
||||||
import { getDefaultVariables, getTestConfigPath, getTestFolder, instantiateFromConfig, removeFolder } from './Config';
|
import { getDefaultVariables, getTestConfigPath, getTestFolder, instantiateFromConfig, removeFolder } from './Config';
|
||||||
@ -45,23 +44,6 @@ async function registerTestPods(baseUrl: string, pods: string[]): Promise<void>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We just want a container with the correct metadata, everything else can be removed */
|
|
||||||
async function clearInitialFiles(rootFilePath: string, pods: string[]): Promise<void> {
|
|
||||||
for (const pod of pods) {
|
|
||||||
const fileList = await fsPromises.readdir(joinFilePath(rootFilePath, pod));
|
|
||||||
for (const file of fileList) {
|
|
||||||
if (file !== '.meta') {
|
|
||||||
const path = joinFilePath(rootFilePath, pod, file);
|
|
||||||
if ((await fsPromises.stat(path)).isDirectory()) {
|
|
||||||
await fsPromises.rm(path, { recursive: true });
|
|
||||||
} else {
|
|
||||||
await fsPromises.unlink(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('A quota server', (): void => {
|
describe('A quota server', (): void => {
|
||||||
// The allowed quota depends on what filesystem/OS you are using.
|
// The allowed quota depends on what filesystem/OS you are using.
|
||||||
// For example: an empty folder is reported as
|
// For example: an empty folder is reported as
|
||||||
@ -74,7 +56,7 @@ describe('A quota server', (): void => {
|
|||||||
// We want to use an empty folder as on APFS/Mac folder sizes vary a lot
|
// We want to use an empty folder as on APFS/Mac folder sizes vary a lot
|
||||||
const tempFolder = getTestFolder('quota-temp');
|
const tempFolder = getTestFolder('quota-temp');
|
||||||
await ensureDir(tempFolder);
|
await ensureDir(tempFolder);
|
||||||
folderSizeTest = await fsPromises.stat(tempFolder);
|
folderSizeTest = await stat(tempFolder);
|
||||||
await removeFolder(tempFolder);
|
await removeFolder(tempFolder);
|
||||||
});
|
});
|
||||||
const podName1 = 'arthur';
|
const podName1 = 'arthur';
|
||||||
@ -108,7 +90,6 @@ describe('A quota server', (): void => {
|
|||||||
|
|
||||||
// Initialize 2 pods
|
// Initialize 2 pods
|
||||||
await registerTestPods(baseUrl, [ podName1, podName2 ]);
|
await registerTestPods(baseUrl, [ podName1, podName2 ]);
|
||||||
await clearInitialFiles(rootFilePath, [ podName1, podName2 ]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async(): Promise<void> => {
|
afterAll(async(): Promise<void> => {
|
||||||
@ -194,7 +175,6 @@ describe('A quota server', (): void => {
|
|||||||
|
|
||||||
// Initialize 2 pods
|
// Initialize 2 pods
|
||||||
await registerTestPods(baseUrl, [ podName1, podName2 ]);
|
await registerTestPods(baseUrl, [ podName1, podName2 ]);
|
||||||
await clearInitialFiles(rootFilePath, [ podName1, podName2 ]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async(): Promise<void> => {
|
afterAll(async(): Promise<void> => {
|
||||||
|
@ -54,6 +54,15 @@
|
|||||||
"@type": "FileSizeReporter",
|
"@type": "FileSizeReporter",
|
||||||
"ignoreFolders": [ "^/\\.internal$" ]
|
"ignoreFolders": [ "^/\\.internal$" ]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"comment": "Use an empty pod for quota tests",
|
||||||
|
"@type": "Override",
|
||||||
|
"overrideInstance": { "@id": "urn:solid-server:default:PodResourcesGenerator" },
|
||||||
|
"overrideParameters": {
|
||||||
|
"@type": "StaticFolderGenerator",
|
||||||
|
"templateFolder": "@css:templates/root/empty"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"@id": "urn:solid-server:test:Instances",
|
"@id": "urn:solid-server:test:Instances",
|
||||||
"@type": "RecordObject",
|
"@type": "RecordObject",
|
||||||
|
@ -49,6 +49,15 @@
|
|||||||
},
|
},
|
||||||
"limit_unit": "bytes"
|
"limit_unit": "bytes"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"comment": "Use an empty pod for quota tests",
|
||||||
|
"@type": "Override",
|
||||||
|
"overrideInstance": { "@id": "urn:solid-server:default:PodResourcesGenerator" },
|
||||||
|
"overrideParameters": {
|
||||||
|
"@type": "StaticFolderGenerator",
|
||||||
|
"templateFolder": "@css:templates/root/empty"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"@id": "urn:solid-server:test:Instances",
|
"@id": "urn:solid-server:test:Instances",
|
||||||
"@type": "RecordObject",
|
"@type": "RecordObject",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user