Skip to content

Commit 8ad17dc

Browse files
jason-haanthony-murphy-agent
authored andcommitted
test(client-azure-end-to-end): fix Azure connect timeouts (microsoft#25781)
allow more time for connecting to real AFR service in Presence tests. Change from a fixed 10s to dynamic time based on number of clients. Additionally changes: - fix `beforeEach` cross contamination from different client counts by injected a `describe` block within loop body - output `beforeEach` completion time (otherwise untracked from mocha output) - output timestamp under verbose logging - send along or request and show log if connect times out
1 parent 397eea4 commit 8ad17dc

File tree

4 files changed

+289
-243
lines changed

4 files changed

+289
-243
lines changed

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/childClient.tool.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import type {
4040
EventEntry,
4141
} from "./messageTypes.js";
4242

43-
const connectTimeoutMs = 10_000;
4443
const testLabel = process.argv[2];
4544
// Identifier given to child process
4645
const process_id = process.argv[3];
@@ -62,6 +61,10 @@ const containerSchema = {
6261
},
6362
} as const satisfies ContainerSchema;
6463

64+
function log(...data: unknown[]): void {
65+
console.log(`[${testLabel}] [${new Date().toISOString()}] [${process_id}]`, ...data);
66+
}
67+
6568
function telemetryEventInterestLevel(eventName: string): "none" | "basic" | "details" {
6669
if (eventName.includes(":Signal") || eventName.includes(":Join")) {
6770
return "details";
@@ -83,7 +86,7 @@ function selectiveVerboseLog(event: ITelemetryBaseEvent, logLevel?: LogLevel): v
8386
if (interest === "details") {
8487
content.details = event.details;
8588
}
86-
console.log(`[${testLabel}] [${process_id}] [${logLevel ?? LogLevel.default}]`, content);
89+
log(`[${logLevel ?? LogLevel.default}]`, content);
8790
}
8891

8992
/**
@@ -96,6 +99,7 @@ const getOrCreateContainer = async (params: {
9699
user: UserIdAndName;
97100
scopes?: ScopeType[];
98101
createScopes?: ScopeType[];
102+
connectTimeoutMs: number;
99103
}): Promise<{
100104
container: IFluidContainer<typeof containerSchema>;
101105
services: AzureContainerServices;
@@ -105,7 +109,7 @@ const getOrCreateContainer = async (params: {
105109
}> => {
106110
let container: IFluidContainer<typeof containerSchema>;
107111
let { containerId } = params;
108-
const { logger, onDisconnected, user, scopes, createScopes } = params;
112+
const { logger, onDisconnected, user, scopes, createScopes, connectTimeoutMs } = params;
109113
const connectionProps: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = useAzure
110114
? {
111115
tenantId,
@@ -164,7 +168,7 @@ function createSendFunction(): (msg: MessageToParent) => void {
164168
const sendFn = process.send.bind(process);
165169
if (verbosity.includes("msgs")) {
166170
return (msg: MessageToParent) => {
167-
console.log(`[${testLabel}] [${process_id}] Sending`, msg);
171+
log(`Sending`, msg);
168172
sendFn(msg);
169173
};
170174
}
@@ -381,7 +385,7 @@ class MessageHandler {
381385
eventCategory: "messageReceived",
382386
eventName: msg.command,
383387
});
384-
console.log(`[${testLabel}] [${process_id}] Received`, msg);
388+
log(`Received`, msg);
385389
}
386390

387391
if (msg.command === "ping") {
@@ -478,7 +482,10 @@ class MessageHandler {
478482
this.presence = presence;
479483

480484
// wait for 'ConnectionState.Connected'
481-
await connected;
485+
await connected.catch((error) => {
486+
(error as Error).message += `\nLog: ${JSON.stringify(this.log)}`;
487+
throw error;
488+
});
482489

483490
// Acknowledge connection before sending current attendee information
484491
this.send({
@@ -519,9 +526,7 @@ class MessageHandler {
519526
connectedCount++;
520527
}
521528
}
522-
console.log(
523-
`[${testLabel}] [${process_id}] Report: ${attendees.size} attendees, ${connectedCount} connected`,
524-
);
529+
log(`Report: ${attendees.size} attendees, ${connectedCount} connected`);
525530
} else {
526531
this.send({ event: "error", error: `${process_id} is not connected to presence` });
527532
}

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/messageTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface ConnectCommand {
5757
* If not provided, a new Fluid container will be created.
5858
*/
5959
containerId?: string;
60+
connectTimeoutMs: number;
6061
}
6162

6263
/**

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/orchestratorUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export async function executeDebugReports(
154154
function composeConnectMessage(
155155
id: string | number,
156156
scopes: ScopeType[] = [ScopeType.DocRead],
157+
connectTimeoutMs: number,
157158
): ConnectCommand {
158159
return {
159160
command: "connect",
@@ -163,6 +164,7 @@ function composeConnectMessage(
163164
},
164165
scopes,
165166
createScopes: [ScopeType.DocWrite, ScopeType.DocRead],
167+
connectTimeoutMs,
166168
};
167169
}
168170

@@ -257,6 +259,7 @@ export async function connectChildProcesses(
257259
const connectContainerCreator = composeConnectMessage(
258260
0,
259261
writeClients > 0 ? [ScopeType.DocWrite, ScopeType.DocRead] : [ScopeType.DocRead],
262+
/* connectTimeoutMs */ readyTimeoutMs,
260263
);
261264
firstChild.send(connectContainerCreator);
262265
}
@@ -266,7 +269,10 @@ export async function connectChildProcesses(
266269
durationMs: readyTimeoutMs,
267270
errorMsg: "did not receive 'connected' from child process",
268271
},
269-
);
272+
).catch(async (error) => {
273+
await executeDebugReports([firstChild]);
274+
throw error;
275+
});
270276

271277
const attendeeIdPromises: Promise<AttendeeId>[] = [];
272278
for (const [index, child] of childProcesses.entries()) {
@@ -277,6 +283,7 @@ export async function connectChildProcesses(
277283
const message = composeConnectMessage(
278284
index,
279285
index < writeClients ? [ScopeType.DocWrite, ScopeType.DocRead] : [ScopeType.DocRead],
286+
/* connectTimeoutMs */ readyTimeoutMs,
280287
);
281288
message.containerId = containerId;
282289
attendeeIdPromises.push(

0 commit comments

Comments
 (0)