Skip to content

Commit 093b4bf

Browse files
authored
Small fixes and tweeks for nightly cluster cleanup (#796)
1 parent 58277c9 commit 093b4bf

File tree

10 files changed

+55
-28
lines changed

10 files changed

+55
-28
lines changed

.github/workflows/acceptance-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ on:
4848
description: "Type of management cluster e.g. kind, eks or gke"
4949
required: true
5050
type: string
51+
capi_provider:
52+
description: "Capi provider e.g. capd, capa or capg"
53+
default: "capd"
54+
required: false
55+
type: string
5156
gitops-bin-path:
5257
description: "Path to gitops binary"
5358
default: "/usr/local/bin/gitops"
@@ -161,6 +166,7 @@ env:
161166
MANAGEMENT_CLUSTER_CNAME: weave.gitops.enterprise.com
162167
UPGRADE_MANAGEMENT_CLUSTER_CNAME: weave.gitops.upgrade.enterprise.com
163168
MANAGEMENT_CLUSTER_KIND: ${{ inputs.management-cluster-kind }}
169+
CAPI_PROVIDER: ${{ inputs.capi_provider }}
164170
GITOPS_BIN_PATH: ${{ inputs.gitops-bin-path }}
165171
ACCEPTANCE_TESTS_DATABASE_TYPE: ${{ inputs.database-type }}
166172
EKS_LEAF_KUBECONFIG: ${{ inputs.eks-leaf-kubeconfig }}

.github/workflows/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
git-provider_hostname: gitlab.git.dev.weave.works
9292
cluster_resource_set: true
9393
management-cluster-kind: kind
94+
capi_provider: capd
9495
gitops-bin-path: /usr/local/bin/gitops
9596
database-type: sqlite
9697
artifacts-base-dir: "/tmp/acceptance-test-gitlab-on-prem"

.github/workflows/nightly.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
git-provider_hostname: github.com
3838
cluster_resource_set: false
3939
management-cluster-kind: eks
40+
capi_provider: capa
4041
gitops-bin-path: /usr/local/bin/gitops
4142
database-type: postgres
4243
eks-leaf-kubeconfig: "/tmp/eks-leaf-kubeconfig"
@@ -75,6 +76,7 @@ jobs:
7576
git-provider_hostname: gitlab.com
7677
cluster_resource_set: false
7778
management-cluster-kind: gke
79+
capi_provider: capg
7880
gitops-bin-path: /usr/local/bin/gitops
7981
database-type: postgres
8082
gce-leaf-kubeconfig: "/tmp/gce-leaf-kubeconfig"

.github/workflows/test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ jobs:
237237
git-provider_hostname: github.com
238238
cluster_resource_set: true
239239
management-cluster-kind: kind
240+
capi_provider: capd
240241
gitops-bin-path: /usr/local/bin/gitops
241242
database-type: sqlite
242243
artifacts-base-dir: "/tmp/smoke-test-github"
@@ -265,6 +266,7 @@ jobs:
265266
git-provider_hostname: gitlab.com
266267
cluster_resource_set: true
267268
management-cluster-kind: kind
269+
capi_provider: capd
268270
gitops-bin-path: /usr/local/bin/gitops
269271
database-type: sqlite
270272
artifacts-base-dir: "/tmp/smoke-test-gitlab"
@@ -295,6 +297,7 @@ jobs:
295297
git-provider_hostname: gitlab.git.dev.weave.works
296298
cluster_resource_set: true
297299
management-cluster-kind: kind
300+
capi_provider: capd
298301
gitops-bin-path: /usr/local/bin/gitops
299302
database-type: sqlite
300303
artifacts-base-dir: "/tmp/smoke-test-gitlab-on-prem"
@@ -331,6 +334,7 @@ jobs:
331334
git-provider_hostname: github.com
332335
cluster_resource_set: true
333336
management-cluster-kind: kind
337+
capi_provider: capd
334338
gitops-bin-path: /usr/local/bin/gitops
335339
database-type: sqlite
336340
artifacts-base-dir: "/tmp/acceptance-test-github"

docs/acceptance_testing.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export SELENIUM_DEBUG=true
5555
export GITOPS_BIN_PATH=/usr/local/bin/gitops
5656
export ARTIFACTS_BASE_DIR=/tmp/acceptance-tests
5757
export MANAGEMENT_CLUSTER_KIND=kind
58+
export CAPI_PROVIDER=capd
5859
export ACCEPTANCE_TESTS_DATABASE_TYPE=sqlite
5960
export EXP_CLUSTER_RESOURCE_SET=true
6061
export UI_NODEPORT=30080
@@ -64,12 +65,13 @@ export CLUSTER_REPOSITORY=gitops-testing
6465
export LOGIN_USER_TYPE=cluster-user
6566
```
6667

67-
You can either set 'LOGIN_USER_TYPE' to `oidc` if oidc user authentication is desired or `cluster-user` if cluster user i.e. `admin` account authentication is desired to run the tests.
68+
You can either set 'LOGIN_USER_TYPE' to `oidc` if oidc user authentication is desired or `cluster-user` if cluster user i.e. `wego-admin` account authentication is desired to run the tests.
69+
You can also set 'CAPI_PROVIDER' to 'capa' or 'capg' as per requirements.
6870

6971
**User login**
7072
```
71-
export CLUSTER_ADMIN_PASSWORD=<Your chosen password for admin account>
72-
export CLUSTER_ADMIN_PASSWORD_HASH=<Bcrypt hash for your chosen password>
73+
export CLUSTER_ADMIN_PASSWORD=wego-enterprise
74+
export CLUSTER_ADMIN_PASSWORD_HASH='$2b$12$1mxK92n85K.Zga8eNe2j.eqhtC2HnSrvbOk9obSVKbUgJm4SCMwFm'
7375
export OIDC_ISSUER_URL='https://dex-01.wge.dev.weave.works'
7476
export DEX_CLIENT_ID='weave-gitops-enterprise'
7577
export DEX_CLIENT_SECRET='2JPIcb5IvO1isJ3Zii7jvjqbUtLtTC'

test/acceptance/test/ui_templates.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
849849
}
850850

