mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virshtest: Adapt 'virsh-start' and 'virsh-undefine' tests as 'lifecycle' case
The 'virsh-start' case simply tried to start an already running VM. This can be easily tested together with the tests for undefining a VM. For this test the test driver config with multiple VMs comes handy as we need to test 3 situations when we undefine and stop the VM. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6bc71ed27c
commit
a068dec641
@ -696,8 +696,6 @@ if conf.has('WITH_LIBVIRTD')
|
||||
'virsh-read-non-seekable',
|
||||
'virsh-self-test',
|
||||
'virsh-snapshot',
|
||||
'virsh-start',
|
||||
'virsh-undefine',
|
||||
'virsh-uriprecedence',
|
||||
'virt-admin-self-test',
|
||||
]
|
||||
|
@ -1,41 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ensure that virsh start works properly
|
||||
|
||||
# Copyright (C) 2008 Red Hat, Inc.
|
||||
|
||||
# This program 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 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program 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 this program. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
. "$(dirname $0)/test-lib.sh"
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
$abs_top_builddir/tools/virsh --version
|
||||
fi
|
||||
|
||||
fail=0
|
||||
|
||||
test_url=test:///default
|
||||
|
||||
# expect this to fail
|
||||
$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail=1
|
||||
|
||||
# stdout gets a newline
|
||||
echo > exp || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
echo 'error: Domain is already active' > exp || fail=1
|
||||
compare exp err || fail=1
|
||||
|
||||
(exit $fail); exit $fail
|
@ -1,76 +0,0 @@
|
||||
#!/bin/sh
|
||||
# exercise virsh's "undefine" command
|
||||
|
||||
# Copyright (C) 2008-2009, 2011 Red Hat, Inc.
|
||||
|
||||
# This program 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 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program 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 this program. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
. "$(dirname $0)/test-lib.sh"
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
$abs_top_builddir/tools/virsh --version
|
||||
fi
|
||||
|
||||
fail=0
|
||||
|
||||
# Attempt to undefine a running domain, by domain name. Every time a new
|
||||
# connection is opened to the test driver, it starts life with a new
|
||||
# persistent running domain named 'test' with a different uuid, so
|
||||
# testing this command requires batch mode use of virsh.
|
||||
$abs_top_builddir/tools/virsh -c test:///default \
|
||||
'dominfo test; undefine test; dominfo test' > out1 2>&1
|
||||
test $? = 0 || fail=1
|
||||
sed '/^Persistent/n; /:/d' < out1 > out
|
||||
cat <<\EOF > exp || fail=1
|
||||
Persistent: yes
|
||||
|
||||
Domain 'test' has been undefined
|
||||
|
||||
Persistent: no
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# A similar diagnostic when specifying a domain ID
|
||||
$abs_top_builddir/tools/virsh -c test:///default \
|
||||
'dominfo 1; undefine 1; dominfo 1' > out1 2>&1
|
||||
test $? = 0 || fail=1
|
||||
sed '/^Persistent/n; /:/d' < out1 > out
|
||||
cat <<\EOF > exp || fail=1
|
||||
Persistent: yes
|
||||
|
||||
Domain '1' has been undefined
|
||||
|
||||
Persistent: no
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# Succeed, now: first shut down, then undefine, both via name.
|
||||
$abs_top_builddir/tools/virsh -c test:///default \
|
||||
'shutdown test; undefine test; dominfo test' > out 2>&1
|
||||
test $? = 1 || fail=1
|
||||
cat <<\EOF > expout || fail=1
|
||||
Domain 'test' is being shutdown
|
||||
|
||||
Domain 'test' has been undefined
|
||||
|
||||
error: failed to get domain 'test'
|
||||
|
||||
EOF
|
||||
compare expout out || fail=1
|
||||
|
||||
(exit $fail); exit $fail
|
@ -213,6 +213,7 @@ mymain(void)
|
||||
DO_TEST_SCRIPT_FULL("numeric-parsing-event", true, NULL, VIRSH_DEFAULT);
|
||||
DO_TEST_SCRIPT("attach-disk", NULL, VIRSH_DEFAULT);
|
||||
DO_TEST_SCRIPT("vcpupin", NULL, VIRSH_DEFAULT);
|
||||
DO_TEST_SCRIPT("lifecycle", "\nCPU time:", VIRSH_CUSTOM);
|
||||
|
||||
DO_TEST_FULL("domain-id-overflow", NULL, VIRSH_CUSTOM, "-q", "domname", "4294967298");
|
||||
DO_TEST_FULL("schedinfo-invalid-argument", NULL, VIRSH_DEFAULT, "schedinfo", "1", "--set", "j=k");
|
||||
|
23
tests/virshtestdata/lifecycle.in
Normal file
23
tests/virshtestdata/lifecycle.in
Normal file
@ -0,0 +1,23 @@
|
||||
list --all
|
||||
|
||||
echo test failure when starting already running guest
|
||||
start fv0
|
||||
|
||||
echo undefine a running domain - by domain name
|
||||
dominfo fc4
|
||||
undefine fc4
|
||||
dominfo fc4
|
||||
shutdown fc4
|
||||
dominfo fc4
|
||||
|
||||
echo undefine a running domain - by domain id
|
||||
dominfo 3
|
||||
undefine 3
|
||||
dominfo 3
|
||||
shutdown 3
|
||||
dominfo fc5
|
||||
|
||||
echo shutdown then undefine
|
||||
shutdown fv0
|
||||
undefine fv0
|
||||
dominfo fv0
|
106
tests/virshtestdata/lifecycle.out
Normal file
106
tests/virshtestdata/lifecycle.out
Normal file
@ -0,0 +1,106 @@
|
||||
Id Name State
|
||||
----------------------
|
||||
1 fv0 running
|
||||
2 fc4 running
|
||||
3 fc5 running
|
||||
|
||||
test failure when starting already running guest
|
||||
error: Domain is already active
|
||||
|
||||
undefine a running domain - by domain name
|
||||
Id: 2
|
||||
Name: fc4
|
||||
UUID: ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 1
|
||||
Max memory: 261072 KiB
|
||||
Used memory: 131072 KiB
|
||||
Persistent: yes
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: network configuration using opaque shell scripts
|
||||
|
||||
Domain 'fc4' has been undefined
|
||||
|
||||
Id: 2
|
||||
Name: fc4
|
||||
UUID: ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 1
|
||||
Max memory: 261072 KiB
|
||||
Used memory: 131072 KiB
|
||||
Persistent: no
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: network configuration using opaque shell scripts
|
||||
|
||||
Domain 'fc4' is being shutdown
|
||||
|
||||
error: failed to get domain 'fc4'
|
||||
|
||||
undefine a running domain - by domain id
|
||||
Id: 3
|
||||
Name: fc5
|
||||
UUID: 08721f99-3d1d-4aec-96eb-97803297bb36
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 4
|
||||
Max memory: 2097152 KiB
|
||||
Used memory: 2097152 KiB
|
||||
Persistent: yes
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: running with undesirable elevated privileges
|
||||
tainted: network configuration using opaque shell scripts
|
||||
tainted: use of host cdrom passthrough
|
||||
tainted: custom device tree blob used
|
||||
tainted: use of deprecated configuration settings
|
||||
deprecated configuration: CPU model Deprecated-Test
|
||||
|
||||
Domain '3' has been undefined
|
||||
|
||||
Id: 3
|
||||
Name: fc5
|
||||
UUID: 08721f99-3d1d-4aec-96eb-97803297bb36
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 4
|
||||
Max memory: 2097152 KiB
|
||||
Used memory: 2097152 KiB
|
||||
Persistent: no
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: running with undesirable elevated privileges
|
||||
tainted: network configuration using opaque shell scripts
|
||||
tainted: use of host cdrom passthrough
|
||||
tainted: custom device tree blob used
|
||||
tainted: use of deprecated configuration settings
|
||||
deprecated configuration: CPU model Deprecated-Test
|
||||
|
||||
Domain '3' is being shutdown
|
||||
|
||||
error: failed to get domain 'fc5'
|
||||
|
||||
shutdown then undefine
|
||||
Domain 'fv0' is being shutdown
|
||||
|
||||
Domain 'fv0' has been undefined
|
||||
|
||||
error: failed to get domain 'fv0'
|
||||
|
||||
|
||||
## Exit code: 1
|
Loading…
Reference in New Issue
Block a user