Skip to content

Commit

Permalink
Merge 8f402c3 into 20d2c53
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Jul 11, 2024
2 parents 20d2c53 + 8f402c3 commit d1e3354
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/lovely-swans-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@replayio/cypress": minor
"@replayio/playwright": minor
---

Added a new `upload` option: `maximumLimit`. It can be used to limit how many replay recordings can be uploaded by the currently executing shard.
10 changes: 10 additions & 0 deletions packages/test-utils/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default class ReplayReporter<
private _uploadableResults: Map<string, UploadableTestResult<TRecordingMetadata>> = new Map();
private _testRunShardIdPromise: Promise<TestRunPendingWork> | null = null;
private _uploadStatusThreshold: UploadStatusThresholdInternal = "none";
private _uploadMaxLimit = Infinity;
private _uploadWorker: UploadWorker | undefined;
private _uploadedRecordings = new Set<string>();
private _recordingMetadatas = new Map<
Expand Down Expand Up @@ -364,6 +365,12 @@ export default class ReplayReporter<
if (typeof config.upload === "object") {
this._minimizeUploads = !!config.upload.minimizeUploads;
this._uploadStatusThreshold = config.upload.statusThreshold ?? "all";
if (typeof config.upload.maximumLimit === "number") {
if (!Number.isFinite(config.upload.maximumLimit) || config.upload.maximumLimit <= 0) {
throw new Error("`upload.maximumLimit` must be a finite number higher than 0");
}
this._uploadMaxLimit = config.upload.maximumLimit;
}
} else {
this._uploadStatusThreshold = "all";
}
Expand Down Expand Up @@ -763,6 +770,9 @@ export default class ReplayReporter<
});
return;
}
if (this._uploadedRecordings.size >= this._uploadMaxLimit) {
return;
}
const uploadableRecording = getRecordings().find(r => r.id === recording.id);
if (!uploadableRecording) {
logger.info("UploadRecording:NoUploadableRecording", {
Expand Down
4 changes: 4 additions & 0 deletions packages/test-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export type RecordingEntry<TMetadata extends UnstructuredMetadata = Unstructured
export type UploadStatusThreshold = "all" | "failed-and-flaky" | "failed";

export type UploadOptions = {
/**
* Maximum number of recordings to upload (within a shard).
*/
maximumLimit?: number;
/**
* Minimize the number of recordings uploaded for a test attempt (within a shard).
* e.g. Only one recording would be uploaded for a failing test attempt, regardless of retries.
Expand Down

0 comments on commit d1e3354

Please sign in to comment.