[PATCH 25/35] virshtest: Adapt 'virsh-start' and 'virsh-undefine' tests as 'lifecycle' case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tests/meson.build                 |   2 -
 tests/virsh-start                 |  41 ------------
 tests/virsh-undefine              |  76 ---------------------
 tests/virshtest.c                 |   1 +
 tests/virshtestdata/lifecycle.in  |  23 +++++++
 tests/virshtestdata/lifecycle.out | 106 ++++++++++++++++++++++++++++++
 6 files changed, 130 insertions(+), 119 deletions(-)
 delete mode 100755 tests/virsh-start
 delete mode 100755 tests/virsh-undefine
 create mode 100644 tests/virshtestdata/lifecycle.in
 create mode 100644 tests/virshtestdata/lifecycle.out

diff --git a/tests/meson.build b/tests/meson.build
index 8392778a76..5a2a499461 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -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',
   ]
diff --git a/tests/virsh-start b/tests/virsh-start
deleted file mode 100755
index cb58c3b09c..0000000000
--- a/tests/virsh-start
+++ /dev/null
@@ -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
diff --git a/tests/virsh-undefine b/tests/virsh-undefine
deleted file mode 100755
index dbbb367391..0000000000
--- a/tests/virsh-undefine
+++ /dev/null
@@ -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
diff --git a/tests/virshtest.c b/tests/virshtest.c
index f4c41fca46..9cad18cf58 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -213,6 +213,7 @@ mymain(void)
     DO_TEST_SCRIPT_FULL("numeric-parsing-event", true, NULL, VIRSH_DEFAULT, "-q");
     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");
diff --git a/tests/virshtestdata/lifecycle.in b/tests/virshtestdata/lifecycle.in
new file mode 100644
index 0000000000..e585ad08e1
--- /dev/null
+++ b/tests/virshtestdata/lifecycle.in
@@ -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
diff --git a/tests/virshtestdata/lifecycle.out b/tests/virshtestdata/lifecycle.out
new file mode 100644
index 0000000000..1d87cb44f6
--- /dev/null
+++ b/tests/virshtestdata/lifecycle.out
@@ -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
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux