[ROBOT] Adopt HVVES test case in order to work with strimzi kafka
[testsuite.git] / robot / resources / mariadb_galera_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with Mariadb Galera. It contains the keywords which will login to the Mariadb Galera pod and validates SO databases connectivity.
3
4 Library               Collections
5 Library               OperatingSystem
6 Library               String
7
8 *** Variables ***
9 &{MARIADB_GALERA_CREDENTIALS}               user=root  password=secretpassword
10 @{MARIADB_GALERA_SO_DATABASES}              catalogdb  requestdb  camundabpmn
11 @{CONNECTION_ERROR_MESSAGE}                 Can't connect  No such file or directory  command terminated
12 ${POD_LOGGED_IN_MESSAGE}                    logged into Mariadb Galera pod
13 ${MYSQL_STATUS_MESSAGE}                     Current database:
14
15
16 *** Keywords ***
17 Fetch Namespace
18     [Documentation]    This keyword is responsible for fetching and returning the value of namespace from the provided Global IP Address variable.
19     [Arguments]    ${GLOBAL_INJECTED_SO_BPMN_IP_ADDR}
20     ${namespace}=    Evaluate    "${GLOBAL_INJECTED_SO_BPMN_IP_ADDR}".split(".")[-1]
21     [Return]    ${namespace}
22
23 Check for Mariadb Galera Pod Connection
24     [Documentation]    This keyword is responsible for logging into the Mariadb Galera pod and check if we can login to the Mariadb Galera pod. To verify we print a string and match the output whether the same string was returned or not.
25     [Arguments]    ${message}=${POD_LOGGED_IN_MESSAGE}
26     ${namespace}=    Fetch Namespace    ${GLOBAL_INJECTED_SO_BPMN_IP_ADDR}
27     # Extracting the mariadb galera pod and storing it into a variable
28     ${mariadb_pod}=    Run    kubectl -n ${namespace} get po -o name | grep -w 'mariadb-galera-[0-9]'
29     ${pod_connectivity_command}=    Catenate    kubectl -n ${namespace} exec ${mariadb_pod} -- sh -c "echo ${message}"
30     ${pod_connectivity_output}=    Run    ${pod_connectivity_command}
31     # The output should contain the exact same message which we are printing by logging into the Mariadb Galera pod
32     Should Contain    ${pod_connectivity_output}    ${message}    ignore_case=True
33
34 Check for SO Databases Connection
35     [Documentation]    This keyword is responsible for logging into the Mariadb Galera pod and check if we can login to the SO MySQL Databases.
36     ${namespace}=    Fetch Namespace    ${GLOBAL_INJECTED_SO_BPMN_IP_ADDR}
37     # Extracting the mariadb galera pod and storing it into a variable
38     ${mariadb_pod}=    Run    kubectl -n ${namespace} get po -o name | grep -w 'mariadb-galera-[0-9]'
39     # Looping through all 3 mariadb galera databases (catalogdb, requestdb and camundabpmn) to validate SO connectivity
40     FOR    ${index}    IN RANGE    3
41            ${mysql_connectivity_command}=    Catenate    kubectl -n ${namespace} exec ${mariadb_pod} -- sh
42                ...  -c "mysql -u ${MARIADB_GALERA_CREDENTIALS}[user] -p${MARIADB_GALERA_CREDENTIALS}[password] ${MARIADB_GALERA_SO_DATABASES}[${index}]
43                ...  -e 'status'"
44            ${mysql_connectivity_output}=    Run    ${mysql_connectivity_command}
45            # The output should contain the message that is having SO databases name.
46            Should Contain    ${mysql_connectivity_output}    ${MYSQL_STATUS_MESSAGE}    ${MARIADB_GALERA_SO_DATABASES}[${index}]    ignore_case=True
47            Should Not Contain Any    ${CONNECTION_ERROR_MESSAGE}    ${mysql_connectivity_output}    ignore_case=True
48     END