]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/suites/cephfs_journal_tool_smoke.sh
update sources to v12.1.1
[ceph.git] / ceph / qa / workunits / suites / cephfs_journal_tool_smoke.sh
1 #!/bin/bash
2
3 set -e
4 set -x
5
6 export BIN="${BIN:-cephfs-journal-tool}"
7 export JOURNAL_FILE=/tmp/journal.bin
8 export JSON_OUTPUT=/tmp/json.tmp
9 export BINARY_OUTPUT=/tmp/binary.tmp
10
11 if [ -d $BINARY_OUTPUT ] ; then
12 rm -rf $BINARY_OUTPUT
13 fi
14
15 # Check that the import/export stuff really works as expected
16 # first because it's used as the reset method between
17 # following checks.
18 echo "Testing that export/import cycle preserves state"
19 HEADER_STATE=`$BIN header get`
20 EVENT_LIST=`$BIN event get list`
21 $BIN journal export $JOURNAL_FILE
22 $BIN journal import $JOURNAL_FILE
23 NEW_HEADER_STATE=`$BIN header get`
24 NEW_EVENT_LIST=`$BIN event get list`
25
26 if [ ! "$HEADER_STATE" = "$NEW_HEADER_STATE" ] ; then
27 echo "Import failed to preserve header state"
28 echo $HEADER_STATE
29 echo $NEW_HEADER_STATE
30 exit -1
31 fi
32
33 if [ ! "$EVENT_LIST" = "$NEW_EVENT_LIST" ] ; then
34 echo "Import failed to preserve event state"
35 echo $EVENT_LIST
36 echo $NEW_EVENT_LIST
37 exit -1
38 fi
39
40 echo "Testing 'journal' commands..."
41
42 # Simplest thing: print the vital statistics of the journal
43 $BIN journal inspect
44 $BIN header get
45
46 # Make a copy of the journal in its original state
47 $BIN journal export $JOURNAL_FILE
48 if [ ! -s $JOURNAL_FILE ] ; then
49 echo "Export to $JOURNAL_FILE failed"
50 exit -1
51 fi
52
53 # Can we execute a journal reset?
54 $BIN journal reset
55 $BIN journal inspect
56 $BIN header get
57
58 echo "Rolling back journal to original state..."
59 $BIN journal import $JOURNAL_FILE
60
61 echo "Testing 'header' commands..."
62 $BIN header get
63 $BIN header set write_pos 123
64 $BIN header set expire_pos 123
65 $BIN header set trimmed_pos 123
66
67 echo "Rolling back journal to original state..."
68 $BIN journal import $JOURNAL_FILE
69
70 echo "Testing 'event' commands..."
71 $BIN event get summary
72 $BIN event get --type=UPDATE --path=/ --inode=0 --frag=0x100 summary
73 $BIN event get json --path $JSON_OUTPUT
74 if [ ! -s $JSON_OUTPUT ] ; then
75 echo "Export to $JSON_OUTPUT failed"
76 exit -1
77 fi
78 $BIN event get binary --path $BINARY_OUTPUT
79 if [ ! -s $BINARY_OUTPUT ] ; then
80 echo "Export to $BINARY_OUTPUT failed"
81 exit -1
82 fi
83 $BIN event recover_dentries summary
84 $BIN event splice summary
85
86 # Tests finish.
87 # Metadata objects have been modified by the 'event recover_dentries' command.
88 # Journal is no long consistent with respect to metadata objects (especially inotable).
89 # To ensure mds successfully replays its journal, we need to do journal reset.
90 $BIN journal reset
91 cephfs-table-tool all reset session
92