Skip to content

Commit 7681e96

Browse files
authored
Extended capd acceptance tests for bootstrapping and profile installtion (#389)
Co-authored-by: Saeed Fazal <[email protected]>
1 parent 2701ea3 commit 7681e96

18 files changed

+3150
-337
lines changed

.github/workflows/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
TOTP_TOKEN: ${{ secrets.WGE_GITHUB_MFA_KEY }}
101101
DOCKER_IO_USER: ${{ secrets.WGE_DOCKER_IO_USER }}
102102
DOCKER_IO_PASSWORD: ${{ secrets.WGE_DOCKER_IO_PASSWORD }}
103+
EXP_CLUSTER_RESOURCE_SET: true
103104
GITOPS_BIN_PATH: /tmp/gitops
104105
WKP_BIN_PATH: ${{ github.workspace }}/cmd/wk/wk-v2.5.0-${{ matrix.os_name }}-amd64
105106
SELENIUM_DEBUG: true

.github/workflows/nightly.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
TOTP_TOKEN: ${{ secrets.WGE_GITHUB_MFA_KEY }}
3636
DOCKER_IO_USER: ${{ secrets.WGE_DOCKER_IO_USER }}
3737
DOCKER_IO_PASSWORD: ${{ secrets.WGE_DOCKER_IO_PASSWORD }}
38+
EXP_CLUSTER_RESOURCE_SET: true
3839
GITOPS_BIN_PATH: /tmp/gitops
3940
WKP_BIN_PATH: ${{ github.workspace }}/cmd/wk/wk-v2.5.0-${{ matrix.os_name }}-amd64
4041
WGE_ACCEPTANCE_EKS_KUBECONFIG: ${{ secrets.WGE_ACCEPTANCE_EKS_KUBECONFIG }}
@@ -224,6 +225,7 @@ jobs:
224225
TOTP_TOKEN: ${{ secrets.WGE_GITHUB_MFA_KEY }}
225226
DOCKER_IO_USER: ${{ secrets.WGE_DOCKER_IO_USER }}
226227
DOCKER_IO_PASSWORD: ${{ secrets.WGE_DOCKER_IO_PASSWORD }}
228+
EXP_CLUSTER_RESOURCE_SET: true
227229
GITOPS_BIN_PATH: /tmp/gitops
228230
WKP_BIN_PATH: ${{ github.workspace }}/cmd/wk/wk-v2.5.0-${{ matrix.os_name }}-amd64
229231
WGE_ACCEPTANCE_GCE_KUBECONFIG: ${{ secrets.WGE_ACCEPTANCE_GCE_KUBECONFIG }}

.github/workflows/test.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ jobs:
229229
GITHUB_ORG: ${{ secrets.WGE_GITHUB_ORG }}
230230
GITHUB_USER: ${{ secrets.WGE_GITHUB_USER }}
231231
GITHUB_PASSWORD: ${{ secrets.WGE_GITHUB_PASSWORD }}
232+
EXP_CLUSTER_RESOURCE_SET: true
232233
GITOPS_BIN_PATH: /tmp/gitops
233234
SELENIUM_DEBUG: true
234235
ACCEPTANCE_TESTS_DATABASE_TYPE: sqlite
@@ -327,6 +328,7 @@ jobs:
327328
GITHUB_USER: ${{ secrets.WGE_GITHUB_USER }}
328329
GITHUB_PASSWORD: ${{ secrets.WGE_GITHUB_PASSWORD }}
329330
TOTP_TOKEN: ${{ secrets.WGE_GITHUB_MFA_KEY }}
331+
EXP_CLUSTER_RESOURCE_SET: true
330332
GITOPS_BIN_PATH: /tmp/gitops
331333
WKP_BIN_PATH: ${{ github.workspace }}/cmd/wk/wk-v2.5.0-linux-amd64
332334
SELENIUM_DEBUG: true
@@ -335,10 +337,6 @@ jobs:
335337
CONNECT_KIND_WKP_LEAF_TEST: true
336338
ARTEFACTS_BASE_DIR: /tmp/workspace/test/
337339
steps:
338-
- name: "Setup dynamic env vars"
339-
run: |
340-
export CLUSTER_REPOSITORY=gitops-capi-template-${{ github.run_id }}-$(openssl rand -hex 8)
341-
echo "CLUSTER_REPOSITORY=$CLUSTER_REPOSITORY" >> $GITHUB_ENV
342340
- id: go-cache-paths
343341
run: |
344342
echo "::set-output name=go-build::$(go env GOCACHE)"
@@ -408,6 +406,10 @@ jobs:
408406
kubectl get pods -A
409407
- name: Install wego enterprise components on management cluster
410408
run: |
409+
export CLUSTER_REPOSITORY=gitops-capi-template-${{ github.run_id }}-$(openssl rand -hex 8)
410+
# Set the CLUSTER_REPOSITORY as environment variable for subsequent steps
411+
echo "CLUSTER_REPOSITORY=$CLUSTER_REPOSITORY" >> $GITHUB_ENV
412+
411413
./test/utils/scripts/wego-enterprise.sh setup ${{ github.workspace }}
412414
- name: Run acceptance tests
413415
run: |

test/acceptance/test/cli_add_delete.go

Lines changed: 106 additions & 117 deletions
Large diffs are not rendered by default.

test/acceptance/test/cli_get.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func DescribeCliGet(gitopsTestRunner GitopsTestRunner) {
195195
capdTemplateCount := 5
196196
totalTemplateCount := awsTemplateCount + eksFargateTemplateCount + capdTemplateCount
197197
By("Apply/Install CAPITemplate", func() {
198-
templateFiles = append(templateFiles, gitopsTestRunner.CreateApplyCapitemplates(5, "capi-server-v1-template-capd.yaml")...)
198+
templateFiles = append(templateFiles, gitopsTestRunner.CreateApplyCapitemplates(5, "capi-template-capd.yaml")...)
199199
templateFiles = append(templateFiles, gitopsTestRunner.CreateApplyCapitemplates(2, "capi-server-v1-template-aws.yaml")...)
200200
templateFiles = append(templateFiles, gitopsTestRunner.CreateApplyCapitemplates(2, "capi-server-v1-template-eks-fargate.yaml")...)
201201
})
@@ -279,7 +279,7 @@ func DescribeCliGet(gitopsTestRunner GitopsTestRunner) {
279279
It("Verify gitops can list template parameters of a template from template library", func() {
280280

281281
By("Apply/Install CAPITemplate", func() {
282-
templateFiles = gitopsTestRunner.CreateApplyCapitemplates(1, "capi-server-v1-template-capd.yaml")
282+
templateFiles = gitopsTestRunner.CreateApplyCapitemplates(1, "capi-template-capd.yaml")
283283
})
284284

285285
By(fmt.Sprintf("And I run gitops get templates cluster-template-development-0 --list-parameters --endpoint %s", CAPI_ENDPOINT_URL), func() {
@@ -294,8 +294,7 @@ func DescribeCliGet(gitopsTestRunner GitopsTestRunner) {
294294

295295
By("And I should see parameter rows", func() {
296296
output := session.Wait().Out.Contents()
297-
re := regexp.MustCompile(`CLUSTER_NAME+\s+true\s+This is used for the cluster naming.\s+KUBERNETES_VERSION\s+false\s+Kubernetes version to use for the cluster\s+1.19.7, 1.19.8\s+NAMESPACE\s+false\s+Namespace to create the cluster in`)
298-
Eventually((re.Find(output))).ShouldNot(BeNil())
297+
Eventually(string(output)).Should(MatchRegexp(`CLUSTER_NAME+\s+true\s+This is used for the cluster naming.\s+KUBERNETES_VERSION\s+false\s+Kubernetes version to use for the cluster\s+1.19.11, 1.21.1, 1.22.0, 1.23.0\s+NAMESPACE\s+false\s+Namespace to create the cluster in`))
299298

300299
})
301300
})

test/acceptance/test/pages/create_cluster.go

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import (
1313
type CreateCluster struct {
1414
CreateHeader *agouti.Selection
1515
// TemplateName *agouti.Selection
16-
Credentials *agouti.Selection
17-
TemplateSection *agouti.MultiSelection
18-
PreviewPR *agouti.Selection
16+
Credentials *agouti.Selection
17+
TemplateSection *agouti.MultiSelection
18+
ProfileSelect *agouti.Selection
19+
ProfileSelectPopup *agouti.MultiSelection
20+
PreviewPR *agouti.Selection
1921
}
2022

2123
type FormField struct {
@@ -28,6 +30,19 @@ type TemplateSection struct {
2830
Fields []FormField
2931
}
3032

33+
type Profile struct {
34+
Name *agouti.Selection
35+
Version *agouti.Selection
36+
Values *agouti.Selection
37+
}
38+
39+
type ValuesYaml struct {
40+
Title *agouti.Selection
41+
Cancel *agouti.Selection
42+
Save *agouti.Selection
43+
TextArea *agouti.Selection
44+
}
45+
3146
type Preview struct {
3247
PreviewLabel *agouti.Selection
3348
PreviewText *agouti.Selection
@@ -51,9 +66,11 @@ func GetCreateClusterPage(webDriver *agouti.Page) *CreateCluster {
5166
clusterPage := CreateCluster{
5267
CreateHeader: webDriver.Find(`.count-header`),
5368
// TemplateName: webDriver.FindByXPath(`//*/div[text()="Create new cluster with template"]/following-sibling::text()`),
54-
Credentials: webDriver.FindByXPath(`//div[@class="credentials"]//div[contains(@class, "dropdown-toggle")]`),
55-
TemplateSection: webDriver.AllByXPath(`//div[contains(@class, "form-group field field-object")]/child::div`),
56-
PreviewPR: webDriver.FindByButton("Preview PR"),
69+
Credentials: webDriver.FindByXPath(`//div[@class="credentials"]//div[contains(@class, "dropdown-toggle")]`),
70+
TemplateSection: webDriver.AllByXPath(`//div[contains(@class, "form-group field field-object")]/child::div`),
71+
ProfileSelect: webDriver.Find(`div.profiles-select > div`),
72+
ProfileSelectPopup: webDriver.All(`ul[role="listbox"] li`),
73+
PreviewPR: webDriver.FindByButton("Preview PR"),
5774
}
5875

5976
return &clusterPage
@@ -89,6 +106,50 @@ func (c CreateCluster) GetTemplateSection(webdriver *agouti.Page, sectionName st
89106
Fields: formFields,
90107
}
91108
}
109+
110+
func GetProfile(webDriver *agouti.Page, profileName string) Profile {
111+
fields := webDriver.All("div.MuiBox-root ul li")
112+
pCnt, _ := fields.Count()
113+
for i := 0; i < pCnt; i++ {
114+
pName, _ := fields.At(i).Find(`div.profile-name`).Text()
115+
if profileName == pName {
116+
return Profile{
117+
Name: fields.At(i).Find(`div.profile-name`),
118+
Version: fields.At(i).Find(`div.profile-version`),
119+
Values: fields.At(i).Find(`button`),
120+
}
121+
}
122+
}
123+
return Profile{}
124+
}
125+
126+
func GetValuesYaml(webDriver *agouti.Page) ValuesYaml {
127+
Eventually(webDriver.Find(`div.MuiDialogTitle-root`)).Should(BeVisible())
128+
return ValuesYaml{
129+
Title: webDriver.Find(`div.MuiDialogTitle-root > h5`),
130+
Cancel: webDriver.Find(`div.MuiDialogTitle-root > button`),
131+
TextArea: webDriver.FindByXPath(`//div[@class="MuiDialogContent-root"]/textarea[1]`),
132+
Save: webDriver.Find(`button#edit-yaml`),
133+
}
134+
}
135+
136+
func (c CreateCluster) SelectProfile(profileName string) *agouti.Selection {
137+
time.Sleep(2 * time.Second)
138+
pCount, _ := c.ProfileSelectPopup.Count()
139+
140+
for i := 0; i < pCount; i++ {
141+
pName, _ := c.ProfileSelectPopup.At(i).Text()
142+
if profileName == pName {
143+
return c.ProfileSelectPopup.At(i)
144+
}
145+
}
146+
return nil
147+
}
148+
149+
func DissmissProfilePopup(webDriver *agouti.Page) {
150+
Expect(webDriver.Find(`div[name=Profiles]`).DoubleClick()).To(Succeed())
151+
}
152+
92153
func GetCredentials(webDriver *agouti.Page) *agouti.MultiSelection {
93154
return webDriver.All(`div.dropdown-item`)
94155
}
@@ -97,8 +158,12 @@ func GetCredential(webDriver *agouti.Page, value string) *agouti.Selection {
97158
return webDriver.Find(fmt.Sprintf(`div.dropdown-item[title*="%s"]`, value))
98159
}
99160

100-
func GetParameterOption(webDriver *agouti.Page, value string) *agouti.Selection {
101-
return webDriver.Find(fmt.Sprintf(`li[data-value="%s"]`, value))
161+
func GetOption(webDriver *agouti.Page, sectionType string, value string) *agouti.Selection {
162+
if sectionType == "profile" {
163+
return webDriver.FindByXPath(fmt.Sprintf(`//div[.="%s"]`, value))
164+
} else {
165+
return webDriver.Find(fmt.Sprintf(`li[data-value="%s"]`, value))
166+
}
102167
}
103168

104169
func GetPreview(webDriver *agouti.Page) Preview {

test/acceptance/test/ui_applications.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,21 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
148148
Eventually(addApp.GitCredentials).Should(BeVisible())
149149
}
150150
addApp = pages.GetAddApplicationForm(webDriver)
151-
Expect(addApp.Submit.Click()).To(Succeed())
151+
// workaround when simple 'Submit' button click fails to trigger add application event
152+
if pages.ElementExist(addApp.Submit) {
153+
clickSubmit := func() bool {
154+
err := addApp.Submit.Click()
155+
if err == nil {
156+
visible, _ := addApp.Submit.Visible()
157+
return !visible
158+
}
159+
return false
160+
}
161+
Eventually(clickSubmit).Should(BeTrue(), "Failed to click application add Submit button")
162+
} else {
163+
Fail("Can't find the submit button on application page")
164+
}
165+
152166
pages.WaitForAuthenticationAlert(webDriver, "Application added successfully!")
153167
Expect(addApp.ViewApplication.Click()).To(Succeed())
154168
})
@@ -163,8 +177,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
163177
})
164178

165179
By("And I should see workload is deployed to the cluster", func() {
166-
Expect(waitForResource("deploy", appName, appNamespace, ASSERTION_5MINUTE_TIME_OUT)).To(Succeed())
167-
Expect(waitForResource("pods", "", appNamespace, ASSERTION_5MINUTE_TIME_OUT)).To(Succeed())
180+
Expect(waitForResource("deploy", appName, appNamespace, "", ASSERTION_5MINUTE_TIME_OUT)).To(Succeed())
181+
Expect(waitForResource("pods", "", appNamespace, "", ASSERTION_5MINUTE_TIME_OUT)).To(Succeed())
168182
command := exec.Command("sh", "-c", fmt.Sprintf("kubectl wait --for=condition=Ready --timeout=60s -n %s --all pods --selector='app!=wego-app'", appNamespace))
169183
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
170184
Expect(err).ShouldNot(HaveOccurred())

0 commit comments

Comments
 (0)