mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
ci: Test container enhancements (#17008)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { setTimeout as wait } from 'node:timers/promises';
|
||||
import type { StartedTestContainer, StoppedTestContainer } from 'testcontainers';
|
||||
|
||||
export interface LogMatch {
|
||||
@@ -118,14 +119,15 @@ export class ContainerTestHelpers {
|
||||
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
iteration++;
|
||||
await this.sleep(ContainerTestHelpers.POLL_INTERVAL_MS);
|
||||
await wait(ContainerTestHelpers.POLL_INTERVAL_MS);
|
||||
|
||||
// Capture the timestamp for this iteration to avoid race conditions
|
||||
const checkTimestamp = currentCheckTime;
|
||||
|
||||
// Check all containers concurrently
|
||||
const matchPromises = targetContainers.map((container) =>
|
||||
this.checkContainerForMatch(container, messageRegex, checkTimestamp),
|
||||
const matchPromises = targetContainers.map(
|
||||
async (container) =>
|
||||
await this.checkContainerForMatch(container, messageRegex, checkTimestamp),
|
||||
);
|
||||
|
||||
const results = await Promise.all(matchPromises);
|
||||
@@ -228,6 +230,7 @@ export class ContainerTestHelpers {
|
||||
* Strip ANSI escape codes from log text
|
||||
*/
|
||||
private stripAnsiCodes(text: string): string {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
return text.replace(/\x1B\[[0-9;]*[mGKH]/g, '');
|
||||
}
|
||||
|
||||
@@ -248,7 +251,7 @@ export class ContainerTestHelpers {
|
||||
since?: number,
|
||||
): Promise<StreamLogMatch | null> {
|
||||
try {
|
||||
const logOptions: any = {};
|
||||
const logOptions: { since?: number } = {};
|
||||
if (since !== undefined) {
|
||||
logOptions.since = since;
|
||||
}
|
||||
@@ -311,7 +314,7 @@ export class ContainerTestHelpers {
|
||||
since?: number,
|
||||
): Promise<string> {
|
||||
try {
|
||||
const logOptions: any = {};
|
||||
const logOptions: { since?: number } = {};
|
||||
if (since !== undefined) {
|
||||
logOptions.since = since;
|
||||
}
|
||||
@@ -370,8 +373,4 @@ export class ContainerTestHelpers {
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
private sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user