Skip to content

Commit f63d3bf

Browse files
jason-haanthony-murphy-agent
authored andcommitted
test(client-azure-end-to-end-tests): debug support (microsoft#25773)
- Add additional child logging prefix for distinction under CI where output appears jumbled - Exclude non-interactive connection telemetry from logs - On unexpect ClientJoin send additional details
1 parent bc4484e commit f63d3bf

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ import type {
4141
} from "./messageTypes.js";
4242

4343
const connectTimeoutMs = 10_000;
44+
const testLabel = process.argv[2];
4445
// Identifier given to child process
45-
const process_id = process.argv[2];
46-
const verbosity = process.argv[3] ?? "";
46+
const process_id = process.argv[3];
47+
const verbosity = process.argv[4] ?? "";
4748

4849
const useAzure = process.env.FLUID_CLIENT === "azure";
4950
const tenantId = useAzure
@@ -82,7 +83,7 @@ function selectiveVerboseLog(event: ITelemetryBaseEvent, logLevel?: LogLevel): v
8283
if (interest === "details") {
8384
content.details = event.details;
8485
}
85-
console.log(`[${process_id}] [${logLevel ?? LogLevel.default}]`, content);
86+
console.log(`[${testLabel}] [${process_id}] [${logLevel ?? LogLevel.default}]`, content);
8687
}
8788

