Commit 82d7a4f7 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Test lock files of lyskomd and dbck.

parent 70e218b3
# Test suite for lyskomd.
# Copyright (C) 1999 Lysator Academic Computer Association.
#
# This file is part of the LysKOM server.
#
# LysKOM 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 1, or (at your option)
# any later version.
#
# LysKOM 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 LysKOM; see the file COPYING. If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se.
# Test the lock file of lyskomd and dbck.
# Start a server that locks the database.
lyskomd_start
# Start dbck in read-only mode. No lock is required.
spawn ../dbck -d config/lyskomd-config
set test "dbck started in read-only mode"
expect {
-re "^MSG: init_cache: using datafile\.$nl" { pass "$test" }
}
set test "read-only dbck sent second line"
expect {
-re "^Read $any_num confs/persons and $any_num texts, eof at $any_num$nl" {
pass "$test"
}
}
set test "read-only dbck sent final line"
expect {
-re "^Press enter to terminate dbck$nl" {
pass "$test"
}
}
send "\n"
set test "read-only dbck died"
expect {
eof { pass "$test" }
}
unset test
# Attempt to start dbck in read-write mode.
spawn ../dbck -d -i config/lyskomd-config
set test "dbck finds a lock"
expect {
-re "^Database locked by $any*\.$nl" { pass "$test" }
}
set test "read-write dbck sent final line"
expect {
-re "^Press enter to terminate dbck$nl" {
pass "$test"
}
}
send "\n"
set test "read-write dbck died"
expect {
eof { pass "$test" }
}
unset test
# Attempt to start a second lyskomd.
spawn ../lyskomd -d config/lyskomd-config
set test "lyskomd finds a lock"
expect {
-re "Database locked by $any*:$lyskomd_pid$nl" { pass "$test" }
}
set test "read-write lyskomd sent final line"
expect {
-re "^\[0-9 :\]* Press enter to terminate lyskomd$nl" {
pass "$test"
}
}
send "\n"
set test "read-write lyskomd died"
expect {
eof { pass "$test" }
}
unset test
# Shut down lyskomd.
system "kill -HUP $lyskomd_pid"
lyskomd_death
# Start a new lyskomd.
lyskomd_start
# Kill it so that it cannot remove the lock file.
system "kill -KILL $lyskomd_pid"
set test "lyskomd was killed"
expect {
eof { pass "$test" }
}
# Start a new lyskomd. Check that it removes the stale lock file.
set new_pid [spawn ../lyskomd -d config/lyskomd-config]
set test "stale lock file removed"
expect {
-re "Stale lock file left by $any*:$lyskomd_pid removed\.$nl" {
pass "$test"
}
}
system "kill -HUP $lyskomd_pid"
set test "non-stale lyskomd sent final line"
expect {
-re "^\[0-9 :\]* Press enter to terminate lyskomd$nl" {
pass "$test"
}
}
send "\n"
set test "non-stale lyskomd died"
expect {
eof { pass "$test" }
}
unset test
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment