From 05f7c599a762ed09e056da61e361486e4f0e2223 Mon Sep 17 00:00:00 2001 From: nsathyaseelan Date: Fri, 6 Aug 2021 18:58:24 +0530 Subject: [PATCH] refactor[e2e]: Modify the test case to provision the jiva operator Signed-off-by: nsathyaseelan --- .../jiva-csi-provisioner/test.yml | 246 +++++++++++++++--- .../jiva-csi-provisioner/test_vars.yml | 12 + .../jiva-csi-storage-policies/localpv-sc.yml | 13 + .../jiva-csi-storage-policies/test.yml | 2 + .../jiva-csi-storage-policies/test_vars.yml | 1 + 5 files changed, 231 insertions(+), 43 deletions(-) create mode 100644 e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/localpv-sc.yml diff --git a/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test.yml b/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test.yml index df47324..79fe9f7 100644 --- a/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test.yml +++ b/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test.yml @@ -18,39 +18,128 @@ status: 'SOT' - block: - - - name: Downloading jiva operator yaml for rc tag - get_url: - url: "{{ release_operator_link }}" - dest: "{{ playbook_dir }}/{{ jiva_operator }}" - force: yes - register: release_operator + - block: + - name: Downloading jiva operator yaml for release tag + get_url: + url: "{{ release_operator_link }}" + dest: "{{ playbook_dir }}/{{ jiva_operator }}" + force: yes + register: release_operator + + - name: Downloading localpv operator yaml for release tag + get_url: + url: "{{ release_hostpath_link }}" + dest: "{{ playbook_dir }}/{{ charts_localpv_operator }}" + force: yes + register: localpv_operator + + - block: + + - name: Deploy localpv operator + shell: > + kubectl apply -f {{ charts_localpv_operator }} + args: + executable: /bin/bash + register: localpv_status + + - name: Deploy jiva operator + shell: > + kubectl apply -f {{ jiva_operator }} + args: + executable: /bin/bash + register: deploy_status + + when: lookup('env','ACTION') == "provision" + + - block: + + - name: Deprovision jiva operator + shell: > + kubectl delete -f {{ jiva_operator }} + args: + executable: /bin/bash + register: jiva_deprovision + ignore_errors: True + + - name: Deprovision localpv operator + shell: > + kubectl delete -f {{ charts_localpv_operator }} + args: + executable: /bin/bash + register: deprovision_status + ignore_errors: True + + when: lookup('env','ACTION') == "deprovision" + when: rc_tag == "" + + - block: - - name: Downloading jiva operator yaml release tag - get_url: - url: "{{ rc_operator_link }}" - dest: "{{ playbook_dir }}/{{ jiva_operator }}" - force: yes - register: rc_operator - when: rc_tag != "" + - name: Downloading jiva operator yaml release tag + get_url: + url: "{{ rc_operator_link }}" + dest: "{{ playbook_dir }}/{{ jiva_operator }}" + force: yes + register: rc_operator + + - name: Downloading hostpath operator yaml + get_url: + url: "{{ hostpath_operator_link }}" + dest: "{{ playbook_dir }}/{{ hostpath_operator }}" + force: yes + register: result_hostpath + + - name: Change the Localpv provisioner image + replace: + path: "{{ hostpath_operator }}" + regexp: "openebs/provisioner-localpv-ci:dev-120403" + replace: "openebs/provisioner-localpv:{{ localpv_tag }}" - - name: Deploy jiva operator - shell: > - kubectl apply -f {{ jiva_operator }} - args: - executable: /bin/bash - register: deploy_status - when: lookup('env','ACTION') == "provision" + - name: Change the OpenEBS component labels to desired version in Operator yaml + replace: + path: "{{ hostpath_operator }}" + regexp: 'openebs.io/version: dev' + replace: "openebs.io/version: {{ localpv_tag }}" + + - block: + + - name: Deploy localpv operator + shell: > + kubectl apply -f {{ hostpath_operator }} + args: + executable: /bin/bash + register: localpv_status + + - name: Deploy jiva operator + shell: > + kubectl apply -f {{ jiva_operator }} + args: + executable: /bin/bash + register: deploy_status + + when: lookup('env','ACTION') == "provision" + + - block: + + - name: Deprovision jiva operator + shell: > + kubectl delete -f {{ jiva_operator }} + args: + executable: /bin/bash + register: jiva_deprovision + ignore_errors: True + + - name: Deprovision localpv operator + shell: > + kubectl delete -f {{ hostpath_operator }} + args: + executable: /bin/bash + register: deprovision_status + ignore_errors: True + + when: lookup('env','ACTION') == "deprovision" - - name: Deprovision jiva operator - shell: > - kubectl delete -f {{ jiva_operator }} - args: - executable: /bin/bash - register: deprovision_status - ignore_errors: True - when: lookup('env','ACTION') == "deprovision" + when: rc_tag != "" when: - release_tag == "commit_id" @@ -67,21 +156,52 @@ delay: 5 retries: 3 - - name: Deploy jiva operator - shell: > - kubectl apply -f {{ jiva_operator }} - args: - executable: /bin/bash - register: deploy_status + - name: Downloading the localpv operator file from charts + get_url: + url: "{{ charts_hostpath_link }}" + dest: "{{ playbook_dir }}/{{ charts_localpv_operator }}" + force: yes + register: status + until: "'OK' in status.msg" + delay: 5 + retries: 3 + + - block: + + - name: Deploy localpv operator + shell: > + kubectl apply -f {{ charts_localpv_operator }} + args: + executable: /bin/bash + register: charts_localpv + + - name: Deploy jiva operator + shell: > + kubectl apply -f {{ jiva_operator }} + args: + executable: /bin/bash + register: deploy_status + when: lookup('env','ACTION') == "provision" - - name: Deprovision jiva operator - shell: > - kubectl delete -f {{ jiva_operator }} - args: - executable: /bin/bash - register: deprovision_status - ignore_errors: True + - block: + + - name: Deprovision jiva operator + shell: > + kubectl delete -f {{ jiva_operator }} + args: + executable: /bin/bash + register: deprovision_status + ignore_errors: True + + - name: Deprovision localpv operator + shell: > + kubectl delete -f {{ charts_localpv_operator }} + args: + executable: /bin/bash + register: deprovision_localpv + ignore_errors: True + when: lookup('env','ACTION') == "deprovision" when: @@ -109,7 +229,23 @@ until: "'OK' in result.msg" delay: 5 retries: 3 - + + - name: Downloading hostpath operator yaml + get_url: + url: "{{ hostpath_operator_link }}" + dest: "{{ playbook_dir }}/{{ hostpath_operator }}" + force: yes + register: result_hostpath + until: "'OK' in result_hostpath.msg" + delay: 5 + retries: 3 + + - name: Change the Localpv provisioner image + replace: + path: "{{ hostpath_operator }}" + regexp: "openebs/provisioner-localpv-ci:dev-120403" + replace: "openebs/provisioner-localpv:ci" + - block: - name: Change the OpenEBS component labels to desired version in Operator yaml @@ -158,6 +294,13 @@ - block: + - name: Deploy localpv operator + shell: > + kubectl apply -f {{ hostpath_operator }} + args: + executable: /bin/bash + register: charts_localpv + - name: Install the Jiva operator in operator namespace shell: kubectl apply -f operator.yaml args: @@ -192,6 +335,14 @@ register: status failed_when: "status.rc != 0" + - name: Deprovision localpv operator + shell: > + kubectl delete -f {{ hostpath_operator }} + args: + executable: /bin/bash + register: deprovision_localpv + ignore_errors: True + when: action == "deprovision" when: @@ -199,6 +350,15 @@ - block: + - name: Check if the OpenEBS-localpv-provisioner is running + shell: > + kubectl get pods -n {{ operator_ns }} + -o jsonpath='{.items[?(@.metadata.labels.name=="openebs-localpv-provisioner")].status.phase}' + register: local_pv + until: "'Running' in local_pv.stdout" + delay: 5 + retries: 120 + - name: Obtain the Jiva operator pod in operator namespace shell: > kubectl get po -n {{ operator_ns }} --no-headers -l name=jiva-operator diff --git a/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test_vars.yml b/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test_vars.yml index c73724a..7b55ffa 100644 --- a/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test_vars.yml +++ b/e2e-tests/experiments/jiva-operator/jiva-csi-provisioner/test_vars.yml @@ -22,6 +22,8 @@ commit_id: "{{ lookup('env','COMMIT_ID') }}" rc_tag: "{{ lookup('env','RC_TAG') }}" +localpv_tag: "{{ lookup('env','OPENEBS_VERSION') }}-{{ lookup('env','RC_TAG') }}" + operator_ns: "{{ lookup('env','OPERATOR_NS') }}" operator_link: https://raw.githubusercontent.com/openebs/jiva-operator/master/deploy/operator.yaml @@ -34,6 +36,16 @@ release_operator_link: "https://raw.githubusercontent.com/openebs/charts/{{ comm rc_operator_link: "https://raw.githubusercontent.com/openebs/charts/{{ commit_id }}/{{ openebs_version }}/jiva-operator-{{ rc_tag }}.yaml" +hostpath_operator_link: "https://raw.githubusercontent.com/openebs/dynamic-localpv-provisioner/develop/deploy/kubectl/provisioner-hostpath.yaml" + +charts_hostpath_link: "https://raw.githubusercontent.com/openebs/charts/gh-pages/{{ openebs_version }}/hostpath-operator.yaml" + +release_hostpath_link: "https://raw.githubusercontent.com/openebs/charts/{{ commit_id }}/{{ openebs_version }}/hostpath-operator.yaml" + +charts_localpv_operator: hostpath-operator.yaml + +hostpath_operator: provisioner-hostpath.yaml + jiva_operator: jiva-operator.yaml operator_yaml: operator.yaml diff --git a/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/localpv-sc.yml b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/localpv-sc.yml new file mode 100644 index 0000000..71dc577 --- /dev/null +++ b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/localpv-sc.yml @@ -0,0 +1,13 @@ +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: openebs-hostpath + annotations: + openebs.io/cas-type: local + cas.openebs.io/config: | + - name: StorageType + value: hostpath +provisioner: openebs.io/local +reclaimPolicy: Delete +volumeBindingMode: WaitForFirstConsumer diff --git a/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test.yml b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test.yml index f68954a..45481f9 100644 --- a/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test.yml +++ b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test.yml @@ -46,6 +46,7 @@ with_items: - jiva-csi - jiva-csi-xfs + - openebs-hostpath when: action == "provision" @@ -70,6 +71,7 @@ with_items: - jiva-csi - jiva-csi-xfs + - openebs-hostpath when: action == "deprovision" diff --git a/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test_vars.yml b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test_vars.yml index 118a567..31beac4 100644 --- a/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test_vars.yml +++ b/e2e-tests/experiments/jiva-operator/jiva-csi-storage-policies/test_vars.yml @@ -13,3 +13,4 @@ action: "{{ lookup('env','ACTION') }}" storage_policies: - jiva-csi-xfs-sc.yml - jiva-csi-sc.yml + - localpv-sc.yml