[bug] Add storage test with tenant; Fix bug 68563

This commit is contained in:
Sergey Konovalov
2024-06-11 19:18:00 +03:00
parent 96a5d76fb7
commit bf8ff4daa8
3 changed files with 30 additions and 7 deletions

View File

@ -16,6 +16,7 @@ jest.mock("fs/promises", () => ({
const { cp } = require('fs/promises');
const operationContext = require('../../../Common/sources/operationContext');
const tenantManager = require('../../../Common/sources/tenantManager');
const storage = require('../../../Common/sources/storage-base');
const utils = require('../../../Common/sources/utils');
const commonDefines = require("../../../Common/sources/commondefines");
@ -52,8 +53,12 @@ function request(url) {
});
});
}
function runTestForDir(specialDir) {
function runTestForDir(ctx, isMultitenantMode, specialDir) {
let oldMultitenantMode = tenantManager.isMultitenantMode();
test("start listObjects", async () => {
//todo set in all tests do not rely on test order
tenantManager.setMultitenantMode(isMultitenantMode);
let list = await storage.listObjects(ctx, testDir, specialDir);
expect(list).toEqual([]);
});
@ -213,20 +218,32 @@ function runTestForDir(specialDir) {
list = await storage.listObjects(ctx, testDir, specialDir);
expect(list.sort()).toEqual([].sort());
tenantManager.setMultitenantMode(oldMultitenantMode);
});
}
// Assumed, that server is already up.
describe('storage common dir', function () {
runTestForDir(specialDirCache);
runTestForDir(ctx, false, specialDirCache);
});
describe('storage forgotten dir', function () {
runTestForDir(specialDirForgotten);
runTestForDir(ctx, false, specialDirForgotten);
});
describe('storage common dir with tenants', function () {
runTestForDir(ctx, true, specialDirCache);
});
describe('storage forgotten dir with tenants', function () {
runTestForDir(ctx, true, specialDirForgotten);
});
describe('storage mix common and forgotten dir', function () {
test("putObject", async () => {
tenantManager.setMultitenantMode(false);
let buffer = Buffer.from(testFileData1);
let res = await storage.putObject(ctx, testFile1, buffer, buffer.length, specialDirCache);
expect(res).toEqual(undefined);