From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- ctdb/tests/UNIT/eventscripts/00.ctdb.init.001.sh | 13 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.002.sh | 17 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.003.sh | 16 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.004.sh | 18 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.005.sh | 20 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.006.sh | 23 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.007.sh | 16 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.008.sh | 19 + ctdb/tests/UNIT/eventscripts/00.ctdb.init.009.sh | 51 ++ .../tests/UNIT/eventscripts/01.reclock.init.001.sh | 10 + .../tests/UNIT/eventscripts/01.reclock.init.002.sh | 10 + .../tests/UNIT/eventscripts/01.reclock.init.003.sh | 20 + .../UNIT/eventscripts/05.system.monitor.001.sh | 13 + .../UNIT/eventscripts/05.system.monitor.002.sh | 14 + .../UNIT/eventscripts/05.system.monitor.003.sh | 17 + .../UNIT/eventscripts/05.system.monitor.004.sh | 15 + .../UNIT/eventscripts/05.system.monitor.005.sh | 17 + .../UNIT/eventscripts/05.system.monitor.006.sh | 17 + .../UNIT/eventscripts/05.system.monitor.007.sh | 14 + .../UNIT/eventscripts/05.system.monitor.011.sh | 13 + .../UNIT/eventscripts/05.system.monitor.012.sh | 14 + .../UNIT/eventscripts/05.system.monitor.014.sh | 18 + .../UNIT/eventscripts/05.system.monitor.015.sh | 20 + .../UNIT/eventscripts/05.system.monitor.017.sh | 20 + .../UNIT/eventscripts/05.system.monitor.018.sh | 82 ++ .../UNIT/eventscripts/06.nfs.releaseip.001.sh | 12 + .../UNIT/eventscripts/06.nfs.releaseip.002.sh | 12 + ctdb/tests/UNIT/eventscripts/06.nfs.takeip.001.sh | 12 + ctdb/tests/UNIT/eventscripts/06.nfs.takeip.002.sh | 12 + ctdb/tests/UNIT/eventscripts/10.interface.010.sh | 23 + ctdb/tests/UNIT/eventscripts/10.interface.011.sh | 28 + ctdb/tests/UNIT/eventscripts/10.interface.012.sh | 31 + ctdb/tests/UNIT/eventscripts/10.interface.013.sh | 36 + .../UNIT/eventscripts/10.interface.init.001.sh | 13 + .../UNIT/eventscripts/10.interface.init.002.sh | 11 + .../UNIT/eventscripts/10.interface.init.021.sh | 11 + .../UNIT/eventscripts/10.interface.init.022.sh | 18 + .../UNIT/eventscripts/10.interface.init.023.sh | 23 + .../UNIT/eventscripts/10.interface.monitor.001.sh | 13 + .../UNIT/eventscripts/10.interface.monitor.002.sh | 11 + .../UNIT/eventscripts/10.interface.monitor.003.sh | 15 + .../UNIT/eventscripts/10.interface.monitor.004.sh | 15 + .../UNIT/eventscripts/10.interface.monitor.005.sh | 15 + .../UNIT/eventscripts/10.interface.monitor.006.sh | 15 + .../UNIT/eventscripts/10.interface.monitor.009.sh | 19 + .../UNIT/eventscripts/10.interface.monitor.010.sh | 25 + .../UNIT/eventscripts/10.interface.monitor.011.sh | 21 + .../UNIT/eventscripts/10.interface.monitor.012.sh | 29 + .../UNIT/eventscripts/10.interface.monitor.013.sh | 15 + .../UNIT/eventscripts/10.interface.monitor.014.sh | 16 + .../UNIT/eventscripts/10.interface.monitor.015.sh | 16 + .../UNIT/eventscripts/10.interface.monitor.016.sh | 20 + .../UNIT/eventscripts/10.interface.monitor.017.sh | 20 + .../UNIT/eventscripts/10.interface.monitor.018.sh | 20 + .../UNIT/eventscripts/10.interface.multi.001.sh | 14 + .../eventscripts/10.interface.releaseip.001.sh | 13 + .../eventscripts/10.interface.releaseip.002.sh | 14 + .../UNIT/eventscripts/10.interface.startup.001.sh | 13 + .../UNIT/eventscripts/10.interface.startup.002.sh | 11 + .../UNIT/eventscripts/10.interface.takeip.001.sh | 13 + .../UNIT/eventscripts/10.interface.takeip.002.sh | 13 + .../UNIT/eventscripts/10.interface.takeip.003.sh | 22 + ctdb/tests/UNIT/eventscripts/11.natgw.001.sh | 12 + ctdb/tests/UNIT/eventscripts/11.natgw.002.sh | 24 + ctdb/tests/UNIT/eventscripts/11.natgw.003.sh | 24 + ctdb/tests/UNIT/eventscripts/11.natgw.004.sh | 24 + ctdb/tests/UNIT/eventscripts/11.natgw.011.sh | 23 + ctdb/tests/UNIT/eventscripts/11.natgw.012.sh | 23 + ctdb/tests/UNIT/eventscripts/11.natgw.013.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.014.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.015.sh | 61 ++ ctdb/tests/UNIT/eventscripts/11.natgw.021.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.022.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.023.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.024.sh | 27 + ctdb/tests/UNIT/eventscripts/11.natgw.025.sh | 65 ++ ctdb/tests/UNIT/eventscripts/11.natgw.031.sh | 62 ++ ctdb/tests/UNIT/eventscripts/11.natgw.041.sh | 24 + ctdb/tests/UNIT/eventscripts/11.natgw.042.sh | 25 + ctdb/tests/UNIT/eventscripts/11.natgw.051.sh | 17 + ctdb/tests/UNIT/eventscripts/11.natgw.052.sh | 21 + ctdb/tests/UNIT/eventscripts/11.natgw.053.sh | 17 + ctdb/tests/UNIT/eventscripts/11.natgw.054.sh | 21 + .../UNIT/eventscripts/13.per_ip_routing.001.sh | 19 + .../UNIT/eventscripts/13.per_ip_routing.002.sh | 18 + .../UNIT/eventscripts/13.per_ip_routing.003.sh | 16 + .../UNIT/eventscripts/13.per_ip_routing.004.sh | 17 + .../UNIT/eventscripts/13.per_ip_routing.005.sh | 20 + .../UNIT/eventscripts/13.per_ip_routing.006.sh | 24 + .../UNIT/eventscripts/13.per_ip_routing.007.sh | 17 + .../UNIT/eventscripts/13.per_ip_routing.008.sh | 23 + .../UNIT/eventscripts/13.per_ip_routing.009.sh | 20 + .../UNIT/eventscripts/13.per_ip_routing.010.sh | 19 + .../UNIT/eventscripts/13.per_ip_routing.011.sh | 21 + .../UNIT/eventscripts/13.per_ip_routing.012.sh | 29 + .../UNIT/eventscripts/13.per_ip_routing.013.sh | 23 + .../UNIT/eventscripts/13.per_ip_routing.014.sh | 29 + .../UNIT/eventscripts/13.per_ip_routing.015.sh | 29 + .../UNIT/eventscripts/13.per_ip_routing.016.sh | 14 + .../UNIT/eventscripts/13.per_ip_routing.017.sh | 15 + .../UNIT/eventscripts/13.per_ip_routing.018.sh | 21 + .../UNIT/eventscripts/13.per_ip_routing.019.sh | 23 + .../UNIT/eventscripts/13.per_ip_routing.021.sh | 15 + .../UNIT/eventscripts/13.per_ip_routing.022.sh | 15 + .../UNIT/eventscripts/13.per_ip_routing.023.sh | 25 + .../UNIT/eventscripts/13.per_ip_routing.024.sh | 30 + .../UNIT/eventscripts/20.multipathd.monitor.001.sh | 11 + .../UNIT/eventscripts/20.multipathd.monitor.002.sh | 11 + .../UNIT/eventscripts/20.multipathd.monitor.003.sh | 14 + .../UNIT/eventscripts/20.multipathd.monitor.004.sh | 15 + .../UNIT/eventscripts/31.clamd.monitor.002.sh | 16 + .../UNIT/eventscripts/31.clamd.monitor.003.sh | 16 + .../UNIT/eventscripts/40.vsftpd.monitor.002.sh | 52 ++ .../UNIT/eventscripts/40.vsftpd.shutdown.002.sh | 12 + .../UNIT/eventscripts/40.vsftpd.startup.002.sh | 12 + .../UNIT/eventscripts/41.httpd.monitor.002.sh | 30 + .../UNIT/eventscripts/41.httpd.shutdown.002.sh | 12 + .../UNIT/eventscripts/41.httpd.startup.002.sh | 12 + .../UNIT/eventscripts/48.netbios.shutdown.011.sh | 14 + .../UNIT/eventscripts/48.netbios.startup.011.sh | 14 + .../UNIT/eventscripts/49.winbind.monitor.101.sh | 11 + .../UNIT/eventscripts/49.winbind.monitor.102.sh | 13 + .../UNIT/eventscripts/49.winbind.shutdown.002.sh | 12 + .../UNIT/eventscripts/49.winbind.startup.002.sh | 12 + .../UNIT/eventscripts/50.samba.monitor.101.sh | 11 + .../UNIT/eventscripts/50.samba.monitor.103.sh | 13 + .../UNIT/eventscripts/50.samba.monitor.104.sh | 13 + .../UNIT/eventscripts/50.samba.monitor.105.sh | 12 + .../UNIT/eventscripts/50.samba.monitor.106.sh | 15 + .../UNIT/eventscripts/50.samba.monitor.110.sh | 20 + .../UNIT/eventscripts/50.samba.monitor.111.sh | 23 + .../UNIT/eventscripts/50.samba.monitor.112.sh | 13 + .../UNIT/eventscripts/50.samba.monitor.113.sh | 16 + .../UNIT/eventscripts/50.samba.shutdown.001.sh | 12 + .../UNIT/eventscripts/50.samba.shutdown.002.sh | 15 + .../UNIT/eventscripts/50.samba.shutdown.011.sh | 14 + .../UNIT/eventscripts/50.samba.startup.011.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.101.sh | 11 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.102.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.103.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.104.sh | 17 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.105.sh | 10 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.106.sh | 11 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.107.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.108.sh | 12 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.109.sh | 12 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.111.sh | 13 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.112.sh | 13 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.113.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.114.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.121.sh | 15 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.122.sh | 18 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.131.sh | 11 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.132.sh | 15 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.141.sh | 13 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.142.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.143.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.144.sh | 13 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.151.sh | 13 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.152.sh | 15 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.153.sh | 15 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.161.sh | 12 + ctdb/tests/UNIT/eventscripts/60.nfs.monitor.162.sh | 15 + ctdb/tests/UNIT/eventscripts/60.nfs.multi.001.sh | 19 + ctdb/tests/UNIT/eventscripts/60.nfs.multi.002.sh | 17 + .../UNIT/eventscripts/60.nfs.releaseip.001.sh | 14 + .../UNIT/eventscripts/60.nfs.releaseip.002.sh | 12 + .../tests/UNIT/eventscripts/60.nfs.shutdown.001.sh | 14 + .../tests/UNIT/eventscripts/60.nfs.shutdown.002.sh | 12 + ctdb/tests/UNIT/eventscripts/60.nfs.startup.001.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.startup.002.sh | 12 + ctdb/tests/UNIT/eventscripts/60.nfs.takeip.001.sh | 14 + ctdb/tests/UNIT/eventscripts/60.nfs.takeip.002.sh | 12 + ctdb/tests/UNIT/eventscripts/91.lvs.001.sh | 54 ++ .../UNIT/eventscripts/91.lvs.ipreallocated.011.sh | 14 + .../UNIT/eventscripts/91.lvs.ipreallocated.012.sh | 17 + .../UNIT/eventscripts/91.lvs.ipreallocated.013.sh | 17 + .../UNIT/eventscripts/91.lvs.ipreallocated.014.sh | 27 + ctdb/tests/UNIT/eventscripts/91.lvs.monitor.001.sh | 11 + ctdb/tests/UNIT/eventscripts/91.lvs.monitor.002.sh | 14 + ctdb/tests/UNIT/eventscripts/91.lvs.monitor.003.sh | 19 + .../tests/UNIT/eventscripts/91.lvs.shutdown.001.sh | 11 + .../tests/UNIT/eventscripts/91.lvs.shutdown.002.sh | 18 + ctdb/tests/UNIT/eventscripts/91.lvs.startup.001.sh | 11 + ctdb/tests/UNIT/eventscripts/91.lvs.startup.002.sh | 14 + ctdb/tests/UNIT/eventscripts/README | 46 ++ ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh | 9 + ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh | 9 + .../UNIT/eventscripts/etc-ctdb/public_addresses | 9 + ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local | 56 ++ ctdb/tests/UNIT/eventscripts/etc/init.d/nfs | 7 + ctdb/tests/UNIT/eventscripts/etc/init.d/nfslock | 7 + ctdb/tests/UNIT/eventscripts/etc/os-release | 2 + ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf | 43 ++ ctdb/tests/UNIT/eventscripts/etc/sysconfig/nfs | 2 + ctdb/tests/UNIT/eventscripts/scripts/00.ctdb.sh | 24 + ctdb/tests/UNIT/eventscripts/scripts/01.reclock.sh | 16 + ctdb/tests/UNIT/eventscripts/scripts/05.system.sh | 48 ++ ctdb/tests/UNIT/eventscripts/scripts/06.nfs.sh | 4 + .../UNIT/eventscripts/scripts/10.interface.sh | 72 ++ ctdb/tests/UNIT/eventscripts/scripts/11.natgw.sh | 120 +++ .../UNIT/eventscripts/scripts/13.per_ip_routing.sh | 47 ++ .../UNIT/eventscripts/scripts/20.multipathd.sh | 25 + ctdb/tests/UNIT/eventscripts/scripts/31.clamd.sh | 8 + ctdb/tests/UNIT/eventscripts/scripts/40.vsftpd.sh | 14 + ctdb/tests/UNIT/eventscripts/scripts/41.httpd.sh | 14 + ctdb/tests/UNIT/eventscripts/scripts/48.netbios.sh | 23 + ctdb/tests/UNIT/eventscripts/scripts/49.winbind.sh | 28 + ctdb/tests/UNIT/eventscripts/scripts/50.samba.sh | 58 ++ ctdb/tests/UNIT/eventscripts/scripts/60.nfs.sh | 435 +++++++++++ ctdb/tests/UNIT/eventscripts/scripts/91.lvs.sh | 76 ++ .../tests/UNIT/eventscripts/scripts/debug_locks.sh | 272 +++++++ ctdb/tests/UNIT/eventscripts/scripts/local.sh | 568 ++++++++++++++ .../UNIT/eventscripts/scripts/statd-callout.sh | 65 ++ ctdb/tests/UNIT/eventscripts/statd-callout.001.sh | 13 + ctdb/tests/UNIT/eventscripts/statd-callout.002.sh | 14 + ctdb/tests/UNIT/eventscripts/statd-callout.003.sh | 16 + ctdb/tests/UNIT/eventscripts/statd-callout.004.sh | 17 + ctdb/tests/UNIT/eventscripts/statd-callout.005.sh | 25 + ctdb/tests/UNIT/eventscripts/statd-callout.006.sh | 27 + ctdb/tests/UNIT/eventscripts/statd-callout.007.sh | 14 + ctdb/tests/UNIT/eventscripts/stubs/ctdb | 481 ++++++++++++ ctdb/tests/UNIT/eventscripts/stubs/ctdb-config | 2 + ctdb/tests/UNIT/eventscripts/stubs/ctdb_killtcp | 10 + ctdb/tests/UNIT/eventscripts/stubs/ctdb_lvs | 53 ++ ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw | 34 + ctdb/tests/UNIT/eventscripts/stubs/date | 7 + ctdb/tests/UNIT/eventscripts/stubs/df | 38 + ctdb/tests/UNIT/eventscripts/stubs/ethtool | 12 + ctdb/tests/UNIT/eventscripts/stubs/exportfs | 13 + ctdb/tests/UNIT/eventscripts/stubs/gstack | 19 + ctdb/tests/UNIT/eventscripts/stubs/id | 3 + ctdb/tests/UNIT/eventscripts/stubs/ip | 833 +++++++++++++++++++++ ctdb/tests/UNIT/eventscripts/stubs/ip6tables | 5 + ctdb/tests/UNIT/eventscripts/stubs/iptables | 5 + ctdb/tests/UNIT/eventscripts/stubs/ipvsadm | 154 ++++ ctdb/tests/UNIT/eventscripts/stubs/kill | 7 + ctdb/tests/UNIT/eventscripts/stubs/killall | 7 + ctdb/tests/UNIT/eventscripts/stubs/multipath | 36 + ctdb/tests/UNIT/eventscripts/stubs/net | 5 + .../tests/UNIT/eventscripts/stubs/nfs-fake-callout | 15 + ctdb/tests/UNIT/eventscripts/stubs/nfsconf | 5 + ctdb/tests/UNIT/eventscripts/stubs/pidof | 17 + ctdb/tests/UNIT/eventscripts/stubs/pkill | 7 + ctdb/tests/UNIT/eventscripts/stubs/ps | 48 ++ ctdb/tests/UNIT/eventscripts/stubs/rm | 6 + ctdb/tests/UNIT/eventscripts/stubs/rpc.lockd | 6 + ctdb/tests/UNIT/eventscripts/stubs/rpc.mountd | 6 + ctdb/tests/UNIT/eventscripts/stubs/rpc.rquotad | 6 + ctdb/tests/UNIT/eventscripts/stubs/rpc.statd | 6 + ctdb/tests/UNIT/eventscripts/stubs/rpcinfo | 78 ++ ctdb/tests/UNIT/eventscripts/stubs/service | 65 ++ ctdb/tests/UNIT/eventscripts/stubs/sleep | 9 + ctdb/tests/UNIT/eventscripts/stubs/smnotify | 65 ++ ctdb/tests/UNIT/eventscripts/stubs/ss | 206 +++++ ctdb/tests/UNIT/eventscripts/stubs/stat | 71 ++ ctdb/tests/UNIT/eventscripts/stubs/tdb_mutex_check | 10 + ctdb/tests/UNIT/eventscripts/stubs/tdbdump | 9 + ctdb/tests/UNIT/eventscripts/stubs/tdbtool | 36 + ctdb/tests/UNIT/eventscripts/stubs/testparm | 84 +++ ctdb/tests/UNIT/eventscripts/stubs/timeout | 8 + ctdb/tests/UNIT/eventscripts/stubs/wbinfo | 7 + 276 files changed, 8286 insertions(+) create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.007.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.008.sh create mode 100755 ctdb/tests/UNIT/eventscripts/00.ctdb.init.009.sh create mode 100755 ctdb/tests/UNIT/eventscripts/01.reclock.init.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/01.reclock.init.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/01.reclock.init.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.007.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.014.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh create mode 100755 ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh create mode 100755 ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/06.nfs.takeip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/06.nfs.takeip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.010.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.013.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.init.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.init.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.init.021.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.init.022.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.init.023.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.009.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.010.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.013.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.014.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.015.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.016.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.017.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.monitor.018.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.multi.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.releaseip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.releaseip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.startup.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.startup.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.takeip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.takeip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/10.interface.takeip.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.013.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.014.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.015.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.021.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.022.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.023.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.024.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.025.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.031.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.041.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.042.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.051.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.052.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.053.sh create mode 100755 ctdb/tests/UNIT/eventscripts/11.natgw.054.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.007.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.008.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.009.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.010.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.013.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.014.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.015.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.016.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.017.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.018.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.019.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.021.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.022.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.023.sh create mode 100755 ctdb/tests/UNIT/eventscripts/13.per_ip_routing.024.sh create mode 100755 ctdb/tests/UNIT/eventscripts/20.multipathd.monitor.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/20.multipathd.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/20.multipathd.monitor.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/20.multipathd.monitor.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/31.clamd.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/31.clamd.monitor.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/40.vsftpd.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/40.vsftpd.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/40.vsftpd.startup.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/41.httpd.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/41.httpd.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/41.httpd.startup.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/48.netbios.shutdown.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/48.netbios.startup.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/49.winbind.monitor.101.sh create mode 100755 ctdb/tests/UNIT/eventscripts/49.winbind.monitor.102.sh create mode 100755 ctdb/tests/UNIT/eventscripts/49.winbind.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/49.winbind.startup.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.101.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.103.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.104.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.105.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.106.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.110.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.111.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.112.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.monitor.113.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.shutdown.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.shutdown.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/50.samba.startup.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.101.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.102.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.103.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.104.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.105.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.106.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.107.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.108.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.109.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.111.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.112.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.113.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.114.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.121.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.122.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.131.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.132.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.141.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.142.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.143.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.144.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.151.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.152.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.153.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.161.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.monitor.162.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.multi.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.multi.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.releaseip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.releaseip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.shutdown.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.startup.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.startup.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.takeip.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/60.nfs.takeip.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.011.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.012.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.013.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.014.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.monitor.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.monitor.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.monitor.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.shutdown.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.shutdown.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.startup.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/91.lvs.startup.002.sh create mode 100644 ctdb/tests/UNIT/eventscripts/README create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh create mode 100755 ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh create mode 100644 ctdb/tests/UNIT/eventscripts/etc-ctdb/public_addresses create mode 100755 ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local create mode 100755 ctdb/tests/UNIT/eventscripts/etc/init.d/nfs create mode 100755 ctdb/tests/UNIT/eventscripts/etc/init.d/nfslock create mode 100644 ctdb/tests/UNIT/eventscripts/etc/os-release create mode 100644 ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf create mode 100644 ctdb/tests/UNIT/eventscripts/etc/sysconfig/nfs create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/00.ctdb.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/01.reclock.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/05.system.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/06.nfs.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/10.interface.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/11.natgw.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/13.per_ip_routing.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/20.multipathd.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/31.clamd.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/40.vsftpd.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/41.httpd.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/48.netbios.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/49.winbind.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/50.samba.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/60.nfs.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/91.lvs.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/local.sh create mode 100644 ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.001.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.002.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.003.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.004.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.005.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.006.sh create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.007.sh create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb-config create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb_killtcp create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb_lvs create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/date create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/df create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ethtool create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/exportfs create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/gstack create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/id create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ip create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ip6tables create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/iptables create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ipvsadm create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/kill create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/killall create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/multipath create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/net create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/nfs-fake-callout create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/nfsconf create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/pidof create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/pkill create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ps create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rm create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rpc.lockd create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rpc.mountd create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rpc.rquotad create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rpc.statd create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/rpcinfo create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/service create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/sleep create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/smnotify create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ss create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/stat create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/tdb_mutex_check create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/tdbdump create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/tdbtool create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/testparm create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/timeout create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/wbinfo (limited to 'ctdb/tests/UNIT/eventscripts') diff --git a/ctdb/tests/UNIT/eventscripts/00.ctdb.init.001.sh b/ctdb/tests/UNIT/eventscripts/00.ctdb.init.001.sh new file mode 100755 index 0000000..807f3ef --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/00.ctdb.init.001.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "TDB check, tdbtool supports check" + +setup + +FAKE_TDBTOOL_SUPPORTS_CHECK="yes" + +ok_null + +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/00.ctdb.init.002.sh b/ctdb/tests/UNIT/eventscripts/00.ctdb.init.002.sh new file mode 100755 index 0000000..7ff5385 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/00.ctdb.init.002.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "TDB check, tdbtool does no support check" + +setup + +FAKE_TDBTOOL_SUPPORTS_CHECK="no" + +ok <= threshold 90% +EOF +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.002.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.002.sh new file mode 100755 index 0000000..4e78a56 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.002.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Filesystem use check, good situation, 1 error check enabled" + +setup + +setup_script_options <= threshold 80% +EOF +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.004.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.004.sh new file mode 100755 index 0000000..3400393 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.004.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Filesystem use check, warn situation, only error check enabled" + +setup + +setup_script_options <= threshold 80% +EOF +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.006.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.006.sh new file mode 100755 index 0000000..48008d9 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.006.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Filesystem use check, error situation, both checks enabled" + +setup + +setup_script_options <= threshold 90% +EOF +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.007.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.007.sh new file mode 100755 index 0000000..68b99cf --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.007.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Filesystem use check, good situation, both checks enabled, multiple filesystems" + +setup + +setup_script_options <= threshold 80% +EOF +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.012.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.012.sh new file mode 100755 index 0000000..9e84056 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.012.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Memory check (custom, both), good situation" + +setup + +setup_script_options <= threshold 85% +EOF + +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh new file mode 100755 index 0000000..76b73a3 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.015.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Memory check (custom, error only), error situation" + +setup + +setup_script_options <= threshold 85% +$FAKE_PROC_MEMINFO +$(ps auxfww) +EOF + +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh new file mode 100755 index 0000000..b2e5029 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.017.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Memory check (custom, both), error situation" + +setup + +setup_script_options <= threshold 80% +$FAKE_PROC_MEMINFO +$(ps auxfww) +EOF + +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh b/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh new file mode 100755 index 0000000..427adc6 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/05.system.monitor.018.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Memory check (custom, both), check throttling of warnings" + +setup + +setup_script_options <= threshold 70%" +simple_test + +# 2nd time at same level, nothing logged +set_mem_usage 71 71 +ok_null +simple_test + +set_mem_usage 73 73 +ok "WARNING: System memory utilization 73% >= threshold 70%" +simple_test + +# 2nd time at same level, nothing logged +set_mem_usage 73 73 +ok_null +simple_test + +set_mem_usage 79 79 +ok "WARNING: System memory utilization 79% >= threshold 70%" +simple_test + +set_mem_usage 80 80 +required_result 1 <= threshold 80% +$FAKE_PROC_MEMINFO +$(ps auxfww) +EOF +simple_test + +# Fall back into warning at same level as last warning... should log +set_mem_usage 79 79 +ok "WARNING: System memory utilization 79% >= threshold 70%" +simple_test + +# Below threshold, notice +set_mem_usage 69 69 +ok <= threshold 70%" +simple_test + +# Back up above critical threshold... unhealthy +set_mem_usage 81 81 +required_result 1 <= threshold 80% +$FAKE_PROC_MEMINFO +$(ps auxfww) +EOF +simple_test + +# Straight back down to a good level... notice +set_mem_usage 65 65 +ok "NOTICE: System memory utilization 65% < threshold 70%" +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.001.sh b/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.001.sh new file mode 100755 index 0000000..0546863 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.001.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "callout succeeds" + +setup + +setup_nfs_callout + +ok_null +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.002.sh b/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.002.sh new file mode 100755 index 0000000..dc44d2d --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/06.nfs.releaseip.002.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "callout causes releaseip-pre to fail" + +setup + +setup_nfs_callout "releaseip-pre" + +required_result 1 "releaseip-pre" +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.001.sh b/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.001.sh new file mode 100755 index 0000000..0546863 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.001.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "callout succeeds" + +setup + +setup_nfs_callout + +ok_null +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.002.sh b/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.002.sh new file mode 100755 index 0000000..c9f3db9 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/06.nfs.takeip.002.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "callout causes takeip-pre to fail" + +setup + +setup_nfs_callout "takeip-pre" + +required_result 1 "takeip-pre" +simple_test diff --git a/ctdb/tests/UNIT/eventscripts/10.interface.010.sh b/ctdb/tests/UNIT/eventscripts/10.interface.010.sh new file mode 100755 index 0000000..171a697 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/10.interface.010.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Release 1 IP, 10 connections killed OK" + +setup + +ctdb_get_1_public_address | +while read dev ip bits ; do + ok_null + simple_test_event "takeip" $dev $ip $bits + + count=10 + setup_tcp_connections $count \ + "$ip" 445 10.254.254.0 12300 + + ok <= threshold 1 +EOF +simple_test + +setup "up" + +ok <= threshold 1 +EOF +simple_test + +required_result 1 <= threshold 2 +EOF +simple_test + +required_result 1 <= threshold 2 +EOF +simple_test + +setup "up" + +ok < reconfigure" + +setup + +public_address=$(ctdb_get_1_public_address) + +ok_null + +simple_test_event "takeip" $public_address + +ok < no reconfigure" + +setup + +public_address=$(ctdb_get_1_public_address) + +ok_null + +simple_test_event "takeip" $public_address + +ok_null + +simple_test_event "monitor" diff --git a/ctdb/tests/UNIT/eventscripts/60.nfs.releaseip.001.sh b/ctdb/tests/UNIT/eventscripts/60.nfs.releaseip.001.sh new file mode 100755 index 0000000..8bf0fa2 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/60.nfs.releaseip.001.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "callout is 'true'" + +setup + +setup_script_options < 127.0.0.1:0 Local 1 0 0 + -> 192.168.1.1:0 Route 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +EOF + +ipvsadm -A -t 10.1.1.201 -s lc -p 1999999 +ipvsadm -a -t 10.1.1.201 -r 192.168.1.3 -g +ipvsadm -a -t 10.1.1.201 -r 192.168.1.1 -g +ipvsadm -a -t 10.1.1.201 -r 192.168.1.2:0 -g + +check_ipvsadm < 192.168.1.1:0 Route 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +UDP 10.1.1.201:0 lc persistent 1999999 + -> 127.0.0.1:0 Local 1 0 0 + -> 192.168.1.1:0 Route 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +EOF + +ipvsadm -D -u 10.1.1.201 + +check_ipvsadm < 192.168.1.1:0 Route 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +EOF + +ipvsadm -D -t 10.1.1.201 + +check_ipvsadm NULL diff --git a/ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.011.sh b/ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.011.sh new file mode 100755 index 0000000..6866047 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/91.lvs.ipreallocated.011.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "configured, no nodes in config" + +setup "10.1.1.201" "eth0" < 127.0.0.1:0 Local 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +UDP 10.1.1.201:0 lc persistent 1999999 + -> 127.0.0.1:0 Local 1 0 0 + -> 192.168.1.2:0 Route 1 0 0 + -> 192.168.1.3:0 Route 1 0 0 +EOF + +check_lvs_ip global diff --git a/ctdb/tests/UNIT/eventscripts/91.lvs.monitor.001.sh b/ctdb/tests/UNIT/eventscripts/91.lvs.monitor.001.sh new file mode 100755 index 0000000..42831fb --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/91.lvs.monitor.001.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "not configured" + +setup <..NNN.sh + +The test helper functions will run with specified +options. If using the simple_test() helper function then the 1st + argument is automatically passed. When simple_test_event() is +used the event name must be explicitly passed as the 1st argument - +this is more flexible and supports multiple events per test. + +Examples: + +* ../run_tests.sh . + + Run all tests, displaying minimal output. + +* ../run_tests.sh -s . + + Run all tests, displaying minimal output and a summary. + +* ../run_tests.sh -s ./10.interface.*.sh + + Run all the tests against the 10.interface eventscript. + +* ../run_tests.sh -v -s . + + Run all tests, displaying extra output and a summary. + +* ../run_tests.sh -sq . + + Run all tests, displaying only a summary. + +* ../run_tests.sh -X ./10.interface.startup.002.sh + + Run a test and have the eventscript itself run with "sh -x". This + will usually make a test fail because the (undesirable) trace output + will be included with the output of the eventscript. However, this + is useful for finding out why a test might be failing. diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh new file mode 100755 index 0000000..8f10200 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.001.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB S+ DB" + +setup + +do_test "DB" "S+" "DB" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh new file mode 100755 index 0000000..31ae3df --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.002.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB D. DB" + +setup + +do_test "DB" "D." "DB" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh new file mode 100755 index 0000000..89ab2f1 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.003.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD S+ DB" + +setup + +do_test "RECORD" "S+" "DB" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh new file mode 100755 index 0000000..35500cb --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.004.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD D. DB" + +setup + +do_test "RECORD" "D." "DB" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh new file mode 100755 index 0000000..10cbade --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.005.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB S+ RECORD" + +setup + +do_test "DB" "S+" "RECORD" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh new file mode 100755 index 0000000..c4988b7 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.006.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB D. RECORD" + +setup + +do_test "DB" "D." "RECORD" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh new file mode 100755 index 0000000..b186d20 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.007.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD S+ RECORD" + +setup + +do_test "RECORD" "S+" "RECORD" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh new file mode 100755 index 0000000..7b7ac9b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.008.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD D. RECORD" + +setup + +do_test "RECORD" "D." "RECORD" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh new file mode 100755 index 0000000..f324803 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.021.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB S+ DB MUTEX" + +setup + +do_test "DB" "S+" "DB" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh new file mode 100755 index 0000000..0e70771 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.022.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB D. DB MUTEX" + +setup + +do_test "DB" "D." "DB" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh new file mode 100755 index 0000000..de84c81 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.023.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD S+ DB MUTEX" + +setup + +do_test "RECORD" "S+" "DB" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh new file mode 100755 index 0000000..30ad6bd --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.024.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD D. DB MUTEX" + +setup + +do_test "RECORD" "D." "DB" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh new file mode 100755 index 0000000..f259db5 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.025.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB S+ RECORD MUTEX" + +setup + +do_test "DB" "S+" "RECORD" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh new file mode 100755 index 0000000..9e057af --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.026.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "DB D. RECORD MUTEX" + +setup + +do_test "DB" "D." "RECORD" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh new file mode 100755 index 0000000..d70e7b7 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.027.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD S+ RECORD MUTEX" + +setup + +do_test "RECORD" "S+" "RECORD" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh new file mode 100755 index 0000000..7199035 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/debug_locks.sh.028.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "RECORD D. RECORD MUTEX" + +setup + +do_test "RECORD" "D." "RECORD" "MUTEX" diff --git a/ctdb/tests/UNIT/eventscripts/etc-ctdb/public_addresses b/ctdb/tests/UNIT/eventscripts/etc-ctdb/public_addresses new file mode 100644 index 0000000..cd2f6be --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/etc-ctdb/public_addresses @@ -0,0 +1,9 @@ +10.0.0.1/24 dev123 +10.0.0.2/24 dev123 +10.0.0.3/24 dev123 +10.0.0.4/24 dev123 +10.0.0.5/24 dev123 +10.0.0.6/24 dev123 +10.0.1.1/24 dev456 +10.0.1.2/24 dev456 +10.0.1.3/24 dev456 diff --git a/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local b/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local new file mode 100755 index 0000000..777aeaf --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local @@ -0,0 +1,56 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! :-) + +# Always use stub version of service command +service () +{ + "${CTDB_HELPER_BINDIR}/service" "$@" +} + +nice_service () +{ + nice "${CTDB_HELPER_BINDIR}/service" "$@" +} + +# Always succeeds +set_proc () { : ; } +set_proc_maybe () { : ; } + +get_proc () +{ + case "$1" in + net/bonding/*) + cat "$FAKE_PROC_NET_BONDING/${1##*/}" + ;; + sys/net/ipv4/conf/all/arp_filter) + echo 1 + ;; + sys/net/ipv4/conf/all/promote_secondaries) + echo 1 + ;; + fs/nfsd/threads) + echo "$FAKE_NFSD_THREAD_PIDS" | wc -w + ;; + */stack) + echo "[] fake_stack_trace_for_pid_${1}+0x0/0xff" + ;; + meminfo) + echo "$FAKE_PROC_MEMINFO" + ;; + locks) + echo "$FAKE_PROC_LOCKS" + ;; + *) + echo "get_proc: \"$1\" not implemented" + exit 1 + esac +} + +# Do not actually background - we want to see the output +background_with_logging () +{ + "$@" 2>&1 >"${CTDB_BASE}/ctdb.conf" <"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" +} + +setup_tcp_connections_unkillable() +{ + # These connections are listed by the "ss" stub but are not + # killed by the "ctdb killtcp" stub. So killing these + # connections will never succeed... and will look like a time + # out. + _t=$(_tcp_connections "$@" | sed -e 's/ /|/g') + export FAKE_NETSTAT_TCP_ESTABLISHED="$_t" +} + +# Setup some fake /proc/net/bonding files with just enough info for +# the eventscripts. + +# arg1 is interface name, arg2 is currently active slave (use "None" +# if none), arg3 is MII status ("up" or "down"). +setup_bond() +{ + _iface="$1" + _slave="${2:-${_iface}_sl_0}" + _mii_s="${3:-up}" + _mii_subs="${4:-${_mii_s:-up}}" + + cat <"${FAKE_PROC_NET_BONDING}/$_iface" <"$natgw_nodes" + + # Assume all of the nodes are on a /24 network and have IPv4 + # addresses: + read -r _ip <"$natgw_nodes" + + setup_script_options < mtu 1500 qdisc pfifo_fast state UP qlen 1000 + link/ether ${_mac} brd ff:ff:ff:ff:ff:ff + inet ${CTDB_NATGW_PUBLIC_IP} brd ${_brd} scope global ${CTDB_NATGW_PUBLIC_IFACE} + valid_lft forever preferred_lft forever +EOF +} + +ok_natgw_follower_ip_addr_show() +{ + _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | + cksum | + sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@') + + ok < mtu 1500 qdisc pfifo_fast state UP qlen 1000 + link/ether ${_mac} brd ff:ff:ff:ff:ff:ff +EOF +} + +ok_natgw_leader_static_routes() +{ + _nl=" +" + _t="" + for _i in $CTDB_NATGW_STATIC_ROUTES; do + # This is intentionally different to the code in 11.natgw ;-) + case "$_i" in + *@*) + _net=$(echo "$_i" | sed -e 's|@.*||') + _gw=$(echo "$_i" | sed -e 's|.*@||') + ;; + *) + _net="$_i" + _gw="$CTDB_NATGW_DEFAULT_GATEWAY" + ;; + esac + + [ -n "$_gw" ] || continue + _t="${_t}${_t:+${_nl}}" + _t="${_t}${_net} via ${_gw} dev ethXXX metric 10 " + done + _t=$(echo "$_t" | sort) + ok "$_t" +} + +ok_natgw_follower_static_routes() +{ + _nl=" +" + _t="" + for _i in $CTDB_NATGW_STATIC_ROUTES; do + # This is intentionally different to the code in 11.natgw ;-) + _net=$(echo "$_i" | sed -e 's|@.*||') + + # The interface for the private network isn't + # specified as part of the NATGW configuration and + # isn't part of the command to add the route. It is + # implicitly added by "ip route" but our stub doesn't + # do this and adds "ethXXX". + _t="${_t}${_t:+${_nl}}" + _t="${_t}${_net} via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 " + done + _t=$(echo "$_t" | sort) + ok "$_t" +} diff --git a/ctdb/tests/UNIT/eventscripts/scripts/13.per_ip_routing.sh b/ctdb/tests/UNIT/eventscripts/scripts/13.per_ip_routing.sh new file mode 100644 index 0000000..aac2c3d --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/scripts/13.per_ip_routing.sh @@ -0,0 +1,47 @@ +setup() +{ + setup_public_addresses + + # shellcheck disable=SC2034 + # Used in expected output + service_name="per_ip_routing" + + setup_script_options <, all), defaulting to +# 1. If $2 is "default" then a default route is also added. +create_policy_routing_config() +{ + _num_ips="${1:-1}" + _should_add_default="$2" + + ctdb_get_my_public_addresses | + if [ "$_num_ips" = "all" ]; then + cat + else + { + head -n "$_num_ips" + cat >/dev/null + } + fi | + while read -r _dev _ip _bits; do + _net=$(ipv4_host_addr_to_net "$_ip" "$_bits") + _gw="${_net%.*}.254" # a dumb, calculated default + + echo "$_ip $_net" + + if [ "$_should_add_default" = "default" ]; then + echo "$_ip 0.0.0.0/0 $_gw" + fi + done >"$CTDB_PER_IP_ROUTING_CONF" +} diff --git a/ctdb/tests/UNIT/eventscripts/scripts/20.multipathd.sh b/ctdb/tests/UNIT/eventscripts/scripts/20.multipathd.sh new file mode 100644 index 0000000..9add0bc --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/scripts/20.multipathd.sh @@ -0,0 +1,25 @@ +setup() +{ + _failures="" + _devices="" + for i; do + case "$i" in + \!*) + _t="${i#!}" + echo "Marking ${_t} as having no active paths" + _failures="${_failures}${_failures:+ }${_t}" + ;; + *) + _t="$i" + ;; + esac + _devices="${_devices}${_devices:+ }${_t}" + done + + setup_script_options <"$_threads" + export FAKE_NFSD_THREAD_PIDS="$*" + ;; + *) + export FAKE_RPC_THREAD_PIDS="$*" + ;; + esac +} + +guess_output() +{ + case "$1" in + "${CTDB_NFS_CALLOUT} start nlockmgr") + case "$CTDB_NFS_DISTRO_STYLE" in + sysvinit-redhat) + echo "&Starting nfslock: OK" + ;; + sysvinit-debian) + cat </dev/null; then + echo "Stopping quotarpc: OK" + else + echo "service: can't stop quotarpc - not running" + fi + ;; + esac + ;; + "${CTDB_NFS_CALLOUT} stop status") + case "$CTDB_NFS_DISTRO_STYLE" in + systemd-*) + echo "Stopping rpc-statd: OK" + ;; + esac + ;; + "${CTDB_NFS_CALLOUT} start mountd") + case "$CTDB_NFS_DISTRO_STYLE" in + systemd-*) + echo "&Starting nfs-mountd: OK" + ;; + esac + ;; + "${CTDB_NFS_CALLOUT} start rquotad") + case "$CTDB_NFS_DISTRO_STYLE" in + systemd-redhat) + echo "&Starting rpc-rquotad: OK" + ;; + systemd-debian) + echo "&Starting quotarpc: OK" + ;; + esac + ;; + "${CTDB_NFS_CALLOUT} start status") + case "$CTDB_NFS_DISTRO_STYLE" in + systemd-*) + echo "&Starting rpc-statd: OK" + ;; + esac + ;; + *) + : # Nothing + ;; + esac +} + +# Set the required result for a particular RPC program having failed +# for a certain number of iterations. This is probably still a work +# in progress. Note that we could hook aggressively +# nfs_check_rpc_service() to try to implement this but we're better +# off testing nfs_check_rpc_service() using independent code... even +# if it is incomplete and hacky. So, if the 60.nfs eventscript +# changes and the tests start to fail then it may be due to this +# function being incomplete. +rpc_set_service_failure_response() +{ + _rpc_service="$1" + _numfails="${2:-1}" # default 1 + + # Default + ok_null + if [ "$_numfails" -eq 0 ]; then + return + fi + + nfs_load_config + + # A handy newline. :-) + _nl=" +" + + _dir="${CTDB_NFS_CHECKS_DIR:-${CTDB_BASE}/nfs-checks.d}" + + _file=$(ls "$_dir"/[0-9][0-9]."${_rpc_service}.check") + [ -r "$_file" ] || + die "RPC check file \"$_file\" does not exist or is not unique" + + _out="${CTDB_TEST_TMP_DIR}/rpc_failure_output" + : >"$_out" + _rc_file="${CTDB_TEST_TMP_DIR}/rpc_result" + + ( + # Subshell to restrict scope variables... + + # Defaults + # shellcheck disable=SC2034 + # Unused, but for completeness, possible future use + family="tcp" + version="" + unhealthy_after=1 + restart_every=0 + service_stop_cmd="" + service_start_cmd="" + # shellcheck disable=SC2034 + # Unused, but for completeness, possible future use + service_check_cmd="" + service_debug_cmd="" + + # Don't bother syntax checking, eventscript does that... + . "$_file" + + # Just use the first version, or use default. This is + # dumb but handles all the cases that we care about + # now... + if [ -n "$version" ]; then + _ver="${version%% *}" + else + case "$_rpc_service" in + portmapper) _ver="" ;; + *) _ver=1 ;; + esac + fi + _rpc_check_out="\ +$_rpc_service failed RPC check: +rpcinfo: RPC: Program not registered +program $_rpc_service${_ver:+ version }${_ver} is not available" + + if [ $unhealthy_after -gt 0 ] && + [ "$_numfails" -ge $unhealthy_after ]; then + _unhealthy=true + echo 1 >"$_rc_file" + echo "ERROR: ${_rpc_check_out}" >>"$_out" + else + _unhealthy=false + echo 0 >"$_rc_file" + fi + + if [ $restart_every -gt 0 ] && + [ $((_numfails % restart_every)) -eq 0 ]; then + if ! $_unhealthy; then + echo "WARNING: ${_rpc_check_out}" >>"$_out" + fi + + echo "Trying to restart service \"${_rpc_service}\"..." \ + >>"$_out" + + guess_output "$service_stop_cmd" >>"$_out" + + if [ -n "$service_debug_cmd" ]; then + $service_debug_cmd >>"$_out" 2>&1 + fi + + guess_output "$service_start_cmd" >>"$_out" + fi + ) + + read -r _rc <"$_rc_file" + required_result "$_rc" <"$_out" + + rm -f "$_out" "$_rc_file" +} + +program_stack_traces() +{ + _prog="$1" + _max="${2:-1}" + + _count=1 + if [ "$_prog" = "nfsd" ]; then + _pids="$FAKE_NFSD_THREAD_PIDS" + else + _pids="$FAKE_RPC_THREAD_PIDS" + fi + for _pid in $_pids; do + [ $_count -le "$_max" ] || break + + program_stack_trace "$_prog" "$_pid" + _count=$((_count + 1)) + done +} + +# Run an NFS eventscript iteratively. +# +# - 1st argument is the number of iterations. +# +# - 2nd argument is the NFS/RPC service being tested +# +# rpcinfo is used on each iteration to test the availability of the +# service +# +# If this is not set or null then no RPC service is checked and the +# required output is not reset on each iteration. This is useful in +# baseline tests to confirm that the eventscript and test +# infrastructure is working correctly. +# +# - Subsequent arguments come in pairs: an iteration number and +# something to eval before that iteration. Each time an iteration +# number is matched the associated argument is given to eval after +# the default setup is done. The iteration numbers need to be given +# in ascending order. +# +# These arguments can allow a service to be started or stopped +# before a particular iteration. +# +nfs_iterate_test() +{ + _repeats="$1" + _rpc_service="$2" + if [ -n "$2" ]; then + shift 2 + else + shift + fi + + # shellcheck disable=SC2154 + # Variables defined in define_test() + echo "Running $_repeats iterations of \"$script $event\" $args" + + _iterate_failcount=0 + for _iteration in $(seq 1 "$_repeats"); do + # This is not a numerical comparison because $1 will + # often not be set. + if [ "$_iteration" = "$1" ]; then + debug </dev/null 2>&1 ; then + _iterate_failcount=0 + else + _iterate_failcount=$((_iterate_failcount + 1)) + fi + rpc_set_service_failure_response \ + "$_rpc_service" $_iterate_failcount + fi + _out=$(simple_test 2>&1) + _ret=$? + if "$CTDB_TEST_VERBOSE" || [ $_ret -ne 0 ]; then + cat <"$CTDB_LVS_NODES" +} + +check_ipvsadm() +{ + if [ "$1" = "NULL" ]; then + required_result 0 < mtu 65536 qdisc noqueue state UNKNOWN + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +EOF + else + required_result 0 < mtu 65536 qdisc noqueue state UNKNOWN + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet ${CTDB_LVS_PUBLIC_IP}/32 scope ${_scope} lo + valid_lft forever preferred_lft forever +EOF + fi + + simple_test_command ip addr show dev lo +} diff --git a/ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh b/ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh new file mode 100644 index 0000000..b0cd039 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh @@ -0,0 +1,272 @@ +setup() +{ + setup_dbdir +} + +result_filter() +{ + sed -e 's|\( of debug locks PID=\)[0-9]*|\1PID|' +} + +tdb_path() +{ + echo "${CTDB_DBDIR}/${1}.${FAKE_CTDB_PNN}" +} + +fake_file_id() +{ + _path="$1" + + echo "$FAKE_FILE_ID_MAP" | + awk -v path="$_path" '$1 == path { print $2 }' +} + +fake_stack_trace() +{ + _pid="$1" + _command="${2:-smbd}" + _state="$3" + + echo "----- Stack trace for PID=${_pid} -----" + + case "$_state" in + D*) + cat <] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff +EOF + ;; + *) + cat <, argv=) at ${_command}.c +EOF + ;; + esac +} + +do_test() +{ + _holder_scope="$1" + _holder_state="$2" + _helper_scope="$3" + _lock_type="${4:-FCNTL}" + + _lock_helper_pid="4132032" + + FAKE_PS_MAP=$( + cat < POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 168 170 +EOF + ) + elif [ "$_helper_scope" = "RECORD" ] && + [ "$_lock_type" = "FCNTL" ]; then + _helper_lock=$( + cat < POSIX ADVISORY WRITE ${_lock_helper_pid} ${_locking_tdb_id} 112736 112736 +EOF + ) + fi + _t=$( + cat <&2 + else + cat >&2 + fi + } +else + debug() + { + : + } +fi + +###################################################################### + +# General setup fakery + +# Default is to use script name with ".options" appended. With +# arguments, this can specify an alternate script name (and +# component). +setup_script_options() +{ + if [ $# -eq 2 ]; then + _script="$2" + elif [ $# -eq 0 ]; then + _script="" + else + die "usage: setup_script_options [ component script ]" + fi + + if [ -n "$_script" ]; then + _options="${CTDB_BASE}/events/legacy/${_script}.options" + else + _options="${script_dir}/${script%.script}.options" + fi + + cat >>"$_options" + + # Source the options so that tests can use the variables + . "$_options" +} + +setup_dbdir() +{ + export CTDB_DBDIR_BASE="${CTDB_TEST_TMP_DIR}/db" + CTDB_DBDIR="${CTDB_DBDIR_BASE}/volatile" + CTDB_DBDIR_PERSISTENT="${CTDB_DBDIR_BASE}/persistent" + CTDB_DBDIR_STATE="${CTDB_DBDIR_BASE}/state" + cat >>"${CTDB_BASE}/ctdb.conf" <> 8)) + done + + echo "${_net}/${_maskbits}" +} + +###################################################################### + +# CTDB fakery + +# shellcheck disable=SC2120 +# Argument can be used in testcases +setup_numnodes() +{ + export FAKE_CTDB_NUMNODES="${1:-3}" + echo "Setting up CTDB with ${FAKE_CTDB_NUMNODES} fake nodes" +} + +# For now this creates the same public addresses each time. However, +# it could be made more flexible. +setup_public_addresses() +{ + _f="${CTDB_BASE}/public_addresses" + + echo "Setting up public addresses in ${_f}" + cat >"$_f" < 1 {print $2}' | xargs +} + +ctdb_get_1_interface() +{ + _t=$(ctdb_get_interfaces) + echo "${_t%% *}" +} + +# Print public addresses on this node as: interface IP maskbits +# Each line is suitable for passing to takeip/releaseip +ctdb_get_my_public_addresses() +{ + ctdb ip -v -X | { + read -r _ # skip header line + + while IFS="|" read -r _ _ip _ _iface _; do + [ -n "$_iface" ] || continue + while IFS="/$IFS" read -r _i _maskbits _; do + if [ "$_ip" = "$_i" ]; then + echo "$_iface $_ip $_maskbits" + break + fi + done <"${CTDB_BASE}/public_addresses" + done + } +} + +# Prints the 1st public address as: interface IP maskbits +# This is suitable for passing to takeip/releaseip +ctdb_get_1_public_address() +{ + ctdb_get_my_public_addresses | { + head -n 1 + cat >/dev/null + } +} + +# Check the routes against those that are expected. $1 is the number +# of assigned IPs to use (, all), defaulting to 1. If $2 is +# "default" then expect default routes to have been added. +check_routes() +{ + _num_ips="${1:-1}" + _should_add_default="$2" + + _policy_rules="" + _policy_routes="" + + ctdb_get_my_public_addresses | + if [ "$_num_ips" = "all" ]; then + cat + else + { + head -n "$_num_ips" + cat >/dev/null + } + fi | { + while read -r _dev _ip _bits; do + _net=$(ipv4_host_addr_to_net "$_ip" "$_bits") + _gw="${_net%.*}.254" # a dumb, calculated default + + _policy_rules="${_policy_rules} +${CTDB_PER_IP_ROUTING_RULE_PREF}: from $_ip lookup ctdb.$_ip " + _policy_routes="${_policy_routes} +# ip route show table ctdb.$_ip +$_net dev $_dev scope link " + + if [ "$_should_add_default" = "default" ]; then + _policy_routes="${_policy_routes} +default via $_gw dev $_dev " + fi + done + + ok <] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff +EOF +} + +###################################################################### + +# Result and test functions + +############################################################ + +setup() +{ + die "setup() is not defined" +} + +# Set some globals and print the summary. +define_test() +{ + desc="$1" + + _f=$(basename "$0" ".sh") + + # Remaining format should be NN.script.event.NUM or + # NN.script.NUM or script.NUM: + _num="${_f##*.}" + _f="${_f%.*}" + + case "$_f" in + [0-9][0-9].*) + case "$_f" in + [0-9][0-9].*.*) + script="${_f%.*}.script" + event="${_f##*.}" + ;; + [0-9][0-9].*) + script="${_f}.script" + unset event + ;; + esac + # "Enable" the script + _subdir="events/legacy" + script_dir="${CTDB_BASE}/${_subdir}" + # Symlink target needs to be absolute + case "$CTDB_SCRIPTS_DATA_DIR" in + /*) _data_dir="${CTDB_SCRIPTS_DATA_DIR}/${_subdir}" ;; + *) _data_dir="${PWD}/${CTDB_SCRIPTS_DATA_DIR}/${_subdir}" ;; + esac + mkdir -p "$script_dir" + ln -s "${_data_dir}/${script}" "$script_dir" + ;; + *) + script="${_f%.*}" + script="$_f" + unset event + script_dir="${CTDB_BASE}" + ;; + esac + + _s="${script_dir}/${script}" + [ -r "$_s" ] || + die "Internal error - unable to find script \"${_s}\"" + + case "$script" in + *.script) script_short="${script%.script}" ;; + *.sh) script_short="${script%.sh}" ;; + *) script_short="$script" ;; + esac + + printf "%-17s %-10s %-4s - %s\n\n" \ + "$script_short" "$event" "$_num" "$desc" + + _f="${CTDB_TEST_SUITE_DIR}/scripts/${script_short}.sh" + if [ -r "$_f" ]; then + . "$_f" + fi + + ctdb_set_pnn 0 +} + +# Run an eventscript once. The test passes if the return code and +# output match those required. + +# Any args are passed to the eventscript. + +simple_test() +{ + [ -n "$event" ] || die 'simple_test: event not set' + + args="$*" + + # shellcheck disable=SC2317 + # used in unit_test(), etc. + test_header() + { + echo "Running script \"$script $event${args:+ }$args\"" + } + + # shellcheck disable=SC2317 + # used in unit_test(), etc. + extra_header() + { + cat < ${_cip}, MON_NAME=${_sip}, STATE=${_state_even} +SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_even} +SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${_sip}, STATE=${_state_odd} +SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_odd} +EOF + done + done | { + ok + simple_test_event "notify" + } || exit $? +} diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh new file mode 100755 index 0000000..7293390 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.001.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "single add-client" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "update" + +check_ctdb_tdb_statd_state "192.168.123.45" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh new file mode 100755 index 0000000..ce9f139 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.002.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "2 x add-client, update" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "add-client" "192.168.123.46" +simple_test_event "update" + +check_ctdb_tdb_statd_state "192.168.123.45" "192.168.123.46" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh new file mode 100755 index 0000000..25bec29 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.003.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "add-client, update, del-client, update" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "update" + +simple_test_event "del-client" "192.168.123.45" +simple_test_event "update" + +check_ctdb_tdb_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh new file mode 100755 index 0000000..dc2156b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.004.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "single add-client, notify" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "update" + +check_ctdb_tdb_statd_state "192.168.123.45" + +check_statd_callout_smnotify "192.168.123.45" + +check_ctdb_tdb_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh new file mode 100755 index 0000000..1f802a2 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.005.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "2 x add-client to different nodes, notify on 1" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "update" + +ctdb_set_pnn 1 + +ok_null +simple_test_event "add-client" "192.168.123.46" +simple_test_event "update" + +ctdb_set_pnn 0 + +check_statd_callout_smnotify "192.168.123.45" + +ctdb_set_pnn 1 + +check_ctdb_tdb_statd_state "192.168.123.46" diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh new file mode 100755 index 0000000..8ecba5c --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.006.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "2 x add-client to different nodes, notify on both" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "update" + +ctdb_set_pnn 1 + +ok_null +simple_test_event "add-client" "192.168.123.46" +simple_test_event "update" + +ctdb_set_pnn 0 + +check_statd_callout_smnotify "192.168.123.45" + +ctdb_set_pnn 1 + +check_statd_callout_smnotify "192.168.123.46" + +check_ctdb_tdb_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh b/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh new file mode 100755 index 0000000..4445fff --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/statd-callout.007.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "add-client, del-client, update" + +setup + +ok_null +simple_test_event "add-client" "192.168.123.45" +simple_test_event "del-client" "192.168.123.45" +simple_test_event "update" + +check_ctdb_tdb_statd_state diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb b/ctdb/tests/UNIT/eventscripts/stubs/ctdb new file mode 100755 index 0000000..20135eb --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb @@ -0,0 +1,481 @@ +#!/bin/sh + +prog="ctdb" + +# Print a message and exit. +die() +{ + echo "$1" >&2 + exit "${2:-1}" +} + +not_implemented_exit_code=1 + +usage() +{ + cat >&2 <&2 + exit $not_implemented_exit_code +} + +verbose=false +machine_readable=false +nodespec="" + +args="" + +# Options and command argument can appear in any order, so when +# getopts thinks it is done, process any non-option arguments and go +# around again. +while [ $# -gt 0 ]; do + while getopts "Xvhn:?" opt; do + case "$opt" in + X) machine_readable=true ;; + v) verbose=true ;; + n) nodespec="$OPTARG" ;; + \? | *) usage ;; + esac + done + shift $((OPTIND - 1)) + + # Anything left over must be a non-option arg + if [ $# -gt 0 ]; then + args="${args}${args:+ }${1}" + shift + fi +done + +[ -n "$args" ] || usage +# Want word splitting +# shellcheck disable=SC2086 +set -- $args + +setup_tickles() +{ + # Make sure tickles file exists. + tickles_file="${CTDB_TEST_TMP_DIR}/fake-ctdb/tickles" + mkdir -p "$(dirname "$tickles_file")" + touch "$tickles_file" +} + +ctdb_gettickles() +{ + _ip="$1" + _port="$2" + + setup_tickles + + echo "|source ip|port|destination ip|port|" + while read -r _src _dst; do + if [ -z "$_ip" ] || [ "$_ip" = "${_dst%:*}" ]; then + if [ -z "$_port" ] || [ "$_port" = "${_dst##*:}" ]; then + echo "|${_src%:*}|${_src##*:}|${_dst%:*}|${_dst##*:}|" + fi + fi + done <"$tickles_file" +} + +ctdb_addtickle() +{ + _src="$1" + _dst="$2" + + setup_tickles + + if [ -n "$_dst" ]; then + echo "${_src} ${_dst}" >>"$tickles_file" + else + cat >>"$tickles_file" + fi +} + +ctdb_deltickle() +{ + _src="$1" + _dst="$2" + + setup_tickles + + if [ -n "$_dst" ]; then + _t=$(grep -F -v "${_src} $${_dst}" "$tickles_file") + else + _t=$(cat "$tickles_file") + while read -r _src _dst; do + _t=$(echo "$_t" | grep -F -v "${_src} ${_dst}") + done + fi + echo "$_t" >"$tickles_file" +} + +parse_nodespec() +{ + if [ "$nodespec" = "all" ]; then + nodes="$(seq 0 $((FAKE_CTDB_NUMNODES - 1)))" + elif [ -n "$nodespec" ]; then + nodes="$(echo "$nodespec" | sed -e 's@,@ @g')" + else + nodes=$(ctdb_pnn) + fi +} + +# For testing backward compatibility... +for i in $CTDB_NOT_IMPLEMENTED; do + if [ "$i" = "$1" ]; then + not_implemented "$i" + fi +done + +ctdb_pnn() +{ + # Defaults to 0 + echo "${FAKE_CTDB_PNN:-0}" +} + +###################################################################### + +FAKE_CTDB_NODE_STATE="$FAKE_CTDB_STATE/node-state" +FAKE_CTDB_NODES_DISABLED="$FAKE_CTDB_NODE_STATE/0x4" + +###################################################################### + +# NOTE: all nodes share public addresses file + +FAKE_CTDB_IP_LAYOUT="$FAKE_CTDB_STATE/ip-layout" + +ip_reallocate() +{ + touch "$FAKE_CTDB_IP_LAYOUT" + + # ShellCheck doesn't understand this flock pattern + # shellcheck disable=SC2094 + ( + flock 0 + + _pa="${CTDB_BASE}/public_addresses" + + if [ ! -s "$FAKE_CTDB_IP_LAYOUT" ]; then + sed -n -e 's@^\([^#][^/]*\)/.*@\1 -1@p' \ + "$_pa" >"$FAKE_CTDB_IP_LAYOUT" + fi + + _t="${FAKE_CTDB_IP_LAYOUT}.new" + + _flags="" + for _i in $(seq 0 $((FAKE_CTDB_NUMNODES - 1))); do + if ls "$FAKE_CTDB_STATE/node-state/"*"/$_i" >/dev/null 2>&1; then + # Have non-zero flags + _this=0 + for _j in "$FAKE_CTDB_STATE/node-state/"*"/$_i"; do + _tf="${_j%/*}" # dirname + _f="${_tf##*/}" # basename + _this=$((_this | _f)) + done + else + _this="0" + fi + _flags="${_flags}${_flags:+,}${_this}" + done + CTDB_TEST_LOGLEVEL=NOTICE \ + "ctdb_takeover_tests" \ + "ipalloc" "$_flags" <"$FAKE_CTDB_IP_LAYOUT" | + sort >"$_t" + mv "$_t" "$FAKE_CTDB_IP_LAYOUT" + ) <"$FAKE_CTDB_IP_LAYOUT" +} + +ctdb_ip() +{ + # If nobody has done any IP-fu then generate a layout. + [ -f "$FAKE_CTDB_IP_LAYOUT" ] || ip_reallocate + + _mypnn=$(ctdb_pnn) + + if $machine_readable; then + if $verbose; then + echo "|Public IP|Node|ActiveInterface|AvailableInterfaces|ConfiguredInterfaces|" + else + echo "|Public IP|Node|" + fi + else + echo "Public IPs on node ${_mypnn}" + fi + + # Join public addresses file with $FAKE_CTDB_IP_LAYOUT, and + # process output line by line... + _pa="${CTDB_BASE}/public_addresses" + sed -e 's@/@ @' "$_pa" | sort | join - "$FAKE_CTDB_IP_LAYOUT" | + while read -r _ip _ _ifaces _pnn; do + if $verbose; then + # If more than 1 interface, assume all addresses are on the 1st. + _first_iface="${_ifaces%%,*}" + # Only show interface if address is on this node. + _my_iface="" + if [ "$_pnn" = "$_mypnn" ]; then + _my_iface="$_first_iface" + fi + if $machine_readable; then + echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|" + else + echo "${_ip} node[${_pnn}] active[${_my_iface}] available[${_first_iface}] configured[[${_ifaces}]" + fi + else + if $machine_readable; then + echo "|${_ip}|${_pnn}|" + else + echo "${_ip} ${_pnn}" + fi + fi + done +} + +ctdb_moveip() +{ + _ip="$1" + _target="$2" + + ip_reallocate # should be harmless and ensures we have good state + + # ShellCheck doesn't understand this flock pattern + # shellcheck disable=SC2094 + ( + flock 0 + + _t="${FAKE_CTDB_IP_LAYOUT}.new" + + while read -r _i _pnn; do + if [ "$_ip" = "$_i" ]; then + echo "$_i $_target" + else + echo "$_i $_pnn" + fi + done | sort >"$_t" + mv "$_t" "$FAKE_CTDB_IP_LAYOUT" + ) <"$FAKE_CTDB_IP_LAYOUT" +} + +###################################################################### + +ctdb_enable() +{ + parse_nodespec + + for _i in $nodes; do + rm -f "${FAKE_CTDB_NODES_DISABLED}/${_i}" + done + + ip_reallocate +} + +ctdb_disable() +{ + parse_nodespec + + for _i in $nodes; do + mkdir -p "$FAKE_CTDB_NODES_DISABLED" + touch "${FAKE_CTDB_NODES_DISABLED}/${_i}" + done + + ip_reallocate +} + +###################################################################### + +ctdb_shutdown() +{ + echo "CTDB says BYE!" +} + +###################################################################### + +# This is only used by the NAT and LVS gateway code at the moment, so +# use a hack. Assume that $CTDB_NATGW_NODES or $CTDB_LVS_NODES +# contains all nodes in the cluster (which is what current tests +# assume). Use the PNN to find the address from this file. The NAT +# gateway code only used the address, so just mark the node healthy. +ctdb_nodestatus() +{ + echo '|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|' + _line=$((FAKE_CTDB_PNN + 1)) + _ip=$(sed -e "${_line}p" "${CTDB_NATGW_NODES:-${CTDB_LVS_NODES}}") + echo "|${FAKE_CTDB_PNN}|${_ip}|0|0|0|0|0|0|0|Y|" +} + +###################################################################### + +_t_setup() +{ + _t_dir="${CTDB_TEST_TMP_DIR}/fake-ctdb/fake-tdb/$1" + mkdir -p "$_t_dir" +} + +_t_put() +{ + echo "$2" >"${_t_dir}/$1" +} + +_t_get() +{ + cat "${_t_dir}/$1" +} + +_t_del() +{ + rm -f "${_t_dir}/$1" +} + +ctdb_pstore() +{ + _t_setup "$1" + _t_put "$2" "$3" +} + +ctdb_pdelete() +{ + _t_setup "$1" + _t_del "$2" +} + +ctdb_pfetch() +{ + _t_setup "$1" + _t_get "$2" >"$3" 2>/dev/null +} + +ctdb_ptrans() +{ + _t_setup "$1" + + while IFS="" read -r _line; do + _k=$(echo "$_line" | sed -n -e 's@^"\([^"]*\)" "[^"]*"$@\1@p') + _v=$(echo "$_line" | sed -e 's@^"[^"]*" "\([^"]*\)"$@\1@') + [ -n "$_k" ] || die "ctdb ptrans: bad line \"${_line}\"" + if [ -n "$_v" ]; then + _t_put "$_k" "$_v" + else + _t_del "$_k" + fi + done +} + +ctdb_catdb() +{ + _t_setup "$1" + + # This will break on keys with spaces but we don't have any of + # those yet. + _count=0 + for _i in "${_t_dir}/"*; do + [ -r "$_i" ] || continue + _k="${_i##*/}" # basename + _v=$(_t_get "$_k") + _kn=$(printf '%s' "$_k" | wc -c) + _vn=$(printf '%s' "$_v" | wc -c) + cat </dev/null 2>&1; then + "$func" "$@" +else + not_implemented "$cmd" +fi diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb-config b/ctdb/tests/UNIT/eventscripts/stubs/ctdb-config new file mode 100755 index 0000000..818e3db --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb-config @@ -0,0 +1,2 @@ +#!/bin/sh +exec $VALGRIND "${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb-config" "$@" diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb_killtcp b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_killtcp new file mode 100755 index 0000000..2a4bac4 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_killtcp @@ -0,0 +1,10 @@ +#!/bin/sh + +# Only supports reading from stdin + +# shellcheck disable=SC2034 +iface="$1" # ignored + +while read -r src dst; do + sed -i -e "/^${dst} ${src}\$/d" "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" +done diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb_lvs b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_lvs new file mode 100755 index 0000000..31f56e8 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_lvs @@ -0,0 +1,53 @@ +#!/bin/sh + +prog="ctdb_lvs" + +# Print a message and exit. +die() +{ + echo "$1" >&2 + exit "${2:-1}" +} + +not_implemented_exit_code=1 + +usage() +{ + cat >&2 <&2 + exit $not_implemented_exit_code +} + +ctdb_lvs_leader() +{ + if [ -n "$FAKE_CTDB_LVS_LEADER" ]; then + echo "$FAKE_CTDB_LVS_LEADER" + return 0 + else + return 255 + fi +} + +ctdb_lvs_list() +{ + _pnn=0 + while read -r _ip _; do + echo "${_pnn} ${_ip}" + _pnn=$((_pnn + 1)) + done <"$CTDB_LVS_NODES" +} + +###################################################################### + +case "$1" in +leader) ctdb_lvs_leader "$@" ;; +list) ctdb_lvs_list "$@" ;; +*) not_implemented "$1" ;; +esac diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw new file mode 100755 index 0000000..22a2191 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw @@ -0,0 +1,34 @@ +#!/bin/sh + +prog="ctdb_natgw" + +not_implemented_exit_code=1 + +not_implemented() +{ + echo "${prog}: command \"$1\" not implemented in stub" >&2 + exit $not_implemented_exit_code +} + +ctdb_natgw_leader() +{ + [ -r "$CTDB_NATGW_NODES" ] || + die "error: missing CTDB_NATGW_NODES=${CTDB_NATGW_NODES}" + + # Determine the leader node + _leader="-1 0.0.0.0" + _pnn=0 + while read -r _ip; do + if [ "$FAKE_CTDB_NATGW_LEADER" = "$_ip" ]; then + _leader="${_pnn} ${_ip}" + break + fi + _pnn=$((_pnn + 1)) + done <"$CTDB_NATGW_NODES" + echo "$_leader" +} + +case "$1" in +leader) ctdb_natgw_leader "$@" ;; +*) not_implemented "$1" ;; +esac diff --git a/ctdb/tests/UNIT/eventscripts/stubs/date b/ctdb/tests/UNIT/eventscripts/stubs/date new file mode 100755 index 0000000..8319c9c --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/date @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "$FAKE_DATE_OUTPUT" ]; then + echo "$FAKE_DATE_OUTPUT" +else + /bin/date "$@" +fi diff --git a/ctdb/tests/UNIT/eventscripts/stubs/df b/ctdb/tests/UNIT/eventscripts/stubs/df new file mode 100755 index 0000000..858f0ef --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/df @@ -0,0 +1,38 @@ +#!/bin/sh + +usage() +{ + echo "usage: df [-kP] []" + exit 1 +} + +if [ "$1" = "-kP" ]; then + shift +fi + +case "$1" in +-*) usage ;; +esac + +fs="${1:-/}" + +# Anything starting with CTDB_DBDIR_BASE gets canonicalised to +# CTDB_DBDIR_BASE. This helps with the setting of defaults for the +# filesystem checks. +if [ "${fs#"${CTDB_DBDIR_BASE}"}" != "$fs" ]; then + fs="$CTDB_DBDIR_BASE" +fi + +# A default, for tests that don't initialise this... +if [ -z "$FAKE_FS_USE" ]; then + FAKE_FS_USE=10 +fi + +echo "Filesystem 1024-blocks Used Available Capacity Mounted on" + +blocks="1000000" +used=$((blocks * FAKE_FS_USE / 100)) +available=$((blocks - used)) + +printf "%-36s %10d %10d %10d %10d%% %s\n" \ + "/dev/sda1" "$blocks" "$used" "$available" "$FAKE_FS_USE" "$fs" diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ethtool b/ctdb/tests/UNIT/eventscripts/stubs/ethtool new file mode 100755 index 0000000..3d4b889 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ethtool @@ -0,0 +1,12 @@ +#!/bin/sh + +link="yes" + +if [ -f "${FAKE_ETHTOOL_LINK_DOWN}/${1}" ]; then + link="no" +fi + +# Expect to add more fields later. +cat <, argv=) at ${command}.c +EOF diff --git a/ctdb/tests/UNIT/eventscripts/stubs/id b/ctdb/tests/UNIT/eventscripts/stubs/id new file mode 100755 index 0000000..1ecd2f8 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/id @@ -0,0 +1,3 @@ +#!/bin/sh +# Make statd-callout happy +echo 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ip b/ctdb/tests/UNIT/eventscripts/stubs/ip new file mode 100755 index 0000000..090afae --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ip @@ -0,0 +1,833 @@ +#!/bin/sh + +FAKE_IP_STATE="${FAKE_NETWORK_STATE}/ip-state" +mkdir -p "$FAKE_IP_STATE" + +promote_secondaries=true + +not_implemented() +{ + echo "ip stub command: \"$1\" not implemented" + exit 127 +} + +###################################################################### + +ip_link() +{ + case "$1" in + set) + shift + # iface="$1" + case "$2" in + up) ip_link_set_up "$1" ;; + down) ip_link_down_up "$1" ;; + *) not_implemented "\"$2\" in \"$orig_args\"" ;; + esac + ;; + show) + shift + ip_link_show "$@" + ;; + add*) + shift + ip_link_add "$@" + ;; + del*) + shift + ip_link_delete "$@" + ;; + *) not_implemented "$*" ;; + esac +} + +ip_link_add() +{ + _link="" + _name="" + _type="" + + while [ -n "$1" ]; do + case "$1" in + link) + _link="$2" + shift 2 + ;; + name) + _name="$2" + shift 2 + ;; + type) + if [ "$2" != "vlan" ]; then + not_implemented "link type $1" + fi + _type="$2" + shift 2 + ;; + id) shift 2 ;; + *) not_implemented "$1" ;; + esac + done + + case "$_type" in + vlan) + if [ -z "$_name" ] || [ -z "$_link" ]; then + not_implemented "ip link add with null name or link" + fi + + mkdir -p "${FAKE_IP_STATE}/interfaces-vlan" + echo "$_link" >"${FAKE_IP_STATE}/interfaces-vlan/${_name}" + ip_link_set_down "$_name" + ;; + esac +} + +ip_link_delete() +{ + mkdir -p "${FAKE_IP_STATE}/interfaces-deleted" + touch "${FAKE_IP_STATE}/interfaces-deleted/$1" + rm -f "${FAKE_IP_STATE}/interfaces-vlan/$1" +} + +ip_link_set_up() +{ + rm -f "${FAKE_IP_STATE}/interfaces-down/$1" + rm -f "${FAKE_IP_STATE}/interfaces-deleted/$1" +} + +ip_link_set_down() +{ + rm -f "${FAKE_IP_STATE}/interfaces-deleted/$1" + mkdir -p "${FAKE_IP_STATE}/interfaces-down" + touch "${FAKE_IP_STATE}/interfaces-down/$1" +} + +ip_link_show() +{ + dev="$1" + if [ "$dev" = "dev" ] && [ -n "$2" ]; then + dev="$2" + fi + + if [ -e "${FAKE_IP_STATE}/interfaces-deleted/$dev" ]; then + echo "Device \"${dev}\" does not exist." >&2 + exit 255 + fi + + if [ -r "${FAKE_IP_STATE}/interfaces-vlan/${dev}" ]; then + read -r _link <"${FAKE_IP_STATE}/interfaces-vlan/${dev}" + dev="${dev}@${_link}" + fi + + _state="UP" + _flags=",UP,LOWER_UP" + if [ -e "${FAKE_IP_STATE}/interfaces-down/$dev" ]; then + _state="DOWN" + _flags="" + fi + case "$dev" in + lo) + _mac="00:00:00:00:00:00" + _brd="00:00:00:00:00:00" + _type="loopback" + _state="UNKNOWN" + _status="" + _opts="mtu 65536 qdisc noqueue state ${_state}" + ;; + *) + _mac=$(echo "$dev" | cksum | sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@') + _brd="ff:ff:ff:ff:ff:ff" + _type="ether" + _status="" + _opts="mtu 1500 qdisc pfifo_fast state ${_state} qlen 1000" + ;; + esac + + if $brief; then + printf '%-16s %-14s %-17s %s\n' \ + "$dev" "$_status" "$_mac" "$_status" + else + echo "${n:-42}: ${dev}: ${_status} ${_opts}" + echo " link/${_type} ${_mac} brd ${_brd}" + fi +} + +# This is incomplete because it doesn't actually look up table ids in +# /etc/iproute2/rt_tables. The rules/routes are actually associated +# with the name instead of the number. However, we include a variable +# to fake a bad table id. +[ -n "$IP_ROUTE_BAD_TABLE_ID" ] || IP_ROUTE_BAD_TABLE_ID=false + +ip_check_table() +{ + _cmd="$1" + + if [ "$_cmd" = "route" ] && [ -z "$_table" ]; then + _table="main" + fi + + [ -n "$_table" ] || not_implemented "ip rule/route without \"table\"" + + # Only allow tables names from 13.per_ip_routing and "main". This + # is a cheap way of avoiding implementing the default/local + # tables. + case "$_table" in + ctdb.* | main) + if $IP_ROUTE_BAD_TABLE_ID; then + # Ouch. Simulate inconsistent errors from ip. :-( + case "$_cmd" in + route) + echo "Error: argument \"${_table}\" is wrong: table id value is invalid" >&2 + + ;; + *) + echo "Error: argument \"${_table}\" is wrong: invalid table ID" >&2 + ;; + esac + exit 255 + fi + ;; + *) not_implemented "table=${_table} ${orig_args}" ;; + esac +} + +###################################################################### + +ip_addr() +{ + case "$1" in + show | list | "") + shift + ip_addr_show "$@" + ;; + add*) + shift + ip_addr_add "$@" + ;; + del*) + shift + ip_addr_del "$@" + ;; + *) not_implemented "\"$1\" in \"$orig_args\"" ;; + esac +} + +ip_addr_show() +{ + dev="" + primary=true + secondary=true + _to="" + + if $brief; then + not_implemented "ip -br addr show in \"$orig_args\"" + fi + + while [ -n "$1" ]; do + case "$1" in + dev) + dev="$2" + shift 2 + ;; + # Do stupid things and stupid things will happen! + primary) + primary=true + secondary=false + shift + ;; + secondary) + secondary=true + primary=false + shift + ;; + to) + _to="$2" + shift 2 + ;; + *) + # Assume an interface name + dev="$1" + shift 1 + ;; + esac + done + devices="$dev" + if [ -z "$devices" ]; then + # No device specified? Get all the primaries... + devices=$(find "${FAKE_IP_STATE}/addresses" -name "*-primary" | + sed -e 's@.*/@@' -e 's@-.*-primary$@@' | + sort -u) + fi + calc_brd() + { + case "${local#*/}" in + 24) brd="${local%.*}.255" ;; + 32) brd="" ;; + *) not_implemented "list ... fake bits other than 24/32: ${local#*/}" ;; + esac + } + show_iface() + { + ip_link_show "$dev" + + nets=$(find "${FAKE_IP_STATE}/addresses" -name "${dev}-*-primary" | + sed -e 's@.*/@@' -e "s@${dev}-\(.*\)-primary\$@\1@") + + for net in $nets; do + pf="${FAKE_IP_STATE}/addresses/${dev}-${net}-primary" + sf="${FAKE_IP_STATE}/addresses/${dev}-${net}-secondary" + if $primary && [ -r "$pf" ]; then + read -r local scope <"$pf" + if [ -z "$_to" ] || [ "${_to%/*}" = "${local%/*}" ]; then + calc_brd + echo " inet ${local} ${brd:+brd ${brd} }scope ${scope} ${dev}" + fi + fi + if $secondary && [ -r "$sf" ]; then + while read -r local scope; do + if [ -z "$_to" ] || [ "${_to%/*}" = "${local%/*}" ]; then + calc_brd + echo " inet ${local} ${brd:+brd }${brd} scope ${scope} secondary ${dev}" + fi + done <"$sf" + fi + if [ -z "$_to" ]; then + echo " valid_lft forever preferred_lft forever" + fi + done + } + n=1 + for dev in $devices; do + if [ -z "$_to" ] || + grep -F "${_to%/*}/" "${FAKE_IP_STATE}/addresses/${dev}-"* >/dev/null; then + show_iface + fi + n=$((n + 1)) + done +} + +# Copied from 13.per_ip_routing for now... so this is lazy testing :-( +ipv4_host_addr_to_net() +{ + _addr="$1" + + _host="${_addr%/*}" + _maskbits="${_addr#*/}" + + # Convert the host address to an unsigned long by splitting out + # the octets and doing the math. + _host_ul=0 + # Want word splitting here + # shellcheck disable=SC2086 + for _o in $( + export IFS="." + echo $_host + ); do + _host_ul=$(((_host_ul << 8) + _o)) # work around Emacs color bug + done + + # Calculate the mask and apply it. + _mask_ul=$((0xffffffff << (32 - _maskbits))) + _net_ul=$((_host_ul & _mask_ul)) + + # Now convert to a network address one byte at a time. + _net="" + for _o in $(seq 1 4); do + _net="$((_net_ul & 255))${_net:+.}${_net}" + _net_ul=$((_net_ul >> 8)) + done + + echo "${_net}/${_maskbits}" +} + +ip_addr_add() +{ + local="" + dev="" + brd="" + scope="global" + while [ -n "$1" ]; do + case "$1" in + *.*.*.*/*) + local="$1" + shift + ;; + local) + local="$2" + shift 2 + ;; + broadcast | brd) + # For now assume this is always '+'. + if [ "$2" != "+" ]; then + not_implemented "addr add ... brd $2 ..." + fi + shift 2 + ;; + dev) + dev="$2" + shift 2 + ;; + scope) + scope="$2" + shift 2 + ;; + *) + not_implemented "$@" + ;; + esac + done + if [ -z "$dev" ]; then + not_implemented "addr add (without dev)" + fi + mkdir -p "${FAKE_IP_STATE}/addresses" + net_str=$(ipv4_host_addr_to_net "$local") + net_str=$(echo "$net_str" | sed -e 's@/@_@') + pf="${FAKE_IP_STATE}/addresses/${dev}-${net_str}-primary" + sf="${FAKE_IP_STATE}/addresses/${dev}-${net_str}-secondary" + # We could lock here... but we should be the only ones playing + # around here with these stubs. + if [ ! -f "$pf" ]; then + echo "$local $scope" >"$pf" + elif grep -Fq "$local" "$pf"; then + echo "RTNETLINK answers: File exists" >&2 + exit 254 + elif [ -f "$sf" ] && grep -Fq "$local" "$sf"; then + echo "RTNETLINK answers: File exists" >&2 + exit 254 + else + echo "$local $scope" >>"$sf" + fi +} + +ip_addr_del() +{ + local="" + dev="" + while [ -n "$1" ]; do + case "$1" in + *.*.*.*/*) + local="$1" + shift + ;; + local) + local="$2" + shift 2 + ;; + dev) + dev="$2" + shift 2 + ;; + *) + not_implemented "addr del ... $1 ..." + ;; + esac + done + if [ -z "$dev" ]; then + not_implemented "addr del (without dev)" + fi + mkdir -p "${FAKE_IP_STATE}/addresses" + net_str=$(ipv4_host_addr_to_net "$local") + net_str=$(echo "$net_str" | sed -e 's@/@_@') + pf="${FAKE_IP_STATE}/addresses/${dev}-${net_str}-primary" + sf="${FAKE_IP_STATE}/addresses/${dev}-${net_str}-secondary" + # We could lock here... but we should be the only ones playing + # around here with these stubs. + if [ ! -f "$pf" ]; then + echo "RTNETLINK answers: Cannot assign requested address" >&2 + exit 254 + elif grep -Fq "$local" "$pf"; then + if $promote_secondaries && [ -s "$sf" ]; then + head -n 1 "$sf" >"$pf" + sed -i -e '1d' "$sf" + else + # Remove primaries AND SECONDARIES. + rm -f "$pf" "$sf" + fi + elif [ -f "$sf" ] && grep -Fq "$local" "$sf"; then + grep -Fv "$local" "$sf" >"${sf}.new" + mv "${sf}.new" "$sf" + else + echo "RTNETLINK answers: Cannot assign requested address" >&2 + exit 254 + fi +} + +###################################################################### + +ip_rule() +{ + case "$1" in + show | list | "") + shift + ip_rule_show "$@" + ;; + add) + shift + ip_rule_add "$@" + ;; + del*) + shift + ip_rule_del "$@" + ;; + *) not_implemented "$1 in \"$orig_args\"" ;; + esac + +} + +# All non-default rules are in $FAKE_IP_STATE_RULES/rules. As with +# the real version, rules can be repeated. Deleting just deletes the +# 1st match. + +ip_rule_show() +{ + if $brief; then + not_implemented "ip -br rule show in \"$orig_args\"" + fi + + ip_rule_show_1() + { + _pre="$1" + _table="$2" + _selectors="$3" + # potentially more options + + printf "%d:\t%s lookup %s \n" "$_pre" "$_selectors" "$_table" + } + + ip_rule_show_some() + { + _min="$1" + _max="$2" + + [ -f "${FAKE_IP_STATE}/rules" ] || return + + while read -r _pre _table _selectors; do + # Only print those in range + if [ "$_min" -le "$_pre" ] && + [ "$_pre" -le "$_max" ]; then + ip_rule_show_1 "$_pre" "$_table" "$_selectors" + fi + done <"${FAKE_IP_STATE}/rules" + } + + ip_rule_show_1 0 "local" "from all" + + ip_rule_show_some 1 32765 + + ip_rule_show_1 32766 "main" "from all" + ip_rule_show_1 32767 "default" "from all" + + ip_rule_show_some 32768 2147483648 +} + +ip_rule_common() +{ + _from="" + _pre="" + _table="" + while [ -n "$1" ]; do + case "$1" in + from) + _from="$2" + shift 2 + ;; + pref) + _pre="$2" + shift 2 + ;; + table) + _table="$2" + shift 2 + ;; + *) not_implemented "$1 in \"$orig_args\"" ;; + esac + done + + [ -n "$_pre" ] || not_implemented "ip rule without \"pref\"" + ip_check_table "rule" + # Relax this if more selectors added later... + [ -n "$_from" ] || not_implemented "ip rule without \"from\"" +} + +ip_rule_add() +{ + ip_rule_common "$@" + + _f="${FAKE_IP_STATE}/rules" + touch "$_f" + ( + flock 0 + # Filter order must be consistent with the comparison in ip_rule_del() + echo "$_pre $_table${_from:+ from }$_from" >>"$_f" + ) <"$_f" +} + +ip_rule_del() +{ + ip_rule_common "$@" + + _f="${FAKE_IP_STATE}/rules" + touch "$_f" + # ShellCheck doesn't understand this flock pattern + # shellcheck disable=SC2094 + ( + flock 0 + _tmp="${_f}.new" + : >"$_tmp" + _found=false + while read -r _p _t _s; do + if ! $_found && + [ "$_p" = "$_pre" ] && [ "$_t" = "$_table" ] && + [ "$_s" = "${_from:+from }$_from" ]; then + # Found. Skip this one but not future ones. + _found=true + else + echo "$_p $_t $_s" >>"$_tmp" + fi + done + if cmp -s "$_tmp" "$_f"; then + # No changes, must not have found what we wanted to delete + echo "RTNETLINK answers: No such file or directory" >&2 + rm -f "$_tmp" + exit 2 + else + mv "$_tmp" "$_f" + fi + ) <"$_f" || exit $? +} + +###################################################################### + +ip_route() +{ + case "$1" in + show | list) + shift + ip_route_show "$@" + ;; + flush) + shift + ip_route_flush "$@" + ;; + add) + shift + ip_route_add "$@" + ;; + del*) + shift + ip_route_del "$@" + ;; + *) not_implemented "$1 in \"ip route\"" ;; + esac +} + +ip_route_common() +{ + if [ "$1" = table ]; then + _table="$2" + shift 2 + fi + + ip_check_table "route" +} + +# Routes are in a file per table in the directory +# $FAKE_IP_STATE/routes. These routes just use the table ID +# that is passed and don't do any lookup. This could be "improved" if +# necessary. + +ip_route_show() +{ + ip_route_common "$@" + + # Missing file is just an empty table + sort "$FAKE_IP_STATE/routes/${_table}" 2>/dev/null || true +} + +ip_route_flush() +{ + ip_route_common "$@" + + rm -f "$FAKE_IP_STATE/routes/${_table}" +} + +ip_route_add() +{ + _prefix="" + _dev="" + _gw="" + _table="" + _metric="" + + while [ -n "$1" ]; do + case "$1" in + *.*.*.*/* | *.*.*.*) + _prefix="$1" + shift 1 + ;; + local) + _prefix="$2" + shift 2 + ;; + dev) + _dev="$2" + shift 2 + ;; + via) + _gw="$2" + shift 2 + ;; + table) + _table="$2" + shift 2 + ;; + metric) + _metric="$2" + shift 2 + ;; + *) not_implemented "$1 in \"$orig_args\"" ;; + esac + done + + ip_check_table "route" + [ -n "$_prefix" ] || not_implemented "ip route without inet prefix in \"$orig_args\"" + # This can't be easily deduced, so print some garbage. + [ -n "$_dev" ] || _dev="ethXXX" + + # Alias or add missing bits + case "$_prefix" in + 0.0.0.0/0) _prefix="default" ;; + */*) : ;; + *) _prefix="${_prefix}/32" ;; + esac + + _f="$FAKE_IP_STATE/routes/${_table}" + mkdir -p "$FAKE_IP_STATE/routes" + touch "$_f" + + # Check for duplicate + _prefix_regexp=$(echo "^${_prefix}" | sed -e 's@\.@\\.@g') + if [ -n "$_metric" ]; then + _prefix_regexp="${_prefix_regexp} .*metric ${_metric} " + fi + if grep -q "$_prefix_regexp" "$_f"; then + echo "RTNETLINK answers: File exists" >&2 + exit 1 + fi + + ( + flock 0 + + _out="${_prefix} " + [ -z "$_gw" ] || _out="${_out}via ${_gw} " + [ -z "$_dev" ] || _out="${_out}dev ${_dev} " + [ -n "$_gw" ] || _out="${_out} scope link " + [ -z "$_metric" ] || _out="${_out} metric ${_metric} " + echo "$_out" >>"$_f" + ) <"$_f" +} + +ip_route_del() +{ + _prefix="" + _dev="" + _gw="" + _table="" + _metric="" + + while [ -n "$1" ]; do + case "$1" in + *.*.*.*/* | *.*.*.*) + _prefix="$1" + shift 1 + ;; + local) + _prefix="$2" + shift 2 + ;; + dev) + _dev="$2" + shift 2 + ;; + via) + _gw="$2" + shift 2 + ;; + table) + _table="$2" + shift 2 + ;; + metric) + _metric="$2" + shift 2 + ;; + *) not_implemented "$1 in \"$orig_args\"" ;; + esac + done + + ip_check_table "route" + [ -n "$_prefix" ] || not_implemented "ip route without inet prefix in \"$orig_args\"" + # This can't be easily deduced, so print some garbage. + [ -n "$_dev" ] || _dev="ethXXX" + + # Alias or add missing bits + case "$_prefix" in + 0.0.0.0/0) _prefix="default" ;; + */*) : ;; + *) _prefix="${_prefix}/32" ;; + esac + + _f="$FAKE_IP_STATE/routes/${_table}" + mkdir -p "$FAKE_IP_STATE/routes" + touch "$_f" + + # ShellCheck doesn't understand this flock pattern + # shellcheck disable=SC2094 + ( + flock 0 + + # Escape some dots + [ -z "$_gw" ] || _gw=$(echo "$_gw" | sed -e 's@\.@\\.@g') + _prefix=$(echo "$_prefix" | sed -e 's@\.@\\.@g' -e 's@/@\\/@') + + _re="^${_prefix}\>.*" + [ -z "$_gw" ] || _re="${_re}\.*" + [ -z "$_dev" ] || _re="${_re}\.*" + [ -z "$_metric" ] || _re="${_re}.*\.*" + sed -i -e "/${_re}/d" "$_f" + ) <"$_f" +} + +###################################################################### + +orig_args="$*" + +brief=false +case "$1" in +-br*) + brief=true + shift + ;; +esac + +case "$1" in +link) + shift + ip_link "$@" + ;; +addr*) + shift + ip_addr "$@" + ;; +rule) + shift + ip_rule "$@" + ;; +route) + shift + ip_route "$@" + ;; +*) not_implemented "$1" ;; +esac + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ip6tables b/ctdb/tests/UNIT/eventscripts/stubs/ip6tables new file mode 100755 index 0000000..2c65f7b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ip6tables @@ -0,0 +1,5 @@ +#!/bin/sh + +# Always succeed. + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/iptables b/ctdb/tests/UNIT/eventscripts/stubs/iptables new file mode 100755 index 0000000..2c65f7b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/iptables @@ -0,0 +1,5 @@ +#!/bin/sh + +# Always succeed. + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ipvsadm b/ctdb/tests/UNIT/eventscripts/stubs/ipvsadm new file mode 100755 index 0000000..31bdf2c --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ipvsadm @@ -0,0 +1,154 @@ +#!/bin/sh + +die() +{ + echo "$1" >&2 + exit "${2:-1}" +} + +[ -n "$FAKE_LVS_STATE_DIR" ] || die "FAKE_LVS_STATE_DIR not set" + +service_address="" +scheduling_method="wlc" +persistent_timeout="" +real_server="" +forwarding_method="Route" + +set_service_address() +{ + [ -z "$service_address" ] || + die "multiple 'service-address' options specified" 2 + case "$2" in + *:*) service_address="${1} ${2}" ;; + *) service_address="${1} ${2}:0" ;; + esac +} + +set_real_server() +{ + [ -z "$real_server" ] || + die "multiple 'real-server' options specified" 2 + case "$1" in + *\]:*) real_server="${1}" ;; + *\]) real_server="${1}:0" ;; + *:*) real_server="${1}" ;; + *) real_server="${1}:0" ;; + esac + + case "$real_server" in + 127.0.0.1:* | \[::1\]:*) forwarding_method="Local" ;; + esac +} + +case "$1" in +-A) + shift + while [ -n "$1" ]; do + case "$1" in + -t) + set_service_address "TCP" "$2" + shift 2 + ;; + -u) + set_service_address "UDP" "$2" + shift 2 + ;; + -s) + scheduling_method="$2" + shift 2 + ;; + -p) + persistent_timeout="persistent $2" + shift 2 + ;; + *) die "Unsupported -A option $1" ;; + esac + done + [ -n "$service_address" ] || + die "You need to supply the 'service-address' option for the 'add-service' command" 2 + d="${FAKE_LVS_STATE_DIR}/${service_address}" + mkdir "$d" 2>/dev/null || die "Service already exists" 255 + t="${scheduling_method}${persistent_timeout:+ }${persistent_timeout}" + echo "$t" >"${d}/.info" + ;; +-D) + shift + while [ -n "$1" ]; do + case "$1" in + -t) + set_service_address "TCP" "$2" + shift 2 + ;; + -u) + set_service_address "UDP" "$2" + shift 2 + ;; + *) die "Unsupported -D option $1" ;; + esac + done + [ -n "$service_address" ] || + die "You need to supply the 'service-address' option for the 'delete-service' command" 2 + d="${FAKE_LVS_STATE_DIR}/${service_address}" + rm -f "${d}/"* + rm -f "${d}/.info" + rmdir "$d" 2>/dev/null || die "No such service" 255 + ;; +-a) + shift + while [ -n "$1" ]; do + case "$1" in + -t) + set_service_address "TCP" "$2" + shift 2 + ;; + -u) + set_service_address "UDP" "$2" + shift 2 + ;; + -r) + set_real_server "$2" + shift 2 + ;; + -g) + forwarding_method="Route" + shift 1 + ;; + *) die "Unsupported -A option $1" ;; + esac + done + [ -n "$service_address" ] || + die "You need to supply the 'service-address' option for the 'delete-service' command" 2 + d="${FAKE_LVS_STATE_DIR}/${service_address}" + [ -d "$d" ] || die "Service not defined" 255 + [ -n "$real_server" ] || + die "You need to supply the 'real-server' option for the 'add-server' command" 2 + f="${d}/${real_server}" + echo "$forwarding_method" >"$f" + ;; +-l) + cat < RemoteAddress:Port Forward Weight ActiveConn InActConn +EOF + cd "$FAKE_LVS_STATE_DIR" || exit 0 + ( + for d in *; do + [ -d "$d" ] || continue + printf '%s ' "$d" + cat "${d}/.info" + for f in "${d}/"*; do + [ -f "$f" ] || continue + read -r forwarding_method <"$f" + printf " -> %-28s %-7s %-6s %-10s %-10s\n" \ + "${f##*/}" "$forwarding_method" 1 0 0 + done + done + ) + ;; +*) + die "Unknown option $1" + ;; +esac + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/kill b/ctdb/tests/UNIT/eventscripts/stubs/kill new file mode 100755 index 0000000..b69e3e6 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/kill @@ -0,0 +1,7 @@ +#!/bin/sh + +# Always succeed. This means that kill -0 will always find a +# process and anything else will successfully kill. This should +# exercise a good avriety of code paths. + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/killall b/ctdb/tests/UNIT/eventscripts/stubs/killall new file mode 100755 index 0000000..1e182e1 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/killall @@ -0,0 +1,7 @@ +#!/bin/sh + +# Always succeed. This means that killall -0 will always find a +# process and anything else will successfully kill. This should +# exercise a good avriety of code paths. + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/multipath b/ctdb/tests/UNIT/eventscripts/stubs/multipath new file mode 100755 index 0000000..319b734 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/multipath @@ -0,0 +1,36 @@ +#!/bin/sh + +usage() +{ + die "usage: ${0} -ll device" +} + +[ "$1" = "-ll" ] || usage +shift +[ $# -eq 1 ] || usage + +device="$1" + +if [ -n "$FAKE_MULTIPATH_HANG" ]; then + FAKE_SLEEP_REALLY="yes" sleep 999 +fi + +path1_state="active" +path2_state="enabled" + +for i in $FAKE_MULTIPATH_FAILURES; do + if [ "$device" = "$i" ]; then + path1_state="inactive" + path2_state="inactive" + break + fi +done + +cat <&2 <&2 + echo "program ${p} version ${v} is not available" + exit 1 + fi + else + for j in $(seq "$2" "$3"); do + echo "program ${p} version ${j} ready and waiting" + done + exit 0 + fi + fi +done + +echo "rpcinfo: RPC: Program not registered" >&2 +if [ -n "$v" ]; then + echo "program ${p} version ${v} is not available" +else + echo "program ${p} is not available" +fi + +exit 1 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/service b/ctdb/tests/UNIT/eventscripts/stubs/service new file mode 100755 index 0000000..d706280 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/service @@ -0,0 +1,65 @@ +#!/bin/sh + +service_status_dir="${CTDB_TEST_TMP_DIR}/service_fake_status" +mkdir -p "$service_status_dir" + +service="$1" +flag="${service_status_dir}/${service}" + +start() +{ + if [ -f "$flag" ]; then + echo "service: can't start ${service} - already running" + exit 1 + else + touch "$flag" + echo "Starting ${service}: OK" + fi +} + +stop() +{ + if [ -f "$flag" ]; then + echo "Stopping ${service}: OK" + rm -f "$flag" + else + echo "service: can't stop ${service} - not running" + exit 1 + fi +} + +case "$2" in +start) + start + ;; +stop) + stop + ;; +restart | reload) + stop + start + ;; +status) + if [ -f "$flag" ]; then + echo "$service running" + exit 0 + else + echo "$service not running" + exit 3 + fi + ;; +force-started) + # For test setup... + touch "$flag" + ;; +force-stopped) + # For test setup... + rm -f "$flag" + ;; +*) + echo "service $service $2 not supported" + exit 1 + ;; +esac + +exit 0 diff --git a/ctdb/tests/UNIT/eventscripts/stubs/sleep b/ctdb/tests/UNIT/eventscripts/stubs/sleep new file mode 100755 index 0000000..0d0e82b --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/sleep @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$FAKE_SLEEP_REALLY" = "yes" ]; then + /bin/sleep "$@" +elif [ -n "$FAKE_SLEEP_FORCE" ]; then + /bin/sleep "$FAKE_SLEEP_FORCE" +else + : +fi diff --git a/ctdb/tests/UNIT/eventscripts/stubs/smnotify b/ctdb/tests/UNIT/eventscripts/stubs/smnotify new file mode 100755 index 0000000..5606b3d --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/smnotify @@ -0,0 +1,65 @@ +#!/bin/sh + +usage() +{ + _prog="${0##*/}" # basename + cat < ${cip}, MON_NAME=${mon_name}, STATE=${state}" diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ss b/ctdb/tests/UNIT/eventscripts/stubs/ss new file mode 100755 index 0000000..c1199fe --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/ss @@ -0,0 +1,206 @@ +#!/bin/sh + +prog="ss" + +usage() +{ + cat >&2 <&2 + usage +} + +############################################################ + +# +parse_filter() +{ + # Very limited implementation: + # We only expect to find || inside parentheses + # We don't expect to see && - it is implied by juxtaposition + # Operator for port comparison is ignored and assumed to be == + + # Build lists of source ports and source IP addresses where + # each entry is surrounded by '|' characters. These lists can + # be easily "searched" using the POSIX prefix and suffix + # removal operators. + in_parens=false + sports="|" + srcs="|" + + while [ -n "$1" ]; do + case "$1" in + \() + in_parens=true + shift + ;; + \)) + in_parens=false + shift + ;; + \|\|) + if ! $in_parens; then + not_supported "|| in parentheses" + fi + shift + ;; + sport) + p="${3#:}" + sports="${sports}${p}|" + shift 3 + ;; + src) + ip="${2#\[}" + ip="${ip%\]}" + srcs="${srcs}${ip}|" + shift 2 + ;; + *) + usage + ;; + esac + done +} + +# Check if socket has matches in both ok_ips and ok_ports +filter_socket() +{ + ok_ips="$1" + ok_ports="$2" + socket="$3" + + ip="${socket%:*}" + port="${socket##*:}" + + if [ "$ok_ports" != "|" ] && + [ "${ok_ports#*|"${port}"|}" = "$ok_ports" ]; then + return 1 + fi + if [ "$ok_ips" != "|" ] && [ "${ok_ips#*|"${ip}"|}" = "$ok_ips" ]; then + return 1 + fi + + return 0 +} + +ss_tcp_established() +{ + if $header; then + echo "Recv-Q Send-Q Local Address:Port Peer Address:Port" + fi + + # Yes, lose the quoting so we can do a hacky parsing job + # shellcheck disable=SC2048,SC2086 + parse_filter $* + + for i in $FAKE_NETSTAT_TCP_ESTABLISHED; do + src="${i%|*}" + dst="${i#*|}" + if filter_socket "$srcs" "$sports" "$src"; then + echo 0 0 "$src" "$dst" + fi + done + + if [ -z "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" ]; then + return + fi + while read -r src dst; do + if filter_socket "$srcs" "$sports" "$src"; then + echo 0 0 "$src" "$dst" + fi + done <"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" +} + +############################################################ + +unix_listen() +{ + if $header; then + cat <&2 + exit 2 +} + +error() +{ + cat >&2 <&2 + + cat >&2 <&2 +} + +if [ -n "$FAKE_TESTPARM_FAIL" ]; then + error +fi + +if [ -n "$FAKE_TIMEOUT" ]; then + timeout +fi + +# Ensure that testparm always uses our canned configuration instead of +# the global one, unless some other file is specified. + +file="" +param="" +for i; do + case "$i" in + --parameter-name=*) param="${i#--parameter-name=}" ;; + -*) : ;; + *) file="$i" ;; + esac +done + +# Parse out parameter request +if [ -n "$param" ]; then + sed -n \ + -e "s|^[[:space:]]*${param}[[:space:]]*=[[:space:]]\(..*\)|\1|p" \ + "${file:-"${CTDB_SYS_ETCDIR}/samba/smb.conf"}" + exit 0 +fi + +if [ -n "$file" ]; then + # This should include the shares, since this is used when the + # samba eventscript caches the output. + cat "$file" +else + # We force our own smb.conf and add the shares. + cat "${CTDB_SYS_ETCDIR}/samba/smb.conf" + + for i in $FAKE_SHARES; do + bi=$(basename "$i") + cat <