github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/recreate/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  create_infra $namespace
    11  desc 'create first PXC cluster'
    12  cluster="some-name"
    13  spinup_pxc "$cluster" "$conf_dir/$cluster.yml"
    14  
    15  desc 'pause'
    16  cat_config "$conf_dir/$cluster.yml" \
    17      | sed -e 's/pause: false/pause: true/' \
    18      | kubectl_bin apply -f-
    19  wait_for_delete pod/$cluster-proxysql-0
    20  wait_for_delete pod/$cluster-pxc-2
    21  wait_for_delete pod/$cluster-pxc-1
    22  wait_for_delete pod/$cluster-pxc-0
    23  
    24  desc 'unpause, check data'
    25  cat_config "$conf_dir/$cluster.yml" \
    26      | sed -e 's/pause: true/pause: false/' \
    27      | kubectl_bin apply -f-
    28  wait_for_running "$cluster-proxysql" 1
    29  wait_for_running "$cluster-pxc" 3
    30  
    31  desc "check data"
    32  compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
    33  compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
    34  compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
    35  run_mysql \
    36      'INSERT myApp.myApp (id) VALUES (100501)' \
    37      "-h $cluster-proxysql -uroot -proot_password"
    38  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
    39  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
    40  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
    41  
    42  desc 'delete cluster'
    43  kubectl_bin delete \
    44      -f $conf_dir/$cluster.yml
    45  wait_for_delete pod/$cluster-pxc-2
    46  wait_for_delete pod/$cluster-pxc-1
    47  wait_for_delete pod/$cluster-pxc-0
    48  
    49  desc 'recreate cluster, check data'
    50  cat_config "$conf_dir/$cluster.yml" \
    51      | sed -e 's/storage: 2Gi/storage: 3Gi/; s/size: 3/size: 5/; s/antiAffinityTopologyKey:.*/antiAffinityTopologyKey: none/' \
    52      | kubectl_bin apply -f-
    53  wait_for_running "$cluster-proxysql" 1
    54  wait_for_running "$cluster-pxc" 5
    55  
    56  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
    57  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
    58  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
    59  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-3.$cluster-pxc -uroot -proot_password"
    60  compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-4.$cluster-pxc -uroot -proot_password"
    61  
    62  desc 'write data to ProxySQL, read from all'
    63  run_mysql \
    64      'INSERT myApp.myApp (id) VALUES (100502)' \
    65      "-h $cluster-proxysql -uroot -proot_password"
    66  compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
    67  compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
    68  compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
    69  compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-3.$cluster-pxc -uroot -proot_password"
    70  compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-4.$cluster-pxc -uroot -proot_password"
    71  
    72  destroy $namespace
    73  desc "test passed"