Skip to content

Commit b4e2626

Browse files
authored
Allow user to start failed instances (#2439)
* allow user to start failed instance * let's write a test. why not
1 parent cdecf4e commit b4e2626

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

app/api/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export const genName = (...parts: [string, ...string[]]) => {
9090
}
9191

9292
const instanceActions: Record<string, InstanceState[]> = {
93-
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/src/app/instance.rs#L1960-L1963
94-
start: ['stopped'],
93+
// https://github.com/oxidecomputer/omicron/blob/0496637/nexus/src/app/instance.rs#L2064
94+
start: ['stopped', 'failed'],
9595

9696
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-queries/src/db/datastore/instance.rs#L865
9797
delete: ['stopped', 'failed'],

test/e2e/instance.e2e.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,48 @@ test('can delete a failed instance', async ({ page }) => {
1212

1313
await expect(page).toHaveTitle('Instances / mock-project / Oxide Console')
1414

15-
const row = page.getByRole('row', { name: 'you-fail', exact: false })
16-
await expect(row).toBeVisible()
17-
await expect(row.getByRole('cell', { name: /failed/ })).toBeVisible()
15+
const cell = page.getByRole('cell', { name: 'you-fail' })
16+
await expect(cell).toBeVisible() // just to match hidden check at the end
1817

19-
await row.getByRole('button', { name: 'Row actions' }).click()
20-
await page.getByRole('menuitem', { name: 'Delete' }).click()
18+
const table = page.getByRole('table')
19+
await expectRowVisible(table, {
20+
name: 'you-fail',
21+
state: expect.stringContaining('failed'),
22+
})
23+
24+
await clickRowAction(page, 'you-fail', 'Delete')
2125
await page.getByRole('button', { name: 'Confirm' }).click()
2226

23-
await expect(row).toBeHidden() // bye
27+
await expect(cell).toBeHidden() // bye
28+
})
29+
30+
test('can start a failed instance', async ({ page }) => {
31+
await page.goto('/projects/mock-project/instances')
32+
33+
// check the start button disabled message on a running instance
34+
await page
35+
.getByRole('row', { name: 'db1', exact: false })
36+
.getByRole('button', { name: 'Row actions' })
37+
.click()
38+
await page.getByRole('menuitem', { name: 'Start' }).hover()
39+
await expect(
40+
page.getByText('Only stopped or failed instances can be started')
41+
).toBeVisible()
42+
await page.keyboard.press('Escape') // get out of the menu
43+
44+
// now start the failed one
45+
const table = page.getByRole('table')
46+
await expectRowVisible(table, {
47+
name: 'you-fail',
48+
state: expect.stringContaining('failed'),
49+
})
50+
51+
await clickRowAction(page, 'you-fail', 'Start')
52+
53+
await expectRowVisible(table, {
54+
name: 'you-fail',
55+
state: expect.stringContaining('starting'),
56+
})
2457
})
2558

2659
test('can stop and delete a running instance', async ({ page }) => {

0 commit comments

Comments
 (0)