Skip to content

Commit

Permalink
Allow user to start failed instances (#2439)
Browse files Browse the repository at this point in the history
* allow user to start failed instance

* let's write a test. why not
  • Loading branch information
david-crespo authored Sep 12, 2024
1 parent cdecf4e commit b4e2626
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/api/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export const genName = (...parts: [string, ...string[]]) => {
}

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

// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-queries/src/db/datastore/instance.rs#L865
delete: ['stopped', 'failed'],
Expand Down
45 changes: 39 additions & 6 deletions test/e2e/instance.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,48 @@ test('can delete a failed instance', async ({ page }) => {

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

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

await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Delete' }).click()
const table = page.getByRole('table')
await expectRowVisible(table, {
name: 'you-fail',
state: expect.stringContaining('failed'),
})

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

await expect(row).toBeHidden() // bye
await expect(cell).toBeHidden() // bye
})

test('can start a failed instance', async ({ page }) => {
await page.goto('/projects/mock-project/instances')

// check the start button disabled message on a running instance
await page
.getByRole('row', { name: 'db1', exact: false })
.getByRole('button', { name: 'Row actions' })
.click()
await page.getByRole('menuitem', { name: 'Start' }).hover()
await expect(
page.getByText('Only stopped or failed instances can be started')
).toBeVisible()
await page.keyboard.press('Escape') // get out of the menu

// now start the failed one
const table = page.getByRole('table')
await expectRowVisible(table, {
name: 'you-fail',
state: expect.stringContaining('failed'),
})

await clickRowAction(page, 'you-fail', 'Start')

await expectRowVisible(table, {
name: 'you-fail',
state: expect.stringContaining('starting'),
})
})

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

0 comments on commit b4e2626

Please sign in to comment.