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
3 changes: 1 addition & 2 deletions .github/workflows/acceptance-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ jobs:
key: ${{ runner.os }}-go-build-${{ env.GO_CACHE_NAME }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-${{ env.GO_CACHE_NAME }}-
- name: setup aws credentials
if: ${{ inputs.management-cluster-kind == 'eks' }}
- name: setup aws credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.WGE_EKS_AWS_ACCESS_KEY_ID }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
WGE_GITLAB_PASSWORD: ${{ secrets.WGE_ON_PREM_GITLAB_PASSWORD }}
WGE_GITLAB_CLIENT_ID: ${{ secrets.WGE_ON_PREM_GITLAB_CLIENT_ID }}
WGE_GITLAB_CLIENT_SECRET: ${{ secrets.WGE_ON_PREM_GITLAB_CLIENT_SECRET }}
WGE_EKS_AWS_ACCESS_KEY_ID: ${{ secrets.WGE_EKS_AWS_ACCESS_KEY_ID }}
WGE_EKS_AWS_SECRET_ACCESS_KEY: ${{ secrets.WGE_EKS_AWS_SECRET_ACCESS_KEY }}

acceptance-tests-eks-github:
needs: [build]
Expand Down Expand Up @@ -109,6 +111,8 @@ jobs:
WGE_GITLAB_CLIENT_SECRET: ${{ secrets.WGE_SAS_GITLAB_CLIENT_SECRET }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
WGE_EKS_AWS_ACCESS_KEY_ID: ${{ secrets.WGE_EKS_AWS_ACCESS_KEY_ID }}
WGE_EKS_AWS_SECRET_ACCESS_KEY: ${{ secrets.WGE_EKS_AWS_SECRET_ACCESS_KEY }}

acceptance-test-results:
if: ${{ always() }}
Expand Down
18 changes: 9 additions & 9 deletions test/acceptance/test/cli_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {

ginkgo.BeforeEach(ginkgo.OncePerOrdered, func() {
// Delete the oidc user default roles/rolebindings because the same user is used as a tenant
_ = runCommandPassThrough("kubectl", "delete", "-f", path.Join(getCheckoutRepoPath(), "test", "utils", "data", "user-role-bindings.yaml"))
_ = runCommandPassThrough("kubectl", "delete", "-f", path.Join(testDataPath, "user-role-bindings.yaml"))
})

ginkgo.AfterEach(ginkgo.OncePerOrdered, func() {
// Create the oidc user default roles/rolebindings after tenant tests completed
_ = runCommandPassThrough("kubectl", "apply", "-f", path.Join(getCheckoutRepoPath(), "test", "utils", "data", "user-role-bindings.yaml"))
_ = runCommandPassThrough("kubectl", "apply", "-f", path.Join(testDataPath, "user-role-bindings.yaml"))
})

ginkgo.Context("[CLI] When input tenant definition yaml is available", ginkgo.Ordered, func() {
Expand All @@ -95,7 +95,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.It("Verify a single tenant resources can be exported", ginkgo.Label("tenant"), func() {
tenatDefination := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "single-tenant.yaml")
tenatDefination := path.Join(testDataPath, "tenancy", "single-tenant.yaml")

// verify tenants resources are exported to terminal
stdOut, stdErr = runGitopsCommand(fmt.Sprintf(`create tenants --from-file %s --export`, tenatDefination))
Expand All @@ -114,7 +114,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.It("Verify global service account reconciliation by tenant", ginkgo.Label("tenant"), func() {
tenatDefination := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "single-tenant-sa.yaml")
tenatDefination := path.Join(testDataPath, "tenancy", "single-tenant-sa.yaml")

_, stdErr = runGitopsCommand(fmt.Sprintf(`create tenants --from-file %s --export > %s`, tenatDefination, tenantYaml))
gomega.Expect(stdErr).Should(gomega.BeEmpty(), "gitops create tenant command failed with an error")
Expand All @@ -126,7 +126,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.It("Verify global service account reconciliation by tenant with deployment RBAC", ginkgo.Label("tenant"), func() {
tenatDefination := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "single-tenant-deployment-sa.yaml")
tenatDefination := path.Join(testDataPath, "tenancy", "single-tenant-deployment-sa.yaml")

_, stdErr = runGitopsCommand(fmt.Sprintf(`create tenants --from-file %s --export > %s`, tenatDefination, tenantYaml))
gomega.Expect(stdErr).Should(gomega.BeEmpty(), "gitops create tenant command failed with an error")
Expand All @@ -139,7 +139,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {

ginkgo.It("Verify creating tenant resource using kubeconfig ", ginkgo.Label("tenant"), func() {
_ = gitopsTestRunner.KubectlDelete([]string{}, tenantYaml)
tenatDefination := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "multiple-tenant.yaml")
tenatDefination := path.Join(testDataPath, "tenancy", "multiple-tenant.yaml")

// Export tenants resources to output file (required to delete tenant resources after test completion)
_, stdErr = runGitopsCommand(fmt.Sprintf(`create tenants --from-file %s --export > %s`, tenatDefination, tenantYaml))
Expand All @@ -154,7 +154,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.It("Verify tenant can only install the application from allowed repositories", ginkgo.Label("tenant"), func() {
createTenant(path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "multiple-tenant.yaml"))
createTenant(path.Join(testDataPath, "tenancy", "multiple-tenant.yaml"))

// Adding not allowed git repository source
namespace := "dev-system"
Expand All @@ -179,7 +179,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
bootstrapLabel := "bootstrap"
leafClusterkubeconfig := "wge-leaf-tenant-kind-kubeconfig"

createTenant(path.Join(getCheckoutRepoPath(), "test", "utils", "data", "tenancy", "multiple-tenant.yaml"))
createTenant(path.Join(testDataPath, "tenancy", "multiple-tenant.yaml"))
createPATSecret(leafCluster.Namespace, patSecret)
defer deleteSecret([]string{patSecret}, leafCluster.Namespace)
clusterBootstrapCopnfig := createClusterBootstrapConfig(leafCluster.Name, leafCluster.Namespace, bootstrapLabel, patSecret)
Expand All @@ -188,7 +188,7 @@ func DescribeCliTenant(gitopsTestRunner GitopsTestRunner) {
}()

ginkgo.By(fmt.Sprintf("Add GitopsCluster resource for %s cluster to management cluster", leafCluster.Name), func() {
contents, err := ioutil.ReadFile(path.Join(getCheckoutRepoPath(), "test/utils/data/gitops-cluster.yaml"))
contents, err := ioutil.ReadFile(path.Join(testDataPath, "gitops-cluster.yaml"))
gomega.Expect(err).To(gomega.BeNil(), "Failed to read GitopsCluster template yaml")

t := template.Must(template.New("gitops-cluster").Parse(string(contents)))
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/test/cli_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.By("And I install the entitlement for cluster upgrade", func() {
gomega.Expect(gitopsTestRunner.KubectlApply([]string{}, path.Join(getCheckoutRepoPath(), "test", "utils", "scripts", "entitlement-secret.yaml")), "Failed to create/configure entitlement")
gomega.Expect(gitopsTestRunner.KubectlApply([]string{}, path.Join(testScriptsPath, "entitlement-secret.yaml")), "Failed to create/configure entitlement")
})

ginkgo.By("And secure access to dashboard for dex users", func() {
Expand Down Expand Up @@ -181,7 +181,7 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
})

ginkgo.By("And I should install rolebindings for default enterprise roles'", func() {
gomega.Expect(gitopsTestRunner.KubectlApply([]string{}, path.Join(getCheckoutRepoPath(), "test", "utils", "data", "user-role-bindings.yaml")), "Failed to install rolbindings for enterprise default roles")
gomega.Expect(gitopsTestRunner.KubectlApply([]string{}, path.Join(testDataPath, "user-role-bindings.yaml")), "Failed to install rolbindings for enterprise default roles")
})

ginkgo.By("And I can also use upgraded enterprise UI/CLI after port forwarding (for loadbalancer ingress controller)", func() {
Expand Down
16 changes: 16 additions & 0 deletions test/acceptance/test/pages/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ type ValuesYaml struct {
TextArea *agouti.Selection
}

type CostEstimation struct {
Label *agouti.Selection
Price *agouti.Selection
Message *agouti.Selection
Estimate *agouti.Selection
}

func GetCreateClusterPage(webDriver *agouti.Page) *CreateCluster {
clusterPage := CreateCluster{
CreateHeader: webDriver.Find(`.count-header`),
Expand Down Expand Up @@ -100,3 +107,12 @@ func GetCredential(webDriver *agouti.Page, value string) *agouti.Selection {
func GetOption(webDriver *agouti.Page, value string) *agouti.Selection {
return webDriver.Find(fmt.Sprintf(`li[data-value="%s"]`, value))
}

func GetCostEstimation(webDriver *agouti.Page) *CostEstimation {
return &CostEstimation{
Label: webDriver.FindByXPath(`//h2[.="Cost Estimation"]`),
Price: webDriver.FindByXPath(`//div[.="Monthly Cost:"]/following-sibling::div`),
Message: webDriver.FindByXPath(`//h2[.="Cost Estimation"]/following-sibling::div//div[contains(@class, "message")]`),
Estimate: webDriver.FindByID(`get-estimation`),
}
}
24 changes: 13 additions & 11 deletions test/acceptance/test/pages/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ func GetTemplatesPage(webDriver *agouti.Page) *TemplatesPage {
return &templatesPage
}

type TemplateRecord struct {
type TemplateInformation struct {
Name string
Type *agouti.Selection
Namespace *agouti.Selection
Provider *agouti.Selection
Description *agouti.Selection
CreateTemplate *agouti.Selection
ErrorHeader *agouti.Selection
ErrorDescription *agouti.Selection
}

func GetTemplateTile(webDriver *agouti.Page, templateName string) *TemplateRecord {
func GetTemplateTile(webDriver *agouti.Page, templateName string) *TemplateInformation {
tileNode := webDriver.Find(fmt.Sprintf(`[data-template-name="%s"]`, templateName))
return &TemplateRecord{
return &TemplateInformation{
Name: templateName,
Description: tileNode.Find(`P[class^=MuiTypography-root]`),
CreateTemplate: tileNode.Find(`#create-cluster`),
Expand All @@ -65,18 +67,18 @@ func (t TemplatesPage) CountTemplateRows() int {
return count
}

func (t TemplatesPage) GetTemplateRow(webDriver *agouti.Page, templateName string) *TemplateRecord {
func (t TemplatesPage) GetTemplateInformation(webDriver *agouti.Page, templateName string) *TemplateInformation {
rowCount, _ := t.TemplatesList.Count()
for i := 0; i < rowCount; i++ {
tileRow := t.TemplatesList.At(i).FindByXPath(fmt.Sprintf(`//td[1]//span[contains(text(), "%s")]/ancestor::tr`, templateName))
if count, _ := tileRow.Count(); count == 1 {
return &TemplateRecord{
Name: templateName,
Provider: tileRow.FindByXPath(`td[4]`),
Description: tileRow.FindByXPath(`td[5]`),
CreateTemplate: tileRow.FindByXPath(`td[6]//button[@id="create-cluster"]`),
ErrorHeader: tileRow.Find(`.template-error-header`),
ErrorDescription: tileRow.Find(`.template-error-description`),
return &TemplateInformation{
Name: templateName,
Type: tileRow.FindByXPath(`td[2]`),
Namespace: tileRow.FindByXPath(`td[3]`),
Provider: tileRow.FindByXPath(`td[4]`),
Description: tileRow.FindByXPath(`td[5]`),
CreateTemplate: tileRow.FindByXPath(`td[6]//button[@id="create-cluster"]`),
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions test/acceptance/test/pages/violations_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@ func (v ViolationsPage) FindViolationInList(violationMsg string) *ViolationInfor
}
}

func (v ViolationsPage) CountViolations() int {
violations := v.ViolationList.All("tr")
count, _ := violations.Count()
func (v ViolationsPage) CountViolations(clusterName ...string) int {
count := 0

if len(clusterName) > 0 {
violations := v.ViolationList.AllByXPath(fmt.Sprintf(`//tr//td[contains(.,"%s")]`, clusterName[0]))

count, _ = violations.Count()
} else {
violations := v.ViolationList.All("tr")
count, _ = violations.Count()
}

return count
}

Expand Down
37 changes: 14 additions & 23 deletions test/acceptance/test/ui_applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type ApplicationViolations struct {
}

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

t := template.Must(template.New("kustomization").Parse(string(contents)))
Expand Down Expand Up @@ -791,6 +791,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {

defer deleteSource("git", podinfo.Source, podinfo.Namespace, "")
defer cleanGitRepository(appKustomization)
defer cleanGitRepository(fmt.Sprintf("./clusters/%s/%s-namespace.yaml", mgmtCluster.Name, podinfo.TargetNamespace))

repoAbsolutePath := configRepoAbsolutePath(gitProviderEnv)
existingAppCount = getApplicationCount()
Expand Down Expand Up @@ -915,7 +916,6 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
var leafClusterkubeconfig string
var clusterBootstrapCopnfig string
var gitopsCluster string
var appDir string
var existingAppCount int
patSecret := "application-pat"
bootstrapLabel := "bootstrap"
Expand All @@ -931,7 +931,6 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {

ginkgo.JustBeforeEach(func() {
existingAppCount = getApplicationCount()
appDir = path.Join("clusters", leafCluster.Namespace, leafCluster.Name, "apps")
mgmtClusterContext, _ = runCommandAndReturnStringOutput("kubectl config current-context")
createCluster("kind", leafCluster.Name, "")
createNamespace([]string{appNameSpace, appTargetNamespace})
Expand All @@ -946,7 +945,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
_ = gitopsTestRunner.KubectlDelete([]string{}, gitopsCluster)

deleteCluster("kind", leafCluster.Name, "")
cleanGitRepository(appDir)
cleanGitRepository(path.Join("./clusters", leafCluster.Namespace))
deleteNamespace([]string{leafCluster.Namespace})

})
Expand Down Expand Up @@ -1222,9 +1221,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
ginkgo.Context("[UI] Application violations are available for management cluster", func() {
// Count of existing applications before deploying new application
var existingAppCount int

// Just specify policies yaml path
policiesYaml := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "policies.yaml")
var policiesYaml string

// Just specify the violated application info to create it
appNameSpace := "test-kustomization"
Expand All @@ -1237,6 +1235,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
}

ginkgo.JustBeforeEach(func() {
policiesYaml = path.Join(testDataPath, "policies.yaml")
createNamespace([]string{appNameSpace, appTargetNamespace})

// Add/Install test Policies to the management cluster
Expand Down Expand Up @@ -1285,7 +1284,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {

ginkgo.By("Add Application/Kustomization manifests to management cluster's repository main branch", func() {
pullGitRepo(repoAbsolutePath)
podinfoPath := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "podinfo-app-violations-manifest.yaml")
podinfoPath := path.Join(testDataPath, "podinfo-app-violations-manifest.yaml")
createCommand := fmt.Sprintf("mkdir -p %[2]v && cp -f %[1]v %[2]v", podinfoPath, path.Join(repoAbsolutePath, "apps/podinfo"))
err := runCommandPassThrough("sh", "-c", createCommand)
gomega.Expect(err).Should(gomega.BeNil(), "Failed to run '%s'", createCommand)
Expand Down Expand Up @@ -1334,14 +1333,12 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
var leafClusterkubeconfig string
var clusterBootstrapCopnfig string
var gitopsCluster string
var appDir string
var appSourcePath string
var existingAppCount int
var policiesYaml string
patSecret := "application-violations-pat"
bootstrapLabel := "bootstrap"

// Just specify policies yaml path
policiesYaml := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "policies.yaml")

// Just specify the violated application info to create it
appNameSpace := "test-kustomization"
appTargetNamespace := "test-system"
Expand All @@ -1354,9 +1351,10 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
}

ginkgo.JustBeforeEach(func() {
// Just specify policies yaml path
policiesYaml = path.Join(testDataPath, "policies.yaml")
// Get the count of existing applications before deploying new application
existingAppCount = getApplicationCount()
appDir = path.Join("clusters", leafCluster.Namespace, leafCluster.Name, "apps")
mgmtClusterContext, _ = runCommandAndReturnStringOutput("kubectl config current-context")

createCluster("kind", leafCluster.Name, "")
Expand All @@ -1380,8 +1378,8 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
_ = gitopsTestRunner.KubectlDelete([]string{}, gitopsCluster)

deleteCluster("kind", leafCluster.Name, "")

cleanGitRepository(appDir)
cleanGitRepository(path.Join("./clusters", leafCluster.Namespace))
cleanGitRepository(appSourcePath)

deleteNamespace([]string{leafCluster.Namespace})

Expand All @@ -1396,7 +1394,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {
Namespace: appNameSpace,
TargetNamespace: appTargetNamespace,
Source: "flux-system",
Path: "./apps/podinfo",
Path: "./apps/podinfo-app-violations-manifest",
SyncInterval: "30s",
}
// App Violations data
Expand Down Expand Up @@ -1439,14 +1437,7 @@ func DescribeApplications(gitopsTestRunner GitopsTestRunner) {

useClusterContext(mgmtClusterContext)

ginkgo.By("Add Application/Kustomization manifests to leaf cluster's repository main branch", func() {
pullGitRepo(repoAbsolutePath)
podinfoPath := path.Join(getCheckoutRepoPath(), "test", "utils", "data", "podinfo-app-violations-manifest.yaml")
createCommand := fmt.Sprintf("mkdir -p %[2]v && cp -f %[1]v %[2]v", podinfoPath, path.Join(repoAbsolutePath, "apps/podinfo"))
err := runCommandPassThrough("sh", "-c", createCommand)
gomega.Expect(err).Should(gomega.BeNil(), "Failed to run '%s'", createCommand)
gitUpdateCommitPush(repoAbsolutePath, "Adding podinfo kustomization")
})
appSourcePath = addKustomizationManifests([]string{"podinfo-app-violations-manifest.yaml"})

ginkgo.By("Install kustomization Application on leaf cluster", func() {
pullGitRepo(repoAbsolutePath)
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/test/ui_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func createLeafClusterKubeconfig(leafClusterContext string, leafClusterName stri
gomega.Expect(stdErr).Should(gomega.BeEmpty(), "Failed to get control plane of kind cluster")

env := []string{"CLUSTER_NAME=" + leafClusterName, "CA_AUTHORITY=" + caAuthority, fmt.Sprintf("ENDPOINT=https://%s:6443", controlPlane), "TOKEN=" + token}
err = runCommandPassThroughWithEnv(env, "sh", "-c", fmt.Sprintf("%s > /tmp/%s", path.Join(getCheckoutRepoPath(), "test/utils/scripts/static-kubeconfig.sh"), leafClusterkubeconfig))
err = runCommandPassThroughWithEnv(env, "sh", "-c", fmt.Sprintf("%s > /tmp/%s", path.Join(testScriptsPath, "static-kubeconfig.sh"), leafClusterkubeconfig))
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to create kubeconfig for service account")
})
useClusterContext(currentContext)
Expand Down
Loading