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

upcoming: [DI-20595] - ACLP Supported regions per service type #11382

Merged
merged 21 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ae045fb
upcoming: [DI-20595] - ACLP Supported regions per service type
ankita-akamai Dec 2, 2024
b576975
upcoming: [DI-20595] - small fix
ankita-akamai Dec 2, 2024
1832509
upcoming: [DI-20595] - improved test quality
ankita-akamai Dec 3, 2024
78a1489
upcoming: [DI-20595] - PR Comments
ankita-akamai Dec 3, 2024
615c573
upcoming: [DI-20595] - small fix
ankita-akamai Dec 3, 2024
19db96e
upcoming: [DI-20595] - updated UT
ankita-akamai Dec 3, 2024
00d89ed
upcoming: [DI-20595] - updated UT
ankita-akamai Dec 3, 2024
5614b9b
upcoming: [DI-20595] - updated types
ankita-akamai Dec 3, 2024
1dcb4af
upcoming: [DI-20595] - small linting fix
ankita-akamai Dec 3, 2024
a6cb633
upcoming: [DI-20595] - handle empty regions
ankita-akamai Dec 5, 2024
d748c7d
upcoming: [DI-20595] - Added changeset
ankita-akamai Dec 6, 2024
2854e2d
upcoming: [DI-20595] - Added changeset
ankita-akamai Dec 6, 2024
d224809
upcoming: [DI-20595] - edge case fix
ankita-akamai Dec 9, 2024
9cef426
upcoming: [DI-20595] - linting fix
ankita-akamai Dec 9, 2024
0e3f89c
Test[DI-20595] -add region select testcases
agorthi-akamai Dec 9, 2024
398d3b6
Merge pull request #1 from agorthi-akamai/supported_regions
ankita-akamai Dec 9, 2024
f5cfdb2
upcoming: [DI-20595] - PR Comments
ankita-akamai Dec 10, 2024
c94801d
upcoming: [DI-20595] - PR Comments
ankita-akamai Dec 10, 2024
e74d09f
upcoming: [DI-20595] - linting fix
ankita-akamai Dec 10, 2024
9edb799
upcoming: [DI-20595] - linting fix
ankita-akamai Dec 10, 2024
1cb3c4b
upcoming: [DI-20595] - linting fix
ankita-akamai Dec 10, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Show ACLP supported regions per service type in region select ([#11382](https://github.com/linode/manager/pull/11382))
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from 'support/intercepts/databases';
import { Database } from '@linode/api-v4';
import { mockGetAccount } from 'support/intercepts/account';
import { Flags } from 'src/featureFlags';

/**
* Verifies the presence and values of specific properties within the aclpPreference object
Expand All @@ -44,6 +45,24 @@ import { mockGetAccount } from 'support/intercepts/account';
* @param requestPayload - The payload received from the request, containing the aclpPreference object.
* @param expectedValues - An object containing the expected values for properties to validate against the requestPayload.
*/

const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: 'us-ord',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: 'us-ord',
},
],
};
const {
metrics,
id,
Expand Down Expand Up @@ -78,10 +97,9 @@ const metricDefinitions = {
};

const mockRegion = regionFactory.build({
capabilities: ['Linodes'],
capabilities: ['Managed Databases'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
});

const databaseMock: Database = databaseFactory.build({
Expand All @@ -97,9 +115,7 @@ const mockAccount = accountFactory.build();

describe('Tests for API error handling', () => {
beforeEach(() => {
mockAppendFeatureFlags({
aclp: { beta: true, enabled: true },
});
mockAppendFeatureFlags(flags);
mockGetAccount(mockAccount);
mockGetCloudPulseMetricDefinitions(serviceType, metricDefinitions);
mockGetCloudPulseDashboards(serviceType, [dashboard]).as('fetchDashboard');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { mockGetAccount } from 'support/intercepts/account';
import { mockGetLinodes } from 'support/intercepts/linodes';
import { mockGetUserPreferences } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { extendRegion } from 'support/util/regions';
import { CloudPulseMetricsResponse, Database } from '@linode/api-v4';
import { Interception } from 'cypress/types/net-stubbing';
import { generateRandomMetricsData } from 'support/util/cloudpulse';
Expand All @@ -49,14 +48,29 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';

const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: '',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: 'us-ord',
},
],
};

const {
metrics,
id,
serviceType,
dashboardName,
region,
engine,
clusterName,
nodeType,
Expand Down Expand Up @@ -91,14 +105,18 @@ const mockLinode = linodeFactory.build({
});

const mockAccount = accountFactory.build();
const mockRegion = extendRegion(
regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
})
);

const mockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-ord',
label: 'Chicago, IL',
});

const extendedMockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-east',
label: 'Newark,NL',
});
const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
data: generateRandomMetricsData(timeDurationToSelect, '5 min'),
});
Expand Down Expand Up @@ -151,9 +169,9 @@ const getWidgetLegendRowValuesFromResponse = (
};

