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

refactor(core): Generalize binary data manager interface (no-changelog) #7164

Merged
merged 115 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
29f1d11
refactor(core): Simplify executions and binary data pruning
netroy Aug 31, 2023
f7206fd
Merge branch 'master' into pay-771-implement-soft-deletion
ivov Sep 4, 2023
9c8efbc
Merge branch 'master' into pay-771-implement-soft-deletion
ivov Sep 5, 2023
05e3fef
Remove test code from service
ivov Sep 5, 2023
9dabbe8
Use time constants
ivov Sep 5, 2023
3f7de8e
Improve naming
ivov Sep 5, 2023
5583814
Use native typeorm soft deletion
ivov Sep 5, 2023
f50108a
Improve naming
ivov Sep 5, 2023
85ac53a
Make batch size class field
ivov Sep 5, 2023
1d87e9e
Cleanup
ivov Sep 5, 2023
dd16e45
Remove unused method
ivov Sep 5, 2023
619bff6
Cleanup
ivov Sep 5, 2023
8cace11
Filter out soft-deleted executions
ivov Sep 5, 2023
1fea046
Merge branch 'master' into pay-771-implement-soft-deletion
ivov Sep 5, 2023
c4ffe6d
Add tests
ivov Sep 5, 2023
738eb1b
Improve test
ivov Sep 6, 2023
259fe75
Soft-delete in single pass
ivov Sep 13, 2023
f3f5b27
Restore value
ivov Sep 13, 2023
65d17cb
Restore from debug value
ivov Sep 13, 2023
96ae7b4
Add clarifying comments
ivov Sep 13, 2023
21040b5
Update tests
ivov Sep 13, 2023
aa4d633
Add `typedi` to core
ivov Sep 13, 2023
e54becb
Update package.json
ivov Sep 13, 2023
80e7258
Turn `BinaryDataManager` into service
ivov Sep 13, 2023
3a8960f
Add `object` to binary data schema options
ivov Sep 13, 2023
64b1a96
Use service throughout core and cli
ivov Sep 13, 2023
f974b55
Update tests
ivov Sep 13, 2023
36d0243
Reduce diff
ivov Sep 13, 2023
5e209e9
Update default
ivov Sep 13, 2023
0c3a6aa
Add docline
ivov Sep 13, 2023
3d4beba
Remove redundant output types
ivov Sep 13, 2023
1bf7a3d
Remove unused type
ivov Sep 13, 2023
1152092
Rename to submanagers to client
ivov Sep 13, 2023
5627b4c
Rename `BinaryDataFileSystem` to `FileSystemClient`
ivov Sep 13, 2023
6451750
Clean up types
ivov Sep 13, 2023
7a7ad54
Move `binaryToBuffer` to manager
ivov Sep 13, 2023
cdfe2fc
Rename `BinaryDataManager` to `BinaryDataService`
ivov Sep 13, 2023
b5bc390
Unify storage path naming
ivov Sep 13, 2023
c876697
Set binary data service in nodes-base test helper
ivov Sep 13, 2023
25a796c
Rename manager in nodes-base
ivov Sep 13, 2023
538d318
More renamings
ivov Sep 13, 2023
c7cf4b1
Generalize interface
ivov Sep 13, 2023
307bb1b
Continue generalizing
ivov Sep 13, 2023
a2528d7
Fix test
ivov Sep 13, 2023
d0cd85e
Better naming
ivov Sep 13, 2023
bfdbdf5
More renamings
ivov Sep 13, 2023
25e80b9
Minor cleanup
ivov Sep 13, 2023
3476f6c
More minor cleanup
ivov Sep 13, 2023
9a25301
Add clarifying comment
ivov Sep 13, 2023
0e075c2
Speed up pruning if high volume
ivov Sep 14, 2023
e8ccf05
Merge branch 'master' into pay-771-implement-soft-deletion
ivov Sep 14, 2023
2071c7f
Remove call from hook
ivov Sep 14, 2023
be44721
Merge parent branch
ivov Sep 14, 2023
1d50b61
Refix conflict
ivov Sep 14, 2023
e042e91
Add formats to schema
ivov Sep 14, 2023
e948f8f
Add `ensureStringArray` util
ivov Sep 14, 2023
0feb926
Adjust types based on parsing
ivov Sep 14, 2023
c73f18c
Add type guard
ivov Sep 14, 2023
f8fec92
Clean up types in `init()`
ivov Sep 14, 2023
93ea57c
Fix test
ivov Sep 14, 2023
c8676be
Remove unneeded modifier
ivov Sep 14, 2023
25006e8
Cleanup
ivov Sep 14, 2023
a7156f8
Fix node tests
ivov Sep 14, 2023
e0e90b6
Remove unneeded line
ivov Sep 14, 2023
219addb
Rename constant
ivov Sep 14, 2023
d7c7f5f
Remove comment
ivov Sep 14, 2023
1ea380d
Fix tests
ivov Sep 14, 2023
a5b388b
Cleanup
ivov Sep 14, 2023
9204754
Rename error
ivov Sep 14, 2023
9597508
Improve error message
ivov Sep 14, 2023
8fde8be
Better error
ivov Sep 14, 2023
ada012e
Better message
ivov Sep 14, 2023
67e163f
Make execution ID non-nullable
ivov Sep 15, 2023
9665da1
Merge master
ivov Sep 15, 2023
12636dd
Readability improvements
ivov Sep 15, 2023
e5c8c72
Adjust types, followup to 67e163f
ivov Sep 15, 2023
8849007
Merge parent branch
ivov Sep 15, 2023
b7062e5
Fix lint
ivov Sep 15, 2023
79ecaa9
Fix lint
ivov Sep 15, 2023
02b6d86
Cleanup
ivov Sep 18, 2023
96ea9ea
Comment out cache keys
ivov Sep 18, 2023
3d76b21
Revert "Comment out cache keys"
ivov Sep 18, 2023
455c327
Rename dir to `TempBinaryData`
ivov Sep 18, 2023
65b4fb0
Rename back to `BinaryData`
ivov Sep 18, 2023
3bf3430
Merge master
ivov Sep 18, 2023
abe6d9d
Clear timers on shutdown
ivov Sep 18, 2023
2682b3d
Set timers only on main instance
ivov Sep 18, 2023
1c788fe
Also for clearing timers
ivov Sep 18, 2023
f248982
Merge parent branch
ivov Sep 18, 2023
04f4b83
Rename back to `localStoragePath`
ivov Sep 18, 2023
03264f9
Remove unused arg
ivov Sep 18, 2023
a6e33d4
Fix lint
ivov Sep 18, 2023
8823554
Add logging, refactor for readability
ivov Sep 19, 2023
a5def40
Ensure hard-deletion select includes soft-deleted rows
ivov Sep 19, 2023
77955e4
Switch `info` to `debug`
ivov Sep 19, 2023
b930e3e
Fix tests
ivov Sep 19, 2023
e91f3de
Remove redundant checks for `deletedAt` being `NULL`
ivov Sep 19, 2023
2c3704d
Fix lint
ivov Sep 19, 2023
215f58e
Fix last test
ivov Sep 19, 2023
c33d164
More missing loggers in tests
ivov Sep 19, 2023
69764f7
Add logger to even more test
ivov Sep 19, 2023
7c3e58d
Refactor logging for tests
ivov Sep 19, 2023
6fe79b8
Merge parent branch
ivov Sep 19, 2023
4f025b2
Merge master, fix conflicts
ivov Sep 20, 2023
80a4fc5
Fix misresolved conflict
ivov Sep 20, 2023
20d5ea7
Remove excess check on init
ivov Sep 20, 2023
0f84eb6
Remove `ObjectStore.manager.ts` stub
ivov Sep 21, 2023
605d02b
Revert rename to `BinaryDataManager`
ivov Sep 21, 2023
c430f22
Missing renaming in test
ivov Sep 21, 2023
0cdfb79
Rename constant
ivov Sep 22, 2023
08ce3f7
Merge master
ivov Sep 22, 2023
61c2f5a
Restore `LogCatch`
ivov Sep 22, 2023
74adb24
Add file not found error to `getSize`
ivov Sep 22, 2023
0bc2457
Add `mode` to `InvalidBinaryDataManagerError`
ivov Sep 22, 2023
d27e4c4
Delete many by execution IDs only if manager available
ivov Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { RequestOptions } from 'oauth-1.0a';
import clientOAuth1 from 'oauth-1.0a';

