-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [UIE-6937] - Add the ability to scale up DBaaS (#9869)
* feat: [UIE-6937] - Add the ability to scale DBaaS * Added changeset: Add the ability to scale up DBaaS * Addressed review comments * Show confirmation popup message conditionally based on node size of cluster * Addressed review comments * Fixed issue with unit test case and addressed review comments * Update logic to disable smaller plans in plan selection table * UIE-7092: Added feature flag, disable tabs other than active one and addressed review comments * Addressed review comments * Addressed review comments * Fix unit test --------- Co-authored-by: Banks Nussman <banks@nussman.us>
- Loading branch information
1 parent
f6dff19
commit 14e6d00
Showing
21 changed files
with
862 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Added | ||
--- | ||
|
||
Ability to scale up Database instances ([#9869](https://github.com/linode/manager/pull/9869)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
Ability to scale up Database instances ([#9869](https://github.com/linode/manager/pull/9869)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...es/manager/src/features/Databases/DatabaseDetail/DatabaseScaleUp/DatabaseScaleUp.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import { styled } from '@mui/material/styles'; | ||
|
||
import { Button } from 'src/components/Button/Button'; | ||
import { PlansPanel } from 'src/features/components/PlansPanel/PlansPanel'; | ||
|
||
export const StyledGrid = styled(Grid, { label: 'StyledGrid' })( | ||
({ theme }) => ({ | ||
alignItems: 'center', | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
marginTop: theme.spacing(2), | ||
[theme.breakpoints.down('sm')]: { | ||
alignItems: 'flex-end', | ||
flexDirection: 'column', | ||
marginTop: theme.spacing(), | ||
}, | ||
}) | ||
); | ||
|
||
export const StyledScaleUpButton = styled(Button, { | ||
label: 'StyledScaleUpButton', | ||
})(({ theme }) => ({ | ||
[theme.breakpoints.down('md')]: { | ||
marginRight: theme.spacing(), | ||
}, | ||
whiteSpace: 'nowrap', | ||
})); | ||
|
||
export const StyledPlansPanel = styled(PlansPanel, { | ||
label: 'StyledPlansPanel', | ||
})(() => ({ | ||
margin: 0, | ||
padding: 0, | ||
})); | ||
|
||
export const StyledPlanSummarySpan = styled('span', { | ||
label: 'StyledPlanSummarySpan', | ||
})(({ theme }) => ({ | ||
fontFamily: theme.font.bold, | ||
})); |
141 changes: 141 additions & 0 deletions
141
...es/manager/src/features/Databases/DatabaseDetail/DatabaseScaleUp/DatabaseScaleUp.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { | ||
fireEvent, | ||
queryByAttribute, | ||
waitForElementToBeRemoved, | ||
} from '@testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
import * as React from 'react'; | ||
import { QueryClient } from 'react-query'; | ||
import { Router } from 'react-router-dom'; | ||
|
||
import { databaseFactory, databaseTypeFactory } from 'src/factories'; | ||
import { makeResourcePage } from 'src/mocks/serverHandlers'; | ||
import { rest, server } from 'src/mocks/testServer'; | ||
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { DatabaseScaleUp } from './DatabaseScaleUp'; | ||
|
||
const queryClient = new QueryClient(); | ||
const loadingTestId = 'circle-progress'; | ||
|
||
beforeAll(() => mockMatchMedia()); | ||
afterEach(() => { | ||
queryClient.clear(); | ||
}); | ||
|
||
describe('database scale up', () => { | ||
const database = databaseFactory.build(); | ||
const dedicatedTypes = databaseTypeFactory.buildList(7, { | ||
class: 'dedicated', | ||
}); | ||
|
||
it('should render a loading state', async () => { | ||
const { getByTestId } = renderWithTheme( | ||
<DatabaseScaleUp database={database} />, | ||
{ | ||
queryClient, | ||
} | ||
); | ||
|
||
// Should render a loading state | ||
expect(getByTestId(loadingTestId)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render configuration, summary sections and input field to choose a plan', async () => { | ||
// Mock database types | ||
const standardTypes = [ | ||
databaseTypeFactory.build({ | ||
class: 'nanode', | ||
id: 'g6-standard-0', | ||
label: `Nanode 1 GB`, | ||
memory: 1024, | ||
}), | ||
...databaseTypeFactory.buildList(7, { class: 'standard' }), | ||
]; | ||
server.use( | ||
rest.get('*/databases/types', (req, res, ctx) => { | ||
return res( | ||
ctx.json(makeResourcePage([...standardTypes, ...dedicatedTypes])) | ||
); | ||
}) | ||
); | ||
|
||
const { getByTestId, getByText } = renderWithTheme( | ||
<DatabaseScaleUp database={database} />, | ||
{ | ||
queryClient, | ||
} | ||
); | ||
expect(getByTestId(loadingTestId)).toBeInTheDocument(); | ||
|
||
await waitForElementToBeRemoved(getByTestId(loadingTestId)); | ||
|
||
getByText('Current Configuration'); | ||
getByText('Choose a Plan'); | ||
getByText('Summary'); | ||
}); | ||
|
||
describe('On rendering of page', () => { | ||
const examplePlanType = 'g6-standard-60'; | ||
const dedicatedTypes = databaseTypeFactory.buildList(7, { | ||
class: 'dedicated', | ||
}); | ||
const database = databaseFactory.build(); | ||
beforeEach(() => { | ||
// Mock database types | ||
const standardTypes = [ | ||
databaseTypeFactory.build({ | ||
class: 'nanode', | ||
id: 'g6-standard-0', | ||
label: `Nanode 1 GB`, | ||
memory: 1024, | ||
}), | ||
...databaseTypeFactory.buildList(7, { class: 'standard' }), | ||
]; | ||
server.use( | ||
rest.get('*/databases/types', (req, res, ctx) => { | ||
return res( | ||
ctx.json(makeResourcePage([...standardTypes, ...dedicatedTypes])) | ||
); | ||
}) | ||
); | ||
}); | ||
|
||
it('scale up button should be disabled when no input is provided in the form', async () => { | ||
const { getByTestId, getByText } = renderWithTheme( | ||
<DatabaseScaleUp database={database} />, | ||
{ | ||
queryClient, | ||
} | ||
); | ||
await waitForElementToBeRemoved(getByTestId(loadingTestId)); | ||
expect( | ||
getByText(/Scale Up Database Cluster/i).closest('button') | ||
).toHaveAttribute('aria-disabled', 'true'); | ||
}); | ||
|
||
it('when a plan is selected, scale up button should be enabled and on click of it, it should show a confirmation dialog', async () => { | ||
// Mock route history so the Plan Selection table displays prices without requiring a region in the DB scale up flow. | ||
const history = createMemoryHistory(); | ||
history.push(`databases/${database.engine}/${database.id}/scale-up`); | ||
const { container, getByTestId, getByText } = renderWithTheme( | ||
<Router history={history}> | ||
<DatabaseScaleUp database={database} /> | ||
</Router>, | ||
{ | ||
queryClient, | ||
} | ||
); | ||
await waitForElementToBeRemoved(getByTestId(loadingTestId)); | ||
const getById = queryByAttribute.bind(null, 'id'); | ||
fireEvent.click(getById(container, examplePlanType)); | ||
const scaleUpButton = getByText(/Scale Up Database Cluster/i); | ||
expect(scaleUpButton.closest('button')).toHaveAttribute( | ||
'aria-disabled', | ||
'false' | ||
); | ||
fireEvent.click(scaleUpButton); | ||
getByText(`Scale up ${database.label}?`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.