github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/auto-tuning/run (about)

     1  #!/bin/bash
     2  
     3  set -o errexit
     4  
     5  test_dir=$(realpath $(dirname $0))
     6  . ${test_dir}/../functions
     7  
     8  set_debug
     9  
    10  cluster="auto-tuning"
    11  
    12  does_autotune_cm_exists() {
    13  	local exit_status=0
    14  	set +e
    15  	kubectl_bin get configmap auto-${cluster}-pxc -o 'jsonpath={.metadata.name}'
    16  	exit_status=$?
    17  	set -e
    18  	return ${exit_status}
    19  }
    20  
    21  get_variable_from_cm() {
    22  	kubectl_bin get configmap auto-${cluster}-pxc -o yaml | grep -oE "$1 = [0-9]+" | awk '{print $3}'
    23  }
    24  
    25  create_infra $namespace
    26  
    27  spinup_pxc "$cluster" "${test_dir}/conf/${cluster}-with-limits.yml"
    28  
    29  INNODB_SIZE=$(run_mysql \
    30  	'SELECT @@innodb_buffer_pool_size;' \
    31  	"-h $cluster-pxc -uroot -proot_password")
    32  CONNECTIONS=$(run_mysql \
    33  	'SELECT @@max_connections;' \
    34  	"-h $cluster-pxc -uroot -proot_password")
    35  desc "get cm_buffer_size"
    36  cm_buffer_size=$(get_variable_from_cm innodb_buffer_pool_size)
    37  if [[ ${INNODB_SIZE} != ${cm_buffer_size} ]]; then
    38  	echo "with-limits: innodb_buffer_pool_size is set to ${INNODB_SIZE}, which does not correlate with configmap value: ${cm_buffer_size}"
    39  	exit 1
    40  fi
    41  desc "get cm_max_connections"
    42  cm_max_connections=$(get_variable_from_cm max_connections)
    43  if [[ ${CONNECTIONS} != ${cm_max_connections} ]]; then
    44  	echo "with-limits: max_connections is set to ${CONNECTIONS}, which does not correlate with configmap value: ${cm_max_connections}"
    45  	exit 1
    46  fi
    47  desc "with-requests: apply config and wait cluster consistency"
    48  apply_config "${test_dir}/conf/${cluster}-with-requests.yml"
    49  wait_cluster_consistency "$cluster" 3
    50  
    51  if does_autotune_cm_exists; then
    52  	echo "with-requests: Operator shouldn't create autotune configmap just with resource requests"
    53  	exit 1
    54  fi
    55  
    56  desc "with-custom-config: apply config and wait cluster consistency"
    57  
    58  apply_config "${test_dir}/conf/${cluster}-with-custom-config.yml"
    59  wait_cluster_consistency "$cluster" 3
    60  
    61  INNODB_SIZE=$(run_mysql \
    62  	'SELECT @@innodb_buffer_pool_size;' \
    63  	"-h $cluster-pxc -uroot -proot_password")
    64  CONNECTIONS=$(run_mysql \
    65  	'SELECT @@max_connections;' \
    66  	"-h $cluster-pxc -uroot -proot_password")
    67  
    68  if [[ ${INNODB_SIZE} != 805306368 ]]; then
    69  	echo "with-custom-config: innodb_buffer_pool_size ${AUTO_INNODB_SIZE} should be 805306368"
    70  	exit 1
    71  fi
    72  
    73  if [[ ${CONNECTIONS} != 200 ]]; then
    74  	echo "with-custom-config: max_connections ${CONNECTIONS} should be 200"
    75  	exit 1
    76  fi
    77  
    78  desc "with-template: apply config  and wait cluster consistency"
    79  apply_config "${test_dir}/conf/${cluster}-with-template.yml"
    80  wait_cluster_consistency "$cluster" 3
    81  
    82  INNODB_SIZE=$(run_mysql \
    83  	'SELECT @@innodb_buffer_pool_size;' \
    84  	"-h $cluster-pxc -uroot -proot_password")
    85  CONNECTIONS=$(run_mysql \
    86  	'SELECT @@max_connections;' \
    87  	"-h $cluster-pxc -uroot -proot_password")
    88  
    89  if [[ ${INNODB_SIZE} != 2147483648 ]]; then
    90  	echo "with-template: innodb_buffer_pool_size ${INNODB_SIZE} should be 2147483648"
    91  	exit 1
    92  fi
    93  
    94  if [[ ${CONNECTIONS} != 200 ]]; then
    95  	echo "with-template: max_connections ${CONNECTIONS} should be 200"
    96  	exit 1
    97  fi
    98  desc "with-template-transform: apply config and wait cluster consistency"
    99  apply_config "${test_dir}/conf/${cluster}-with-template-transform.yml"
   100  wait_cluster_consistency "$cluster" 3
   101  
   102  INNODB_SIZE=$(run_mysql \
   103  	'SELECT @@innodb_buffer_pool_size;' \
   104  	"-h $cluster-pxc -uroot -proot_password")
   105  CONNECTIONS=$(run_mysql \
   106  	'SELECT @@max_connections;' \
   107  	"-h $cluster-pxc -uroot -proot_password")
   108  
   109  if [[ ${INNODB_SIZE} != 805306368 ]]; then
   110  	echo "with-template-transform: innodb_buffer_pool_size ${INNODB_SIZE} should be 805306368"
   111  	exit 1
   112  fi
   113  
   114  if [[ ${CONNECTIONS} != 200 ]]; then
   115  	echo "with-template-transform: max_connections ${CONNECTIONS} should be 200"
   116  	exit 1
   117  fi
   118  
   119  destroy $namespace
   120  desc "test passed"