Debian Codegraph @

mysql-test/suite/network_namespace/t/network_namespace_errors.test

raw
1 #####################################################################
2 # #
3 # The aim of this test is verify error checks for usage of network #
4 # namespaces introduced by WL#12720. #
5 # #
6 # The test requires following conditions to be met in order for #
7 # it to run :- #
8 # 1. mysqld has been granted the capability to switch network #
9 # namespaces. #
10 # 2. A network namespace named 'red' containing the IP '10.0.2.1' #
11 # is created and is accessible. #
12 # #
13 # Creation Date: 2019-02-20 #
14 # Author: Srikanth B R #
15 # #
16 #####################################################################
17
18 # Network namespaces is a feature of Linux.
19 # So, ignore this test on any platform except Linux.
20 --source include/linux.inc
21
22 --source ../include/have_network_namespaces.inc
23
24 --let $MYSQLD_DATADIR= `SELECT @@datadir`
25
26 --echo # Stop DB server which was created by default
27 --source include/shutdown_mysqld.inc
28
29 --let $MYSQLD_LOG=$MYSQLTEST_VARDIR/tmp/netns.err
30
31 --let $DEFARGS= --no-defaults --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --secure-file-priv="" --socket=$MYSQLD_SOCKET --skip-ssl --skip-mysqlx
32
33 --echo # Using an unknown network namespace with bind-address
34 --error 1
35 --exec $MYSQLD $DEFARGS --bind-address=10.0.2.1/green
36
37 --let SEARCH_FILE=$MYSQLD_LOG
38 --let SEARCH_PATTERN=ERROR.*Server.*Unknown network namespace 'green'
39 --source include/search_pattern.inc
40
41 --remove_file $MYSQLD_LOG
42
43 --echo # Simulate lack of cap_sys_admin capability
44
45 # Since capabilities are granted on file paths, they are not transferred
46 # when a binary is copied to another location
47 --copy_file $MYSQLD $MYSQLTEST_VARDIR/tmp/mysqld
48
49 --error 1
50 --exec $MYSQLTEST_VARDIR/tmp/mysqld $DEFARGS --bind-address=10.0.2.1/red
51
52 --let SEARCH_PATTERN=ERROR.*Server.*setns\(\) failed with error 'Operation not permitted'
53 --source include/search_pattern.inc
54 --remove_file $MYSQLD_LOG
55
56 --error 1
57 --exec $MYSQLTEST_VARDIR/tmp/mysqld $DEFARGS --admin-address=10.0.2.1/red
58
59 --let SEARCH_PATTERN=ERROR.*Server.*setns\(\) failed with error 'Operation not permitted'
60 --source include/search_pattern.inc
61 --remove_file $MYSQLD_LOG
62
63 --remove_file $MYSQLTEST_VARDIR/tmp/mysqld
64
65 --echo # Try specifying wildcard address for bind-address/admin-address with network namespaces
66 --error 1
67 --exec $MYSQLD $DEFARGS --bind-address=*/red
68
69 --error 1
70 --exec $MYSQLD $DEFARGS --bind-address=0.0.0.0/red
71
72 --error 1
73 --exec $MYSQLD $DEFARGS --bind-address=::/red
74
75 --error 1
76 --exec $MYSQLD $DEFARGS --admin-address=*/red
77
78 --error 1
79 --exec $MYSQLD $DEFARGS --admin-address=0.0.0.0/red
80
81 --error 1
82 --exec $MYSQLD $DEFARGS --admin-address=::/red
83
84 --error 1
85 --exec $MYSQLD $DEFARGS --bind-address=127.0.0.1/
86
87 --error 1
88 --exec $MYSQLD $DEFARGS --admin-address=127.0.0.1/
89
90 --error 1
91 --exec $MYSQLD $DEFARGS --bind-address=127.0.0.1/,localhost
92
93 --let SEARCH_PATTERN=ERROR.*Server.*Network namespace not allowed for wildcard interface address
94 --source include/search_pattern.inc
95
96 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option bind-addresses: '\*/red'
97 --source include/search_pattern.inc
98
99 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option bind-addresses: '0.0.0.0/red'
100 --source include/search_pattern.inc
101
102 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option bind-addresses: '::/red'
103 --source include/search_pattern.inc
104
105 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option admin-address: '\*/red'
106 --source include/search_pattern.inc
107
108 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option admin-address: '0.0.0.0/red'
109 --source include/search_pattern.inc
110
111 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option admin-address: '::/red'
112 --source include/search_pattern.inc
113
114 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option bind-addresses: '127.0.0.1/'
115 --source include/search_pattern.inc
116
117 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option bind-addresses: '127.0.0.1/,localhost'
118 --source include/search_pattern.inc
119
120 --let SEARCH_PATTERN=ERROR.*Server.*Invalid value for command line option admin-address: '127.0.0.1/'
121 --source include/search_pattern.inc
122
123 --remove_file $MYSQLD_LOG
124
125 --echo # Try specifying incorrect values to --mysqlx-bind-address
126
127 # mysqld doesn't abort when invalid mysqlx bind address is given
128 # as it sets up a socket. Hence, it should be specified that MTR
129 # need not wait for the xplugin tcp socket to be setup.
130 --let $wait_for_tcpsocket_status = no_wait
131
132 # Unknown network namespace
133 --let $restart_parameters=restart: --log-error=$MYSQLD_LOG --mysqlx-bind-address=10.0.2.1/green
134 --connection default
135 --replace_result $MYSQLD_LOG MYSQLD_LOG
136 --source include/start_mysqld.inc
137
138 --let SEARCH_PATTERN=ERROR.*Server.*Unknown network namespace 'green'
139 --source include/search_pattern.inc
140
141 --let $wait_for_tcpsocket_status = no_wait
142
143 # Wildcard address with network namespaces
144 --let $restart_parameters=restart: --log-error=$MYSQLD_LOG --mysqlx-bind-address=*/red
145 --replace_result $MYSQLD_LOG MYSQLD_LOG
146 --source include/restart_mysqld.inc
147
148 --let SEARCH_PATTERN=ERROR.*Server.*Plugin mysqlx reported: 'Validation of value '\*/red' set to `Mysqlx_bind_address` failed: network namespace are not allowed for wildcards. Skipping this value.'
149 --source include/search_pattern.inc
150
151 --remove_file $MYSQLD_LOG
152
153 --echo # Starting mysqld with original parameters
154 --let $restart_parameters=
155 --connection default
156
157 --source include/restart_mysqld.inc