const databaseMock: Database = databaseFactory.build({
label: widgetDetails.dbaas.clusterName,
type: widgetDetails.dbaas.engine,
region: widgetDetails.dbaas.region,
label: clusterName,
type: engine,
region: mockRegion.label,
version: '1',
status: 'provisioning',
cluster_size: 1,
Expand All @@ -177,7 +195,7 @@ describe('Integration Tests for DBaaS Dashboard ', () => {
mockCreateCloudPulseMetrics(serviceType, metricsAPIResponsePayload).as(
'getMetrics'
);
mockGetRegions([mockRegion]);
mockGetRegions([mockRegion, extendedMockRegion]);
mockGetUserPreferences({});
mockGetDatabases([databaseMock]).as('getDatabases');

Expand All @@ -191,35 +209,60 @@ describe('Integration Tests for DBaaS Dashboard ', () => {
ui.autocomplete
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');
.type(dashboardName);

ui.autocompletePopper
.findByTitle(dashboardName)
.should('be.visible')
.click();

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');
.type(timeDurationToSelect);

ui.autocompletePopper
.findByTitle(timeDurationToSelect)
.should('be.visible')
.click();

//Select a Engine from the autocomplete input.
//Select a Database Engine from the autocomplete input.
ui.autocomplete
.findByLabel('Database Engine')
.should('be.visible')
.type(`${engine}{enter}`)
.should('be.visible');
.type(engine);

ui.autocompletePopper.findByTitle(engine).should('be.visible').click();

// Select a region from the dropdown.
ui.regionSelect.find().click();

// Select a region from the dropdown.
ui.regionSelect.find().click().type(`${region}{enter}`);
ui.regionSelect.find().type(extendedMockRegion.label);

// Since DBaaS does not support this region, we expect it to not be in the dropdown.

ui.autocompletePopper.find().within(() => {
cy.findByText(
`${extendedMockRegion.label} (${extendedMockRegion.id})`
).should('not.exist');
});

// Select a resource from the autocomplete input.
ui.regionSelect.find().click().clear();
ui.regionSelect
.findItemByRegionId(mockRegion.id, [mockRegion])
.should('be.visible')
.click();

// Select a resource (Database Clusters) from the autocomplete input.
ui.autocomplete
.findByLabel('Database Clusters')
.should('be.visible')
.type(`${clusterName}{enter}`)
.click();
cy.findByText(clusterName).should('be.visible');
.type(clusterName);

ui.autocompletePopper.findByTitle(clusterName).should('be.visible').click();

//Select a Node from the autocomplete input.
// Select a Node from the autocomplete input.
ui.autocomplete
.findByLabel('Node Type')
.should('be.visible')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { mockGetAccount } from 'support/intercepts/account';
import { mockGetLinodes } from 'support/intercepts/linodes';
import { mockGetUserPreferences } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { extendRegion } from 'support/util/regions';
import { CloudPulseMetricsResponse } from '@linode/api-v4';
import { generateRandomMetricsData } from 'support/util/cloudpulse';
import { Interception } from 'cypress/types/net-stubbing';
Expand All @@ -46,15 +45,25 @@ import { formatToolTip } from 'src/features/CloudPulse/Utils/unitConversion';
*/
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
const timeDurationToSelect = 'Last 24 Hours';
const flags: Partial<Flags> = { aclp: { enabled: true, beta: true } };
const {
metrics,
id,
serviceType,
dashboardName,
region,
resource,
} = widgetDetails.linode;
const flags: Partial<Flags> = {
aclp: { enabled: true, beta: true },
aclpResourceTypeMap: [
{
dimensionKey: 'LINODE_ID',
maxResourceSelections: 10,
serviceType: 'linode',
supportedRegionIds: 'us-ord',
},
{
dimensionKey: 'cluster_id',
maxResourceSelections: 10,
serviceType: 'dbaas',
supportedRegionIds: '',
},
],
};
const { metrics, id, serviceType, dashboardName, region, resource } =
widgetDetails.linode;

const dashboard = dashboardFactory.build({
label: dashboardName,
Expand Down Expand Up @@ -85,14 +94,18 @@ const mockLinode = linodeFactory.build({
});

const mockAccount = accountFactory.build();
const mockRegion = extendRegion(
regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
country: 'us',
})
);

const mockRegion = regionFactory.build({
capabilities: ['Linodes'],
id: 'us-ord',
label: 'Chicago, IL',
});

const extendedMockRegion = regionFactory.build({
capabilities: ['Managed Databases'],
id: 'us-east',
label: 'Newark,NL',
});
const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
data: generateRandomMetricsData(timeDurationToSelect, '5 min'),
});
Expand Down Expand Up @@ -170,18 +183,41 @@ describe('Integration Tests for Linode Dashboard ', () => {
ui.autocomplete
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');
.type(dashboardName);

ui.autocompletePopper
.findByTitle(dashboardName)
.should('be.visible')
.click();

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');
.type(timeDurationToSelect);

ui.autocompletePopper
.findByTitle(timeDurationToSelect)
.should('be.visible')
.click();

ui.regionSelect.find().click();

// Select a region from the dropdown.
ui.regionSelect.find().click();

ui.regionSelect.find().type(extendedMockRegion.label);

// Since Linode does not support this region, we expect it to not be in the dropdown.

ui.autocompletePopper.find().within(() => {
cy.findByText(
`${extendedMockRegion.label} (${extendedMockRegion.id})`
).should('not.exist');
});

// Select a region from the dropdown.
ui.regionSelect.find().click().type(`${region}{enter}`);
ui.regionSelect.find().click().clear().type(`${region}{enter}`);

// Select a resource from the autocomplete input.
ui.autocomplete
Expand All @@ -191,6 +227,7 @@ describe('Integration Tests for Linode Dashboard ', () => {
.click();

cy.findByText(resource).should('be.visible');

// Wait for all metrics query requests to resolve.
cy.wait(['@getMetrics', '@getMetrics', '@getMetrics', '@getMetrics']);
});
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 @@ -73,6 +73,7 @@ export interface CloudPulseResourceTypeMapFlag {
dimensionKey: string;
maxResourceSelections?: number;
serviceType: string;
supportedRegionIds?: string;
}

interface gpuV2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { CloudPulseSelectTypes } from './models';
import type { CloudPulseServiceTypeFilterMap } from './models';

const TIME_DURATION = 'Time Range';
export const DBAAS_CAPABILITY = 'Managed Databases';
export const LINODE_CAPABILITY = 'Linodes';

export const LINODE_CONFIG: Readonly<CloudPulseServiceTypeFilterMap> = {
capability: LINODE_CAPABILITY,
filters: [
{
configuration: {
Expand Down Expand Up @@ -52,6 +55,7 @@ export const LINODE_CONFIG: Readonly<CloudPulseServiceTypeFilterMap> = {
};

export const DBAAS_CONFIG: Readonly<CloudPulseServiceTypeFilterMap> = {
capability: DBAAS_CAPABILITY,
filters: [
{
configuration: {
Expand Down
10 changes: 9 additions & 1 deletion packages/manager/src/features/CloudPulse/Utils/models.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import type { DatabaseEngine, DatabaseType } from '@linode/api-v4';
import type {
Capabilities,
DatabaseEngine,
DatabaseType,
} from '@linode/api-v4';
import type { QueryFunction, QueryKey } from '@tanstack/react-query';

/**
* The CloudPulseServiceTypeMap has list of filters to be built for different service types like dbaas, linode etc.,The properties here are readonly as it is only for reading and can't be modified in code
*/
export interface CloudPulseServiceTypeFilterMap {
/**
* Current capability corresponding to a service type
*/
readonly capability: Capabilities;
/**
* The list of filters for a service type
*/
Expand Down
Loading
Loading