n8n/packages/cli/test/unit
Iván Ovejero c857e42677
feat(core): Coordinate workflow activation in multiple main scenario in internal API (#7566)
Story: https://linear.app/n8n/issue/PAY-926

This PR coordinates workflow activation on instance startup and on
leadership change in multiple main scenario in the internal API. Part 3
on manual workflow activation and deactivation will be a separate PR.

### Part 1: Instance startup

In multi-main scenario, on starting an instance...
- [x] If the instance is the leader, it should add webhooks, triggers
and pollers.
- [x] If the instance is the follower, it should not add webhooks,
triggers or pollers.
- [x] Unit tests.

### Part 2: Leadership change 

In multi-main scenario, if the main instance leader dies…

- [x] The new main instance leader must activate all trigger- and
poller-based workflows, excluding webhook-based workflows.
- [x] The old main instance leader must deactivate all trigger- and
poller-based workflows, excluding webhook-based workflows.
- [x] Unit tests.

To test, start two instances and check behavior on startup and
leadership change:

```
EXECUTIONS_MODE=queue N8N_LEADER_SELECTION_ENABLED=true N8N_LICENSE_TENANT_ID=... N8N_LICENSE_ACTIVATION_KEY=... N8N_LOG_LEVEL=debug npm run start

EXECUTIONS_MODE=queue N8N_LEADER_SELECTION_ENABLED=true N8N_LICENSE_TENANT_ID=... N8N_LICENSE_ACTIVATION_KEY=... N8N_LOG_LEVEL=debug N8N_PORT=5679 npm run start
```
2023-11-07 13:48:48 +01:00
..
controllers refactor(core): Convert OAuth1/OAuth2 routes to decorated controller classes (no-changelog) (#5973) 2023-11-03 17:20:54 +01:00
ExternalSecrets refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
middleware refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
repositories refactor(core): Convert OAuth1/OAuth2 routes to decorated controller classes (no-changelog) (#5973) 2023-11-03 17:20:54 +01:00
services feat(core): Set up leader selection for multiple main instances (#7527) 2023-10-30 16:22:32 +01:00
shared refactor(core): Improve instance owner setup and add unit tests (no-changelog) (#5499) 2023-02-17 10:59:09 +01:00
ActiveExecutions.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
CredentialsHelper.test.ts refactor(core): Avoid passing around static state like default timezone (no-changelog) (#7221) 2023-10-27 14:17:52 +02:00
CredentialTypes.test.ts refactor(core): Refactor nodes loading (no-changelog) (#7283) 2023-10-09 16:09:23 +02:00
CurlConverterHelper.test.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
execution.lifecycle.test.ts refactor(core): Move execution save settings into lifecycle function (no-changelog) (#7370) 2023-10-26 14:35:38 +02:00
Helpers.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
InternalHooks.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
License.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
PermissionChecker.test.ts fix(core): Permission check for subworkflow properly checking for workflow settings (#7576) 2023-11-01 18:31:34 +01:00
PostHog.test.ts refactor(core): Abstract away InstanceSettings and encryptionKey into injectable services (no-changelog) (#7471) 2023-10-23 13:39:35 +02:00
SourceControl.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
Telemetry.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
UserManagementMailer.test.ts fix(core): Do not return inviteAcceptUrl in response if email was sent (#7465) 2023-10-19 13:58:06 +02:00
utils.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
webhooks.test.ts fix(Respond to Webhook Node): Return headers in response (#6921) 2023-08-14 12:38:17 +02:00
WorkflowCredentials.test.ts feat(core): Remove all floating promises. Enforce @typescript-eslint/no-floating-promises (#6281) 2023-05-24 02:01:45 +02:00
WorkflowExecuteAdditionalData.test.ts refactor(core): Set up ExecutionMetadata service (no-changelog) (#7103) 2023-09-05 09:13:30 +02:00
WorkflowHelpers.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
workflowHistoryHelper.test.ts feat: Workflow History pruning and prune time settings (#7343) 2023-10-04 13:57:21 +01:00
WorkflowRunner.test.ts refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00