55 "fmt"
66 "os"
77 "path"
8+ "path/filepath"
89 "sort"
910 "strconv"
1011 "strings"
@@ -63,6 +64,22 @@ func selectCredentials(createPage *pages.CreateCluster, credentialName string, c
6364 gomega .Eventually (selectCredential , ASSERTION_30SECONDS_TIME_OUT , POLL_INTERVAL_5SECONDS ).Should (gomega .BeTrue ())
6465}
6566
67+ func addKustomizationManifests (manifestYamls []string ) string {
68+ manifestPath := "./apps"
69+ ginkgo .By ("Add Application/Kustomization manifests to management cluster's repository main branch)" , func () {
70+ repoAbsolutePath := configRepoAbsolutePath (gitProviderEnv )
71+ pullGitRepo (repoAbsolutePath )
72+
73+ for _ , yaml := range manifestYamls {
74+ manifest := path .Join (testDataPath , yaml )
75+ _ = runCommandPassThrough ("sh" , "-c" , fmt .Sprintf ("mkdir -p %[2]v && cp -f %[1]v %[2]v" , manifest , path .Join (repoAbsolutePath , manifestPath , strings .TrimSuffix (filepath .Base (yaml ), filepath .Ext (yaml )))))
76+ }
77+
78+ gitUpdateCommitPush (repoAbsolutePath , "Adding application kustomization manifests" )
79+ })
80+ return manifestPath
81+ }
82+
6683func DescribeTemplates (gitopsTestRunner GitopsTestRunner ) {
6784 var _ = ginkgo .Describe ("Multi-Cluster Control Plane Templates" , func () {
6885 templateFiles := []string {}
@@ -387,10 +404,6 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
387404 // Force clean the repository directory for subsequent tests
388405 cleanGitRepository (clusterPath )
389406 _ = deleteFile ([]string {downloadedResourcesPath })
390-
391- // Namespaces used for kustomization, waiting for them to terminate
392- reconcile ("reconcile" , "source" , "git" , "flux-system" , GITOPS_DEFAULT_NAMESPACE , "" )
393- waitForNamespaceDeletion ([]string {"test-system" })
394407 })
395408
396409 ginkgo .It ("Verify pull request can be created for capi template to the management cluster" , ginkgo .Label ("integration" , "git" , "browser-logs" ), func () {
@@ -678,7 +691,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
678691 gomega .Expect (gitops .CreatePR .Click ()).To (gomega .Succeed (), "Failed to click 'CREATE PULL REQUEST' button" )
679692 })
680693
681- ginkgo .By ("Then I should not see pull request to be created " , func () {
694+ ginkgo .By ("Then I should not see pull request error creation message " , func () {
682695 gomega .Eventually (messages .Error ).Should (matchers .MatchText (fmt .Sprintf (`unable to create pull request.+unable to create new branch "%s"` , branchName )))
683696 })
684697 })
@@ -687,13 +700,13 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
687700 ginkgo .Context ("[UI] When no infrastructure provider credentials are available in the management cluster" , func () {
688701 ginkgo .It ("Verify no credentials exists in management cluster" , ginkgo .Label ("integration" , "git" ), func () {
689702 ginkgo .By ("Apply/Install CAPITemplate" , func () {
690- templateFiles = gitopsTestRunner .CreateApplyCapitemplates (1 , "capi -template-capd .yaml" )
703+ templateFiles = gitopsTestRunner .CreateApplyCapitemplates (1 , "templates/aws/cluster -template-eks .yaml" )
691704 })
692705
693706 navigateToTemplatesGrid (webDriver )
694707
695708 ginkgo .By ("And User should choose a template" , func () {
696- templateTile := pages .GetTemplateTile (webDriver , "cluster-template-development -0" )
709+ templateTile := pages .GetTemplateTile (webDriver , "capa- cluster-template-eks -0" )
697710 gomega .Expect (templateTile .CreateTemplate .Click ()).To (gomega .Succeed ())
698711 })
699712
@@ -923,6 +936,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
923936 var crsConfigmap string
924937 var downloadedKubeconfigPath string
925938 var capdCluster ClusterConfig
939+ var appSourcePath string
926940
927941 clusterNamespace := map [string ]string {
928942 GitProviderGitLab : "capi-test-system" ,
@@ -954,25 +968,16 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
954968 reconcile ("suspend" , "source" , "git" , "flux-system" , GITOPS_DEFAULT_NAMESPACE , "" )
955969 // Force clean the repository directory for subsequent tests
956970 cleanGitRepository (clusterPath )
957- cleanGitRepository (path .Join ("./clusters" , capdCluster .Namespace , capdCluster .Name ))
971+ cleanGitRepository (path .Join ("./clusters" , capdCluster .Namespace ))
972+ cleanGitRepository (appSourcePath )
958973 // Force delete capicluster incase delete PR fails to delete to free resources
959974 removeGitopsCapiClusters ([]ClusterConfig {capdCluster })
960975 reconcile ("resume" , "source" , "git" , "flux-system" , GITOPS_DEFAULT_NAMESPACE , "" )
961976 })
962977
963978 ginkgo .It ("Verify leaf CAPD cluster can be provisioned and kubeconfig is available for cluster operations" , ginkgo .Label ("smoke" , "integration" , "capd" , "git" , "browser-logs" ), func () {
964979 repoAbsolutePath := configRepoAbsolutePath (gitProviderEnv )
965-
966- ginkgo .By ("Add Application/Kustomization manifests to management cluster's repository main branch)" , func () {
967- pullGitRepo (repoAbsolutePath )
968- postgres := path .Join (testDataPath , "postgres-manifest.yaml" )
969- _ = runCommandPassThrough ("sh" , "-c" , fmt .Sprintf ("mkdir -p %[2]v && cp -f %[1]v %[2]v" , postgres , path .Join (repoAbsolutePath , "apps/postgres" )))
970-
971- podinfo := path .Join (testDataPath , "podinfo-manifest.yaml" )
972- _ = runCommandPassThrough ("sh" , "-c" , fmt .Sprintf ("mkdir -p %[2]v && cp -f %[1]v %[2]v" , podinfo , path .Join (repoAbsolutePath , "apps/podinfo" )))
973-
974- gitUpdateCommitPush (repoAbsolutePath , "Adding postgres kustomization" )
975- })
980+ appSourcePath = addKustomizationManifests ([]string {"postgres-manifest.yaml" , "podinfo-manifest.yaml" })
976981
977982 ginkgo .By ("Then I Apply/Install CAPITemplate" , func () {
978983 templateFiles = gitopsTestRunner .CreateApplyCapitemplates (1 , "capi-template-capd.yaml" )
@@ -1073,7 +1078,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
10731078 Name : "postgres" ,
10741079 Namespace : GITOPS_DEFAULT_NAMESPACE ,
10751080 TargetNamespace : GITOPS_DEFAULT_NAMESPACE ,
1076- Path : "apps/postgres" ,
1081+ Path : "apps/postgres-manifest " ,
10771082 }
10781083 gomega .Expect (createPage .AddApplication .Click ()).Should (gomega .Succeed (), "Failed to click 'Add application' button" )
10791084 application := pages .GetAddApplication (webDriver , 1 )
@@ -1084,7 +1089,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
10841089 Name : "podinfo" ,
10851090 Namespace : GITOPS_DEFAULT_NAMESPACE ,
10861091 TargetNamespace : GITOPS_DEFAULT_NAMESPACE ,
1087- Path : "apps/podinfo" ,
1092+ Path : "apps/podinfo-manifest " ,
10881093 }
10891094 gomega .Expect (createPage .AddApplication .Click ()).Should (gomega .Succeed (), "Failed to click 'Add application' button" )
10901095 application = pages .GetAddApplication (webDriver , 2 )
@@ -1242,17 +1247,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
12421247
12431248 ginkgo .It ("Verify CAPI cluster resource can be modified/edited" , ginkgo .Label ("integration" , "capd" , "git" ), func () {
12441249 repoAbsolutePath := configRepoAbsolutePath (gitProviderEnv )
1245-
1246- ginkgo .By ("Add Application/Kustomization manifests to management cluster's repository main branch)" , func () {
1247- pullGitRepo (repoAbsolutePath )
1248- postgres := path .Join (testDataPath , "postgres-manifest.yaml" )
1249- _ = runCommandPassThrough ("sh" , "-c" , fmt .Sprintf ("mkdir -p %[2]v && cp -f %[1]v %[2]v" , postgres , path .Join (repoAbsolutePath , "apps/postgres" )))
1250-
1251- podinfo := path .Join (testDataPath , "podinfo-manifest.yaml" )
1252- _ = runCommandPassThrough ("sh" , "-c" , fmt .Sprintf ("mkdir -p %[2]v && cp -f %[1]v %[2]v" , podinfo , path .Join (repoAbsolutePath , "apps/podinfo" )))
1253-
1254- gitUpdateCommitPush (repoAbsolutePath , "Adding postgres kustomization" )
1255- })
1250+ appSourcePath = addKustomizationManifests ([]string {"postgres-manifest.yaml" , "podinfo-manifest.yaml" })
12561251
12571252 ginkgo .By ("Then I Apply/Install CAPITemplate" , func () {
12581253 templateFiles = gitopsTestRunner .CreateApplyCapitemplates (1 , "capi-template-capd.yaml" )
@@ -1352,7 +1347,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
13521347 Name : "postgres" ,
13531348 Namespace : GITOPS_DEFAULT_NAMESPACE ,
13541349 TargetNamespace : GITOPS_DEFAULT_NAMESPACE ,
1355- Path : "apps/postgres" ,
1350+ Path : "apps/postgres-manifest " ,
13561351 }
13571352 gomega .Expect (createPage .AddApplication .Click ()).Should (gomega .Succeed (), "Failed to click 'Add application' button" )
13581353 application := pages .GetAddApplication (webDriver , 1 )
@@ -1472,7 +1467,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
14721467 Name : "podinfo" ,
14731468 Namespace : GITOPS_DEFAULT_NAMESPACE ,
14741469 TargetNamespace : "test-system" ,
1475- Path : "apps/podinfo" ,
1470+ Path : "apps/podinfo-manifest " ,
14761471 }
14771472 gomega .Expect (createPage .AddApplication .Click ()).Should (gomega .Succeed (), "Failed to click 'Add application' button" )
14781473 application = pages .GetAddApplication (webDriver , 1 )
0 commit comments