--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/have_mariabackup.inc

--let $node_1=node_1
--let $node_2=node_2
--source include/auto_increment_offset_save.inc

--let $LOG_FILE=$MYSQL_TMP_DIR/galera_node2.log
--error 0,1
--remove_file $LOG_FILE

CREATE TABLE t1 (f1 INT PRIMARY KEY);

--connection node_2

--echo # Verify that graceful shutdown succeeds...
--source include/shutdown_mysqld.inc

--connection node_1

--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);

--connection node_2
--echo # Start node_2 again...
--let $restart_noprint=2
--let $start_mysqld_params=--log-error=$LOG_FILE
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

SELECT * FROM t1;

--let $start_mysqld_params=
--source include/restart_mysqld.inc

--connection node_1

--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

# Confirm that IST took place
--let $assert_text = mariabackup IST completed on joiner
--let $assert_select = mariabackup IST completed on joiner
--let $assert_count = 1
--let $assert_file = $LOG_FILE
--let $assert_only_after = Prepared IST receiver for
--source include/assert_grep.inc

DROP TABLE t1;

--source include/auto_increment_offset_restore.inc

--remove_file $LOG_FILE
