diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagement.test.ts b/apps/studio/components/interfaces/DiskManagement/DiskManagement.test.ts index fb15264e46a..360a08c07ca 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagement.test.ts +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagement.test.ts @@ -8,6 +8,7 @@ import { calculateIOPSPrice, calculateMaxIopsAllowedForDiskSizeWithGp3, calculateMaxIopsForComputeSize, + calculateMaxThroughput, calculateThroughputPrice, mapAddOnVariantIdToComputeSize, mapComputeSizeNameToAddonVariantId, @@ -84,6 +85,18 @@ describe('calculateMaxIopsAllowedForDiskSizeWithGp3', () => { }) }) +describe('calculateMaxThroughput', () => { + // Regression: the ceiling was hardcoded to 1000 MB/s while DISK_LIMITS.gp3.maxThroughput moved + // to 2000, so large gp3 disks were rejected with a misleading "need more IOPS" error. + test('scales with provisioned IOPS below the gp3 max throughput ceiling', () => { + expect(calculateMaxThroughput(4000)).toBe(1024) + }) + + test('caps at the gp3 max throughput ceiling (2000 MB/s)', () => { + expect(calculateMaxThroughput(80000)).toBe(2000) + }) +}) + describe('DiskManagement.utils.ts:calculateDiskSizePrice', () => { test('GP3 with 8GB to GP3 with 10GB for pro plan', () => { const result = calculateDiskSizePrice({ @@ -233,6 +246,24 @@ describe('CreateDiskStorageSchema', () => { ) }) + test('allows gp3 throughput above 1000 MB/s when IOPS and compute support it', () => { + const schema = CreateDiskStorageSchema({ + defaultTotalSize: 4096, + cloudProvider: 'AWS', + isSpendCapEnabled: false, + }) + + const result = schema.safeParse({ + ...validGp3Config, + totalSize: 4096, + provisionedIOPS: 80000, + throughput: 2000, + computeSize: 'ci_16xlarge' as const, + }) + + expect(result.error?.issues ?? []).toEqual([]) + }) + test('allows a legacy disk below 8 GB when its size is unchanged', () => { const schema = CreateDiskStorageSchema({ defaultTotalSize: 2, diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts b/apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts index 4954df5030c..ef2cfe64285 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts @@ -298,8 +298,9 @@ export const calculateDiskSizeRequiredForIopsWithIo2 = (iops: number) => { return Math.max(4, Math.ceil(iops / 1000)) } +const MAX_GP3_THROUGHPUT = DISK_LIMITS[DiskType.GP3]['maxThroughput'] export const calculateMaxThroughput = (iops: number) => { - return Math.min(0.256 * iops, 1000) + return Math.min(0.256 * iops, MAX_GP3_THROUGHPUT) } export const calculateIopsRequiredForThroughput = (throughput: number) => {