Skip to content

Commit 08d801f

Browse files
authored
minor: max disks per instance = 12 (#2995)
* max disks per instance * CLAUDE FIXED ANOTHER FLAKE * turn on no floating promises lint for e2e tests
1 parent 46a6b5e commit 08d801f

File tree

10 files changed

+36
-7
lines changed

10 files changed

+36
-7
lines changed

.oxlintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"rules": {
7070
"import/no-default-export": "off"
7171
}
72+
},
73+
{
74+
// catch unawaited Playwright calls in e2e tests
75+
"files": ["test/e2e/**/*.ts"],
76+
"rules": {
77+
"@typescript-eslint/no-floating-promises": "error"
78+
}
7279
}
7380
],
7481
"ignorePatterns": ["dist/", "node_modules/"]

app/api/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import type {
2424

2525
// API limits encoded in https://github.com/oxidecomputer/omicron/blob/aec3cd8d/nexus/src/app/mod.rs
2626

27+
// These are not actually used in app code, just the mock server. In the app we
28+
// can rely on API errors to communicate these limits.
2729
export const MAX_NICS_PER_INSTANCE = 8
30+
export const MAX_DISKS_PER_INSTANCE = 12
2831

2932
export const INSTANCE_MAX_CPU = 64
3033
export const INSTANCE_MIN_RAM_GiB = 1

eslint.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,13 @@ export default defineConfig(
161161
],
162162
'playwright/no-force-option': 'off',
163163
},
164+
},
165+
166+
// Catch unawaited Playwright calls in e2e tests
167+
{
168+
files: ['test/e2e/**/*.ts'],
169+
rules: {
170+
'@typescript-eslint/no-floating-promises': 'error',
171+
},
164172
}
165173
)

mock-api/msw/handlers.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
INSTANCE_MAX_CPU,
1919
INSTANCE_MAX_RAM_GiB,
2020
INSTANCE_MIN_RAM_GiB,
21+
MAX_DISKS_PER_INSTANCE,
2122
MAX_NICS_PER_INSTANCE,
2223
type AffinityGroupMember,
2324
type AntiAffinityGroupMember,
@@ -424,6 +425,10 @@ export const handlers = makeHandlers({
424425
if (body.disks) allDisks.push(...body.disks)
425426
if (body.boot_disk) allDisks.push(body.boot_disk)
426427

428+
if (allDisks.length > MAX_DISKS_PER_INSTANCE) {
429+
throw `Cannot attach more than ${MAX_DISKS_PER_INSTANCE} disks to an instance`
430+
}
431+
427432
for (const diskParams of allDisks) {
428433
if (diskParams.type === 'create') {
429434
errIfExists(db.disks, { name: diskParams.name, project_id: project.id }, 'disk')
@@ -701,6 +706,12 @@ export const handlers = makeHandlers({
701706
if (instance.run_state !== 'stopped') {
702707
throw 'Cannot attach disk to instance that is not stopped'
703708
}
709+
const attachedDisks = db.disks.filter(
710+
(d) => 'instance' in d.state && d.state.instance === instance.id
711+
)
712+
if (attachedDisks.length >= MAX_DISKS_PER_INSTANCE) {
713+
throw `Cannot attach more than ${MAX_DISKS_PER_INSTANCE} disks to an instance`
714+
}
704715
const disk = lookup.disk({ ...projectParams, disk: body.disk })
705716
disk.state = {
706717
state: 'attached',

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
retries: process.env.CI ? 2 : 0,
2020
// use all available cores (2) on github actions. use fewer locally
2121
workers: process.env.CI ? '100%' : '66%',
22-
timeout: 60 * 1000, // 1 minute
22+
timeout: (process.env.CI ? 60 : 30) * 1000, // shorter timeout locally
2323
fullyParallel: true,
2424
// default is 5 seconds. somehow playwright really hates async route modules,
2525
// takes a long time to load them. https://playwright.dev/docs/test-timeouts

test/e2e/anti-affinity.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test('can add a new anti-affinity group', async ({ page }) => {
8080
// go disable db1
8181
await page.getByRole('button', { name: 'Cancel' }).click()
8282
await page.getByRole('link', { name: 'Instances' }).click()
83-
clickRowAction(page, 'db1', 'Stop')
83+
await clickRowAction(page, 'db1', 'Stop')
8484
await page.getByRole('button', { name: 'Confirm' }).click()
8585
await expectRowVisible(page.getByRole('table'), {
8686
name: 'db1',

test/e2e/firewall-rules.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ test('arbitrary values combobox', async ({ page }) => {
630630
await expectOptions(page, ['Custom: d'])
631631

632632
await vpcInput.blur()
633-
page.getByRole('button', { name: 'Add target' }).click()
633+
await page.getByRole('button', { name: 'Add target' }).click()
634634
await expect(vpcInput).toHaveValue('')
635635

636636
await vpcInput.focus()

test/e2e/image-upload.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ test.describe('Image upload', () => {
177177

178178
let confirmCount = 0
179179

180-
page.on('dialog', (dialog) => {
180+
page.on('dialog', async (dialog) => {
181181
confirmCount += 1
182-
dialog.dismiss()
182+
await dialog.dismiss()
183183
}) // click cancel on the are you sure prompt
184184

185185
await progressModal.getByRole('button', { name: 'Cancel' }).click()

test/e2e/instance.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('can delete a failed instance', async ({ page }) => {
2929

3030
const cell = page.getByRole('cell', { name: 'you-fail' })
3131
await expect(cell).toBeVisible() // just to match hidden check at the end
32-
expectInstanceState(page, 'you-fail', 'failed')
32+
await expectInstanceState(page, 'you-fail', 'failed')
3333

3434
await clickRowAction(page, 'you-fail', 'Delete')
3535
await page.getByRole('button', { name: 'Confirm' }).click()

test/e2e/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export async function scrollTo(page: Page, to: number) {
259259
}
260260

261261
export async function addTlsCert(page: Page) {
262-
page.getByRole('button', { name: 'Add TLS certificate' }).click()
262+
await page.getByRole('button', { name: 'Add TLS certificate' }).click()
263263
await page
264264
.getByRole('dialog', { name: 'Add TLS certificate' })
265265
.getByRole('textbox', { name: 'Name' })

0 commit comments

Comments
 (0)