Skip to content

Commit 9dd1d3d

Browse files
authored
change: [DPS-36769] - Filter clusters in Stream Form based on region capability (#13467)
1 parent 420685e commit 9dd1d3d

7 files changed

Lines changed: 327 additions & 77 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Added
3+
---
4+
5+
Add `ACLP Logs Datacenter LKE-E` to the Region's `Capability` type ([#13467](https://github.com/linode/manager/pull/13467))

packages/api-v4/src/regions/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { COUNTRY_CODE_TO_CONTINENT_CODE } from './constants';
22

33
export type Capabilities =
4+
| 'ACLP Logs Datacenter LKE-E'
45
| 'Backups'
56
| 'Bare Metal'
67
| 'Block Storage'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Changed
3+
---
4+
5+
Stream Create/Edit form: in the Clusters table show only clusters with a region that has "ACLP Logs Datacenter LKE-E" capability ([#13467](https://github.com/linode/manager/pull/13467))

packages/manager/cypress/e2e/core/delivery/create-stream.spec.ts

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { streamType } from '@linode/api-v4';
2+
import { regionFactory } from '@linode/utilities';
23
import { mockDestination } from 'support/constants/delivery';
34
import { mockGetAccount } from 'support/intercepts/account';
45
import {
@@ -9,6 +10,7 @@ import {
910
} from 'support/intercepts/delivery';
1011
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1112
import { mockGetClusters } from 'support/intercepts/lke';
13+
import { mockGetRegions } from 'support/intercepts/regions';
1214
import { ui } from 'support/ui';
1315
import { logsStreamForm } from 'support/ui/pages/logs-stream-form';
1416
import { randomLabel } from 'support/util/random';
@@ -179,25 +181,55 @@ describe('Create Stream', () => {
179181

180182
describe('given Kubernetes API Audit Logs Stream Type', () => {
181183
it('selects clusters and creates new stream', () => {
184+
const regionWithCapabilityAndCluster = regionFactory.build({
185+
id: 'us-southeast',
186+
label: 'Atlanta, GA',
187+
capabilities: ['ACLP Logs Datacenter LKE-E', 'Object Storage'],
188+
});
189+
const regionWithCapabilityNoCluster = regionFactory.build({
190+
id: 'us-chicago',
191+
label: 'Chicago, IL',
192+
capabilities: ['ACLP Logs Datacenter LKE-E', 'Object Storage'],
193+
});
194+
const regionNoCapabilityWithCluster = regionFactory.build({
195+
id: 'us-west',
196+
label: 'Fremont, CA',
197+
capabilities: ['Object Storage'],
198+
});
199+
200+
const cluster1 = kubernetesClusterFactory.build({
201+
id: 1,
202+
label: 'cluster-1',
203+
region: regionWithCapabilityAndCluster.id,
204+
control_plane: { audit_logs_enabled: true },
205+
});
206+
const cluster2 = kubernetesClusterFactory.build({
207+
id: 2,
208+
label: 'cluster-2',
209+
region: regionWithCapabilityAndCluster.id,
210+
control_plane: { audit_logs_enabled: false },
211+
});
212+
const cluster3 = kubernetesClusterFactory.build({
213+
id: 3,
214+
label: 'cluster-3',
215+
region: regionWithCapabilityAndCluster.id,
216+
control_plane: { audit_logs_enabled: true },
217+
});
218+
const clusterNoCap = kubernetesClusterFactory.build({
219+
id: 4,
220+
label: 'cluster-4',
221+
region: regionNoCapabilityWithCluster.id,
222+
control_plane: { audit_logs_enabled: true },
223+
});
224+
182225
// Mock API responses
183226
mockGetDestinations([mockDestination]);
184-
mockGetClusters([
185-
kubernetesClusterFactory.build({
186-
id: 1,
187-
label: 'cluster-1',
188-
control_plane: { audit_logs_enabled: true },
189-
}),
190-
kubernetesClusterFactory.build({
191-
id: 2,
192-
label: 'cluster-2',
193-
control_plane: { audit_logs_enabled: false },
194-
}),
195-
kubernetesClusterFactory.build({
196-
id: 3,
197-
label: 'cluster-3',
198-
control_plane: { audit_logs_enabled: true },
199-
}),
227+
mockGetRegions([
228+
regionWithCapabilityAndCluster,
229+
regionWithCapabilityNoCluster,
230+
regionNoCapabilityWithCluster,
200231
]);
232+
mockGetClusters([cluster1, cluster2, cluster3, clusterNoCap]);
201233

202234
// Visit the Create Stream page
203235
cy.visitWithLogin('/logs/delivery/streams/create');
@@ -213,9 +245,33 @@ describe('Create Stream', () => {
213245
// Select existing destination
214246
logsStreamForm.selectExistingDestination(mockDestination.label);
215247

248+
// Expect only 'Atlanta, GA' to be in Region Select (has capability and is in clusters)
249+
ui.regionSelect.find().should('be.visible').click();
250+
251+
ui.autocompletePopper
252+
.findByTitle(regionWithCapabilityAndCluster.id, { exact: false })
253+
.should('be.visible');
254+
255+
ui.autocompletePopper
256+
.find()
257+
.should('not.contain', regionWithCapabilityNoCluster.id);
258+
259+
ui.autocompletePopper
260+
.find()
261+
.should('not.contain', regionNoCapabilityWithCluster.id);
262+
263+
// Close the dropdown
264+
ui.regionSelect.find().type('{esc}');
265+
216266
cy.findByText('Clusters').should('be.visible');
217267
cy.get('[data-testid="clusters-table"]').should('exist');
218268

269+
// Expect only cluster-1, cluster-2, cluster-3 to be in table.
270+
cy.findByText('cluster-1').should('be.visible');
271+
cy.findByText('cluster-2').should('be.visible');
272+
cy.findByText('cluster-3').should('be.visible');
273+
cy.findByText('cluster-4').should('not.exist');
274+
219275
// Select cluster-1 and cluster-3 individually
220276
logsStreamForm.findClusterCheckbox('cluster-1').check();
221277

packages/manager/cypress/e2e/core/delivery/edit-stream.spec.ts

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { regionFactory } from '@linode/utilities';
12
import {
23
mockAuditLogsStream,
34
mockAuditLogsStreamPayload,
@@ -15,6 +16,7 @@ import {
1516
} from 'support/intercepts/delivery';
1617
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1718
import { mockGetClusters } from 'support/intercepts/lke';
19+
import { mockGetRegions } from 'support/intercepts/regions';
1820
import { ui } from 'support/ui';
1921
import { logsStreamForm } from 'support/ui/pages/logs-stream-form';
2022
import { randomLabel } from 'support/util/random';
@@ -147,28 +149,61 @@ describe('Edit Stream', () => {
147149

148150
describe('given Kubernetes API Audit Logs Stream Type', () => {
149151
it('edits stream label and clusters and saves', () => {
152+
const regionWithCapabilityAndCluster = regionFactory.build({
153+
id: 'us-southeast',
154+
label: 'Atlanta, GA',
155+
capabilities: ['ACLP Logs Datacenter LKE-E', 'Object Storage'],
156+
});
157+
const regionWithCapabilityNoCluster = regionFactory.build({
158+
id: 'us-chicago',
159+
label: 'Chicago, IL',
160+
capabilities: ['ACLP Logs Datacenter LKE-E', 'Object Storage'],
161+
});
162+
const regionNoCapabilityWithCluster = regionFactory.build({
163+
id: 'us-west',
164+
label: 'Fremont, CA',
165+
capabilities: ['Object Storage'],
166+
});
167+
168+
const cluster1 = kubernetesClusterFactory.build({
169+
id: 1,
170+
label: 'cluster-1',
171+
region: regionWithCapabilityAndCluster.id,
172+
control_plane: { audit_logs_enabled: true },
173+
});
174+
const cluster2 = kubernetesClusterFactory.build({
175+
id: 2,
176+
label: 'cluster-2',
177+
region: regionWithCapabilityAndCluster.id,
178+
control_plane: { audit_logs_enabled: false },
179+
});
180+
const cluster3 = kubernetesClusterFactory.build({
181+
id: 3,
182+
label: 'cluster-3',
183+
region: regionWithCapabilityAndCluster.id,
184+
control_plane: { audit_logs_enabled: true },
185+
});
186+
const cluster4 = kubernetesClusterFactory.build({
187+
id: 4,
188+
label: 'cluster-no-cap',
189+
region: regionNoCapabilityWithCluster.id,
190+
control_plane: { audit_logs_enabled: true },
191+
});
192+
150193
// Mock API responses
151194
mockGetDestinations([mockDestination]);
152195
mockGetDestination(mockDestination);
153196
mockGetStreams([mockLKEAuditLogsStream]);
154-
mockGetStream(mockLKEAuditLogsStream);
155-
mockGetClusters([
156-
kubernetesClusterFactory.build({
157-
id: 1,
158-
label: 'cluster-1',
159-
control_plane: { audit_logs_enabled: true },
160-
}),
161-
kubernetesClusterFactory.build({
162-
id: 2,
163-
label: 'cluster-2',
164-
control_plane: { audit_logs_enabled: false },
165-
}),
166-
kubernetesClusterFactory.build({
167-
id: 3,
168-
label: 'cluster-3',
169-
control_plane: { audit_logs_enabled: true },
170-
}),
197+
mockGetStream({
198+
...mockLKEAuditLogsStream,
199+
details: { cluster_ids: [1, 3] },
200+
});
201+
mockGetRegions([
202+
regionWithCapabilityAndCluster,
203+
regionWithCapabilityNoCluster,
204+
regionNoCapabilityWithCluster,
171205
]);
206+
mockGetClusters([cluster1, cluster2, cluster3, cluster4]);
172207

173208
// Visit the Edit Stream page
174209
cy.visitWithLogin(
@@ -196,10 +231,34 @@ describe('Edit Stream', () => {
196231
.should('be.disabled')
197232
.should('have.attr', 'value', 'Kubernetes API Audit Logs');
198233

234+
// Expect only 'Atlanta, GA' to be in Region Select (has capability and is in clusters)
235+
ui.regionSelect.find().should('be.visible').click();
236+
237+
ui.autocompletePopper
238+
.findByTitle(regionWithCapabilityAndCluster.id, { exact: false })
239+
.should('be.visible');
240+
241+
ui.autocompletePopper
242+
.find()
243+
.should('not.contain', regionWithCapabilityNoCluster.id);
244+
245+
ui.autocompletePopper
246+
.find()
247+
.should('not.contain', regionNoCapabilityWithCluster.id);
248+
249+
// Close the dropdown
250+
ui.regionSelect.find().type('{esc}');
251+
199252
// Clusters table should be visible
200253
cy.findByText('Clusters').should('be.visible');
201254
cy.get('[data-testid="clusters-table"]').should('exist');
202255

256+
// Verify Clusters Table content
257+
cy.findByText('cluster-1').should('be.visible');
258+
cy.findByText('cluster-2').should('be.visible');
259+
cy.findByText('cluster-3').should('be.visible');
260+
cy.findByText('cluster-4').should('not.exist');
261+
203262
// Initially selected clusters should be checked
204263
logsStreamForm.findClusterCheckbox('cluster-1').should('be.checked');
205264
logsStreamForm.findClusterCheckbox('cluster-3').should('be.checked');

0 commit comments

Comments
 (0)