851851
setParameterValues(createPage, paramSection)
852+
pages.ScrollWindow(webDriver, 0, 4000)
852853

853854
By("Then I should see PR preview containing identity reference added in the template", func() {
854855
Eventually(createPage.PreviewPR.Click).Should(Succeed())
@@ -958,6 +959,7 @@ func DescribeTemplates(gitopsTestRunner GitopsTestRunner) {
958959
}
959960

960961
setParameterValues(createPage, paramSection)
962+
pages.ScrollWindow(webDriver, 0, 4000)
961963

962964
By("Then I should see PR preview without identity reference added to the template", func() {
963965
Expect(createPage.PreviewPR.Click()).To(Succeed())

test/acceptance/test/utils.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
git_repository_url string
3535
selenium_service_url string
3636
gitops_bin_path string
37+
capi_provider string
3738
capi_endpoint_url string
3839
test_ui_url string
3940
artifacts_base_dir string
@@ -126,6 +127,7 @@ func SetupTestEnvironment() {
126127
test_ui_url = fmt.Sprintf(`https://%s:%s`, GetEnv("MANAGEMENT_CLUSTER_CNAME", "localhost"), GetEnv("UI_NODEPORT", "30080"))
127128
capi_endpoint_url = fmt.Sprintf(`https://%s:%s`, GetEnv("MANAGEMENT_CLUSTER_CNAME", "localhost"), GetEnv("UI_NODEPORT", "30080"))
128129
gitops_bin_path = GetEnv("GITOPS_BIN_PATH", "/usr/local/bin/gitops")
130+
capi_provider = GetEnv("CAPI_PROVIDER", "capd")
129131
artifacts_base_dir = GetEnv("ARTIFACTS_BASE_DIR", "/tmp/gitops-test/")
130132

131133
gitProviderEnv = initGitProviderData()
@@ -190,7 +192,7 @@ func InitializeWebdriver(wgeURL string) {
190192
a["enableNetwork"] = true
191193
chromeDriver := agouti.ChromeDriver(
192194
agouti.ChromeOptions("w3c", false),
193-
agouti.ChromeOptions("args", []string{"--disable-gpu", "--no-sandbox", "window-size=1500,2000", "--disable-blink-features=AutomationControlled", "--ignore-ssl-errors=yes", "--ignore-certificate-errors"}),
195+
agouti.ChromeOptions("args", []string{"--disable-gpu", "--no-sandbox", "window-size=1800,2500", "--disable-blink-features=AutomationControlled", "--ignore-ssl-errors=yes", "--ignore-certificate-errors"}),
194196
agouti.ChromeOptions("excludeSwitches", []string{"enable-automation"}))
195197
err = chromeDriver.Start()
196198
Expect(err).NotTo(HaveOccurred())
@@ -201,7 +203,7 @@ func InitializeWebdriver(wgeURL string) {
201203
webDriver, err = agouti.NewPage(selenium_service_url, agouti.Debug, agouti.Desired(agouti.Capabilities{
202204
"acceptInsecureCerts": true,
203205
"chromeOptions": map[string]interface{}{
204-
"args": []string{"--disable-gpu", "--no-sandbox", "window-size=1500,2000", "--disable-blink-features=AutomationControlled"},
206+
"args": []string{"--disable-gpu", "--no-sandbox", "window-size=1800,2500", "--disable-blink-features=AutomationControlled"},
205207
"w3c": false,
206208
"excludeSwitches": []string{"enable-automation"},
207209
}}))

test/acceptance/test/utils_runner.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,21 @@ func (b RealGitopsTestRunner) RestartDeploymentPods(appName string, namespace st
344344
func (b RealGitopsTestRunner) CreateIPCredentials(infrastructureProvider string) {
345345
testDataPath := path.Join(getCheckoutRepoPath(), "test", "utils", "data")
346346
if infrastructureProvider == "AWS" {
347-
By("Install AWSClusterStaticIdentity CRD", func() {
348-
_, _ = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl apply -f %s/infrastructure.cluster.x-k8s.io_awsclusterstaticidentities.yaml", testDataPath))
349-
_, _ = runCommandAndReturnStringOutput("kubectl wait --for=condition=established --timeout=90s crd/awsclusterstaticidentities.infrastructure.cluster.x-k8s.io", ASSERTION_2MINUTE_TIME_OUT)
350-
})
351-
352-
By("Install AWSClusterRoleIdentity CRD", func() {
353-
_, _ = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl apply -f %s/infrastructure.cluster.x-k8s.io_awsclusterroleidentities.yaml", testDataPath))
354-
_, _ = runCommandAndReturnStringOutput("kubectl wait --for=condition=established --timeout=90s crd/awsclusterroleidentities.infrastructure.cluster.x-k8s.io", ASSERTION_2MINUTE_TIME_OUT)
355-
})
347+
// CAPA installs the AWS identity crds
348+
if capi_provider != "capa" {
349+
By("Install AWSClusterStaticIdentity CRD", func() {
350+
_, _ = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl apply -f %s/infrastructure.cluster.x-k8s.io_awsclusterstaticidentities.yaml", testDataPath))
351+
_, _ = runCommandAndReturnStringOutput("kubectl wait --for=condition=established --timeout=90s crd/awsclusterstaticidentities.infrastructure.cluster.x-k8s.io", ASSERTION_2MINUTE_TIME_OUT)
352+
})
353+
354+
By("Install AWSClusterRoleIdentity CRD", func() {
355+
_, _ = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl apply -f %s/infrastructure.cluster.x-k8s.io_awsclusterroleidentities.yaml", testDataPath))
356+
_, _ = runCommandAndReturnStringOutput("kubectl wait --for=condition=established --timeout=90s crd/awsclusterroleidentities.infrastructure.cluster.x-k8s.io", ASSERTION_2MINUTE_TIME_OUT)
357+
})
358+
}
356359

357360
By("Create AWS Secret, AWSClusterStaticIdentity and AWSClusterRoleIdentity)", func() {
361+
_, _ = runCommandAndReturnStringOutput("kubectl create namespace capa-system")
358362
_, _ = runCommandAndReturnStringOutput(fmt.Sprintf("kubectl apply -f %s/aws_cluster_credentials.yaml", testDataPath), ASSERTION_30SECONDS_TIME_OUT)
359363
})
360364

@@ -375,9 +379,13 @@ func (b RealGitopsTestRunner) DeleteIPCredentials(infrastructureProvider string)
375379
testDataPath := path.Join(getCheckoutRepoPath(), "test", "utils", "data")
376380
if infrastructureProvider == "AWS" {
377381
By("Delete AWS identities and CRD", func() {
382+
// Identity crds are installed as part of CAPA installation
378383
_ = b.KubectlDelete([]string{}, fmt.Sprintf("%s/aws_cluster_credentials.yaml", testDataPath))
379-
_ = b.KubectlDelete([]string{}, fmt.Sprintf("%s/infrastructure.cluster.x-k8s.io_awsclusterroleidentities.yaml", testDataPath))
380-
_ = b.KubectlDelete([]string{}, fmt.Sprintf("%s/infrastructure.cluster.x-k8s.io_awsclusterstaticidentities.yaml", testDataPath))
384+
if capi_provider != "capa" {
385+
_ = b.KubectlDelete([]string{}, fmt.Sprintf("%s/infrastructure.cluster.x-k8s.io_awsclusterroleidentities.yaml", testDataPath))
386+
_ = b.KubectlDelete([]string{}, fmt.Sprintf("%s/infrastructure.cluster.x-k8s.io_awsclusterstaticidentities.yaml", testDataPath))
387+
_, _ = runCommandAndReturnStringOutput("kubectl delete namespace capa-system")
388+
}
381389
})
382390

383391
} else if infrastructureProvider == "AZURE" {

test/utils/data/aws_cluster_credentials.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
---
2-
apiVersion: v1
3-
kind: Namespace
4-
metadata:
5-
name: capa-system
6-
71
---
82
apiVersion: v1
93
kind: Secret

test/utils/scripts/wego-enterprise.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function setup {
215215
# enable cluster resource sets
216216
export EXP_CLUSTER_RESOURCE_SET=true
217217
# Install capi infrastructure provider
218-
if [ "$MANAGEMENT_CLUSTER_KIND" == "eks" ]; then
218+
if [ "$CAPI_PROVIDER" == "capa" ]; then
219219
aws cloudformation describe-stacks --stack-name wge-capi-cluster-api-provider-aws-sigs-k8s-io --region us-east-1
220220
if [ $? -ne 0 ]; then
221221
clusterawsadm bootstrap iam create-cloudformation-stack --config aws_bootstrap_config.yaml --region=us-east-1
@@ -226,7 +226,7 @@ function setup {
226226
aws ec2 create-key-pair --key-name weave-gitops-pesto --region us-east-1 --output text > ~/.ssh/weave-gitops-pesto.pem
227227
fi
228228
clusterctl init --infrastructure aws
229-
elif [ "$MANAGEMENT_CLUSTER_KIND" == "gke" ]; then
229+
elif [ "$CAPI_PROVIDER" == "capg" ]; then
230230
export GCP_B64ENCODED_CREDENTIALS=$( echo ${GCP_SA_KEY} | base64 | tr -d '\n' )
231231
clusterctl init --infrastructure gcp
232232
else
@@ -278,8 +278,6 @@ function reset {
278278
# Delete postgres db
279279
kubectl delete deployment postgres
280280
kubectl delete service postgres
281-
# Delete namespaces and their respective resources
282-
kubectl delete namespaces wkp-agent
283281
# Delete flux system from the management cluster
284282
flux uninstall --silent
285283
# Delete any orphan resources
@@ -288,11 +286,19 @@ function reset {
288286
kubectl delete secret my-pat
289287
kubectl delete ClusterResourceSet --all
290288
kubectl delete configmap calico-crs-configmap
291-
kubectl delete rolebinding read-templates
292-
kubectl delete rolebinding clusters-service-secrets-role
289+
kubectl delete ClusterRoleBinding clusters-service-impersonator
290+
kubectl delete ClusterRole clusters-service-impersonator-role
293291
# Delete policy agent
294292
kubectl delete ValidatingWebhookConfiguration policy-agent
295293
kubectl delete namespaces policy-system
294+
# Delete capi provider
295+
if [ "$CAPI_PROVIDER" == "capa" ]; then
296+
clusterctl delete --infrastructure aws
297+
elif [ "$CAPI_PROVIDER" == "capg" ]; then
298+
clusterctl delete --infrastructure gcp
299+
else
300+
clusterctl delete --infrastructure docker
301+
fi
296302
}
297303

298304
function reset_controllers {

0 commit comments

Comments
 (0)