fix(test): deflake flicker integration test (#11308)

This commit is contained in:
Sandy Tao
2025-10-16 13:53:08 -07:00
committed by GitHub
parent 6b866d1282
commit 2aa1d74286
2 changed files with 30 additions and 2 deletions

View File

@@ -910,6 +910,34 @@ export class TestRig {
return apiRequests.pop() || null;
}
async waitForMetric(metricName: string, timeout?: number) {
await this.waitForTelemetryReady();
const fullName = metricName.startsWith('gemini_cli.')
? metricName
: `gemini_cli.${metricName}`;
return poll(
() => {
const logs = this._readAndParseTelemetryLog();
for (const logData of logs) {
if (logData.scopeMetrics) {
for (const scopeMetric of logData.scopeMetrics) {
for (const metric of scopeMetric.metrics) {
if (metric.descriptor.name === fullName) {
return true;
}
}
}
}
}
return false;
},
timeout ?? getDefaultTimeout(),
100,
);
}
readMetric(metricName: string): Record<string, unknown> | null {
const logs = this._readAndParseTelemetryLog();
for (const logData of logs) {