-
Notifications
You must be signed in to change notification settings - Fork 165
/
admin_portal.go
400 lines (315 loc) · 15.2 KB
/
admin_portal.go
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
package e2e
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"errors"
"fmt"
"os"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
conditions "github.com/serge1peshcoff/selenium-go-conditions"
"github.com/tebeka/selenium"
)
var _ = Describe("Admin Portal E2E Testing", func() {
BeforeEach(
func() {
skipIfNotInDevelopmentEnv()
skipIfSeleniumNotEnabled()
},
)
var wdPoint *selenium.WebDriver
var wd selenium.WebDriver
var host string
var clusterDetailTabs = []string{"Overview", "Nodes", "Machines", "MachineSets", "APIStatistics", "KCMStatistics", "DNSStatistics", "IngressStatistics", "ClusterOperators"}
JustBeforeEach(func() {
host, wdPoint = adminPortalSessionSetup()
wd = *wdPoint
wd.Get(host + "/")
wd.Refresh()
})
JustAfterEach(func() {
if CurrentSpecReport().Failed() {
if wd != nil {
SaveScreenshot(wd, errors.New(CurrentSpecReport().FailureMessage()))
}
}
})
AfterEach(func() {
if wd != nil {
wd.Quit()
}
})
It("Should be able to populate cluster data correctly", func() {
err := wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[data-automation-key='name']"))
Expect(err).ToNot(HaveOccurred())
cluster, err := wd.FindElement(selenium.ByCSSSelector, "div[data-automation-key='name']")
Expect(err).ToNot(HaveOccurred())
Expect(cluster.Text()).To(Equal(os.Getenv("CLUSTER")))
})
It("Should be able to filter cluster data correctly", func() {
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[data-automation-key='name']"))
filter, err := wd.FindElement(selenium.ByCSSSelector, "input[placeholder='Filter on resource ID']")
Expect(err).ToNot(HaveOccurred())
// Set filter so it doesn't match cluster name
filter.SendKeys("Incorrect Cluster")
wd.Wait(conditions.ElementIsLocated(selenium.ByID, "ClusterCount"))
text, err := wd.FindElement(selenium.ByID, "ClusterCount")
Expect(err).ToNot(HaveOccurred())
Expect(text.Text()).To(Equal("Showing 0 items"))
})
It("Should be able to populate cluster info panel correctly", func() {
err := wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[data-automation-key='name']"))
Expect(err).ToNot(HaveOccurred())
cluster, err := wd.FindElement(selenium.ByCSSSelector, "div[data-automation-key='name']")
Expect(err).ToNot(HaveOccurred())
err = cluster.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, ".clusterOverviewList"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(noContentIsLoading, 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
list, err := wd.FindElement(selenium.ByCSSSelector, ".clusterOverviewList")
Expect(err).ToNot(HaveOccurred())
expectedProperties := []string{
"ApiServer Visibility",
"ApiServer URL",
"Architecture Version",
"Console Link",
"Created At",
"Created By",
"Failed Provisioning State",
"Infra Id",
"Last Admin Update Error",
"Last Modified At",
"Last Modified By",
"Last Provisioning State",
"Location",
"Name",
"Provisioning State",
"Resource Id",
"Version",
"Installation Status",
}
Eventually(func(g Gomega) {
for i, wantName := range expectedProperties {
cell, err := list.FindElement(selenium.ByCSSSelector, fmt.Sprintf("div[data-automationid='ListCell'][data-list-index='%d']", i))
Expect(err).ToNot(HaveOccurred())
name, err := cell.FindElement(selenium.ByCSSSelector, "div[data-automationid='DetailsRowCell'][data-automation-key='name']")
Expect(err).ToNot(HaveOccurred())
Expect(name.Text()).To(Equal(wantName))
value, err := cell.FindElement(selenium.ByCSSSelector, "div[data-automationid='DetailsRowCell'][data-automation-key='value']")
Expect(err).ToNot(HaveOccurred())
Expect(value.Text()).To(Not(Equal("")))
}
}).WithTimeout(time.Minute).WithPolling(time.Second).Should(Succeed())
})
It("Should be able to copy cluster resource id", func() {
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "button[aria-label='Copy Resource ID']"))
button, err := wd.FindElement(selenium.ByCSSSelector, "button[aria-label='Copy Resource ID']")
Expect(err).ToNot(HaveOccurred())
button.Click()
filter, err := wd.FindElement(selenium.ByCSSSelector, "input[placeholder='Filter on resource ID']")
Expect(err).ToNot(HaveOccurred())
// Paste clipboard
filter.Click()
filter.SendKeys(selenium.ControlKey + "v")
resourceId, err := filter.GetAttribute("value")
Expect(err).ToNot(HaveOccurred())
Expect(resourceId).To(ContainSubstring("/providers/Microsoft.RedHatOpenShift/openShiftClusters/" + os.Getenv("CLUSTER")))
})
It("Should be able to open ssh panel and get ssh details", func() {
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "button[aria-label='SSH']"))
button, err := wd.FindElement(selenium.ByCSSSelector, "button[aria-label='SSH']")
Expect(err).ToNot(HaveOccurred())
button.Click()
wd.Wait(conditions.ElementIsLocated(selenium.ByID, "sshModal"))
wd.Wait(conditions.ElementIsLocated(selenium.ByID, "sshDropdown"))
sshDropdown, err := wd.FindElement(selenium.ByID, "sshDropdown")
Expect(err).ToNot(HaveOccurred())
sshDropdown.Click()
wd.Wait(conditions.ElementIsLocated(selenium.ByID, "sshDropdown-list0"))
machine, err := wd.FindElement(selenium.ByID, "sshDropdown-list0")
Expect(err).ToNot(HaveOccurred())
machine.Click()
wd.Wait(conditions.ElementIsLocated(selenium.ByID, "sshButton"))
requestBtn, err := wd.FindElement(selenium.ByID, "sshButton")
Expect(err).ToNot(HaveOccurred())
requestBtn.Click()
// Test fails if these labels aren't present
err = wd.Wait(conditions.ElementIsLocated(selenium.ByID, "sshCommand"))
Expect(err).ToNot(HaveOccurred())
})
It("Should be able to navigate to other regions", func() {
NUMBER_OF_REGIONS := 41
err := wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "RegionNavButton"), time.Second*30)
Expect(err).ToNot(HaveOccurred())
button, err := wd.FindElement(selenium.ByID, "RegionNavButton")
Expect(err).ToNot(HaveOccurred())
button.Click()
panel, err := wd.FindElement(selenium.ByID, "RegionsPanel")
Expect(err).ToNot(HaveOccurred())
regionList, err := panel.FindElement(selenium.ByTagName, "ul")
Expect(err).ToNot(HaveOccurred())
regions, err := regionList.FindElements(selenium.ByTagName, "li")
Expect(err).ToNot(HaveOccurred())
Expect(regions).To(HaveLen(NUMBER_OF_REGIONS))
for _, region := range regions {
link, err := region.FindElement(selenium.ByTagName, "a")
Expect(err).ToNot(HaveOccurred())
Expect(link.GetAttribute("href")).To(MatchRegexp(`https://([a-z]|[0-9])+\.admin\.aro\.azure\.com`))
}
})
It("Should display the correct cluster detail view for the resource ID parameter in the URL", func() {
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)
detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())
elem, err := wd.FindElement(selenium.ByID, "ClusterDetailName")
Expect(err).ToNot(HaveOccurred())
Expect(elem.Text()).To(Equal(clusterName))
})
It("Should update URL for each tab in cluster detail page", func() {
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)
detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())
for _, tab := range clusterDetailTabs {
button, err := wd.FindElement(selenium.ByCSSSelector, fmt.Sprintf("div[name='%s']", tab))
Expect(err).ToNot(HaveOccurred())
button.Click()
currentUrl, err := wd.CurrentURL()
Expect(err).ToNot(HaveOccurred())
Expect(currentUrl).To(HaveSuffix("%s%s/%s", host, resourceIDFromEnv(), strings.ToLower(tab)))
}
})
It("Should display refresh button to get latest details for each tab in cluster detail page", func() {
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)
detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[aria-label='Refresh']"))
// Check refresh button clicked event for Overview Tab
button, err := wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(noContentIsLoading, 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for Nodes Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='Nodes']"))
nodesButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='Nodes']")
Expect(err).ToNot(HaveOccurred())
nodesButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for Machines Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='Machines']"))
machinesButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='Machines']")
Expect(err).ToNot(HaveOccurred())
machinesButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for Machine Sets Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='MachineSets']"))
machineSetsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='MachineSets']")
Expect(err).ToNot(HaveOccurred())
machineSetsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for API Statistics Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='APIStatistics']"))
apiStatisticsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='APIStatistics']")
Expect(err).ToNot(HaveOccurred())
apiStatisticsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for KCM Statistics Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='KCMStatistics']"))
kcmStatisticsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='KCMStatistics']")
Expect(err).ToNot(HaveOccurred())
kcmStatisticsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for DNS Statistics Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='DNSStatistics']"))
dnsStatisticsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='DNSStatistics']")
Expect(err).ToNot(HaveOccurred())
dnsStatisticsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for Ingress Statistics Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='IngressStatistics']"))
ingressStatisticsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='IngressStatistics']")
Expect(err).ToNot(HaveOccurred())
ingressStatisticsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
// Check refresh button clicked event for Cluster Operators Tab
wd.Wait(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[name='ClusterOperators']"))
clusterOperatorsButton, err := wd.FindElement(selenium.ByCSSSelector, "div[name='ClusterOperators']")
Expect(err).ToNot(HaveOccurred())
clusterOperatorsButton.Click()
button, err = wd.FindElement(selenium.ByCSSSelector, "div[aria-label='Refresh']")
Expect(err).ToNot(HaveOccurred())
err = button.Click()
Expect(err).ToNot(HaveOccurred())
err = wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByCSSSelector, "div[role='presentation']"), 2*time.Minute)
Expect(err).ToNot(HaveOccurred())
})
It("Should display the action icons on cluster detail page", func() {
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)
detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())
resourceButton, err := wd.FindElement(selenium.ByCSSSelector, "button[aria-label='Copy Resource ID']")
Expect(err).ToNot(HaveOccurred())
Expect(resourceButton.IsDisplayed()).To(BeTrue())
prometheusButton, err := wd.FindElement(selenium.ByCSSSelector, "a[aria-label='Prometheus']")
Expect(err).ToNot(HaveOccurred())
Expect(prometheusButton.IsDisplayed()).To(BeTrue())
sshbutton, err := wd.FindElement(selenium.ByCSSSelector, "button[aria-label='SSH']")
Expect(err).ToNot(HaveOccurred())
Expect(sshbutton.IsDisplayed()).To(BeTrue())
kubeconfigButton, err := wd.FindElement(selenium.ByCSSSelector, "button[aria-label='Download Kubeconfig']")
Expect(err).ToNot(HaveOccurred())
Expect(kubeconfigButton.IsDisplayed()).To(BeTrue())
})
})
func noContentIsLoading(wd selenium.WebDriver) (bool, error) {
shimmerElements, err := wd.FindElements(selenium.ByCSSSelector, ".ms-Shimmer-container")
return len(shimmerElements) == 0, err
}