-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e-test): add e2e-test for upgrade and migration (#107)
Signed-off-by: nsathyaseelan <[email protected]>
- Loading branch information
1 parent
a66838b
commit f59f844
Showing
32 changed files
with
2,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2020-2021 The OpenEBS Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM ubuntu:18.04 | ||
|
||
LABEL maintainer="OpenEBS" | ||
|
||
#Installing necessary ubuntu packages | ||
RUN rm -rf /var/lib/apt/lists/* && \ | ||
apt-get clean && \ | ||
apt-get update --fix-missing || true && \ | ||
apt-get install -y python python-pip netcat iproute2 jq sshpass bc git\ | ||
curl openssh-client | ||
|
||
#Installing ansible | ||
RUN pip install ansible==2.7.3 | ||
|
||
#Installing openshift | ||
RUN pip install openshift==0.11.2 | ||
|
||
#Installing jmespath | ||
RUN pip install jmespath | ||
|
||
#Installing Kubectl | ||
ENV KUBE_LATEST_VERSION="v1.20.0" | ||
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl && \ | ||
chmod +x /usr/local/bin/kubectl | ||
|
||
#Adding hosts entries and making ansible folders | ||
RUN mkdir /etc/ansible/ /ansible && \ | ||
echo "[local]" >> /etc/ansible/hosts && \ | ||
echo "127.0.0.1" >> /etc/ansible/hosts | ||
|
||
#Copying Necessary Files | ||
COPY ./e2e-tests ./e2e-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Test Case to Migrate the spc non-csi components into cspc csi components | ||
|
||
## Description | ||
- This test case is capable of Migrating the OpenEBS SPC pool and cStor volume components into CSPC pool and CSI volume | ||
- Before migrating the pool we have to provision the cStor opertor. | ||
- For Migrate the volumes applications need to be scaled down | ||
- This test constitutes the below files. | ||
- cstor-volume-migration-job.j2 - Volume migration job template which has to be populated with the given variables. | ||
- cstor-spc-migration-job.j2 - Pool migration job template which has to be populated with the given variables. | ||
- test_vars.yml - This test_vars file has the list of test specific variables used in E2eBook. | ||
- test.yml - Playbook where the test logic is built to migrate the CSPC CSI components. | ||
- application_scale.yml - This file includes the task to scaledown and scaleup the application. | ||
- This test case should be provided with the parameters in form of job environmental variables in run_e2e_test.yml | ||
|
||
## E2ebook Environment Variables | ||
|
||
| Parameters | Description | | ||
| ----------------------- | ---------------------------------------------------------- | | ||
| OPERATOR_NS | Namespace where the openebs is deployed | | ||
| Migration_IMAGE_TAG | Image tag for migration job | | ||
| MIGRATE_SPC_POOL | Set the value as `true` to Migrate spc pool | | ||
| MIGRATE_CSTOR_VOLUME | Set the value as `true` to Migrate non-csi volumes | |
93 changes: 93 additions & 0 deletions
93
e2e-tests/experiments/cspc_csi_migration/application_scale.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
|
||
##{{ outer_item }} is name of the pv, the values will passed as a loop variable in test.yml | ||
|
||
- name: Obtain the application namespace to scaledown the application | ||
shell: > | ||
kubectl get pvc --all-namespaces --no-headers | grep {{ outer_item }} | awk '{print $1}' | ||
args: | ||
executable: /bin/bash | ||
register: app_ns | ||
|
||
- name: Obtain the application deployment name to scaledown the application | ||
shell: > | ||
kubectl get deploy -n {{ app_ns.stdout }} --no-headers -o custom-columns=:.metadata.name | ||
args: | ||
executable: /bin/bash | ||
register: app_deploy_name | ||
|
||
- block: | ||
|
||
- name: Obtain the application pod name | ||
shell: > | ||
kubectl get pod -n {{ app_ns.stdout }} -o custom-columns=:.metadata.name --no-headers | grep {{ app_deploy_name.stdout }} | ||
args: | ||
executable: /bin/bash | ||
register: pod_name | ||
|
||
- name: Scaledown the application | ||
shell: > | ||
kubectl scale deploy -n {{ app_ns.stdout }} {{ app_deploy_name.stdout }} --replicas=0 | ||
args: | ||
executable: /bin/bash | ||
register: scale_down_status | ||
|
||
- name: Verify if the application scaled down successfully | ||
shell: > | ||
kubectl get deploy -n {{ app_ns.stdout }} {{ app_deploy_name.stdout }} --no-headers -o custom-columns=:.spec.replicas | ||
args: | ||
executable: /bin/bash | ||
register: deploy_status | ||
until: deploy_status.stdout|int == 0 | ||
delay: 2 | ||
retries: 30 | ||
|
||
- name: check if the application pod is deleted | ||
shell: > | ||
kubectl get pod -n {{ app_ns.stdout }} | ||
args: | ||
executable: /bin/bash | ||
register: status | ||
until: '"{{ pod_name.stdout }}" not in status.stdout' | ||
delay: 10 | ||
retries: 30 | ||
|
||
when: app_status == "scaledown" | ||
|
||
- block: | ||
|
||
- name: Scale the application after migration | ||
shell: > | ||
kubectl scale deploy -n {{ app_ns.stdout }} {{ app_deploy_name.stdout }} --replicas=1 | ||
args: | ||
executable: /bin/bash | ||
register: scale_status | ||
|
||
- name: Verify if the application scaled up successfully | ||
shell: > | ||
kubectl get deploy -n {{ app_ns.stdout }} --no-headers -o custom-columns=:.spec.replicas | ||
args: | ||
executable: /bin/bash | ||
register: deploy_rep_status | ||
until: deploy_rep_status.stdout|int == 1 | ||
delay: 2 | ||
retries: 30 | ||
|
||
- name: Obtain the application pod name | ||
shell: > | ||
kubectl get pod -n {{ app_ns.stdout }} -o custom-columns=:.metadata.name --no-headers | grep {{ app_deploy_name.stdout }} | ||
args: | ||
executable: /bin/bash | ||
register: new_pod_name | ||
|
||
- name: check if the application pod is in running state | ||
shell: > | ||
kubectl get pod -n {{ app_ns.stdout }} {{ new_pod_name.stdout }} --no-headers -o custom-columns=:.status.phase | ||
args: | ||
executable: /bin/bash | ||
register: pod_status | ||
until: "'Running' in pod_status.stdout" | ||
delay: 10 | ||
retries: 30 | ||
|
||
when: app_status == "scaleup" |
27 changes: 27 additions & 0 deletions
27
e2e-tests/experiments/cspc_csi_migration/cstor-spc-migration-job.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: migrate-pool_name | ||
namespace: {{ operator_ns }} | ||
spec: | ||
backoffLimit: 0 | ||
template: | ||
spec: | ||
serviceAccountName: service_account | ||
containers: | ||
- name: migrate | ||
args: | ||
- "cstor-spc" | ||
- "--spc-name=pool_name" | ||
- "--v=4" | ||
env: | ||
- name: OPENEBS_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
tty: true | ||
image: openebs/migrate:{{ migration_image_tag }} | ||
restartPolicy: Never | ||
--- | ||
|
27 changes: 27 additions & 0 deletions
27
e2e-tests/experiments/cspc_csi_migration/cstor-volume-migration-job.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: migrate-cstor-cstor_volume_name | ||
namespace: {{ operator_ns }} | ||
spec: | ||
backoffLimit: 4 | ||
template: | ||
spec: | ||
serviceAccountName: service_account | ||
containers: | ||
- name: migrate | ||
args: | ||
- "cstor-volume" | ||
- "--pv-name=cstor_volume_name" | ||
- "--v=4" | ||
env: | ||
- name: OPENEBS_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
tty: true | ||
image: openebs/migrate:{{ migration_image_tag }} | ||
restartPolicy: Never | ||
--- | ||
|
16 changes: 16 additions & 0 deletions
16
e2e-tests/experiments/cspc_csi_migration/cstor_replica_version_check.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: Obtain the CVR name to verify the current version | ||
shell: > | ||
kubectl get cvr -n {{ operator_ns }} -l openebs.io/persistent-volume={{ outer_item }} | ||
-o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | ||
register: cvr_name | ||
failed_when: 'cvr_name.stdout == ""' | ||
|
||
- name: Check if the CVRs are upgraded to newer version | ||
shell: > | ||
kubectl get cvr -n {{ operator_ns }} {{ item }} | ||
-o custom-columns=:.versionDetails.status.current --no-headers | ||
register: cvr_version | ||
failed_when: "cvr_version.stdout != operator_image_tag" | ||
with_items: | ||
- "{{ cvr_name.stdout_lines }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
generateName: cstor-cspc-csi-migration- | ||
namespace: e2e | ||
spec: | ||
template: | ||
metadata: | ||
name: e2e | ||
labels: | ||
app: cspc-csi-migration | ||
spec: | ||
serviceAccountName: e2e | ||
restartPolicy: Never | ||
containers: | ||
- name: ansibletest | ||
image: openebs/upgrade-e2e:ci | ||
imagePullPolicy: IfNotPresent | ||
|
||
env: | ||
- name: ANSIBLE_STDOUT_CALLBACK | ||
#value: log_plays, actionable, default | ||
value: default | ||
|
||
# Namespace where OpenEBS is deployed | ||
- name: OPERATOR_NS | ||
value: "" | ||
|
||
# Image tag for operator version | ||
- name: OPERATOR_IMAGE_TAG | ||
value: "" | ||
|
||
# Image tag for migration Job | ||
- name: MIGRATATION_IMAGE_TAG | ||
value: "" | ||
|
||
# set to "true" if you want to upgrade cStor CSPC pool | ||
- name: MIGRATE_SPC_POOL | ||
value: "" | ||
|
||
# set to "true" if you want to upgrade CSI volumes | ||
- name: MIGRATE_CSTOR_VOLUME | ||
value: "" | ||
|
||
command: ["/bin/bash"] | ||
args: ["-c", "ansible-playbook ./e2e-tests/experiments/cspc_csi_migration/test.yml -i /etc/ansible/hosts -v; exit 0"] |
Oops, something went wrong.