summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCheng Fang <cfang@redhat.com>2024-10-01 07:34:35 -0400
committerGitHub <noreply@github.com>2024-10-01 07:34:35 -0400
commit720f495fcc3a5a05432fc40c95a08ae49fccba5f (patch)
tree413bbfe103c68aa4426c8fa9a9bbd7ec23daba8a /test
parent5403b3ed2adf04904ed14e8992ab8bed70d26abd (diff)
Add e2e test for adding configMap to allow defining parameters for SSH client (#873)
Signed-off-by: Cheng Fang <cfang@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/suite/103-ssh-client-config/01-assert.yaml35
-rw-r--r--test/e2e/suite/103-ssh-client-config/01-install.yaml5
-rw-r--r--test/e2e/suite/103-ssh-client-config/99-delete.yaml5
-rw-r--r--test/e2e/suite/103-ssh-client-config/README.md55
-rw-r--r--test/e2e/suite/103-ssh-client-config/clusterrolebinding.json7
-rw-r--r--test/e2e/suite/103-ssh-client-config/config3
-rw-r--r--test/e2e/suite/103-ssh-client-config/kustomization.yaml16
7 files changed, 126 insertions, 0 deletions
diff --git a/test/e2e/suite/103-ssh-client-config/01-assert.yaml b/test/e2e/suite/103-ssh-client-config/01-assert.yaml
new file mode 100644
index 0000000..7d9e61a
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/01-assert.yaml
@@ -0,0 +1,35 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: argocd-image-updater-ssh-config
+data:
+ config: |-
+ Host *
+ PubkeyAcceptedAlgorithms +ssh-rsa
+ HostkeyAlgorithms +ssh-rsa
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: argocd-image-updater
+spec:
+ selector:
+ matchLabels:
+ app.kubernetes.io/name: argocd-image-updater
+ template:
+ spec:
+ containers:
+ - name: argocd-image-updater
+ volumeMounts:
+ - mountPath: /app/config
+ name: image-updater-conf
+ - mountPath: /app/config/ssh
+ name: ssh-known-hosts
+ - mountPath: /app/.ssh
+ name: ssh-config
+ - mountPath: /tmp
+ name: tmp
+ - mountPath: /app/ssh-keys/id_rsa
+ name: ssh-signing-key
+ readOnly: true
+ subPath: sshPrivateKey
diff --git a/test/e2e/suite/103-ssh-client-config/01-install.yaml b/test/e2e/suite/103-ssh-client-config/01-install.yaml
new file mode 100644
index 0000000..797ed42
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/01-install.yaml
@@ -0,0 +1,5 @@
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+- command: kubectl -n argocd-image-updater-e2e apply -k .
+- command: sleep 5
diff --git a/test/e2e/suite/103-ssh-client-config/99-delete.yaml b/test/e2e/suite/103-ssh-client-config/99-delete.yaml
new file mode 100644
index 0000000..65fab11
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/99-delete.yaml
@@ -0,0 +1,5 @@
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+- command: kubectl -n argocd-image-updater-e2e delete -k .
+- command: sleep 5
diff --git a/test/e2e/suite/103-ssh-client-config/README.md b/test/e2e/suite/103-ssh-client-config/README.md
new file mode 100644
index 0000000..8f5317d
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/README.md
@@ -0,0 +1,55 @@
+This test case verifies the support for configuring ssh client via the config map `argocd-image-updater-ssh-config`.
+
+This test case performs the following steps:
+* kustomize the default argocd-image-updater installation by adding custom ssh config data to the config map `argocd-image-updater-ssh-config`
+* install the customized argocd-image-updater to the test cluster
+* verify that the customized ssh config (config map and volume mount) are present
+* uninstall argocd-image-updater from the test cluster
+
+To run this individual test case,
+
+* make sure both docker daemon and k8s cluster is running
+* `cd $HOME/go/src/image-updater/test/e2e`
+* `SRC_DIR=$HOME/go/src/image-updater kubectl kuttl test --namespace argocd-image-updater-e2e --timeout 120 --test 103-ssh-client-config`
+
+Test output:
+```bash
+ harness.go:278: Successful connection to cluster at: https://0.0.0.0:58961
+ harness.go:363: running tests
+ harness.go:75: going to run test suite with timeout of 120 seconds for each step
+ harness.go:375: testsuite: ./suite has 8 tests
+=== RUN kuttl/harness
+=== RUN kuttl/harness/103-ssh-client-config
+=== PAUSE kuttl/harness/103-ssh-client-config
+=== CONT kuttl/harness/103-ssh-client-config
+ logger.go:42: 19:47:52 | 103-ssh-client-config/1-install | starting test step 1-install
+ logger.go:42: 19:47:52 | 103-ssh-client-config/1-install | running command: [kubectl -n argocd-image-updater-e2e apply -k .]
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | serviceaccount/argocd-image-updater created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | role.rbac.authorization.k8s.io/argocd-image-updater created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | rolebinding.rbac.authorization.k8s.io/argocd-image-updater created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | configmap/argocd-image-updater-config created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | configmap/argocd-image-updater-ssh-config created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | secret/argocd-image-updater-secret created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | deployment.apps/argocd-image-updater created
+ logger.go:42: 19:47:53 | 103-ssh-client-config/1-install | running command: [sleep 5]
+ logger.go:42: 19:47:58 | 103-ssh-client-config/1-install | test step completed 1-install
+ logger.go:42: 19:47:58 | 103-ssh-client-config/99-delete | starting test step 99-delete
+ logger.go:42: 19:47:58 | 103-ssh-client-config/99-delete | running command: [kubectl -n argocd-image-updater-e2e delete -k .]
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | serviceaccount "argocd-image-updater" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | role.rbac.authorization.k8s.io "argocd-image-updater" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | rolebinding.rbac.authorization.k8s.io "argocd-image-updater" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | configmap "argocd-image-updater-config" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | configmap "argocd-image-updater-ssh-config" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | secret "argocd-image-updater-secret" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | deployment.apps "argocd-image-updater" deleted
+ logger.go:42: 19:47:59 | 103-ssh-client-config/99-delete | running command: [sleep 5]
+ logger.go:42: 19:48:04 | 103-ssh-client-config/99-delete | test step completed 99-delete
+ logger.go:42: 19:48:04 | 103-ssh-client-config | skipping kubernetes event logging
+=== NAME kuttl
+ harness.go:407: run tests finished
+ harness.go:515: cleaning up
+ harness.go:572: removing temp folder: ""
+--- PASS: kuttl (12.08s)
+ --- PASS: kuttl/harness (0.00s)
+ --- PASS: kuttl/harness/103-ssh-client-config (12.07s)
+```
diff --git a/test/e2e/suite/103-ssh-client-config/clusterrolebinding.json b/test/e2e/suite/103-ssh-client-config/clusterrolebinding.json
new file mode 100644
index 0000000..3a1048d
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/clusterrolebinding.json
@@ -0,0 +1,7 @@
+[
+ {
+ "op": "replace",
+ "path": "/subjects/0/namespace",
+ "value": "argocd-image-updater-e2e"
+ }
+]
diff --git a/test/e2e/suite/103-ssh-client-config/config b/test/e2e/suite/103-ssh-client-config/config
new file mode 100644
index 0000000..47210b0
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/config
@@ -0,0 +1,3 @@
+Host *
+ PubkeyAcceptedAlgorithms +ssh-rsa
+ HostkeyAlgorithms +ssh-rsa \ No newline at end of file
diff --git a/test/e2e/suite/103-ssh-client-config/kustomization.yaml b/test/e2e/suite/103-ssh-client-config/kustomization.yaml
new file mode 100644
index 0000000..65568c9
--- /dev/null
+++ b/test/e2e/suite/103-ssh-client-config/kustomization.yaml
@@ -0,0 +1,16 @@
+resources:
+ - https://github.com/argoproj-labs/argocd-image-updater/manifests/base?ref=stable
+
+configMapGenerator:
+ - name: argocd-image-updater-ssh-config
+ behavior: merge
+ files:
+ - config
+
+patches:
+ - path: clusterrolebinding.json
+ target:
+ group: rbac.authorization.k8s.io
+ version: v1
+ kind: ClusterRoleBinding
+ name: argocd-image-updater