summaryrefslogtreecommitdiff
path: root/yarns/0090-lock-handling.yarn
blob: edf40a964182c783b816a77227939d29c364fbc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Lock handling
=============

This chapter contains scenarios for testing Obnam's lock handling,
specifically the forcing of locks to become open when lock files have
been left by Obnam for whatever reason.


Basic forcing of a lock
-----------------------

In this scenario, we force a repository to be locked, and force the
lock open. To do this, we use an Obnam command that locks the desired
parts of the repository, and does nothing else; this is a testing aid.

    SCENARIO force repository open

We first create the repository and back up some data.

    GIVEN 1kB of new data in directory L
    WHEN user U backs up directory L to repository R

We then lock the repository, and verify that a backup now fails.

    AND user U locks repository R
    AND user U attempts to back up directory L to repository R
    THEN the attempt failed with exit code 1
    AND the error message matches "R681AEX"

Now we can force the lock open and verify that a backup now succeeds.

    WHEN user U forces open the lock on repository R
    AND user U attempts to back up directory L to repository R
    THEN the attempt succeeded


Forcing of someone else's lock
------------------------------

We also need to force a lock by someone else. This is otherwise
similar to the basic lock forcing scenario, but the lock is held by a
different client. The lock is created before the second client even
gets added to the client list, to maximise the difficulty.

    SCENARIO force someone else's lock

We first create the repository and back up some data as the first
client.

    GIVEN 1kB of new data in directory L
    WHEN user U1 backs up directory L to repository R

We then lock the repository as the first user, and verify that a
backup now fails when run as the second client.

    AND user U1 locks repository R
    AND user U2 attempts to back up directory L to repository R
    THEN the attempt failed with exit code 1
    AND the error message matches "R681AEX"

The second client can force the lock open and successfully back up.

    WHEN user U2 forces open the lock on repository R
    AND user U2 attempts to back up directory L to repository R
    THEN the attempt succeeded