Debian Codegraph @

unittest/gunit/libmysqlgcs/xcom/gcs_xcom_site_def-t.cc

raw symbols SCIP
1 /* Copyright (c) 2020, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24 #include <xcom/xcom_profile.h>
25 #include <xcom_vp.h>
26 #include "gcs_base_test.h"
27
28 #include "site_def.h"
29
30 namespace xcom_site_def_unittest {
31
32 class XcomSiteDef : public GcsBaseTest {
33 protected:
34 XcomSiteDef() = default;
35 ~XcomSiteDef() override = default;
36 };
37
38 TEST_F(XcomSiteDef, config_max_boot_key) {
39 synode_no const synode_0_1_0{0, 1, 0};
40 synode_no const synode_0_2_0{0, 2, 0};
41 synode_no const synode_0_3_0{0, 3, 0};
42 synode_no const synode_0_3_1{0, 3, 1};
43 synode_no const synode_1_2_0{1, 2, 0};
44 gcs_snapshot gcs_snap{null_synode, null_synode, {0, nullptr}, {{0, nullptr}}};
45 synode_no max_boot_key = null_synode;
46
47 /* `max_boot_key` of empty snapshot is `null_synode`. */
48 max_boot_key = config_max_boot_key(&gcs_snap);
49 ASSERT_TRUE(synode_eq(max_boot_key, null_synode));
50
51 /* `max_boot_key` of snapshot with one config is that config's `boot_key`. */
52 config one_cfg{null_synode, synode_0_1_0, {0, nullptr},
53 {0, nullptr}, EVENT_HORIZON_MIN, 0,
54 {0, nullptr}};
55 config_ptr one_cfg_ptr = &one_cfg;
56 gcs_snap.cfg.configs_len = 1;
57 gcs_snap.cfg.configs_val = &one_cfg_ptr;
58 max_boot_key = config_max_boot_key(&gcs_snap);
59 ASSERT_TRUE(synode_eq(max_boot_key, synode_0_1_0));
60
61 /* `max_boot_key` of snapshot with various configs is highest `boot_key` of a
62 config... */
63 config three_cfg[3] = {
64 {null_synode,
65 synode_0_2_0,
66 {0, nullptr},
67 {0, nullptr},
68 EVENT_HORIZON_MIN,
69 0,
70 {0, nullptr}},
71 {null_synode,
72 synode_0_3_1,
73 {0, nullptr},
74 {0, nullptr},
75 EVENT_HORIZON_MIN,
76 0,
77 {0, nullptr}},
78 {null_synode,
79 synode_0_3_0,
80 {0, nullptr},
81 {0, nullptr},
82 EVENT_HORIZON_MIN,
83 0,
84 {0, nullptr}},
85 };
86 config_ptr three_cfg_ptr[3] = {&three_cfg[0], &three_cfg[1], &three_cfg[2]};
87 gcs_snap.cfg.configs_len = 3;
88 gcs_snap.cfg.configs_val = three_cfg_ptr;
89 max_boot_key = config_max_boot_key(&gcs_snap);
90 ASSERT_TRUE(synode_eq(max_boot_key, synode_0_3_1));
91
92 /* ...whose group_id's match the snapshot, otherwise `max_boot_key` is
93 `null_synode`. */
94 config two_cfg[2] = {
95 {null_synode,
96 synode_1_2_0,
97 {0, nullptr},
98 {0, nullptr},
99 EVENT_HORIZON_MIN,
100 0,
101 {0, nullptr}},
102 {null_synode,
103 synode_0_3_0,
104 {0, nullptr},
105 {0, nullptr},
106 EVENT_HORIZON_MIN,
107 0,
108 {0, nullptr}},
109 };
110 config_ptr two_cfg_ptr[2] = {&two_cfg[0], &two_cfg[1]};
111 gcs_snap.cfg.configs_len = 2;
112 gcs_snap.cfg.configs_val = two_cfg_ptr;
113 gcs_snap.log_start.group_id = 1;
114 max_boot_key = config_max_boot_key(&gcs_snap);
115 ASSERT_TRUE(synode_eq(max_boot_key, synode_1_2_0));
116
117 gcs_snap.log_start.group_id = 2;
118 max_boot_key = config_max_boot_key(&gcs_snap);
119 ASSERT_TRUE(synode_eq(max_boot_key, null_synode));
120 }
121
122 } // namespace xcom_site_def_unittest