1
2##############################################################################
3# WL#4677 Unique Server Ids for Replication Topology (UUIDs)                 #
4#
5# Each server has a UUID generated by server itself. It is stored in auto.cnf
6# in @@DATADIR directory.
7#
8# @@SERVER_UUID is a readonly system variable, it is initialized as the
9# server's UUID when starting. Users can get the server's UUID from
10# @@SERVER_UUID.
11#
12# This test case tests whether the server's UUID can be generated, stored,
13# initialized correctly.
14##############################################################################
15source include/not_embedded.inc;
16
17CALL mtr.add_suppression("Master's UUID has changed, its old UUID is");
18
19--let $uuid_file= auto.cnf
20--let $original_server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
21
22--let $datadir= query_get_value(SELECT @@DATADIR, @@DATADIR, 1)
23--copy_file $datadir/$uuid_file $datadir/original_$uuid_file
24
25--echo
26--echo # Case 1:
27--echo # @@SERVER_UUID is readonly.
28--echo -----------------------------------------------------------------------------
29--error 1238
30SET GLOBAL SERVER_UUID= UUID();
31
32--echo
33--echo # Case 2:
34--echo # If the file does not exists, mysqld generates it automatically.
35--echo -----------------------------------------------------------------------------
36--remove_file $datadir/$uuid_file
37--source include/restart_mysqld.inc
38--let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
39if (`SELECT '$server_uuid' = '' OR '$server_uuid' = 'NULL'`)
40{
41  --die server's UUID is null
42}
43
44--echo
45--echo # Case 3:
46--echo # If there is no UUID in the file, mysqld generates it automatically.
47--echo -----------------------------------------------------------------------------
48
49--remove_file $datadir/$uuid_file
50# There is a blank line in the file
51--write_file $datadir/$uuid_file
52[auto]
53EOF
54--source include/restart_mysqld.inc
55
56--let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
57if (`SELECT '$server_uuid' = '' OR '$server_uuid' = 'NULL'`)
58{
59  --die server's UUID is null
60}
61
62--echo
63--echo # Case 4:
64--echo # If there is a UUID in the file, it will be loaded into SERVER_UUID.
65--echo -----------------------------------------------------------------------------
66
67--remove_file $datadir/$uuid_file
68--move_file $datadir/original_$uuid_file $datadir/$uuid_file
69--source include/restart_mysqld.inc
70
71--let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
72if ($server_uuid != $original_server_uuid)
73{
74  --echo $server_uuid != $original_server_uuid
75  --die wrong server_uuid
76}
77