Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

51 lines
1.7 KiB
TypeScript

import type { LogEntry } from 'n8n-containers';
import { test, expect } from '../../../fixtures/base';
// Enable observability to use VictoriaLogs for log queries
test.use({ capability: 'observability' });
// Helper to extract container name from log entry
// Vector enriches logs with Docker metadata including container_name
const getContainerName = (log: LogEntry): string | undefined => log.container_name ?? log.container;
test('Leader election @mode:multi-main @chaostest @capability:observability', {
annotation: [
{ type: 'owner', description: 'Catalysts' },
],
}, async ({
n8nContainer,
services,
}) => {
// Find the current leader by querying VictoriaLogs
// Vector enriches logs with container_name from Docker metadata
const leaderLog = await services.observability.logs.waitForLog('Leader is now this', {
timeoutMs: 30000,
start: '-5m',
});
expect(leaderLog, 'Leader should be found').toBeDefined();
// Extract the leader container name from the log entry
const currentLeader = getContainerName(leaderLog!);
expect(currentLeader, 'Leader container_name should be in log entry').toBeDefined();
// Stop the leader container
await n8nContainer.stopContainer(currentLeader!);
// Wait for new leader election (another instance should take over)
// Use LogsQL to exclude logs from the stopped container
const newLeaderLog = await services.observability.logs.waitForLog(
`Leader is now this AND NOT container_name:${currentLeader}`,
{
timeoutMs: 30000,
start: '-5m', // Look at all recent logs, filtering by container excludes the old leader
},
);
expect(newLeaderLog).toBeDefined();
const newLeader = getContainerName(newLeaderLog!);
expect(newLeader).toBeDefined();
expect(newLeader).not.toBe(currentLeader);
});