Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [UIE-6937] - Add the ability to scale up DBaaS #9869

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f45a915
feat: [UIE-6937] - Add the ability to scale DBaaS
grevanak-akamai Nov 3, 2023
0a16c3f
Added changeset: Add the ability to scale up DBaaS
grevanak-akamai Nov 3, 2023
27dc1bd
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 3, 2023
d471ff2
Merge remote-tracking branch 'upstream/develop' into feature/UIE-6937…
grevanak-akamai Nov 3, 2023
5500c72
Addressed review comments
grevanak-akamai Nov 9, 2023
163f3f3
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 9, 2023
395b08e
Show confirmation popup message conditionally based on node size of c…
grevanak-akamai Nov 10, 2023
cf1d341
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 13, 2023
f48b783
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 13, 2023
7fca765
Resolved merge conflicts
grevanak-akamai Nov 15, 2023
25a8629
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 16, 2023
4cf9572
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 17, 2023
53dc27b
Addressed review comments
grevanak-akamai Nov 17, 2023
cc90f39
Fixed issue with unit test case and addressed review comments
grevanak-akamai Nov 20, 2023
0507140
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 20, 2023
82502ab
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Nov 21, 2023
0466e33
Update logic to disable smaller plans in plan selection table
grevanak-akamai Nov 21, 2023
7f8d5ca
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Dec 19, 2023
c3616d6
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Dec 19, 2023
5699fe1
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Dec 20, 2023
7aed478
UIE-7092: Added feature flag, disable tabs other than active one and …
grevanak-akamai Dec 20, 2023
dbd8638
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Dec 22, 2023
a5feff9
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Jan 3, 2024
09af88d
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Jan 5, 2024
b28ab66
Addressed review comments
grevanak-akamai Jan 5, 2024
2422a85
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Jan 5, 2024
620ba3c
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Jan 8, 2024
6f1338b
Resolve merge conflicts
grevanak-akamai Jan 8, 2024
62adfa8
Addressed review comments
grevanak-akamai Jan 9, 2024
28bfbcf
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
grevanak-akamai Jan 9, 2024
cd36ff5
Fix unit test
grevanak-akamai Jan 9, 2024
3fad2cf
Merge branch 'develop' into feature/UIE-6937-dbaas-vertical-scaling
bnussman Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-9869-added-1703002185530.md
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))
1 change: 1 addition & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export type EventAction =
| 'community_question_reply'
| 'credit_card_updated'
| 'database_low_disk_space'
| 'database_scale'
| 'database_backup_restore'
| 'database_create'
| 'database_credentials_reset'
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v4/src/databases/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const getEngineDatabase = (engine: Engine, databaseID: number) =>
/**
* updateDatabase
*
* Update the label or allowed IPs of an
* Update the label or allowed IPs or plan of an
* existing database
*
*/
Expand Down
1 change: 1 addition & 0 deletions packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export interface UpdateDatabasePayload {
label?: string;
allow_list?: string[];
updates?: UpdatesSchedule;
type?: string;
grevanak-akamai marked this conversation as resolved.
Show resolved Hide resolved
}

export interface UpdateDatabaseResponse {
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-9869-added-1699013625860.md
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))
11 changes: 10 additions & 1 deletion packages/manager/src/components/TabbedPanel/TabbedPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { TabList } from 'src/components/Tabs/TabList';
import { TabPanel } from 'src/components/Tabs/TabPanel';
import { TabPanels } from 'src/components/Tabs/TabPanels';
import { Tabs } from 'src/components/Tabs/Tabs';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { Typography } from 'src/components/Typography';

import { Box } from '../Box';

export interface Tab {
disabled?: boolean;
render: (props: any) => JSX.Element | null;
title: string;
}
Expand All @@ -31,6 +33,7 @@ interface TabbedPanelProps {
noPadding?: boolean;
rootClass?: string;
sx?: SxProps;
tabDisabledMessage?: string;
tabs: Tab[];
value?: number;
}
Expand Down Expand Up @@ -89,8 +92,14 @@ const TabbedPanel = React.memo((props: TabbedPanelProps) => {
<StyledTabs index={tabIndex} onChange={tabChangeHandler}>
<StyledTabList>
{tabs.map((tab, idx) => (
<StyledTab key={`tabs-${tab.title}-${idx}`}>
<StyledTab
disabled={tab.disabled}
key={`tabs-${tab.title}-${idx}`}
>
{tab.title}
{tab.disabled && props.tabDisabledMessage && (
<TooltipIcon status="help" text={props.tabDisabledMessage} />
grevanak-akamai marked this conversation as resolved.
Show resolved Hide resolved
)}
</StyledTab>
))}
</StyledTabList>
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface Flags {
aglbFullCreateFlow: boolean;
apiMaintenance: APIMaintenance;
databaseBeta: boolean;
databaseScaleUp: boolean;
databases: boolean;
dcGetWell: boolean;
firewallNodebalancer: boolean;
Expand Down
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,
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
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')
).toBeDisabled();
});

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')).not.toBeDisabled();
fireEvent.click(scaleUpButton);
getByText(`Scale up ${database.label}?`);
});
});
});
Loading