backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / virsh-checkpoint
blob92962d2205158b9891a9a93428d64484eda8d473
1 #!/bin/sh
2 # simple testing of checkpoint APIs on test driver
4 # Copyright (C) 2019 Red Hat, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see
18 # <http://www.gnu.org/licenses/>.
20 . "$(dirname $0)/test-lib.sh"
22 if test "$VERBOSE" = yes; then
23 set -x
24 $abs_top_builddir/tools/virsh --version
27 fail=0
29 mock_xdg_ || framework_failure
31 # The test driver loses states between restarts, so we perform a script
32 # with some convenient markers for later post-processing of output.
33 $abs_top_builddir/tools/virsh --connect test:///default >out 2>err '
34 # Create a series of checkpoints, with names that intentionally sort
35 # differently by topology than by name. For now, it is not possible
36 # to create fanout without hacking through redefines.
37 checkpoint-create-as test c1
38 checkpoint-create-as test c1
39 checkpoint-create-as test c3
40 checkpoint-create-as test c2
41 # snapshots cannot be created while checkpoints exist
42 echo --err marker
43 snapshot-create-as test s1
44 echo --err marker
45 # Checking tree view (siblings sorted alphabetically)
46 checkpoint-list test --tree
47 # Demonstrate list filtering
48 checkpoint-list test --roots
49 checkpoint-list test --leaves
50 checkpoint-list test --parent --no-leaves
51 checkpoint-list test --from c3
52 checkpoint-list test --from c1 --descendants --name
53 # Now the tree is linear, so we have an unambiguous topological order
54 checkpoint-list test --name
55 checkpoint-list test --name --topological
56 # Capture some XML for later redefine
57 checkpoint-delete test c1
58 echo "<!--MarkerA-->"
59 checkpoint-dumpxml test c3
60 echo "<!--MarkerB-->"
61 checkpoint-dumpxml test c2
62 echo "<!--MarkerC-->"
63 # Deleting current checkpoint moves current up to remaining parent
64 checkpoint-delete test --children-only c3
65 checkpoint-list test --leaves --name
66 checkpoint-delete test --children c3
67 checkpoint-list test --leaves --name
68 # All done
69 ' || fail=1
71 # First part is expected output, --tree results in trailing spaces,
72 # and checkpoint-list produces timestamps
73 sed 's/ *$//; s/[0-9-]\{10\} [0-9:.]* .[0-9]\{4\}/TIMESTAMP/;
74 /MarkerA/,/MarkerC/d' < out > out.cooked || fail=1
75 # Second part holds domain checkpoint XMLs
76 sed -n '/MarkerA/,/MarkerB/p' < out > c3.xml || fail=1
77 sed -n '/MarkerB/,/MarkerC/p' < out > c2.xml || fail=1
79 cat <<\EOF > exp || fail=1
80 Domain checkpoint c1 created
82 Domain checkpoint c3 created
83 Domain checkpoint c2 created
89 +- c3
91 +- c2
94 Name Creation Time
95 -----------------------------------
96 c1 TIMESTAMP
98 Name Creation Time
99 -----------------------------------
100 c2 TIMESTAMP
102 Name Creation Time Parent
103 --------------------------------------------
104 c1 TIMESTAMP
105 c3 TIMESTAMP c1
107 Name Creation Time
108 -----------------------------------
109 c2 TIMESTAMP
122 Domain checkpoint c1 deleted
124 Domain checkpoint c3 children deleted
128 Domain checkpoint c3 deleted
132 compare exp out.cooked || fail=1
134 cat <<EOF > exp || fail=1
135 error: operation failed: domain moment c1 already exists
136 error: marker
137 error: Operation not supported: cannot create snapshot while checkpoint exists
138 error: marker
140 compare exp err || fail=1
142 # Restore state with redefine
143 $abs_top_builddir/tools/virsh -c test:///default >out 2>err '
144 # Redefine must be in topological order; this will fail
145 checkpoint-create test --redefine c2.xml
146 echo --err marker
147 # This is the right order
148 checkpoint-create test --redefine c3.xml
149 checkpoint-create test --redefine c2.xml
150 checkpoint-list test --leaves --name
151 checkpoint-info test c2
152 ' || fail=1
154 cat <<\EOF > exp || fail=1
157 Domain checkpoint c3 created from 'c3.xml'
158 Domain checkpoint c2 created from 'c2.xml'
161 Name: c2
162 Domain: test
163 Parent: c3
164 Children: 0
165 Descendants: 0
168 compare exp out || fail=1
170 cat <<EOF > exp || fail=1
171 error: invalid argument: parent c3 for moment c2 not found
172 error: marker
174 compare exp err || fail=1
176 (exit $fail); exit $fail