@@ -2,7 +2,6 @@ package acceptance
2
2
3
3
import (
4
4
"fmt"
5
- "io/ioutil"
6
5
"log"
7
6
"os/exec"
8
7
"path"
@@ -14,39 +13,6 @@ import (
14
13
"github.com/onsi/gomega/gexec"
15
14
)
16
15
17
- func configureConfigMapvalues (repoAbsolutePath string , uiNodePort string , natsNodeport string , natsURL string , repositoryURL string ) {
18
- pullGitRepo (repoAbsolutePath )
19
-
20
- configMapYaml := path .Join (repoAbsolutePath , "upgrade" , "weave-gitops-enterprise" , "artifacts" , "mccp-chart" , "helm-chart" , "ConfigMap.yaml" )
21
-
22
- input , err := ioutil .ReadFile (configMapYaml )
23
- Expect (err ).ShouldNot (HaveOccurred ())
24
-
25
- lines := strings .Split (string (input ), "\n " )
26
-
27
- for i , line := range lines {
28
- if uiNodePort != "" && strings .Contains (line , "nginx-ingress-controller" ) {
29
- lines = append (lines [:i + 2 ], lines [i + 1 :]... )
30
- lines [i + 2 ] = " type: NodePort"
31
- lines [i + 5 ] = " " + uiNodePort
32
- }
33
- if natsNodeport != "" && strings .Contains (line , "nodePort: 31490" ) {
34
- lines [i ] = " nodePort: " + natsNodeport
35
- }
36
- if natsURL != "" && strings .Contains (line , "natsURL: " ) {
37
- lines [i ] = " natsURL: " + natsURL
38
- }
39
- if repositoryURL != "" && strings .Contains (line , "repositoryURL: " ) {
40
- lines [i ] = " repositoryURL: " + repositoryURL
41
- }
42
- }
43
-
44
- output := strings .Join (lines , "\n " )
45
- err = ioutil .WriteFile (configMapYaml , []byte (output ), 0644 )
46
- Expect (err ).ShouldNot (HaveOccurred ())
47
-
48
- }
49
-
50
16
func DescribeCliUpgrade (gitopsTestRunner GitopsTestRunner ) {
51
17
var _ = Describe ("Gitops upgrade Tests" , func () {
52
18
@@ -76,8 +42,6 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
76
42
var public_ip string
77
43
kind_upgrade_cluster_name := "test-upgrade"
78
44
79
- appName := "wego-upgrade"
80
- appPath := "upgrade"
81
45
templateFiles := []string {}
82
46
83
47
JustBeforeEach (func () {
@@ -113,26 +77,12 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
113
77
114
78
By ("When I create a private repository for cluster configs" , func () {
115
79
repoAbsolutePath = gitopsTestRunner .InitAndCreateEmptyRepo (CLUSTER_REPOSITORY , true )
116
- testFile := createTestFile ("README.md" , "# gitops-capi-template" )
117
-
118
- gitopsTestRunner .GitAddCommitPush (repoAbsolutePath , testFile )
119
80
})
120
81
121
82
By ("When I install gitops/wego to my active cluster" , func () {
122
83
InstallAndVerifyGitops (GITOPS_DEFAULT_NAMESPACE , GetGitRepositoryURL (repoAbsolutePath ))
123
84
})
124
85
125
- By ("And I install profile controllers to my active cluster" , func () {
126
- InstallAndVerifyPctl (GITOPS_DEFAULT_NAMESPACE )
127
- })
128
-
129
- addCommand := fmt .Sprintf ("add app . --path=./%s --name=%s --auto-merge=true" , appPath , appName )
130
- By (fmt .Sprintf ("And I run gitops add app command ' %s 'in namespace %s from dir %s" , addCommand , GITOPS_DEFAULT_NAMESPACE , repoAbsolutePath ), func () {
131
- cmd := fmt .Sprintf ("cd %s && %s %s" , repoAbsolutePath , GITOPS_BIN_PATH , addCommand )
132
- _ , err := runCommandAndReturnStringOutput (cmd )
133
- Expect (err ).Should (BeEmpty ())
134
- })
135
-
136
86
By ("And I install the entitlement for cluster upgrade" , func () {
137
87
Expect (gitopsTestRunner .KubectlApply ([]string {}, "../../utils/scripts/entitlement-secret.yaml" ), "Failed to create/configure entitlement" )
138
88
})
@@ -143,19 +93,16 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
143
93
Expect (err ).Should (BeEmpty (), "Failed to create git repository secret for cluster service" )
144
94
})
145
95
146
- By ("And I install the docker registry secret for wego enteprise components" , func () {
147
- cmd := fmt .Sprintf (`kubectl create secret docker-registry docker-io-pull-secret --namespace=%s --docker-username=%s --docker-password=%s` , GITOPS_DEFAULT_NAMESPACE , DOCKER_IO_USER , DOCKER_IO_PASSWORD )
148
- _ , err := runCommandAndReturnStringOutput (cmd )
149
- Expect (err ).Should (BeEmpty (), "Failed to create git repository secret for cluster service" )
150
- })
151
-
152
- By ("Then I should see gitops add command linked the repo to the cluster" , func () {
153
- verifyWegoAddCommand (appName , GITOPS_DEFAULT_NAMESPACE )
96
+ By ("And I should update/modify the default upgrade manifest " , func () {
97
+ public_ip = ClusterWorkloadNonePublicIP ("KIND" )
154
98
})
155
99
156
100
prBranch := "wego-upgrade-enterprise"
157
- upgradeCommand := fmt .Sprintf ("upgrade --git-repository %s/%s --branch %s --out %s" , GITOPS_DEFAULT_NAMESPACE , appName , prBranch , appPath )
158
- By (fmt .Sprintf ("And I run gitops upgrade command ' %s ' form firectory %s" , upgradeCommand , repoAbsolutePath ), func () {
101
+ profileVersion := "0.0.15"
102
+ By (fmt .Sprintf ("And I run gitops upgrade command from directory %s" , repoAbsolutePath ), func () {
103
+ natsURL := public_ip + ":" + NATS_NODEPORT
104
+ repositoryURL := fmt .Sprintf (`https://github.com/%s/%s` , GITHUB_ORG , CLUSTER_REPOSITORY )
105
+ upgradeCommand := fmt .Sprintf ("upgrade --profile-version %s --app-config-url %s --branch %s --set 'agentTemplate.natsURL=%s' --set 'nats.client.service.nodePort=%s'" , profileVersion , repositoryURL , prBranch , natsURL , NATS_NODEPORT )
159
106
command := exec .Command ("sh" , "-c" , fmt .Sprintf ("cd %s && %s %s" , repoAbsolutePath , GITOPS_BIN_PATH , upgradeCommand ))
160
107
session , err = gexec .Start (command , GinkgoWriter , GinkgoWriter )
161
108
Expect (err ).ShouldNot (HaveOccurred ())
@@ -166,53 +113,26 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
166
113
By ("Then I should see pull request created to management cluster" , func () {
167
114
output := session .Wait ().Out .Contents ()
168
115
169
- re := regexp .MustCompile (`PR created.*:[\s\w\d]+(?P<URL>https.*\/\d+)` )
116
+ re := regexp .MustCompile (`Pull Request created.*:[\s\w\d]+(?P<URL>https.*\/\d+)` )
170
117
match := re .FindSubmatch ([]byte (output ))
171
118
Eventually (match [1 ]).ShouldNot (BeNil (), "Failed to Create pull request" )
172
119
})
173
120
174
- By ("And I should update/modify the default upgrade manifest " , func () {
175
- public_ip = ClusterWorkloadNonePublicIP ("KIND" )
176
- natsURL := public_ip + ":" + NATS_NODEPORT
177
- repositoryURL := fmt .Sprintf (`https://github.com/%s/%s` , GITHUB_ORG , CLUSTER_REPOSITORY )
178
- gitopsTestRunner .PullBranch (repoAbsolutePath , prBranch )
179
- configureConfigMapvalues (repoAbsolutePath , UI_NODEPORT , NATS_NODEPORT , natsURL , repositoryURL )
180
- GitSetUpstream (repoAbsolutePath , prBranch )
181
- GitUpdateCommitPush (repoAbsolutePath , "" )
182
- })
183
-
184
121
By ("Then I should merge the pull request to start weave gitops enterprise upgrade" , func () {
185
122
gitopsTestRunner .MergePullRequest (repoAbsolutePath , prBranch )
186
123
})
187
124
188
125
By ("And I should see cluster upgraded from 'wego core' to 'wego enterprise'" , func () {
189
- VerifyEnterpriseControllers ("mccp-chart" , GITOPS_DEFAULT_NAMESPACE )
190
- })
191
-
192
- By ("And I can change the config map values for the upgrade profile" , func () {
193
- repositoryURL := fmt .Sprintf (`https://github.com/%s/%s` , GITHUB_ORG , CLUSTER_REPOSITORY )
194
- configureConfigMapvalues (repoAbsolutePath , "" , "" , "" , repositoryURL )
195
- GitUpdateCommitPush (repoAbsolutePath , "" )
196
- })
197
-
198
- By ("Then I restart the cluster service pod for capi config to take effect" , func () {
199
- configmapValuesUpdated := func () bool {
200
- data , _ := runCommandAndReturnStringOutput (fmt .Sprintf (`kubectl get configmap -n %s weave-gitops-enterprise-mccp-chart-defaultvalues -o jsonpath="{.data}"` , GITOPS_DEFAULT_NAMESPACE ))
201
- re := regexp .MustCompile (fmt .Sprintf (`repositoryURL:\s*(?P<url>https:.*%s)` , CLUSTER_REPOSITORY ))
202
- return len (re .FindSubmatch ([]byte (data ))) > 0
203
- }
204
-
205
- Eventually (configmapValuesUpdated , ASSERTION_2MINUTE_TIME_OUT , POLL_INTERVAL_5SECONDS ).Should (BeTrue (), "ConfigMap values failed to reconcile" )
206
- Expect (gitopsTestRunner .RestartDeploymentPods ([]string {}, "mccp-chart-cluster-service" , GITOPS_DEFAULT_NAMESPACE ), "Failed restart deployment successfully" )
126
+ VerifyEnterpriseControllers ("weave-gitops-enterprise" , "mccp-" , GITOPS_DEFAULT_NAMESPACE )
207
127
})
208
128
209
129
By ("And I can also use upgraded enterprise UI/CLI after port forwarding (for loadbalancer ingress controller)" , func () {
210
- serviceType , _ := runCommandAndReturnStringOutput (fmt .Sprintf (`kubectl get service mccp-chart -nginx-ingress-controller -n %s -o jsonpath="{.spec.type}"` , GITOPS_DEFAULT_NAMESPACE ))
130
+ serviceType , _ := runCommandAndReturnStringOutput (fmt .Sprintf (`kubectl get service weave-gitops-enterprise -nginx-ingress-controller -n %s -o jsonpath="{.spec.type}"` , GITOPS_DEFAULT_NAMESPACE ))
211
131
if strings .Trim (serviceType , "\n " ) == "NodePort" {
212
132
capi_endpoint_url = "http://" + public_ip + ":" + UI_NODEPORT
213
133
test_ui_url = "http://" + public_ip + ":" + UI_NODEPORT
214
134
} else {
215
- commandToRun := fmt .Sprintf ("kubectl port-forward --namespace %s deployments.apps/mccp-chart -nginx-ingress-controller 8000:80" , GITOPS_DEFAULT_NAMESPACE )
135
+ commandToRun := fmt .Sprintf ("kubectl port-forward --namespace %s deployments.apps/weave-gitops-enterprise -nginx-ingress-controller 8000:80" , GITOPS_DEFAULT_NAMESPACE )
216
136
217
137
cmd := exec .Command ("sh" , "-c" , commandToRun )
218
138
session , _ := gexec .Start (cmd , GinkgoWriter , GinkgoWriter )
0 commit comments