From dccea239bce2651f4e14e7490b6ed370096d57a7 Mon Sep 17 00:00:00 2001 From: Siddhesh Ghadi Date: Thu, 14 Sep 2023 13:34:23 +0530 Subject: [PATCH] Add kuttl test for resourceCustomization removal in ArgoCD v1beta1 Signed-off-by: Siddhesh Ghadi --- .../01-alpha-argocd.yaml | 50 +++++++++++++++++++ .../01-assert.yaml | 32 ++++++++++++ .../02-errors.yaml | 27 ++++++++++ 3 files changed, 109 insertions(+) create mode 100644 tests/olm/1-005_drop_resource_customizations/01-alpha-argocd.yaml create mode 100644 tests/olm/1-005_drop_resource_customizations/01-assert.yaml create mode 100644 tests/olm/1-005_drop_resource_customizations/02-errors.yaml diff --git a/tests/olm/1-005_drop_resource_customizations/01-alpha-argocd.yaml b/tests/olm/1-005_drop_resource_customizations/01-alpha-argocd.yaml new file mode 100644 index 000000000..7d341ce2a --- /dev/null +++ b/tests/olm/1-005_drop_resource_customizations/01-alpha-argocd.yaml @@ -0,0 +1,50 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ArgoCD +metadata: + name: argocd +spec: + resourceCustomizations: | + PersistentVolumeClaim: + health.lua: | + hs = {} + if obj.status ~= nil then + if obj.status.phase ~= nil then + if obj.status.phase == "Pending" then + hs.status = "Healthy" + hs.message = obj.status.phase + return hs + end + if obj.status.phase == "Bound" then + hs.status = "Healthy" + hs.message = obj.status.phase + return hs + end + end + end + hs.status = "Progressing" + hs.message = "Waiting for certificate" + return hs + resourceHealthChecks: + - group: certmanager.k8s.io + kind: Certificate + check: | + hs = {} + if obj.status ~= nil then + if obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" and condition.status == "False" then + hs.status = "Degraded" + hs.message = condition.message + return hs + end + if condition.type == "Ready" and condition.status == "True" then + hs.status = "Healthy" + hs.message = condition.message + return hs + end + end + end + end + hs.status = "Progressing" + hs.message = "Waiting for certificate" + return hs \ No newline at end of file diff --git a/tests/olm/1-005_drop_resource_customizations/01-assert.yaml b/tests/olm/1-005_drop_resource_customizations/01-assert.yaml new file mode 100644 index 000000000..442d5159a --- /dev/null +++ b/tests/olm/1-005_drop_resource_customizations/01-assert.yaml @@ -0,0 +1,32 @@ +apiVersion: argoproj.io/v1beta1 +kind: ArgoCD +metadata: + name: argocd +spec: + resourceHealthChecks: + - group: certmanager.k8s.io + kind: Certificate + check: | + hs = {} + if obj.status ~= nil then + if obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" and condition.status == "False" then + hs.status = "Degraded" + hs.message = condition.message + return hs + end + if condition.type == "Ready" and condition.status == "True" then + hs.status = "Healthy" + hs.message = condition.message + return hs + end + end + end + end + hs.status = "Progressing" + hs.message = "Waiting for certificate" + return hs +status: + phase: Available + diff --git a/tests/olm/1-005_drop_resource_customizations/02-errors.yaml b/tests/olm/1-005_drop_resource_customizations/02-errors.yaml new file mode 100644 index 000000000..e923cd849 --- /dev/null +++ b/tests/olm/1-005_drop_resource_customizations/02-errors.yaml @@ -0,0 +1,27 @@ +apiVersion: argoproj.io/v1beta1 +kind: ArgoCD +metadata: + name: argocd +spec: + resourceCustomizations: | + PersistentVolumeClaim: + health.lua: | + hs = {} + if obj.status ~= nil then + if obj.status.phase ~= nil then + if obj.status.phase == "Pending" then + hs.status = "Healthy" + hs.message = obj.status.phase + return hs + end + if obj.status.phase == "Bound" then + hs.status = "Healthy" + hs.message = obj.status.phase + return hs + end + end + end + hs.status = "Progressing" + hs.message = "Waiting for certificate" + return hs +