feat(e2e-test): Add e2e-tests for zfs-localpv (#298)

Signed-off-by: w3aman <aman.gupta@mayadata.io>
This commit is contained in:
Aman Gupta 2021-06-09 21:21:39 +05:30 committed by GitHub
parent 53f872fcf1
commit 4e73638b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 8745 additions and 0 deletions

View file

@ -0,0 +1,57 @@
- name: Replace the label in loadgen job spec.
replace:
path: "{{ percona_loadgen }}"
regexp: "loadgen_lkey: loadgen_lvalue"
replace: "{{ loadgen_lkey }}: {{ loadgen_lvalue }}"
- name: Replace the db-user placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_user"
replace: "{{ db_user }}"
- name: Replace the password placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_password"
replace: "{{ db_password }}"
- name: Replace the duration placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_duration"
replace: "{{ load_duration }}"
- name: Replace the warehouse placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_warehouse"
replace: "{{ test_warehouse }}"
- name: Replace the test connections placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_connections"
replace: "{{ test_connections }}"
- name: Replace the test warmup-period placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_warmup_period"
replace: "{{ test_warmup_period }}"
- name: Replace the test interval placeholder in tpcc-config file
replace:
path: "{{ tpcc_conf }}"
regexp: "test_interval"
replace: "{{ test_interval }}"
- name: Getting the Service IP of Application
shell: kubectl get svc -n {{ app_ns }} -l {{ app_service_label }} -o jsonpath='{.items[0].spec.clusterIP}'
register: ip
- name: Replace the Service IP placeholder
replace:
path: "{{ percona_loadgen }}"
regexp: "service_ip"
replace: "{{ ip.stdout }}"

View file

@ -0,0 +1,60 @@
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: percona-loadgen-
namespace: e2e
spec:
template:
metadata:
name: percona-loadgen
namespace: e2e
labels:
loadgen: percona-loadjob
spec:
serviceAccountName: e2e
restartPolicy: Never
containers:
- name: ansibletest
image: openebs/zfs-localpv-e2e:ci
imagePullPolicy: IfNotPresent
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: default
# This is the namespace where percona application is running
- name: APP_NAMESPACE
value: 'percona'
- name: APP_LABEL
value: 'app=percona'
- name: LOADGEN_LABEL
value: loadgen=percona-loadgen
# Database user name
- name: DB_USER
value: root
- name: DB_PASSWORD
value: k8sDem0
# Bench duration (in min)
# TODO: Use a tpcc-template to define workload w/ more granularity
- name: LOAD_DURATION
value: "600"
- name: TPCC_WAREHOUSES
value: "1"
- name: TPCC_CONNECTIONS
value: "18"
- name: TPCC_WARMUP_PERIOD
value: "10"
- name: LOAD_INTERVAL
value: "10"
command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./e2e-tests/apps/percona/workload/test.yml -i /etc/ansible/hosts -v; exit 0"]

View file

@ -0,0 +1,81 @@
---
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- test_vars.yml
tasks:
- block:
## Generating the testname for deployment
- include_tasks: /e2e-tests/hack/create_testname.yml
# RECORD START-OF-TEST IN e2e RESULT CR
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'SOT'
- name: Checking the status of test specific namespace.
include_tasks: /e2e-tests/utils/k8s/status_testns.yml
- name: Get the application label value from env
set_fact:
app_lkey: "{{ app_label.split('=')[0] }}"
app_lvalue: "{{ app_label.split('=')[1] }}"
- name: Checking whether application is running
include_tasks: /e2e-tests/utils/k8s/status_app_pod.yml
- name: Obtaining the loadgen pod label from env.
set_fact:
loadgen_lkey: "{{ loadgen_label.split('=')[0] }}"
loadgen_lvalue: "{{ loadgen_label.split('=')[1] }}"
- name: Replace default values/placeholder with test-specific values
include_tasks: ./replace.yml
- name: Checking for configmap
shell: kubectl get configmap -n {{ app_ns }}
register: configmap
- name: Creating a kubernetes config map to hold the tpcc benchmark config
shell: kubectl create configmap tpcc-config --from-file {{ tpcc_conf }} -n {{ app_ns }}
when: "'tpcc-config' not in configmap.stdout"
- name: Create Percona Loadgen Job
shell: kubectl apply -f {{ percona_loadgen }} -n {{ app_ns }}
- name: Verify load-gen pod is running
shell: kubectl get pods -n {{ app_ns }} -l {{ loadgen_label }} -o jsonpath='{.items[0].status.phase}'
args:
executable: /bin/bash
register: result
until: "'Running' in result.stdout"
delay: 5
retries: 60
- name: Getting the Percona POD name
shell: kubectl get po -n {{ app_ns }} -l {{ app_label }} -o jsonpath='{.items[0].metadata.name}'
register: pod_name
- name: Verifying load-generation
shell: kubectl exec -it {{ pod_name.stdout }} -n {{ app_ns }} -- mysql -u{{ db_user }} -p{{ db_password }} -e "show databases"
register: output
until: "'tpcc-' in output.stdout"
delay: 5
retries: 120
- set_fact:
flag: "Pass"
rescue:
- set_fact:
flag: "Fail"
always:
## RECORD END-OF-TEST IN e2e RESULT CR
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'EOT'

View file

@ -0,0 +1,27 @@
test_name: percona-loadgen-{{ app_ns }}
percona_loadgen: tpcc_bench.yml
app_ns: "{{ lookup('env','APP_NAMESPACE') }}"
app_label: "{{ lookup('env','APP_LABEL') }}"
app_service_label: "{{ lookup('env','APP_LABEL') }}"
loadgen_label: "{{ lookup('env','LOADGEN_LABEL') }}"
db_user: "{{ lookup('env','DB_USER') }}"
db_password: "{{ lookup('env','DB_PASSWORD') }}"
load_duration: "{{ lookup('env','LOAD_DURATION') }}"
test_warehouse: "{{ lookup('env','TPCC_WAREHOUSES') }}"
test_connections: "{{ lookup('env','TPCC_CONNECTIONS') }}"
test_warmup_period: "{{ lookup('env','TPCC_WARMUP_PERIOD') }}"
test_interval: "{{ lookup('env','LOAD_INTERVAL') }}"
tpcc_conf: tpcc.conf

View file

@ -0,0 +1,9 @@
{
"db_user": "test_user",
"db_password": "test_password",
"warehouses": "test_warehouse",
"connections": "test_connections",
"warmup_period": "test_warmup_period",
"run_duration": "test_duration",
"interval": "test_interval"
}

View file

@ -0,0 +1,27 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: tpcc-bench
spec:
template:
metadata:
name: tpcc-bench
labels:
loadgen_lkey: loadgen_lvalue
spec:
restartPolicy: Never
containers:
- name: tpcc-bench
image: openebs/tests-tpcc-client
command: ["/bin/bash"]
args: ["-c", "./tpcc-runner.sh service_ip tpcc.conf; exit 0"]
volumeMounts:
- name: tpcc-configmap
mountPath: /tpcc-mysql/tpcc.conf
subPath: tpcc.conf
tty: true
volumes:
- name: tpcc-configmap
configMap:
name: tpcc-config