import {
BinaryDataManager,
BinaryDataService,
Credentials,
LoadMappingOptions,
LoadNodeParameterOptions,
Expand Down Expand Up @@ -202,6 +202,8 @@ export class Server extends AbstractServer {

push: Push;

binaryDataService: BinaryDataService;

constructor() {
super('main');

Expand Down Expand Up @@ -358,12 +360,13 @@ export class Server extends AbstractServer {
this.endpointPresetCredentials = config.getEnv('credentials.overwrite.endpoint');

this.push = Container.get(Push);
this.binaryDataService = Container.get(BinaryDataService);

await super.start();
LoggerProxy.debug(`Server ID: ${this.uniqueInstanceId}`);

const cpus = os.cpus();
const binaryDataConfig = config.getEnv('binaryDataManager');
const binaryDataConfig = config.getEnv('binaryDataService');
const diagnosticInfo: IDiagnosticInfo = {
databaseType: config.getEnv('database.type'),
disableProductionWebhooksOnMainProcess: config.getEnv(
Expand Down Expand Up @@ -1424,13 +1427,12 @@ export class Server extends AbstractServer {
async (req: BinaryDataRequest, res: express.Response): Promise<void> => {
// TODO UM: check if this needs permission check for UM
const identifier = req.params.path;
const binaryDataManager = BinaryDataManager.getInstance();
try {
const binaryPath = binaryDataManager.getBinaryPath(identifier);
const binaryPath = this.binaryDataService.getPath(identifier);
let { mode, fileName, mimeType } = req.query;
if (!fileName || !mimeType) {
try {
const metadata = await binaryDataManager.getBinaryMetadata(identifier);
const metadata = await this.binaryDataService.getMetadata(identifier);
fileName = metadata.fileName;
mimeType = metadata.mimeType;
res.setHeader('Content-Length', metadata.fileSize);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/WebhookHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import stream from 'stream';
import { promisify } from 'util';
import formidable from 'formidable';

import { BinaryDataManager, NodeExecuteFunctions } from 'n8n-core';
import { BinaryDataService, NodeExecuteFunctions } from 'n8n-core';

import type {
IBinaryData,
Expand Down Expand Up @@ -514,7 +514,7 @@ export async function executeWebhook(
const binaryData = (response.body as IDataObject)?.binaryData as IBinaryData;
if (binaryData?.id) {
res.header(response.headers);
const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id);
const stream = Container.get(BinaryDataService).getAsStream(binaryData.id);
void pipeline(stream, res).then(() =>
responseCallback(null, { noWebhookResponse: true }),
);
Expand Down Expand Up @@ -734,7 +734,7 @@ export async function executeWebhook(
// Send the webhook response manually
res.setHeader('Content-Type', binaryData.mimeType);
if (binaryData.id) {
const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id);
const stream = Container.get(BinaryDataService).getAsStream(binaryData.id);
await pipeline(stream, res);
} else {
res.end(Buffer.from(binaryData.data, BINARY_ENCODING));
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setDefaultResultOrder('ipv4first');

import { Container } from 'typedi';
import type { IProcessMessage } from 'n8n-core';
import { BinaryDataManager, UserSettings, WorkflowExecute } from 'n8n-core';
import { BinaryDataService, UserSettings, WorkflowExecute } from 'n8n-core';

import type {
ExecutionError,
Expand Down Expand Up @@ -123,8 +123,8 @@ class WorkflowRunnerProcess {
await Container.get(PostHogClient).init(instanceId);
await Container.get(InternalHooks).init(instanceId);

const binaryDataConfig = config.getEnv('binaryDataManager');
await BinaryDataManager.init(binaryDataConfig);
const binaryDataConfig = config.getEnv('binaryDataService');
await Container.get(BinaryDataService).init(binaryDataConfig);

const license = Container.get(License);
await license.init(instanceId);
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/BaseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExitError } from '@oclif/errors';
import { Container } from 'typedi';
import { LoggerProxy, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
import type { IUserSettings } from 'n8n-core';
import { BinaryDataManager, UserSettings } from 'n8n-core';
import { BinaryDataService, UserSettings } from 'n8n-core';
import type { AbstractServer } from '@/AbstractServer';
import { getLogger } from '@/Logger';
import config from '@/config';
Expand Down Expand Up @@ -103,9 +103,9 @@ export abstract class BaseCommand extends Command {
process.exit(1);
}

async initBinaryManager() {
const binaryDataConfig = config.getEnv('binaryDataManager');
await BinaryDataManager.init(binaryDataConfig, true);
async initBinaryDataService() {
const binaryDataConfig = config.getEnv('binaryDataService');
await Container.get(BinaryDataService).init(binaryDataConfig);
}

async initExternalHooks() {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Execute extends BaseCommand {

async init() {
await super.init();
await this.initBinaryManager();
await this.initBinaryDataService();
await this.initExternalHooks();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/executeBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class ExecuteBatch extends BaseCommand {

async init() {
await super.init();
await this.initBinaryManager();
await this.initBinaryDataService();
await this.initExternalHooks();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class Start extends BaseCommand {
this.activeWorkflowRunner = Container.get(ActiveWorkflowRunner);

await this.initLicense('main');
await this.initBinaryManager();
await this.initBinaryDataService();
await this.initExternalHooks();
await this.initExternalSecrets();

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Webhook extends BaseCommand {
await super.init();

await this.initLicense('webhook');
await this.initBinaryManager();
await this.initBinaryDataService();
await this.initExternalHooks();
await this.initExternalSecrets();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class Worker extends BaseCommand {
this.logger.debug('Starting n8n worker...');

await this.initLicense('worker');
await this.initBinaryManager();
await this.initBinaryDataService();
await this.initExternalHooks();
await this.initExternalSecrets();
await this.initEventBus();
Expand Down
39 changes: 16 additions & 23 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@ import path from 'path';
import convict from 'convict';
import { UserSettings } from 'n8n-core';
import { jsonParse } from 'n8n-workflow';
import { ensureStringArray } from './utils';

convict.addFormat({
name: 'nodes-list',
// @ts-ignore
validate(values: string[], { env }: { env: string }): void {
try {
if (!Array.isArray(values)) {
throw new Error();
}
name: 'json-string-array',
coerce: (rawStr: string) =>
jsonParse<string[]>(rawStr, {
errorMessage: `Expected this value "${rawStr}" to be valid JSON`,
}),
validate: ensureStringArray,
});

for (const value of values) {
if (typeof value !== 'string') {
throw new Error();
}
}
} catch (error) {
throw new TypeError(`${env} is not a valid Array of strings.`);
}
},
coerce(rawValue: string): string[] {
return jsonParse(rawValue, { errorMessage: 'nodes-list needs to be valid JSON' });
},
convict.addFormat({
name: 'comma-separated-list',
coerce: (rawStr: string) => rawStr.split(','),
validate: ensureStringArray,
});

export const schema = {
Expand Down Expand Up @@ -788,13 +781,13 @@ export const schema = {
nodes: {
include: {
doc: 'Nodes to load',
format: 'nodes-list',
format: 'json-string-array',
default: undefined,
env: 'NODES_INCLUDE',
},
exclude: {
doc: 'Nodes not to load',
format: 'nodes-list',
format: 'json-string-array',
default: undefined,
env: 'NODES_EXCLUDE',
},
Expand Down Expand Up @@ -900,9 +893,9 @@ export const schema = {
},
},

binaryDataManager: {
binaryDataService: {
availableModes: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming this is a breaking change, and should be documented in BREAKING-CHANGES.md

Copy link
Contributor Author

@ivov ivov Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted: 605d02b

Maybe in future we can bundle all changes like this together, to minimize annoyance for users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are reverting, can we revert all of the renaming, and not just the config? either that, or we don't revert and list this as a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is benefit in a temporary middle ground. Preexisting code uses "manager" for both binary data manager and its modes, so it's rather confusing and inconsistent. With this division into service and managers, the distinction is clearer, and the inconsistency is reduced to only this handful of entrypoint config spots where the renaming would cause a breaking change. So on balance the bulk of code becomes clearer.

format: String,
format: 'comma-separated-list',
default: 'filesystem',
env: 'N8N_AVAILABLE_BINARY_DATA_MODES',
doc: 'Available modes of binary data storage, as comma separated strings',
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { IBinaryDataConfig } from 'n8n-core';
import type { BinaryData } from 'n8n-core';
import type { schema } from './schema';

// -----------------------------------
Expand Down Expand Up @@ -76,7 +76,7 @@ type ToReturnType<T extends ConfigOptionPath> = T extends NumericPath

type ExceptionPaths = {
'queue.bull.redis': object;
binaryDataManager: IBinaryDataConfig;
binaryDataService: BinaryData.Config;
'nodes.exclude': string[] | undefined;
'nodes.include': string[] | undefined;
'userManagement.isInstanceOwnerSetUp': boolean;
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/config/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { SchemaObj } from 'convict';

class NotStringArrayError extends Error {
constructor(env: string) {
super(`${env} is not a string array.`);
}
}

export const ensureStringArray = (values: string[], { env }: SchemaObj<string>) => {
if (!env) throw new Error(`Missing env: ${env}`);

if (!Array.isArray(values)) throw new NotStringArrayError(env);

for (const value of values) {
if (typeof value !== 'string') throw new NotStringArrayError(env);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import { parse, stringify } from 'flatted';
import { LoggerProxy as Logger } from 'n8n-workflow';
import type { IExecutionsSummary, IRunExecutionData } from 'n8n-workflow';
import { BinaryDataManager } from 'n8n-core';
import { BinaryDataService } from 'n8n-core';
import type {
ExecutionPayload,
IExecutionBase,
Expand Down Expand Up @@ -89,6 +89,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
constructor(
dataSource: DataSource,
private readonly executionDataRepository: ExecutionDataRepository,
private readonly binaryDataService: BinaryDataService,
) {
super(ExecutionEntity, dataSource.manager);

Expand Down Expand Up @@ -520,8 +521,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
})
).map(({ id }) => id);

const binaryDataManager = BinaryDataManager.getInstance();
await binaryDataManager.deleteBinaryDataByExecutionIds(executionIds);
await this.binaryDataService.deleteManyByExecutionIds(executionIds);

this.logger.debug(`Hard-deleting ${executionIds.length} executions from database`, {
executionIds,
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/test/integration/commands/worker.cmd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LoggerProxy } from 'n8n-workflow';
import { Telemetry } from '@/telemetry';
import { getLogger } from '@/Logger';
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
import { BinaryDataManager } from 'n8n-core';
import { BinaryDataService } from 'n8n-core';
import { CacheService } from '@/services/cache.service';
import { RedisServicePubSubPublisher } from '@/services/redis/RedisServicePubSubPublisher';
import { RedisServicePubSubSubscriber } from '@/services/redis/RedisServicePubSubSubscriber';
Expand All @@ -26,7 +26,7 @@ beforeAll(async () => {
mockInstance(InternalHooks);
mockInstance(CacheService);
mockInstance(ExternalSecretsManager);
mockInstance(BinaryDataManager);
mockInstance(BinaryDataService);
mockInstance(MessageEventBus);
mockInstance(LoadNodesAndCredentials);
mockInstance(CredentialTypes);
Expand All @@ -41,7 +41,7 @@ test('worker initializes all its components', async () => {

jest.spyOn(worker, 'init');
jest.spyOn(worker, 'initLicense').mockImplementation(async () => {});
jest.spyOn(worker, 'initBinaryManager').mockImplementation(async () => {});
jest.spyOn(worker, 'initBinaryDataService').mockImplementation(async () => {});
jest.spyOn(worker, 'initExternalHooks').mockImplementation(async () => {});
jest.spyOn(worker, 'initExternalSecrets').mockImplementation(async () => {});
jest.spyOn(worker, 'initEventBus').mockImplementation(async () => {});
Expand All @@ -64,7 +64,7 @@ test('worker initializes all its components', async () => {
expect(worker.uniqueInstanceId).toContain('worker');
expect(worker.uniqueInstanceId.length).toBeGreaterThan(15);
expect(worker.initLicense).toHaveBeenCalled();
expect(worker.initBinaryManager).toHaveBeenCalled();
expect(worker.initBinaryDataService).toHaveBeenCalled();
expect(worker.initExternalHooks).toHaveBeenCalled();
expect(worker.initExternalSecrets).toHaveBeenCalled();
expect(worker.initEventBus).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/integration/publicApi/executions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ beforeAll(async () => {
user1 = await testDb.createUser({ globalRole: globalUserRole, apiKey: randomApiKey() });
user2 = await testDb.createUser({ globalRole: globalUserRole, apiKey: randomApiKey() });

// TODO: mock BinaryDataManager instead
await utils.initBinaryManager();
// TODO: mock BinaryDataService instead
await utils.initBinaryDataService();
await utils.initNodeTypes();

workflowRunner = await utils.initActiveWorkflowRunner();
Expand Down
13 changes: 8 additions & 5 deletions packages/cli/test/integration/shared/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Container } from 'typedi';
import { randomBytes } from 'crypto';
import { existsSync } from 'fs';
import { BinaryDataManager, UserSettings } from 'n8n-core';
import { BinaryDataService, UserSettings } from 'n8n-core';
import type { INode } from 'n8n-workflow';
import { GithubApi } from 'n8n-nodes-base/credentials/GithubApi.credentials';
import { Ftp } from 'n8n-nodes-base/credentials/Ftp.credentials';
Expand Down Expand Up @@ -72,11 +72,14 @@ export async function initNodeTypes() {
}

/**
* Initialize a BinaryManager for test runs.
* Initialize a BinaryDataService for test runs.
*/
export async function initBinaryManager() {
const binaryDataConfig = config.getEnv('binaryDataManager');
await BinaryDataManager.init(binaryDataConfig);
export async function initBinaryDataService() {
const binaryDataService = new BinaryDataService();

await binaryDataService.init(config.getEnv('binaryDataService'));

Container.set(BinaryDataService, binaryDataService);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"n8n-nodes-base": "workspace:*"
},
"dependencies": {
"axios": "^0.21.1",
"@n8n/client-oauth2": "workspace:*",
"axios": "^0.21.1",
"concat-stream": "^2.0.0",
"cron": "~1.7.2",
"crypto-js": "~4.1.1",
Expand All @@ -63,6 +63,7 @@
"p-cancelable": "^2.0.0",
"pretty-bytes": "^5.6.0",
"qs": "^6.10.1",
"typedi": "^0.10.0",
"uuid": "^8.3.2"
}
}
Loading