8889
/**
@@ -163,7 +164,7 @@ function createSendFunction(): (msg: MessageToParent) => void {
163164
const sendFn = process.send.bind(process);
164165
if (verbosity.includes("msgs")) {
165166
return (msg: MessageToParent) => {
166-
console.log(`[${process_id}] Sending`, msg);
167+
console.log(`[${testLabel}] [${process_id}] Sending`, msg);
167168
sendFn(msg);
168169
};
169170
}
@@ -248,11 +249,17 @@ class MessageHandler {
248249

249250
private readonly logger: ITelemetryBaseLogger = {
250251
send: (event: ITelemetryBaseEvent, logLevel?: LogLevel) => {
252+
// Filter out non-interactive client telemetry
253+
const clientType = event.clientType;
254+
if (typeof clientType === "string" && clientType.startsWith("noninteractive")) {
255+
return;
256+
}
257+
251258
// Special case unexpected telemetry event
252259
if (event.eventName.endsWith(":JoinResponseWhenAlone")) {
253260
this.send({
254261
event: "error",
255-
error: `Unexpected ClientJoin response. Details: ${JSON.stringify(event.details)}`,
262+
error: `Unexpected ClientJoin response. Details: ${JSON.stringify(event.details)}\nLog: ${JSON.stringify(this.log)}`,
256263
});
257264
// Keep going
258265
}
@@ -374,7 +381,7 @@ class MessageHandler {
374381
eventCategory: "messageReceived",
375382
eventName: msg.command,
376383
});
377-
console.log(`[${process_id}] Received`, msg);
384+
console.log(`[${testLabel}] [${process_id}] Received`, msg);
378385
}
379386

380387
if (msg.command === "ping") {
@@ -513,7 +520,7 @@ class MessageHandler {
513520
}
514521
}
515522
console.log(
516-
`[${process_id}] Report: ${attendees.size} attendees, ${connectedCount} connected`,
523+
`[${testLabel}] [${process_id}] Report: ${attendees.size} attendees, ${connectedCount} connected`,
517524
);
518525
} else {
519526
this.send({ event: "error", error: `${process_id} is not connected to presence` });
@@ -712,7 +719,7 @@ function setupMessageHandler(): void {
712719
const messageHandler = new MessageHandler();
713720
process.on("message", (msg: MessageFromParent) => {
714721
messageHandler.onMessage(msg).catch((error: Error) => {
715-
console.error(`Error in client ${process_id}`, error);
722+
console.error(`[${testLabel}] Error in client ${process_id}`, error);
716723
send({ event: "error", error: `${process_id}: ${error.message}` });
717724
});
718725
});

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface ChildProcess extends AnyChildProcess {
5858
* @returns A collection of child processes and a promise that rejects on the first child error.
5959
*/
6060
export async function forkChildProcesses(
61+
testLabel: string,
6162
numProcesses: number,
6263
cleanUpAccumulator: (() => void)[],
6364
): Promise<{
@@ -72,6 +73,7 @@ export async function forkChildProcesses(
7273
const childErrorPromises: Promise<never>[] = [];
7374
for (let i = 0; i < numProcesses; i++) {
7475
const child = fork("./lib/test/multiprocess/childClient.tool.js", [
76+
testLabel,
7577
`child ${i}` /* identifier passed to child process */,
7678
childLoggingVerbosity /* console logging verbosity */,
7779
]);
@@ -348,6 +350,10 @@ export async function connectAndListenForAttendees(
348350
readyTimeoutMs: childConnectTimeoutMs,
349351
});
350352

353+
// These actions are not awaited. They are here to provide additional logging.
354+
// It is up to the caller to await attendeeIdPromises if desired. This can mean
355+
// An "error" message is output, but the caller does not care about attendee
356+
// ids and proceeds.
351357
Promise.all(connectResult.attendeeIdPromises)
352358
.then(() => console.log("All attendees connected."))
353359
.catch((error) => {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ describe(`Presence with AzureClient`, () => {
131131
const allAttendeesFullyJoinedTimeoutMs = (2000 + 300 * numClients) * timeoutMultiplier;
132132

133133
for (const writeClients of [numClients, 1]) {
134-
it(`announces 'attendeeConnected' when remote client joins session [${numClients} clients, ${writeClients} writers]`, async function () {
134+
it(`announces 'attendeeConnected' when remote client joins session [${numClients} clients, ${writeClients} writers]`, async function testAnnouncesAttendeeConnected() {
135135
setTestTimeout(this, childConnectTimeoutMs + allAttendeesJoinedTimeoutMs + 1000);
136136

137137
// Setup
138138
const { children, childErrorPromise } = await forkChildProcesses(
139+
this.test?.title ?? "",
139140
numClients,
140141
afterCleanUp,
141142
);
@@ -153,7 +154,7 @@ describe(`Presence with AzureClient`, () => {
153154
);
154155
});
155156

156-
it(`announces 'attendeeDisconnected' when remote client disconnects [${numClients} clients, ${writeClients} writers]`, async function () {
157+
it(`announces 'attendeeDisconnected' when remote client disconnects [${numClients} clients, ${writeClients} writers]`, async function testAnnouncesAttendeeDisconnected() {
157158
if (useAzure && numClients > 50) {
158159
// Even with increased timeouts, more than 50 clients can be too large for AFR.
159160
// This may be due to slow responses/inactivity from the clients that are
@@ -173,6 +174,7 @@ describe(`Presence with AzureClient`, () => {
173174

174175
// Setup
175176
const { children, childErrorPromise } = await forkChildProcesses(
177+
this.test?.title ?? "",
176178
numClients,
177179
afterCleanUp,
178180
);
@@ -345,8 +347,9 @@ describe(`Presence with AzureClient`, () => {
345347
const testValue = "testValue";
346348
const workspaceId = "presenceTestWorkspace";
347349

348-
beforeEach(async () => {
350+
beforeEach(async function usingLatestStateObject_beforeEach(): Promise<void> {
349351
({ children, childErrorPromise } = await forkChildProcesses(
352+
this.currentTest?.title ?? "",
350353
numClients,
351354
afterCleanUp,
352355
));
@@ -432,8 +435,9 @@ describe(`Presence with AzureClient`, () => {
432435
const value1 = { name: "Alice", score: 100 };
433436
const value2 = { name: "Bob", score: 200 };
434437

435-
beforeEach(async () => {
438+
beforeEach(async function usingLatestMapStateObject_beforeEach(): Promise<void> {
436439
({ children, childErrorPromise } = await forkChildProcesses(
440+
this.currentTest?.title ?? "",
437441
numClients,
438442
afterCleanUp,
439443
));

0 commit comments

Comments
 (0)