Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/acceptance/test/pages/applications_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ApplicationInformation struct {
Name *agouti.Selection
Type *agouti.Selection
Namespace *agouti.Selection
Tenant *agouti.Selection
Cluster *agouti.Selection
Source *agouti.Selection
Status *agouti.Selection
Expand Down Expand Up @@ -72,12 +73,13 @@ func (a ApplicationsPage) FindApplicationInList(applicationName string) *Applica
Name: application.FindByXPath(`td[1]//a`),
Type: application.FindByXPath(`td[2]`),
Namespace: application.FindByXPath(`td[3]`),
Cluster: application.FindByXPath(`td[4]`),
Source: application.FindByXPath(`td[5]`),
Status: application.FindByXPath(`td[6]`),
Message: application.FindByXPath(`td[7]`),
Revision: application.FindByXPath(`td[8]`),
LastUpdated: application.FindByXPath(`td[9]`),
Tenant: application.FindByXPath(`td[4]`),
Cluster: application.FindByXPath(`td[5]`),
Source: application.FindByXPath(`td[6]`),
Status: application.FindByXPath(`td[7]`),
Message: application.FindByXPath(`td[8]`),
Revision: application.FindByXPath(`td[9]`),
LastUpdated: application.FindByXPath(`td[10]`),
}
}

