github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/proxy-protocol/run (about) 1 #!/bin/bash 2 3 set -o errexit 4 5 cluster="proxy-protocol" 6 test_dir=$(realpath $(dirname $0)) 7 . ${test_dir}/../functions 8 9 set_debug 10 11 if [[ $IMAGE_PXC =~ 5\.7 ]]; then 12 echo "Skipping proxy-protocol test because 5.7 doesn't support it!" 13 exit 0 14 fi 15 16 prepare_config() { 17 desc "prepare config" 18 nodes=$(kubectl get nodes | grep -v "NAME" | grep -v 'master' | awk '{print $1}') 19 if [ $(printf "${nodes}\n" | wc -l) -lt 3 ]; then 20 echo "3 nodes are expected for this test to run." 21 exit 1 22 fi 23 haproxy_node=$(echo "${nodes}" | tail -n1) 24 pxc_node=$(echo "${nodes}" | tail -n2 | head -n1) 25 client_node=$(echo "${nodes}" | tail -n3 | head -n1) 26 cat ${test_dir}/conf/${cluster}.yml \ 27 | $sed -e "s#kubernetes.io/hostname:.*-node1\$#kubernetes.io/hostname: ${haproxy_node}#" \ 28 | $sed -e "s#kubernetes.io/hostname:.*-node2\$#kubernetes.io/hostname: ${pxc_node}#" >${tmp_dir}/${cluster}.yml 29 cat ${test_dir}/conf/client.yml | $sed -e "s#kubernetes.io/hostname:.*-node3\$#kubernetes.io/hostname: ${client_node}#" >${tmp_dir}/client.yml 30 } 31 32 prepare_config 33 create_infra ${namespace} 34 35 desc 'create first PXC cluster' 36 spinup_pxc "${cluster}" "${tmp_dir}/${cluster}.yml" "3" "15" "${conf_dir}/secrets.yml" "${tmp_dir}/client.yml" "33062" 37 sleep 120 38 39 client_ip=$(kubectl_bin get pods --selector=name=pxc-client -o 'jsonpath={.items[].status.podIP}') 40 if [ ${EKS} -eq 1 ]; then 41 node_name=$(kubectl_bin get pods --selector=name=pxc-client -o 'jsonpath={.items[].spec.nodeName}') 42 client_ip=$(kubectl_bin get nodes ${node_name} -o 'jsonpath={.status.addresses[?(@.type == "ExternalIP")].address}') 43 fi 44 if [[ -n ${OPENSHIFT} ]]; then 45 pod_name=$(kubectl_bin get pods --selector=name=pxc-client -o 'jsonpath={.items[].metadata.name}') 46 client_ip=$(kubectl_bin exec ${pod_name} -- curl -s ifconfig.io) 47 fi 48 49 service_ip=$(get_service_endpoint proxy-protocol-haproxy) 50 51 desc 'check if service and statefulset created with expected config' 52 compare_kubectl statefulset/${cluster}-pxc 53 compare_kubectl statefulset/${cluster}-haproxy 54 compare_kubectl service/${cluster}-pxc 55 compare_kubectl service/${cluster}-haproxy 56 compare_kubectl service/${cluster}-haproxy-replicas 57 58 desc 'check if client ip visible in mysql processlist' 59 nr_queries=$(run_mysql "show processlist;" "-h ${service_ip} -uroot -proot_password" | grep "show processlist" | grep -c "${client_ip}") 60 if [ ${nr_queries} -ne 1 ]; then 61 echo "Client IP ${client_ip} is not found in process list!" 62 exit 1 63 fi 64 65 desc 'cleanup' 66 kubectl_bin delete -f ${test_dir}/conf/${cluster}.yml 67 destroy ${namespace} 68 desc "test passed"