-
Notifications
You must be signed in to change notification settings - Fork 334
Expand file tree
/
Copy pathdaemonsets.spec.ts
More file actions
367 lines (305 loc) · 14 KB
/
daemonsets.spec.ts
File metadata and controls
367 lines (305 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
import { WorkloadsDaemonsetsListPagePo, WorkLoadsDaemonsetsEditPagePo } from '@/cypress/e2e/po/pages/explorer/workloads-daemonsets.po';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import SortableTablePo from '@/cypress/e2e/po/components/sortable-table.po';
import ClusterDashboardPagePo from '@/cypress/e2e/po/pages/explorer/cluster-dashboard.po';
import { generateDaemonSetsDataSmall } from '@/cypress/e2e/blueprints/explorer/workloads/daemonsets/daemonsets-get';
import { SMALL_CONTAINER } from '@/cypress/e2e/tests/pages/explorer2/workloads/workload.utils';
describe('DaemonSets', { testIsolation: false, tags: ['@explorer2', '@adminUser'] }, () => {
const localCluster = 'local';
before(() => {
cy.login();
});
it('modifying "Scaling and Upgrade Policy" to "On Delete" should use the correct property "OnDelete"', () => {
const daemonsetName = 'daemonset-test';
// to test payload of https://github.com/rancher/dashboard/issues/9874
// we need to mock the PUT reply otherwise we get 409 conflict
cy.intercept('PUT', `/v1/apps.daemonsets/default/${ daemonsetName }`, (req: any) => {
req.reply({
statusCode: 200,
body: {}
});
}).as('daemonsetEdit');
// list view for daemonsets
const workloadsDaemonsetsListPage = new WorkloadsDaemonsetsListPagePo(localCluster);
workloadsDaemonsetsListPage.goTo();
workloadsDaemonsetsListPage.waitForPage();
workloadsDaemonsetsListPage.baseResourceList().masthead().create();
// create a new daemonset
const workloadsDaemonsetsEditPage = new WorkLoadsDaemonsetsEditPagePo(localCluster);
workloadsDaemonsetsEditPage.resourceDetail().createEditView().nameNsDescription()
.name()
.set(daemonsetName);
workloadsDaemonsetsEditPage.containerImageInput().set('nginx');
workloadsDaemonsetsEditPage.resourceDetail().cruResource().saveOrCreate()
.click();
workloadsDaemonsetsListPage.waitForPage();
workloadsDaemonsetsListPage.list().resourceTable().sortableTable()
.rowElementWithName(daemonsetName)
.should('be.visible');
workloadsDaemonsetsListPage.list().actionMenu(daemonsetName).getMenuItem('Edit Config')
.click();
// edit daemonset
workloadsDaemonsetsEditPage.clickTab('#DaemonSet');
workloadsDaemonsetsEditPage.clickTab('#upgrading');
workloadsDaemonsetsEditPage.ScalingUpgradePolicyRadioBtn().set(1);
workloadsDaemonsetsEditPage.resourceDetail().cruResource().saveOrCreate()
.click();
workloadsDaemonsetsListPage.baseResourceList().resourceTable().sortableTable()
.rowElementWithName(daemonsetName)
.should('be.visible');
cy.wait('@daemonsetEdit', { requestTimeout: 4000 }).then((req) => {
expect(req.request.body.spec.updateStrategy.type).to.equal('OnDelete');
});
});
describe('List', { tags: ['@noVai', '@adminUser'] }, () => {
const daemonSetsListPage = new WorkloadsDaemonsetsListPagePo(localCluster);
let uniqueDaemonSet = SortableTablePo.firstByDefaultName('daemonset');
let daemonSetNamesList = [];
let nsName1: string;
let nsName2: string;
let rootResourceName: string;
before('set up', () => {
cy.getRootE2EResourceName().then((root) => {
rootResourceName = root;
});
const createDs = (daemonSetName?: string) => {
return ({ ns, i }: {ns: string, i: number}) => {
const name = daemonSetName || Cypress._.uniqueId(`${ Date.now().toString() }-${ i }`);
return cy.createRancherResource('v1', 'apps.daemonset', JSON.stringify({
apiVersion: 'apps/v1',
kind: 'DaemonSet',
metadata: {
name,
namespace: ns
},
spec: {
selector: { matchLabels: { app: name } },
template: {
metadata: { labels: { app: name } },
spec: { containers: [SMALL_CONTAINER] }
}
}
}));
};
};
cy.createManyNamespacedResources({
context: 'daemonsets1',
createResource: createDs(),
})
.then(({ ns, workloadNames }) => {
daemonSetNamesList = workloadNames;
nsName1 = ns;
})
.then(() => cy.createManyNamespacedResources({
context: 'daemonsets2',
createResource: createDs(uniqueDaemonSet),
count: 1
}))
.then(({ ns, workloadNames }) => {
uniqueDaemonSet = workloadNames[0];
nsName2 = ns;
cy.tableRowsPerPageAndNamespaceFilter(10, localCluster, 'none', `{\"local\":[\"ns://${ nsName1 }\",\"ns://${ nsName2 }\"]}`);
});
});
it('pagination is visible and user is able to navigate through daemonsets data', () => {
ClusterDashboardPagePo.goToAndConfirmNsValues(localCluster, { nsProject: { values: [nsName1, nsName2] } });
WorkloadsDaemonsetsListPagePo.navTo();
daemonSetsListPage.waitForPage();
// check daemonsets count
const count = daemonSetNamesList.length + 1;
cy.waitForRancherResources('v1', 'apps.daemonset', count - 1, true).then((resp: Cypress.Response<any>) => {
// pagination is visible
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.checkVisible();
// basic checks on navigation buttons
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.beginningButton()
.isDisabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.leftButton()
.isDisabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.rightButton()
.isEnabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.endButton()
.isEnabled();
// check text before navigation
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.paginationText()
.then((el) => {
expect(el.trim()).to.eq(`1 - 10 of ${ count } DaemonSets`);
});
// navigate to next page - right button
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.rightButton()
.click();
// check text and buttons after navigation
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.paginationText()
.then((el) => {
expect(el.trim()).to.eq(`11 - 20 of ${ count } DaemonSets`);
});
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.beginningButton()
.isEnabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.leftButton()
.isEnabled();
// navigate to first page - left button
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.leftButton()
.click();
// check text and buttons after navigation
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.paginationText()
.then((el) => {
expect(el.trim()).to.eq(`1 - 10 of ${ count } DaemonSets`);
});
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.beginningButton()
.isDisabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.leftButton()
.isDisabled();
// navigate to last page - end button
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.endButton()
.scrollIntoView()
.click();
// row count on last page
let lastPageCount = count % 10;
if (lastPageCount === 0) {
lastPageCount = 10;
}
// check text after navigation
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.paginationText()
.then((el) => {
expect(el.trim()).to.eq(`${ count - (lastPageCount) + 1 } - ${ count } of ${ count } DaemonSets`);
});
// navigate to first page - beginning button
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.beginningButton()
.click();
// check text and buttons after navigation
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.paginationText()
.then((el) => {
expect(el.trim()).to.eq(`1 - 10 of ${ count } DaemonSets`);
});
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.beginningButton()
.isDisabled();
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.leftButton()
.isDisabled();
});
});
it('sorting changes the order of paginated daemonsets data', () => {
WorkloadsDaemonsetsListPagePo.navTo();
daemonSetsListPage.waitForPage();
// use filter to only show test data
daemonSetsListPage.list().resourceTable().sortableTable().filter(rootResourceName);
// check table is sorted by name in ASC order by default
daemonSetsListPage.list().resourceTable().sortableTable().tableHeaderRow()
.checkSortOrder(2, 'down');
// daemonset name should be visible on first page (sorted in ASC order)
daemonSetsListPage.list().resourceTable().sortableTable().tableHeaderRow()
.self()
.scrollIntoView();
daemonSetsListPage.list().resourceTable().sortableTable().rowElementWithName(daemonSetNamesList[0])
.scrollIntoView()
.should('be.visible');
// sort by name in DESC order
daemonSetsListPage.list().resourceTable().sortableTable().sort(2)
.click({ force: true });
daemonSetsListPage.list().resourceTable().sortableTable().tableHeaderRow()
.checkSortOrder(2, 'up');
// daemonset name should be NOT visible on first page (sorted in DESC order)
daemonSetsListPage.list().resourceTable().sortableTable().rowElementWithName(daemonSetNamesList[0])
.should('not.exist');
// navigate to last page
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.endButton()
.scrollIntoView()
.click();
// daemonset name should be visible on last page (sorted in DESC order)
daemonSetsListPage.list().resourceTable().sortableTable().rowElementWithName(daemonSetNamesList[0])
.scrollIntoView()
.should('be.visible');
});
it('filter daemonsets', () => {
WorkloadsDaemonsetsListPagePo.navTo();
daemonSetsListPage.waitForPage();
daemonSetsListPage.list().resourceTable().sortableTable().checkVisible();
daemonSetsListPage.list().resourceTable().sortableTable().checkLoadingIndicatorNotVisible();
daemonSetsListPage.list().resourceTable().sortableTable().checkRowCount(false, 10);
// filter by name
daemonSetsListPage.list().resourceTable().sortableTable().filter(daemonSetNamesList[0]);
daemonSetsListPage.list().resourceTable().sortableTable().checkRowCount(false, 1);
daemonSetsListPage.list().resourceTable().sortableTable().rowElementWithName(daemonSetNamesList[0])
.should('be.visible');
// filter by namespace
daemonSetsListPage.list().resourceTable().sortableTable().filter(nsName2);
daemonSetsListPage.list().resourceTable().sortableTable().checkRowCount(false, 1);
daemonSetsListPage.list().resourceTable().sortableTable().rowElementWithName(uniqueDaemonSet)
.should('be.visible');
});
it('pagination is hidden', () => {
cy.tableRowsPerPageAndNamespaceFilter(10, localCluster, 'none', '{"local":[]}');
// generate small set of daemonsets data
generateDaemonSetsDataSmall();
HomePagePo.goTo(); // this is needed here for the intercept to work
WorkloadsDaemonsetsListPagePo.navTo();
cy.wait('@daemonSetsDataSmall');
daemonSetsListPage.waitForPage();
daemonSetsListPage.list().resourceTable().sortableTable().checkVisible();
daemonSetsListPage.list().resourceTable().sortableTable().checkLoadingIndicatorNotVisible();
daemonSetsListPage.list().resourceTable().sortableTable().checkRowCount(false, 1);
daemonSetsListPage.list().resourceTable().sortableTable().pagination()
.checkNotExists();
});
after('clean up', () => {
// Ensure the default rows per page value is set after running the tests
cy.tableRowsPerPageAndNamespaceFilter(100, localCluster, 'none', '{"local":["all://user"]}');
// delete namespace (this will also delete all daemonsets in it)
cy.deleteNamespace([nsName1, nsName2]);
});
});
describe('Redeploy dialog', () => {
const daemonsetName = 'daemonset-test';
const apiResource = 'apps.daemonsets';
const redeployEndpoint = `/v1/${ apiResource }/default/${ daemonsetName }`;
const daemonSetsListPage = new WorkloadsDaemonsetsListPagePo(localCluster);
const openRedeployDialog = () => {
daemonSetsListPage.goTo();
daemonSetsListPage.waitForPage();
daemonSetsListPage
.list()
.actionMenu(daemonsetName)
.getMenuItem('Redeploy')
.click();
return daemonSetsListPage
.redeployDialog()
.shouldBeVisible()
.expectCancelButtonLabel('Cancel')
.expectApplyButtonLabel('Redeploy');
};
it('redeploys successfully after confirmation', () => {
const dialog = openRedeployDialog();
dialog.confirmRedeploy(redeployEndpoint);
dialog.shouldBeClosed();
});
it('does not send a request when cancelled', () => {
cy.intercept('PUT', redeployEndpoint).as('redeployCancelled');
const dialog = openRedeployDialog();
dialog.cancel().shouldBeClosed();
cy.get('@redeployCancelled.all').should('have.length', 0);
});
it('displays error banner on failure', () => {
const dialog = openRedeployDialog();
dialog.simulateRedeployError(redeployEndpoint);
});
});
});