message: Add TestOverride setting to disable ODSP snapshot cache
diff: @@ -24,7 +24,12 @@ import {
  IOdspResolvedUrl,
  } from "@fluidframework/odsp-driver-definitions";
  import { DriverErrorType } from "@fluidframework/driver-definitions";
  -import { PerformanceEvent, isFluidError, normalizeError } from "@fluidframework/telemetry-utils";
  +import {
  + PerformanceEvent,
  + isFluidError,
  + normalizeError,
  + loggerToMonitoringContext,
  +} from "@fluidframework/telemetry-utils";
  import { fetchAndParseAsJSONHelper, fetchArray, fetchHelper, getOdspResolvedUrl, IOdspResponse } from "./odspUtils";
  import {
  IOdspCache,
  @@ -55,6 +60,7 @@ export const defaultCacheExpiryTimeoutMs: number = 2 * 24 * 60 * 60 * 1000;
  export class EpochTracker implements IPersistedFileCache {
  private _fluidEpoch: string | undefined;
  + private readonly snapshotCacheExpiryTimeoutMs: number;
  public readonly rateLimiter: RateLimiter;
  private readonly driverId = uuid();
  // This tracks the request number made by the driver instance.
  @@ -67,6 +73,12 @@ export class EpochTracker implements IPersistedFileCache {
  ) {
  // Limits the max number of concurrent requests to 24.
  this.rateLimiter = new RateLimiter(24);
  +
  + // We need this for GC testing until we properly plumb through the snapshot expiration policy (see PR #11168)
  + this.snapshotCacheExpiryTimeoutMs =
  + loggerToMonitoringContext(logger).config.getBoolean("Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache")
  + ? 0
  + : defaultCacheExpiryTimeoutMs;
  }
  // public for UT purposes only!
  @@ -103,17 +115,17 @@ export class EpochTracker implements IPersistedFileCache {
  } else if (this._fluidEpoch !== value.fluidEpoch) {
  return undefined;
  }
  - // Expire the cached snapshot if it's older than the defaultCacheExpiryTimeoutMs and immediately
  + // Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately
  // expire all old caches that do not have cacheEntryTime
  if (entry.type === snapshotKey) {
  const cacheTime = value.value?.cacheEntryTime;
  const currentTime = Date.now();
  - if (cacheTime === undefined || currentTime - cacheTime >= defaultCacheExpiryTimeoutMs) {
  + if (cacheTime === undefined || currentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs) {
  this.logger.sendTelemetryEvent(
  {
  eventName: "odspVersionsCacheExpired",
  duration: currentTime - cacheTime,
  - maxCacheAgeMs: defaultCacheExpiryTimeoutMs,
  + maxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,
  });
  await this.removeEntries();
  return undefined;
  @@ -129,8 +141,8 @@ export class EpochTracker implements IPersistedFileCache {
  public async put(entry: IEntry, value: any) {
  assert(this._fluidEpoch !== undefined, 0x1dd /* "no epoch" */);
  - // For snapshots, the value should have the cacheEntryTime. This will be used to expire snapshots older
  - // than the defaultCacheExpiryTimeoutMs.
  + // For snapshots, the value should have the cacheEntryTime.
  + // This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.
  if (entry.type === snapshotKey) {
  value.cacheEntryTime = value.cacheEntryTime ?? Date.now();
  }
  