Expand Down
24 changes: 12 additions & 12 deletions test/acceptance/test/pages/policies_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type PoliciesPage struct {
type PolicyInformation struct {
Name *agouti.Selection
Category *agouti.Selection
Tenant *agouti.Selection
Severity *agouti.Selection
Cluster *agouti.Selection
Age *agouti.Selection
}

type PolicyDetailPage struct {
Header *agouti.Selection
Title *agouti.Selection
ID *agouti.Selection
ClusterName *agouti.Selection
Tags *agouti.MultiSelection
Expand All @@ -47,9 +47,10 @@ func (p PoliciesPage) FindPolicyInList(policyName string) *PolicyInformation {
return &PolicyInformation{
Name: policy.FindByXPath(`td[1]//a`),
Category: policy.FindByXPath(`td[2]`),
Severity: policy.FindByXPath(`td[3]`),
Cluster: policy.FindByXPath(`td[4]`),
Age: policy.FindByXPath(`td[5]`),
Tenant: policy.FindByXPath(`td[3]`),
Severity: policy.FindByXPath(`td[4]`),
Cluster: policy.FindByXPath(`td[5]`),
Age: policy.FindByXPath(`td[6]`),
}
}

Expand Down Expand Up @@ -78,17 +79,16 @@ func GetPoliciesPage(webDriver *agouti.Page) *PoliciesPage {
func GetPolicyDetailPage(webDriver *agouti.Page) *PolicyDetailPage {
return &PolicyDetailPage{
Header: webDriver.FindByXPath(`//div[@role="heading"]/a[@href="/policies"]/parent::node()/parent::node()/following-sibling::div`),
Title: webDriver.First(`h2`),
ID: webDriver.FindByXPath(`//div[text()="Policy ID:"]/following-sibling::*[1]`),
ClusterName: webDriver.FindByXPath(`//div[text()="Cluster Name:"]/following-sibling::*[1]`),
Tags: webDriver.AllByXPath(`//div/*[text()="Tags:"]/following-sibling::*`),
Severity: webDriver.FindByXPath(`//div[text()="Severity:"]/following-sibling::*[1]`),
Category: webDriver.FindByXPath(`//div[text()="Category:"]/following-sibling::*[1]`),
TargetedK8sKind: webDriver.AllByXPath(`//div[text()="Targeted K8s Kind:"]/following-sibling::*`),
ID: webDriver.Find(`div[data-testid="Policy ID"]`),
ClusterName: webDriver.Find(`div[data-testid="Cluster Name"]`),
Tags: webDriver.All(`div[data-testid="Tags"] span`),
Severity: webDriver.Find(`div[data-testid="Severity"]`),
Category: webDriver.Find(`div[data-testid="Category"]`),
TargetedK8sKind: webDriver.All(`div[data-testid="Targeted K8s Kind"] span`),
Description: webDriver.FindByXPath(`//div[text()="Description:"]/following-sibling::*[1]`),
HowToSolve: webDriver.FindByXPath(`//div[text()="How to solve:"]/following-sibling::*[1]`),
Code: webDriver.FindByXPath(`//div[text()="Policy Code:"]/following-sibling::*[1]`),
Parameters: webDriver.AllByXPath(`//div/*[text()="Parameters Definition"]/following-sibling::*`),
Parameters: webDriver.AllByXPath(`//div/*[text()="Parameters Definition:"]/following-sibling::*`),
}
}

Expand Down
24 changes: 11 additions & 13 deletions test/acceptance/test/pages/violations_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ type ViolationsPage struct {
}

type ViolationInformation struct {
NameMgmtUI *agouti.Selection
Message *agouti.Selection
Cluster *agouti.Selection
Application *agouti.Selection
Severity *agouti.Selection
ValidatedPolicy *agouti.Selection
Cluster *agouti.Selection
Time *agouti.Selection
Application *agouti.Selection
}

type ViolationDetailPage struct {
Header *agouti.Selection
Title *agouti.Selection
ClusterName *agouti.Selection
Time *agouti.Selection
Severity *agouti.Selection
Expand All @@ -39,12 +38,12 @@ type ViolationDetailPage struct {
func (v ViolationsPage) FindViolationInList(violationMsg string) *ViolationInformation {
violation := v.ViolationList.FirstByXPath(fmt.Sprintf(`//tr[.//a[contains(text(), "%s")]]`, violationMsg))
return &ViolationInformation{
NameMgmtUI: violation.FindByXPath(`td[1]//a`),
Severity: violation.FindByXPath(`td[2]`),
ValidatedPolicy: violation.FindByXPath(`td[3]`),
Cluster: violation.FindByXPath(`td[4]`),
Time: violation.FindByXPath(`td[5]`),
Application: violation.FindByXPath(`td[6]`),
Message: violation.FindByXPath(`td[1]//a`),
Cluster: violation.FindByXPath(`td[2]`),
Application: violation.FindByXPath(`td[3]`),
Severity: violation.FindByXPath(`td[4]`),
ValidatedPolicy: violation.FindByXPath(`td[5]`),
Time: violation.FindByXPath(`td[6]`),
}
}

Expand All @@ -56,16 +55,15 @@ func (v ViolationsPage) CountViolations() int {

func GetViolationsPage(webDriver *agouti.Page) *ViolationsPage {
return &ViolationsPage{
ViolationHeader: webDriver.Find(`div[role="heading"] a[href="/clusters/violations"]`),
ViolationHeader: webDriver.Find(`div[role="heading"] a[href="/clusters"]`),
ViolationCount: webDriver.First(`.section-header-count`),
ViolationList: webDriver.First(`table tbody`),
}
}

func GetViolationDetailPage(webDriver *agouti.Page) *ViolationDetailPage {
return &ViolationDetailPage{
Header: webDriver.FindByXPath(`//div[@role="heading"]/a[@href="/clusters/violations"]/parent::node()/parent::node()/following-sibling::div`),
Title: webDriver.First(`h2`),
Header: webDriver.FindByXPath(`//div[@role="heading"]/a[@href="/clusters"]/parent::node()/parent::node()/following-sibling::div[2]`),
ClusterName: webDriver.FindByXPath(`//div[text()="Cluster Name"]/following-sibling::*[1]`),
Time: webDriver.FindByXPath(`//div/*[text()="Violation Time"]/following-sibling::*[1]`),
Severity: webDriver.FindByXPath(`//div[text()="Severity"]/following-sibling::*[1]`),
Expand Down
2 changes: 0 additions & 2 deletions test/acceptance/test/ui_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func DescribePolicies(gitopsTestRunner GitopsTestRunner) {
policyDetailPage := pages.GetPolicyDetailPage(webDriver)
By(fmt.Sprintf("And verify '%s' policy page", policyName), func() {
Eventually(policyDetailPage.Header.Text).Should(MatchRegexp(policyName), "Failed to verify dashboard policy name ")
Eventually(policyDetailPage.Title.Text).Should(MatchRegexp(policyName), "Failed to verify policy title on policy page")
Eventually(policyDetailPage.ID.Text).Should(MatchRegexp(policyID), "Failed to verify policy ID on policy page")
Eventually(policyDetailPage.ClusterName.Text).Should(MatchRegexp(policyClusterName), "Failed to verify policy cluster on policy page")
Eventually(policyDetailPage.Severity.Text).Should(MatchRegexp(policySeverity), "Failed to verify policy Severity on policy page")
Expand Down Expand Up @@ -280,7 +279,6 @@ func DescribePolicies(gitopsTestRunner GitopsTestRunner) {
policyDetailPage := pages.GetPolicyDetailPage(webDriver)
By(fmt.Sprintf("And verify '%s' policy page", policyName), func() {
Eventually(policyDetailPage.Header.Text).Should(MatchRegexp(policyName), "Failed to verify dashboard policy name ")
Eventually(policyDetailPage.Title.Text).Should(MatchRegexp(policyName), "Failed to verify policy title on policy page")
Eventually(policyDetailPage.ID.Text).Should(MatchRegexp(policyID), "Failed to verify policy ID on policy page")
Eventually(policyDetailPage.ClusterName.Text).Should(MatchRegexp(leafClusterName), "Failed to verify policy cluster on policy page")
Eventually(policyDetailPage.Severity.Text).Should(MatchRegexp(policySeverity), "Failed to verify policy Severity on policy page")
Expand Down
73 changes: 35 additions & 38 deletions test/acceptance/test/ui_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,41 +960,18 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
setParameterValues(createPage, parameters)
pages.ScrollWindow(webDriver, 0, 500)

podInfo := Profile{
Name: "podinfo",
Namespace: "flux-system",
Version: "6.0.1",
Values: "",
Layer: "layer-1",
}

By(fmt.Sprintf("And verify default %s profile values.yaml", podInfo.Name), func() {
profile := createPage.FindProfileInList(podInfo.Name)
Eventually(profile.Layer.Text).Should(MatchRegexp(podInfo.Layer))

Eventually(profile.Values.Click).Should(Succeed())
valuesYaml := pages.GetValuesYaml(webDriver)

Eventually(valuesYaml.Title.Text).Should(MatchRegexp(podInfo.Name))
Eventually(valuesYaml.TextArea.Text).Should(MatchRegexp("tag: " + podInfo.Version))
Eventually(valuesYaml.Cancel.Click).Should(Succeed())
})

certManager := Profile{
Name: "cert-manager",
Namespace: "cert-manager",
Version: "0.0.7",
Version: "0.0.8",
Values: "installCRDs: true",
Layer: "layer-0",
}

By(fmt.Sprintf("And select the %s profile to install", certManager.Name), func() {
profile := createPage.FindProfileInList(certManager.Name)
Eventually(profile.Checkbox.Click).Should(Succeed(), fmt.Sprintf("Failed to select the %s profile", certManager.Name))
})

By(fmt.Sprintf("And verify selected %s profile values.yaml", certManager.Name), func() {
By(fmt.Sprintf("And select the %s profile to install and verify values.yaml", certManager.Name), func() {
profile := createPage.FindProfileInList(certManager.Name)
Eventually(profile.Name.Click).Should(Succeed(), fmt.Sprintf("Failed to find %s profile", certManager.Name))
Eventually(profile.Checkbox.Check).Should(Succeed(), fmt.Sprintf("Failed to select the %s profile", certManager.Name))

Eventually(profile.Version.Click).Should(Succeed())
Eventually(pages.GetOption(webDriver, certManager.Version).Click).Should(Succeed(), fmt.Sprintf("Failed to select %s version: %s", certManager.Name, certManager.Version))
Expand All @@ -1010,21 +987,40 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
Eventually(valuesYaml.Cancel.Click).Should(Succeed())
})

metallb := Profile{
Name: "metallb",
Namespace: "flux-system",
Version: "0.0.2",
Values: `prometheus.namespace: \${NAMESPACE}`,
Layer: "layer-0",
}

By(fmt.Sprintf("And verify default %s profile values.yaml", metallb.Name), func() {
profile := createPage.FindProfileInList(metallb.Name)
Eventually(profile.Name.Click).Should(Succeed(), fmt.Sprintf("Failed to find %s profile", metallb.Name))
Eventually(profile.Layer.Text).Should(MatchRegexp(metallb.Layer))

Eventually(profile.Values.Click).Should(Succeed())
valuesYaml := pages.GetValuesYaml(webDriver)

Eventually(valuesYaml.Title.Text).Should(MatchRegexp(metallb.Name))
Eventually(valuesYaml.TextArea.Text).Should(MatchRegexp(metallb.Values))
Eventually(valuesYaml.Cancel.Click).Should(Succeed())
})

pages.ScrollWindow(webDriver, 0, 1500)
policyAgent := Profile{
Name: "weave-policy-agent",
Namespace: "policy-system",
Version: "0.3.1",
Version: "0.3.0",
Values: fmt.Sprintf(`accountId: "weaveworks",clusterId: "%s"`, clusterName),
Layer: "layer-1",
}

By(fmt.Sprintf("And select the %s profile to install", policyAgent.Name), func() {
profile := createPage.FindProfileInList(policyAgent.Name)
Eventually(profile.Checkbox.Click).Should(Succeed(), fmt.Sprintf("Failed to select the %s profile", policyAgent))
})

By(fmt.Sprintf("And verify selected %s profile values.yaml", policyAgent.Name), func() {
By(fmt.Sprintf("And select the %s profile to install and verify values.yaml", policyAgent.Name), func() {
profile := createPage.FindProfileInList(policyAgent.Name)
Eventually(profile.Name.Click).Should(Succeed(), fmt.Sprintf("Failed to find %s profile", policyAgent.Name))
Eventually(profile.Checkbox.Check).Should(Succeed(), fmt.Sprintf("Failed to select the %s profile", policyAgent.Name))

Eventually(profile.Version.Click).Should(Succeed())
Eventually(pages.GetOption(webDriver, policyAgent.Version).Click).Should(Succeed(), fmt.Sprintf("Failed to select %s version: %s", policyAgent.Name, policyAgent.Version))
Expand All @@ -1036,7 +1032,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
valuesYaml := pages.GetValuesYaml(webDriver)

Eventually(valuesYaml.Title.Text).Should(MatchRegexp(policyAgent.Name))
Eventually(valuesYaml.TextArea.Text).Should(MatchRegexp("namespace: " + policyAgent.Namespace))
Eventually(valuesYaml.TextArea.Text).Should(MatchRegexp("image: magalixcorp/policy-agent"))

text, _ := valuesYaml.TextArea.Text()
text = strings.ReplaceAll(text, `accountId: ""`, strings.Split(policyAgent.Values, ",")[0])
Expand All @@ -1047,6 +1043,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
Eventually(valuesYaml.Save.Click).Should(Succeed(), fmt.Sprintf("Failed to save values.yaml for %s profile", policyAgent.Name))
})

pages.ScrollWindow(webDriver, 0, 500)
By("Then I should preview the PR", func() {
preview := pages.GetPreview(webDriver)
Eventually(func(g Gomega) {
Expand Down Expand Up @@ -1133,7 +1130,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
})

By(fmt.Sprintf("And I verify %s capd cluster is healthy and profiles are installed)", clusterName), func() {
verifyCapiClusterHealth(downloadedKubeconfigPath, []Profile{certManager, policyAgent, podInfo})
verifyCapiClusterHealth(downloadedKubeconfigPath, []Profile{certManager, metallb, policyAgent})
})

existingAppCount := getApplicationCount()
Expand All @@ -1146,7 +1143,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
pages.WaitForPageToLoad(webDriver)

By(fmt.Sprintf("And filter capi cluster '%s' application", clusterName), func() {
totalAppCount := existingAppCount + 5 // flux-system, clusters-bases-kustomization, podinfo, cert-manager, policy-agent
totalAppCount := existingAppCount + 6 // flux-system, clusters-bases-kustomization, metallb, cert-manager, policy-agent, policy-library
Eventually(func(g Gomega) int {
return applicationsPage.CountApplications()
}, ASSERTION_3MINUTE_TIME_OUT).Should(Equal(totalAppCount), fmt.Sprintf("There should be %d application enteries in application table", totalAppCount))
Expand All @@ -1161,7 +1158,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
Eventually(applicationsPage.CountApplications).Should(Equal(3), "There should be 3 application enteries in application table")
})

verifyAppInformation(applicationsPage, "podinfo", "HelmRelease", GITOPS_DEFAULT_NAMESPACE, clusterName, clusterNamespace, GITOPS_DEFAULT_NAMESPACE+"-podinfo", "Ready")
verifyAppInformation(applicationsPage, "metallb", "HelmRelease", GITOPS_DEFAULT_NAMESPACE, clusterName, clusterNamespace, GITOPS_DEFAULT_NAMESPACE+"-metallb", "Ready")
verifyAppInformation(applicationsPage, "cert-manager", "HelmRelease", GITOPS_DEFAULT_NAMESPACE, clusterName, clusterNamespace, GITOPS_DEFAULT_NAMESPACE+"-cert-manager", "Ready")
verifyAppInformation(applicationsPage, "weave-policy-agent", "HelmRelease", GITOPS_DEFAULT_NAMESPACE, clusterName, clusterNamespace, GITOPS_DEFAULT_NAMESPACE+"-weave-policy-agent", "Ready")

Expand Down
Loading