]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
1#!/bin/bash
2
3set -e
4set -x
5
6export BIN="${BIN:-cephfs-journal-tool}"
7export JOURNAL_FILE=/tmp/journal.bin
8export JSON_OUTPUT=/tmp/json.tmp
9export BINARY_OUTPUT=/tmp/binary.tmp
10
11if [ -d $BINARY_OUTPUT ] ; then
12 rm -rf $BINARY_OUTPUT
13fi
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.
18echo "Testing that export/import cycle preserves state"
19HEADER_STATE=`$BIN header get`
20EVENT_LIST=`$BIN event get list`
21$BIN journal export $JOURNAL_FILE
22$BIN journal import $JOURNAL_FILE
23NEW_HEADER_STATE=`$BIN header get`
24NEW_EVENT_LIST=`$BIN event get list`
25
26if [ ! "$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
31fi
32
33if [ ! "$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
38fi
39
40echo "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
48if [ ! -s $JOURNAL_FILE ] ; then
49 echo "Export to $JOURNAL_FILE failed"
50 exit -1
51fi
52
53# Can we execute a journal reset?
54$BIN journal reset
55$BIN journal inspect
56$BIN header get
57
224ce89b
WB
58echo "Rolling back journal to original state..."
59$BIN journal import $JOURNAL_FILE
60
61echo "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
67echo "Rolling back journal to original state..."
7c673cae
FG
68$BIN journal import $JOURNAL_FILE
69
70echo "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
74if [ ! -s $JSON_OUTPUT ] ; then
75 echo "Export to $JSON_OUTPUT failed"
76 exit -1
77fi
78$BIN event get binary --path $BINARY_OUTPUT
79if [ ! -s $BINARY_OUTPUT ] ; then
80 echo "Export to $BINARY_OUTPUT failed"
81 exit -1
82fi
224ce89b 83$BIN event recover_dentries summary
7c673cae
FG
84$BIN event splice summary
85
224ce89b
WB
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
91cephfs-table-tool all reset session
7c673cae 92