Debian Codegraph @

debian/tests/configuration-tracing

raw symbols SCIP
1 #!/bin/sh
2 # shellcheck disable=SC2086
3 #
4 # dep8 smoke test for mariadbd
5 # Author: Otto Kekäläinen <[email protected]>
6 #
7 # This test should be declared in debian/tests/control with a dependency
8 # on the package that provides a configured MariaDB server (eg.
9 # mariadb-server).
10 #
11 # This test should be declared in debian/tests/control with the
12 # following restrictions:
13 # - needs-root (binaries in /usr/sbin need root to run)
14 # - allow-stderr (set -x always outputs to stderr, also if mariadbd was not
15 # launched as a service it will complain that mysql.plugin table is empty)
16 #
17 # This test prints out various configuration information from mariadbd and
18 # compares the result to expected values in original binary/build.
19 #
20
21 MARIADB_CLIENT_PATH="${MARIADB_CLIENT_PATH:-/usr/bin}"
22 MARIADB_SERVER_PATH="${MARIADB_SERVER_PATH:-/usr/sbin}"
23
24 normalize_value() {
25 VARIABLE="$1"
26 VALUE="$2"
27 # In sed the '\s.*' will match whitespace followed by any other chars until end of line
28 sed "s/^$VARIABLE\(\s\s*\).*$/$VARIABLE\1$VALUE/" -i "$TEMPFILE"
29 }
30
31 trace() {
32 TRACE_NAME="$(basename "$*" | sed 's/ //g' | sed 's/--/-/g')"
33
34 # Show in test what was run
35 echo
36 echo "Tracing: $*"
37
38 # shellcheck disable=SC2068
39 $@ > "$TRACE_NAME.actual"
40
41 # Normalize contents for know special case
42 if echo "$*" | grep -q verbose
43 then
44 TEMPFILE="$(mktemp)"
45 # Use 'tail' to skip first line that has version and architecture strings which
46 # we intentionally do not want to include in the trace file.
47 tail -n +2 "$TRACE_NAME.actual" > "$TEMPFILE"
48
49 # Hostname varies one very machine
50 sed "s/$(hostname)/HOSTNAME/g" -i "$TEMPFILE"
51
52 # SSL library version inherited form dependency, not relevant for tracing
53 # the correctness of the MariaDB build itself
54 sed 's/OpenSSL 3.*/SSL-VERSION/' -i "$TEMPFILE"
55
56 # Normalize values that depend on build environment
57 normalize_value system-time-zone UTC # depends on OS environment
58 normalize_value open-files-limit 32000 # depends on OS environment
59 normalize_value thread-pool-size 2 # depends on CPU cores available
60 normalize_value version-compile-machine ARCH # x86_64, aarch64, armv7l ..
61
62 # armhf/armel might have: debian-linux-gnueabi, debian-linux-gnueabihf
63 normalize_value version-compile-os debian-linux-gnu
64
65 # Version strings and compilation comment contents may change on every
66 # release and build on different Debian/Ubuntu releases and architectures
67 normalize_value version "VERSION"
68 normalize_value version-comment "VERSION-COMMENT"
69
70 # Inherits git commit id from latest upstream release and thus not constant
71 normalize_value version-source-revision -
72
73 # 32-bit systems (i386, armel, armhf) have lower values
74 normalize_value innodb-buffer-pool-size-max 8796093022208 # 32-bit: 0
75 normalize_value innodb-io-capacity-max 18446744073709551615 # 32-bit: 4294967295
76 normalize_value max-binlog-cache-size 18446744073709547520 # 32-bit: 4294963200
77 normalize_value max-binlog-stmt-cache-size 18446744073709547520 # 32-bit: 4294963200
78 normalize_value myisam-max-sort-file-size 18446744073709551615 # 32-bit: 2146435072
79 normalize_value myisam-mmap-size 9223372036853727232 # 32-bit: 4294967295
80 normalize_value quick-max-column-width 9223372036854775807 # 32-bit: 2147483647
81 normalize_value tmp-disk-table-size 18446744073709551615 # 32-bit: 4294967295
82
83 # ppc64el has larger default value: 393216
84 normalize_value log-tc-size 24576
85
86 # feedback plugin submitter identifier is random
87 normalize_value server-uid 1234567890abcdefghijklmnopq=
88
89 # wsrep-provider exists twice as a system variable: both to control if
90 # plugin is on or off, and to define the path to the plugin. As according to
91 # https://mariadb.com/kb/en/galera-cluster-system-variables/#wsrep_provider)
92 # defining the path is the documented on, clean away the ON/OFF flag from
93 # causing issues in tracing:
94 sed '/wsrep-provider\s\+ON/d' -i "$TEMPFILE"
95 sed '/^ --wsrep-provider\[=name\]/,/^[[:blank:]]\+be uninstalled/d' -i "$TEMPFILE"
96
97 # Due to unknown reasons, in Debian (and in Ubuntu before March 16, 2026)
98 # these values were zero and empty, instead of the actual default values,
99 # which are also documented at
100 # https://mariadb.com/docs/server/server-usage/storage-engines/aria/aria-system-variables
101 normalize_value aria-checkpoint-interval 30
102 normalize_value aria-recover-options BACKUP,QUICK
103
104 mv "$TEMPFILE" "$TRACE_NAME.actual"
105 fi
106
107 echo "diff --ignore-space-change -u $TRACE_NAME.expected $TRACE_NAME.actual"
108 # Validate that trace file in source code matches tested
109 if ! diff --ignore-space-change -u "$TRACE_NAME.expected" "$TRACE_NAME.actual"
110 then
111 echo "Error: Output from '$*' did NOT match what was expected"
112 echo
113 echo "If the change is intentional, update the debian/tests/traces to match"
114 echo "the new values and document change to users in mariadb-server.NEWS"
115
116 if [ -n "$ERRORS" ]
117 then
118 ERRORS="$ERRORS, $TRACE_NAME"
119 else
120 ERRORS="$TRACE_NAME"
121 fi
122 fi
123 }
124
125 TEST_DIR="$(dirname "$(realpath "$0")")"
126 echo "Running test 'configuration-tracing' at $TEST_DIR"
127 cd $TEST_DIR/traces || exit 1
128
129 set -e
130
131 ERRORS=""
132
133 # Dump out what parameters mariadb would be called with by default
134 trace $MARIADB_CLIENT_PATH/mariadb --print-defaults
135
136 # Dump out all help texts, client variables and their default values
137 trace $MARIADB_CLIENT_PATH/mariadb --verbose --help
138
139 # Dump out what parameters mariadbd would be called with by default on system
140 trace $MARIADB_SERVER_PATH/mariadbd --print-defaults
141
142 # Dump out all help texts, server variables and their default values
143 trace $MARIADB_SERVER_PATH/mariadbd --verbose --help
144
145 # Emit non-zero exit code if there was errors
146 if [ -n "$ERRORS" ]
147 then
148 echo "Error: mismatch in $ERRORS"
149 exit 1
150 fi