Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/Makefile.am b/Makefile.am
index 0d7610a..52b8abd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,96 +1,96 @@
SUBDIRS = src agent man tests
# .gz because github doesn't support .xz yet :-(
# this is modified
#
TAG ?= $(shell git log --pretty="format:%H" -n 1 || sed -n -e "s/%global longcommit\s*//p" sbd.spec)$(shell test -n "$$(git status -s)" && echo -n "-mod")
SPEC_VERSION ?= $(shell sed -n -e "s/Version:\s*//p" sbd.spec)
distdir = $(PACKAGE)-$(TAG)
TARFILE = $(distdir).tar.gz
DIST_ARCHIVES = $(TARFILE)
KEEP_EXISTING_TAR = no
INJECT_GIT_COMMIT = yes
CLEANFILES = *.rpm *.tar.* sbd-*
DISTCLEANFILES = sbd-* sbd-*/
RPM_ROOT = $(shell pwd)
RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \
--define "_specdir $(RPM_ROOT)" \
--define "_srcrpmdir $(RPM_ROOT)" \
--define "_builddir $(RPM_ROOT)" \
--define "_rpmdir $(RPM_ROOT)"
MOCK_TARGET ?= rhel-7.1-candidate-x86_64
MOCK_OPTIONS ?= --resultdir=$(RPM_ROOT)/mock --no-cleanup-after
BUILD_COUNTER ?= build.counter
COUNT = $(shell expr 1 + 0$(shell cat $(BUILD_COUNTER)))
COMMIT_COUNTER ?= $(shell git describe --tags --long --always --match v$(SPEC_VERSION) | cut -f 2 -d- -s)
TESTS = tests/regressions.sh
export SBD_BINARY := src/sbd
export SBD_PRELOAD := tests/.libs/libsbdtestbed.so
export SBD_USE_DM ?= no
-export SBD_TRANSLATE_AIO ?= no
+export SBD_TRANSLATE_AIO ?= yes
EXTRA_DIST = sbd.spec tests/regressions.sh man/sbd.8.pod.in
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = sbd.pc
export:
rm -f $(PACKAGE)-HEAD.tar.*
if test "$(KEEP_EXISTING_TAR)" != "yes"; then \
rm -f $(TARFILE); \
fi;
! (git status -s | grep "??" && echo "untracked files present in git-repo" )
if [ -f $(TARFILE) ]; then \
echo `date`: Using existing tarball: $(TARFILE); \
else \
rm -f $(PACKAGE).tar.*; \
(git archive --prefix=$(distdir)/ $(shell echo $(TAG)|cut -f1 -d-) || tar -c --transform="s,^,$(distdir)/," --exclude="*.tar.*" --exclude="$(distdir)" --exclude="*.o" --exclude="*.8" --exclude="config.*" --exclude="libtool" --exclude="ltmain.sh*" --exclude="Makefile" --exclude="Makefile.in" --exclude="stamp-*" --exclude="*.service" --exclude="sbd" --exclude="*.m4" --exclude="*.cache" --exclude="configure" --exclude="*.list" --exclude="depcomp" --exclude="install-sh" --exclude="missing" --exclude="compile" --exclude="sbd.sh" --exclude="sbd.sysconfig" --exclude="~" --exclude="*.swp" --exclude="*.patch" --exclude="*.diff" --exclude="*.orig" --exclude="*.rej" --exclude="*.rpm" --exclude="*.pod" --exclude=".deps" --exclude="test-driver" --exclude="sbd.pc" --exclude="build.counter" *) | gzip > $(TARFILE); \
if test -n "$$(git status -s)" || test "$(INJECT_GIT_COMMIT)" = "yes"; then \
if test -n "$$(git status -s)"; then git diff HEAD --name-only|grep -v "^\."|xargs -n1 git diff HEAD > uncommitted.diff; fi; \
rm -rf $(distdir); tar -xzf $(TARFILE); rm $(TARFILE); \
cd $(distdir); \
if test -n "$$(git status -s)"; then patch -p1 -i ../uncommitted.diff; fi; \
cd ..; \
sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(distdir)/$(PACKAGE).spec; \
tar -czf $(TARFILE) $(distdir); rm -rf $(distdir); \
rm -f uncommitted.diff; \
fi; \
echo `date`: Rebuilt $(TARFILE); \
fi
#replace commit id in sbd.spec
spec:
rm -f *.src.rpm
rm -rf $(distdir)
mkdir $(distdir)
cp $(PACKAGE).spec $(distdir)
sed -i 's/global\ longcommit.*/global\ longcommit\ $(TAG)/' $(distdir)/$(PACKAGE).spec
if [ -e $(BUILD_COUNTER) ]; then \
sed -i 's/global\ build_counter.*/global\ build_counter\ $(COUNT)/' $(distdir)/$(PACKAGE).spec; \
echo $(COUNT) > $(BUILD_COUNTER); \
fi
if [ -n "$(COMMIT_COUNTER)" ]; then \
sed -i 's/global\ commit_counter.*/global\ commit_counter\ $(COMMIT_COUNTER)/' $(distdir)/$(PACKAGE).spec; \
fi
srpm: export spec
rpmbuild $(RPM_OPTS) -bs $(distdir)/$(PACKAGE).spec
rpm: export spec
rpmbuild $(RPM_OPTS) -ba $(distdir)/$(PACKAGE).spec
mock: srpm
-rm -rf $(RPM_ROOT)/mock
@echo "mock --root=$* --rebuild $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm"
mock --root=$(MOCK_TARGET) --rebuild $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm
beekhof: mock
cluster-helper -- 'rm -f sbd-*.x86_64.rpm'
cluster-helper --copy $(RPM_ROOT)/mock/sbd-*.x86_64.rpm {}:
cluster-helper -- yum install -y sbd-*.x86_64.rpm
diff --git a/sbd.spec b/sbd.spec
index b9e7f72..703933d 100644
--- a/sbd.spec
+++ b/sbd.spec
@@ -1,339 +1,341 @@
#
# spec file for package sbd
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2013 Lars Marowsky-Bree
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%global longcommit 7bcdf69597042c31ea0b4a523e732d4bbb99b3a0
%global shortcommit %(echo %{longcommit}|cut -c1-8)
%global modified %(echo %{longcommit}-|cut -f2 -d-)
%global github_owner Clusterlabs
%global commit_counter 0
%global build_counter 0
%global buildnum %(expr %{commit_counter} + %{build_counter})
%ifarch s390x s390
# minimum timeout on LPAR diag288 watchdog is 15s
%global watchdog_timeout_default 15
%else
%global watchdog_timeout_default 5
%endif
# Be careful with sync_resource_startup_default
# being enabled. This configuration has
# to be in sync with configuration in pacemaker
# where it is called sbd_sync - assure by e.g.
# mutual rpm dependencies.
%bcond_without sync_resource_startup_default
# Syncing enabled per default will lead to
# syncing enabled on upgrade without adaption
# of the config.
# Setting can still be overruled via sysconfig.
# The setting in the config-template packaged
# will follow the default if below is is left
# empty. But it is possible to have the setting
# in the config-template deviate from the default
# by setting below to an explicit 'yes' or 'no'.
%global sync_resource_startup_sysconfig ""
Name: sbd
Summary: Storage-based death
License: GPL-2.0-or-later
Group: System Environment/Daemons
Version: 1.5.2
Release: 99.%{buildnum}.%{shortcommit}.%{modified}git%{?dist}
Url: https://github.com/%{github_owner}/%{name}
Source0: https://github.com/%{github_owner}/%{name}/archive/%{longcommit}/%{name}-%{longcommit}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libuuid-devel
BuildRequires: glib2-devel
BuildRequires: libaio-devel
BuildRequires: corosync-devel
%if 0%{?suse_version}
%if 0%{?suse_version} > 1500
BuildRequires: libpacemaker3-devel
%else
BuildRequires: libpacemaker-devel
%endif
%else
BuildRequires: pacemaker-libs-devel
%endif
BuildRequires: libtool
BuildRequires: libuuid-devel
BuildRequires: libxml2-devel
BuildRequires: pkgconfig
BuildRequires: make
+BuildRequires: time
Conflicts: fence-agents-sbd < 4.5.0
%if 0%{?rhel} > 0
ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le
%endif
%if %{defined systemd_requires}
%systemd_requires
%endif
%description
This package contains the storage-based death functionality.
Available rpmbuild rebuild options:
--with(out) : sync_resource_startup_default
%package tests
Summary: Storage-based death environment for regression tests
License: GPL-2.0-or-later
Group: System Environment/Daemons
+Requires: time
%description tests
This package provides an environment + testscripts for
regression-testing sbd.
%prep
###########################################################
# %setup -n sbd-%{version} -q
%setup -q -n %{name}-%{longcommit}
###########################################################
%build
./autogen.sh
export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror"
%configure --with-watchdog-timeout-default=%{watchdog_timeout_default} \
--with-sync-resource-startup-default=%{?with_sync_resource_startup_default:yes}%{!?with_sync_resource_startup_default:no} \
--with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} \
--with-runstatedir=%{_rundir}
make %{?_smp_mflags}
###########################################################
%install
###########################################################
make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install
rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith
install -D -m 0755 src/sbd.sh $RPM_BUILD_ROOT/usr/share/sbd/sbd.sh
install -D -m 0755 tests/regressions.sh $RPM_BUILD_ROOT/usr/share/sbd/regressions.sh
%if %{defined _unitdir}
install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service
install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote.service
%endif
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd
# Don't package static libs
find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f
find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f
%clean
rm -rf %{buildroot}
%if %{defined _unitdir}
%post
%systemd_post sbd.service
%systemd_post sbd_remote.service
%preun
%systemd_preun sbd.service
%systemd_preun sbd_remote.service
%postun
%systemd_postun sbd.service
%systemd_postun sbd_remote.service
%endif
%files
###########################################################
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/sysconfig/sbd
%{_sbindir}/sbd
%{_datadir}/sbd
%{_datadir}/pkgconfig/sbd.pc
%exclude %{_datadir}/sbd/regressions.sh
%doc %{_mandir}/man8/sbd*
%if %{defined _unitdir}
%{_unitdir}/sbd.service
%{_unitdir}/sbd_remote.service
%endif
%doc COPYING
%files tests
%defattr(-,root,root)
%dir %{_datadir}/sbd
%{_datadir}/sbd/regressions.sh
%{_libdir}/libsbdtestbed*
%changelog
* Thu Jan 5 2023 <klaus.wenninger@aon.at> - 1.5.2-99.0.8ec8e011.git
- fail startup if pacemaker integration is disabled while
SBD_SYNC_RESOURCE_STARTUP is conflicting (+ hint to overcome)
- improve logs
- when logging state of SBD_PACEMAKER tell it is just that as
this might still be overridden via cmdline options
- log a warning if SBD_PACEMAKER is overridden by -P or -PP option
- do not warn about startup syncing with pacemaker integration disabled
- when watchdog-device is busy give a hint on who is hogging it
- improve build environment
- have --with-runstatedir overrule --runstatedir
- use new package name for pacemaker devel on opensuse
- make config location configurable for man-page-creation
- reverse alloc/de-alloc order to make gcc-12 static analysis happy
- improve test environment
- have image-files in /dev/shm to assure they are in memory and
sbd opening the files with O_SYNC doesn't trigger unnecessary
syncs on a heavily loaded test-machine
fallback to /tmp if /dev/shm doesn't exist
- wrapping away libaio and usage of device-mapper for block-device
simulation can now be passed into make via
SBD_USE_DM & SBD_TRANSLATE_AIO
- have variables that configure test-environment be printed
out prior to running tests
- finally assure we clean environment when interrupted by a
signal (bash should have done it with just setting EXIT handler -
but avoiding bashism might come handy one day)
* Mon Nov 15 2021 <klaus.wenninger@aon.at> - 1.5.1-99.0.7bcdf695.git
- improve/fix cmdline handling
- tell the actual watchdog device specified with -w
- tolerate and strip any leading spaces of commandline option values
- Sanitize numeric arguments
- if start-delay enabled, not explicitly given and msgwait can't be
read from disk (diskless) use 2 * watchdog-timeout
- avoid using deprecated valloc for disk-io-buffers
- avoid frequent alloc/free of aligned buffers to prevent fragmentation
- fix memory-leak in one-time-allocations of sector-buffers
- fix AIO-API usage: properly destroy io-context
- improve/fix build environment
- validate configure options for paths
- remove unneeded complexity of configure.ac hierarchy
- correctly derive package version from git (regression since 1.5.0)
- make runstatedir configurable and derive from distribution
* Tue Jun 8 2021 <klaus.wenninger@aon.at> - 1.5.0-99.0.2a00ac70.git
- default to resource-syncing with pacemaker in spec-file and configure.ac
This default has to match between sbd and pacemaker and
thus qualifies this release for a minor-version-bump
- fix some regressions introduced by adding configurability previously
- adapt description of startup/shutdown sync with pacemaker
- make watchdog warning messages more understandable
* Wed Dec 2 2020 <klaus.wenninger@aon.at> - 1.4.2-99.1.bfeee963.git
- improve build/CI-friendlyness
- * travis: switch to F32 as build-host
- switch to F32 & leap-15.2
- changes for mock-2.0
- turn off loop-devices & device-mapper on x86_64 targets because
- of changes in GCE
- * regressions.sh: get timeouts from disk-header to go with proper defaults
- for architecture
- * use configure for watchdog-default-timeout & others
- * ship sbd.pc with basic sbd build information for downstream packages
- to use
- * add number of commits since version-tag to build-counter
- add robustness against misconfiguration / improve documentation
- * add environment section to man-page previously just available in
- template-config
- * inform the user to restart the sbd service after disk-initialization
- * refuse to start if any of the configured device names is invalid
- * add handshake to sync startup/shutdown with pacemakerd
- Previously sbd just waited for the cib-connnection to show up/go away
- which isn't robust at all.
- The new feature needs new pacemakerd-api as counterpart.
- Thus build checks for presence of pacemakerd-api.
- To simplify downstream adoption behavior is configurable at runtime
- via configure-file with a build-time-configurable default.
- * refuse to start if qdevice-sync_timeout doesn't match watchdog-timeout
- Needed in particular as qdevice-sync_timeout delays quorum-state-update
- and has a default of 30s that doesn't match the 5s watchdog-timeout
- default.
- Fix: sbd-pacemaker: handle new no_quorum_demote + robustness against new
- policies added
- Fix: agent: correctly compare string values when calculating timeout
- Fix: scheduling: overhaul the whole thing
- * prevent possible lockup when format in proc changes
- * properly get and handle scheduler policy & prio
- * on SCHED_RR failing push to the max with SCHED_OTHER
* Tue Nov 19 2019 <klaus.wenninger@aon.at> - 1.4.1-99.1.aca7907c.git
- improvements/clarifications in documentation
- properly finalize cmap connection when disconnected from cluster
- make handling of cib-connection loss more robust
- silence some coverity findings
- overhaul log for reasonable prios and details
- if current slice doesn't have rt-budget move to root-slice
- periodically ping corosync daemon for liveness
- actually use crashdump timeout if configured
- avoid deprecated names for g_main-loop-funcitons
- conflict with fence-agents-sbd < 4.5.0
- rather require corosync-devel provided by most distributions
- make devices on cmdline overrule those coming via SBD_DEVICE
- make 15s timeout on s390 be used consistently
- improve build/test for CI-friendlyness
- * add autogen.sh
- * enable/improve out-of-tree-building
- * make tar generation smarter
- * don't modify sbd.spec
- * make distcheck-target work
- * Add tests/regressions.sh to check-target
- * use unique devmapper names for multiple tests in parallel
- * consistently use serial test-harness for visible progress
- * package tests into separate package (not packaged before)
- * add preload-library to intercept reboots while testing
- * add tests for sbd in daemon-mode & watchdog-dev-handling
- * make tests work in non-privileged containers
* Mon Jan 14 2019 <klaus.wenninger@aon.at> - 1.4.0-0.1.2d595fdd.git
- updated travis-CI (ppc64le-build, fedora29, remove need for
alectolytic-build-container)
- make watchdog-device-query easier to be handled by an SELinux-policy
- configurable delay value for SBD_DELAY_START
- use pacemaker's new pe api with constructors/destructors
- make timeout-action executed by sbd configurable
- init script for sysv systems
- version bump to v1.4.0 to denote Pacemaker 2.0.0 compatibility
* Fri Jun 29 2018 <klaus.wenninger@aon.at> - 1.3.1-0.1.e102d9ed.git
- removed unneeded python-devel build-requirement
- changed legacy corosync-devel to corosynclib-devel
* Fri Nov 3 2017 <klaus.wenninger@aon.at> - 1.3.1-0.1.a180176c.git
- Add commands to test/query watchdogs
- Allow 2-node-operation with a single shared-disk
- Overhaul of the command-line options & config-file
- Proper handling of off instead of reboot
- Refactored disk-servant for more robust communication with parent
- Fix config for Debian + configurable location of config
- Fixes in sbd.sh - multiple SBD devices and others
* Sun Mar 27 2016 <klaus.wenninger@aon.at> - 1.3.0-0.1.4ee36fa3.git
- Changes since v1.2.0 like adding the possibility to have a
watchdog-only setup without shared-block-devices
legitimate a bump to v1.3.0.
* Mon Oct 13 2014 <andrew@beekhof.net> - 1.2.1-0.4.3de531ed.git
- Fixes for suitability to the el7 environment
* Tue Sep 30 2014 <andrew@beekhof.net> - 1.2.1-0.3.8f912945.git
- Only build on archs supported by the HA Add-on
* Fri Aug 29 2014 <andrew@beekhof.net> - 1.2.1-0.2.8f912945.git
- Remove some additional SUSE-isms
* Fri Aug 29 2014 <andrew@beekhof.net> - 1.2.1-0.1.8f912945.git
- Prepare for package review
Resolves: rhbz#1134245
diff --git a/tests/regressions.sh b/tests/regressions.sh
index 5c354f9..d131b70 100755
--- a/tests/regressions.sh
+++ b/tests/regressions.sh
@@ -1,380 +1,386 @@
#!/bin/bash
#
# Copyright (C) 2013 Lars Marowsky-Bree <lmb@suse.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# TODO:
# - More tests
# - Handle optional, long-running tests better
# - Support for explicitly running a single test
# - Verify output from commands
# - Normalize uuids and device names so they are diffable
# - Log to file, instead of syslog is needed
# - How to test watch mode?
# - Can the unit/service file be tested? or at least the wrapper?
: ${SBD_BINARY:="/usr/sbin/sbd"}
: ${SBD_PRELOAD:="libsbdtestbed.so"}
: ${SBD_USE_DM:="yes"}
: ${SBD_TRANSLATE_AIO:= "no"}
sbd() {
LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
}
+sbd_sleep() {
+ TIME="delay %es" time sleep $1
+}
+
sbd_wipe_disk() {
dd if=/dev/zero of=$1 count=2048 2>/dev/null
}
sbd_setup() {
trap 'sbd_teardown $?' EXIT
trap 'sbd_teardown 134' ABRT
trap 'sbd_teardown 131' QUIT
trap 'sbd_teardown 143' TERM
trap 'sbd_teardown 130' INT
trap "sbd_teardown 1" ERR
if [[ -d /dev/shm ]]; then
SBD_IMGPATH=/dev/shm
else
SBD_IMGPATH=/tmp
fi
for N in $(seq 3) ; do
F[$N]=$(mktemp ${SBD_IMGPATH}/sbd.device.$N.XXXXXX)
sbd_wipe_disk ${F[$N]}
if [[ "${SBD_USE_DM}" == "yes" ]]; then
R[$N]=$(echo ${F[$N]}|cut -f4 -d.)
L[$N]=$(losetup -f)
losetup ${L[$N]} ${F[$N]}
D[$N]="/dev/mapper/sbd_${N}_${R[$N]}"
dmsetup create sbd_${N}_${R[$N]} --table "0 2048 linear ${L[$N]} 0"
dmsetup mknodes sbd_${N}_${R[$N]}
else
D[$N]=${F[$N]}
fi
done
if [[ "${SBD_USE_DM}" != "yes" ]]; then
SBD_DEVICE="${F[1]};${F[2]};${F[3]}"
fi
SBD_PIDFILE=$(mktemp /tmp/sbd.pidfile.XXXXXX)
SBD_PRELOAD_LOG=$(mktemp /tmp/sbd.logfile.XXXXXX)
sbd -d ${D[1]} create
WATCHDOG_TIMEOUT=$(LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${D[1]}" ${SBD_BINARY} dump |grep watchdog|cut -f2 -d:)
MSGWAIT_TIMEOUT=$(LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${D[1]}" ${SBD_BINARY} dump |grep msgwait|cut -f2 -d:)
}
sbd_teardown() {
# disable traps prior to cleanup to avoid loops
trap '' EXIT ABRT QUIT TERM INT ERR
for N in $(seq 3) ; do
if [[ "${SBD_USE_DM}" == "yes" ]]; then
dmsetup remove sbd_${N}_${R[$N]}
losetup -d ${L[$N]}
fi
rm -f ${F[$N]}
sbd_daemon_cleanup
rm -f ${SBD_PIDFILE}
rm -f ${SBD_PRELOAD_LOG}
done
# now that everything should be clean
# return to original handlers to terminate
# as requested
trap - EXIT ABRT QUIT TERM INT ERR
if [[ $1 -eq 134 ]]; then
echo "Received SIGABRT!!!"
kill -ABRT $$
elif [[ $1 -eq 131 ]]; then
echo "Received SIGQUIT!!!"
kill -QUIT $$
elif [[ $1 -eq 143 ]]; then
echo "Received SIGTERM!!!"
kill -TERM $$
elif [[ $1 -eq 130 ]]; then
echo "Received SIGINT!!!"
kill -INT $$
else
exit $1
fi
}
sbd_dev_fail() {
if [[ "${SBD_USE_DM}" == "yes" ]]; then
dmsetup wipe_table sbd_${1}_${R[$1]}
else
D[$1]=/tmp/fail123456789
fi
}
sbd_dev_resume() {
if [[ "${SBD_USE_DM}" == "yes" ]]; then
dmsetup suspend sbd_${1}_${R[$1]}
dmsetup load sbd_${1}_${R[$1]} --table "0 2048 linear ${L[$1]} 0"
dmsetup resume sbd_${1}_${R[$1]}
else
D[$1]=${F[$1]}
fi
}
sbd_daemon_cleanup() {
if [[ "${SBD_PRELOAD_LOG}" != "" ]]; then
echo > ${SBD_PRELOAD_LOG}
fi
if [[ "${SBD_PIDFILE}" != "" ]]; then
pkill -TERM --pidfile ${SBD_PIDFILE} 2>/dev/null
- sleep 5
+ sbd_sleep 5
pkill -KILL --pidfile ${SBD_PIDFILE} 2>/dev/null
pkill -KILL --parent "$(cat ${SBD_PIDFILE} 2>/dev/null)" 2>/dev/null
echo > ${SBD_PIDFILE}
fi
}
_ok() {
echo "-- $*"
"$@"
rc=$?
if [ $rc -ne 0 ]; then
echo "$* failed with $rc"
exit $rc
fi
}
_no() {
echo "-- $*"
"$@"
rc=$?
if [ $rc -eq 0 ]; then
echo "$* did NOT fail ($rc)"
exit $rc
fi
return 0
}
_in_log() {
grep "$@" ${SBD_PRELOAD_LOG} >/dev/null
if [ $? -ne 0 ]; then
echo "didn't find '$*' in log:"
cat ${SBD_PRELOAD_LOG}
sbd_daemon_cleanup
exit 1
fi
}
test_1() {
echo "Creating three devices"
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} create
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} dump
}
test_2() {
echo "Basic functionality"
for S in `seq 2` ; do
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-$S"
done
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 reset
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} list
}
test_3() {
echo "Start mode (expected not to start, because reset was written in test_2)"
_no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-2 -Z -Z -Z -S 1 watch
}
test_4() {
echo "Deliver message with 1 failure"
sbd_dev_fail 1
_no sbd -d ${D[1]} -n test-1 message test-2 exit
_no sbd -d ${D[1]} -d ${D[2]} -n test-1 message test-2 exit
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit
sbd_dev_resume 1
}
test_5() {
echo "Deliver message with 2 failures"
sbd_dev_fail 1
sbd_dev_fail 2
_no sbd -d ${D[1]} -d ${D[2]} -n test-1 message test-2 exit
_no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit
sbd_dev_resume 1
sbd_dev_resume 2
}
test_6() {
echo "Deliver message with 3 failures"
sbd_dev_fail 1
sbd_dev_fail 2
sbd_dev_fail 3
_no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit
sbd_dev_resume 1
sbd_dev_resume 2
sbd_dev_resume 3
}
test_101() {
echo "Creating one device"
_ok sbd -d ${D[1]} create
}
test_102() {
echo "Creating two devices"
_ok sbd -d ${D[1]} -d ${D[2]} create
}
test_7() {
echo "Allocate all slots plus 1"
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -2 0 create
for S in `seq 255` ; do
_ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-$S"
done
_no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-256"
}
test_8() {
echo "Non-existent device path"
_no sbd -d /dev/kfdifdifdfdlfd -create 2>/dev/null
}
test_9() {
echo "Basic sbd invocation"
_no sbd
_ok sbd -h
}
test_watchdog() {
echo "Basic watchdog test"
echo > ${SBD_PRELOAD_LOG}
sbd test-watchdog < /dev/null
_in_log "watchdog fired"
}
test_stall_inquisitor() {
echo "Stall inquisitor test"
sbd_daemon_cleanup
sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 watch
- sleep 10
+ sbd_sleep 10
_ok kill -0 "$(cat ${SBD_PIDFILE})"
kill -STOP "$(cat ${SBD_PIDFILE})"
- sleep $((${WATCHDOG_TIMEOUT} * 2))
+ sbd_sleep $((${WATCHDOG_TIMEOUT} * 2))
kill -CONT "$(cat ${SBD_PIDFILE})" 2>/dev/null
_in_log "watchdog fired"
}
test_wipe_slots1() {
echo "Wipe slots test (with watchdog)"
sbd_daemon_cleanup
sbd -d ${D[1]} -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd_wipe_disk ${D[1]}
- sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
+ sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "watchdog fired"
}
test_wipe_slots2() {
echo "Wipe slots test (without watchdog)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd_wipe_disk ${D[1]}
- sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
+ sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('b')"
_in_log "reboot (reboot)"
}
test_message1() {
echo "Message test (reset)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd -d ${D[1]} message test-1 reset
- sleep 2
+ sbd_sleep 2
_in_log "sysrq-trigger ('b')"
_in_log "reboot (reboot)"
}
test_message2() {
echo "Message test (off)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd -d ${D[1]} message test-1 off
- sleep 2
+ sbd_sleep 2
_in_log "sysrq-trigger ('o')"
_in_log "reboot (poweroff)"
}
test_message3() {
echo "Message test (crashdump)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd -d ${D[1]} message test-1 crashdump
- sleep 2
+ sbd_sleep 2
_in_log "sysrq-trigger ('c')"
}
test_timeout_action1() {
echo "Timeout action test (off)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
SBD_TIMEOUT_ACTION=off sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd_wipe_disk ${D[1]}
- sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
+ sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('o')"
_in_log "reboot (poweroff)"
}
test_timeout_action2() {
echo "Timeout action test (crashdump)"
sbd_daemon_cleanup
sbd -d ${D[1]} create
SBD_TIMEOUT_ACTION=crashdump sbd -d ${D[1]} -w /dev/null -n test-1 watch
- sleep 2
+ sbd_sleep 2
sbd_wipe_disk ${D[1]}
- sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
+ sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('c')"
}
echo "SBD_BINARY = \"${SBD_BINARY}\""
echo "SBD_PRELOAD = \"${SBD_PRELOAD}\""
echo "SBD_USE_DM = \"${SBD_USE_DM}\""
echo "SBD_TRANSLATE_AIO = \"${SBD_TRANSLATE_AIO}"\"
sbd_setup
+MOUNTPOINT=$((mount|grep ${SBD_IMGPATH} || echo unknown)|cut -f1 -d" ")
_ok test "${WATCHDOG_TIMEOUT}" -eq "${WATCHDOG_TIMEOUT}"
_ok test "${MSGWAIT_TIMEOUT}" -eq "${MSGWAIT_TIMEOUT}"
echo "running sbd-tests with WATCHDOG_TIMEOUT=${WATCHDOG_TIMEOUT}s MSGWAIT_TIMEOUT=${MSGWAIT_TIMEOUT}s"
+echo "on randomly named images in SBD_IMGPATH=\"${SBD_IMGPATH}\" on ${MOUNTPOINT} filesystem"
if [[ "${SBD_PRELOAD}" != "" ]]; then
SBD_DAEMON_TESTS="watchdog stall_inquisitor wipe_slots1 wipe_slots2 message1 message2 message3 timeout_action1 timeout_action2"
fi
for T in 101 102 $(seq 9) ${SBD_DAEMON_TESTS}; do
if ! test_$T ; then
echo "FAILURE: Test $T"
break
fi
echo "SUCCESS: Test $T"
done
echo "SUCCESS: All tests completed"

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 5:00 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2002317
Default Alt Text
(28 KB)

Event Timeline