Debian Codegraph @

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

raw
1 # WL#12720 Add support for network namespaces on setting up listening sockets
2
3 # Network namespaces is a feature of Linux.
4 # So, ignore this test on any platform except Linux.
5 --source include/linux.inc
6
7 # This test relies on the fact that environment was configured
8 # to support the network namespace. Namely, the network namespace named 'red'
9 # must be set up on every linux host involved into pushbuild infrastructure.
10 # The network interface in the namespace 'red' must be assigned IP address 10.0.2.1
11 # and routing between the IP address 10.0.2.1 from the network namespace 'red'
12 # and IP addresses from the root (default) network namespace must be configured.
13 # Until it be done on every linux host inside pushbuild infrastructure this
14 # test must be disabled.
15
16 --source ../include/have_network_namespaces.inc
17
18 --let $restart_parameters = restart: --skip-name-resolve --bind-address=127.0.0.1,10.0.2.1/red
19 --source include/restart_mysqld.inc
20
21 CREATE USER [email protected];
22 CREATE USER [email protected];
23 CREATE USER [email protected];
24
25 --let $MYSQL_PORT= `SELECT @@port`
26
27 --echo # Check that client can establish connection to the address 127.0.0.1 from the default network namespace
28 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 127.0.0.1 -e "SELECT USER()"
29
30 --echo # Check that client can establish connection to the address 10.0.2.1 from the network namespace 'red'
31 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()"
32
33 --echo # Check that client can't establish connection to the address 10.0.2.1 from a non-existing network namespace 'green'
34 --error 1
35 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=green -e "SELECT USER()" 2>&1
36
37 --echo # Simulate case where the mysql client doesn't have the cap_sys_admin_capability
38 --copy_file $EXE_MYSQL $MYSQLTEST_VARDIR/tmp/mysql
39 --error 1
40 --exec $MYSQLTEST_VARDIR/tmp/mysql --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()" 2>&1
41 --remove_file $MYSQLTEST_VARDIR/tmp/mysql
42
43 --echo # Check that connections to the host from clients outside the network namespace error out since
44 --echo # they are visible only through the gateway through which the network namespace connects to the
45 --echo # outer root network namespace.
46 --error 1
47 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 -e "SELECT USER()"
48
49 --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1,10.0.2.1/red,10.0.1.1/blue
50 --source include/restart_mysqld.inc
51
52 --echo # Check that client can establish connection to the address 10.0.2.1 from the network namespace 'red'
53 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()"
54
55 --echo # Check that client can establish connection to the address 10.0.1.1 from the network namespace 'blue'
56 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.1.1 --network-namespace=blue -e "SELECT USER()"
57
58 --echo # Use network namespaces with admin port
59
60 --disable_query_log
61 CALL mtr.add_suppression("Failed to initialize TLS for channel: mysql_admin");
62 CALL mtr.add_suppression("Failed to set up SSL because of the following SSL library error");
63 --enable_query_log
64
65 --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1 --admin-address=10.0.2.1/red --admin-port=$MASTER_ADMINPORT
66 --replace_result $MASTER_ADMINPORT ADMIN_PORT
67 --source include/restart_mysqld.inc
68
69 GRANT SERVICE_CONNECTION_ADMIN ON *.* TO [email protected];
70
71 --exec $EXE_MYSQL --no-defaults -u root --host 10.0.2.1 --port $MASTER_ADMINPORT --network-namespace=red -e "SELECT USER()"
72
73 # Restart with a dedicated listener thread for admin connections
74 --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1 --admin-address=10.0.2.1/red --admin-port=$MASTER_ADMINPORT --create-admin-listener-thread=true
75 --replace_result $MASTER_ADMINPORT ADMIN_PORT
76 --source include/restart_mysqld.inc
77
78 --exec $EXE_MYSQL --no-defaults -u root --host 10.0.2.1 --port $MASTER_ADMINPORT --network-namespace=red -e "SELECT USER()"
79
80 REVOKE SERVICE_CONNECTION_ADMIN ON *.* FROM [email protected];
81
82 --let $restart_parameters=restart:
83 --source include/restart_mysqld.inc
84
85 --connection default
86 DROP USER [email protected];
87 DROP USER [email protected];
88 DROP USER [email protected];