| 1 |
################################################################################ |
| 2 |
# BUG#21495778 - VIEW CHANGE ID GENERATION CAN POSSIBLY REPEAT IDS |
| 3 |
# |
| 4 |
# This test checks that the view_id generated for 100 view_changes do not |
| 5 |
# conflict with any of the already existing view_id |
| 6 |
# |
| 7 |
# It starts/stops the group 100 times and check if the view_id is getting |
| 8 |
# repeated. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. The test requires one server. |
| 12 |
# 1. Set bootstrap group ON on member and iterate START and STOP |
| 13 |
# GROUP_REPLICATION 100 times. |
| 14 |
# 2. Check for view_ids. View_id should not be repeated. |
| 15 |
################################################################################ |
| 16 |
--source include/big_test.inc |
| 17 |
--source include/not_valgrind.inc |
| 18 |
--source include/have_group_replication_plugin.inc |
| 19 |
--let $rpl_skip_group_replication_start= 1 |
| 20 |
--source include/group_replication.inc |
| 21 |
--source include/gr_set_bootstrap_group.inc |
| 22 |
|
| 23 |
--let $iterations_expected=50 |
| 24 |
--let $iteration_count=0 |
| 25 |
# disable the logging of the include files since they will just increase the |
| 26 |
# size of the result log file. |
| 27 |
--let $include_silent=1 |
| 28 |
while ($iteration_count < $iterations_expected) |
| 29 |
{ |
| 30 |
--source include/start_group_replication.inc |
| 31 |
--source include/stop_group_replication.inc |
| 32 |
|
| 33 |
if (!$include_silent) |
| 34 |
{ |
| 35 |
--echo ITERATION_COUNT=$iteration_count |
| 36 |
} |
| 37 |
|
| 38 |
--inc $iteration_count |
| 39 |
} |
| 40 |
--let $include_silent=0 |
| 41 |
|
| 42 |
--let $grep_file=$MYSQLTEST_VARDIR/log/mysqld.1.err |
| 43 |
--let _GP_GREP_FILE= $grep_file |
| 44 |
--let _ITERATIONS_EXPECTED= $iterations_expected |
| 45 |
|
| 46 |
--perl |
| 47 |
use strict; |
| 48 |
my $file= $ENV{'_GP_GREP_FILE'} or die "grep_file is not set"; |
| 49 |
my $iterations_expected= $ENV{'_ITERATIONS_EXPECTED'} or die "iterations_expected not set"; |
| 50 |
open(FILE, "$file") or die("Unable to open $file: $!\n"); |
| 51 |
|
| 52 |
my $pattern= 'Group membership changed to'; |
| 53 |
my @view_id; |
| 54 |
my $count= 0; |
| 55 |
my $count_occurence= 0; |
| 56 |
|
| 57 |
while(<FILE>) |
| 58 |
{ |
| 59 |
my $line = $_; |
| 60 |
if ($line =~ /CURRENT_TEST: /) |
| 61 |
{ |
| 62 |
@view_id = (); |
| 63 |
$count= 0; |
| 64 |
$count_occurence= 0; |
| 65 |
} |
| 66 |
if ($line =~ /$pattern/) |
| 67 |
{ |
| 68 |
my $result = index($line, $pattern); |
| 69 |
my $first = substr($line, $result+length($pattern)); |
| 70 |
push(@view_id, $first); |
| 71 |
$count_occurence++; |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
if ($count_occurence != $iterations_expected) |
| 76 |
{ |
| 77 |
die("Failed to generate the specified number of view_id's: expected: $iterations_expected, observed: $count_occurence \n"); |
| 78 |
} |
| 79 |
|
| 80 |
my @B = sort @view_id; |
| 81 |
my $previous = pop @B; |
| 82 |
|
| 83 |
foreach my $value (@B) |
| 84 |
{ |
| 85 |
if ($previous eq $value) |
| 86 |
{ |
| 87 |
$count++; |
| 88 |
} |
| 89 |
$previous = $value; |
| 90 |
} |
| 91 |
print $count ? "View_id repeated.\n" : "View_id not repeated.\n"; |
| 92 |
close (FILE) or die "Error closing $file: $!"; |
| 93 |
EOF |
| 94 |
|
| 95 |
--source include/group_replication_end.inc |