################################################################################
# Validate that when Group Replication number of members reach 9
# members no more members are allowed to join.
#
# Test:
# 1. Bootstrap start a group on server 1.
# 2. Fake that group size will be 10 when server 2 joins. Server 2 will be
#    unable to join.
# 3. Group will remain with only server 1 (and 8 more fake members).
# 4. Clean up.
################################################################################
--source include/have_debug.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc


--echo
--echo ############################################################
--echo # 1. Bootstrap a group.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_and_bootstrap_group_replication.inc


--echo
--echo ############################################################
--echo # 2. Fake that group size will be 10 when server 2 joins.
--echo #    Server 2 will be unable to join.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET SESSION sql_log_bin= 0;
call mtr.add_suppression("The START GROUP_REPLICATION command failed since the group already has 9 members");
SET SESSION sql_log_bin= 1;
--disable_query_log
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
--enable_query_log

SET @debug_save= @@GLOBAL.DEBUG;
SET @@GLOBAL.DEBUG='+d,group_replication_set_number_of_members_on_view_changed_to_10';
--error ER_GROUP_REPLICATION_MAX_GROUP_SIZE
START GROUP_REPLICATION;

--let $group_replication_member_state= OFFLINE
--source include/gr_wait_for_member_state.inc

SET @@GLOBAL.DEBUG= @debug_save;


--echo
--echo ############################################################
--echo # 3. Group will remain with only server 1 (and 8 more fake
--echo #    members).
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $group_replication_number_of_members= 1
--source include/gr_wait_for_number_of_members.inc


--echo
--echo ############################################################
--echo # 4. Cleanup.
--source include/group_replication_end.inc
