Skip to content

Commit

Permalink
Fixed kuttl test 022
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <[email protected]>
  • Loading branch information
ciiay committed Jun 8, 2023
1 parent 16eb088 commit 004ada0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 21 deletions.
16 changes: 2 additions & 14 deletions controllers/argocd/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,24 +411,12 @@ func (r *ReconcileArgoCD) reconcileNotificationsConfigMap(cr *argoprojv1a1.ArgoC
}

log.Info(fmt.Sprintf("Creating configmap %s", desiredConfigMap.Name))
err := r.Client.Create(context.TODO(), desiredConfigMap)
if err != nil {
return err
}

return nil
}

// ConfigMap exists, reconcile if changed
if !reflect.DeepEqual(existingConfigMap.Data, desiredConfigMap.Data) {
existingConfigMap.Data = desiredConfigMap.Data
if err := controllerutil.SetControllerReference(cr, existingConfigMap, r.Scheme); err != nil {
if err := r.Client.Create(context.TODO(), desiredConfigMap); err != nil {
return err
}

return r.Client.Update(context.TODO(), existingConfigMap)
}

// If the ConfigMap already exists, do nothing.
return nil
}

Expand Down
43 changes: 43 additions & 0 deletions tests/k8s/1-022_validate_notifications/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
name: argocd
status:
phase: Available
notificationsController: Running
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: argocd-notifications-controller
status:
conditions:
- type: Available
status: 'True'
- type: Progressing
status: 'True'
---
kind: Secret
apiVersion: v1
metadata:
name: argocd-notifications-secret
---
kind: ConfigMap
apiVersion: v1
metadata:
name: argocd-notifications-cm
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: argocd-argocd-notifications-controller
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: argocd-argocd-notifications-controller
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: argocd-argocd-notifications-controller
6 changes: 6 additions & 0 deletions tests/k8s/1-022_validate_notifications/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.email.gmail: "{host: smtp4dev, port: 2525, from: [email protected]}"
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: sleep 15
- script: |
set -e
kubectl patch cm argocd-notifications-cm -n $NAMESPACE --type merge -p '{"data": {"service.email.gmail": "{host: smtp4dev, port: 2525, from: [email protected] }" }}'
- script: sleep 5

kubectl patch cm argocd-notifications-cm -n $NAMESPACE --type merge -p '{"data": {"service.email.gmail": "{host: smtp4dev, port: 2525, from: [email protected]}" }}'
14 changes: 14 additions & 0 deletions tests/k8s/1-022_validate_notifications/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app-3
annotations:
"notifications.argoproj.io/subscribe.on-created.gmail": "[email protected]"
spec:
destination:
server: https://kubernetes.default.svc
project: default
source:
repoURL: https://github.com/redhat-developer/gitops-operator
path: test/examples/nginx
targetRevision: HEAD
3 changes: 1 addition & 2 deletions tests/k8s/1-022_validate_notifications/03-create-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ commands:
repoURL: https://github.com/redhat-developer/gitops-operator
path: test/examples/nginx
targetRevision: HEAD
EOF
- script: sleep 5
EOF
4 changes: 3 additions & 1 deletion tests/k8s/1-022_validate_notifications/04-delete-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ commands:
set -e
kubectl delete -n $NAMESPACE application.argoproj.io my-app-3
- script: sleep 5
- script: sleep 5
- script: |
! kubectl get -n $NAMESPACE application.argoproj.io my-app-3

0 comments on commit 004ada0

Please sign in to comment.