Repository: avocado-framework/avocado-vt

Issue:
problem in case of avocado vt-bootstrap --vt-type libvirt  
Hello,
I installed avocado/avocado-vt according to the manual described here http://avocado-vt.readthedocs.org/en/latest/GetStartedGuide.html and wanted to try it with libvirt.
First I performed the bootstrap step as it's described: avocado vt-bootstrap --vt-type libvirt  
Then checked with avocado plugins -> no errors.
But when I wanted to list the tests I got the following error:
avocado list --verbose
*\* Message: pygobject_register_sinkfunc is deprecated (GstObject)
Test discovery plugin <avocado.core.plugins.virt_test.VirtTestLoader object at 0x7f1f3f8c5590> failed: 'include base.cfg' (/usr/share/avocado/data/avocado-vt/backends/qemu/cfg/tests-shared.cfg:13): file does not exist or it's not a regular file

looks like the config file is taken from the qemu dir and not from the libvirt one (and there is no base.cfg in qemu subdir, but there is one in libvirt subdir)

ls -la /usr/share/avocado/data/avocado-vt/backends/qemu/cfg/
total 16
drwxr-xr-x. 2 root root 4096 Aug  5 15:20 .
drwxr-xr-x. 3 root root 4096 Aug  5 15:03 ..
-rw-r--r--. 1 root root  373 Aug  4 03:58 tests.cfg
-rw-r--r--. 1 root root 1312 Aug  4 03:58 tests-shared.cfg

ls -la /usr/share/avocado/data/avocado-vt/backends/libvirt/cfg/
total 1304
drwxr-xr-x. 2 root root   4096 Aug  5 15:20 .
drwxr-xr-x. 3 root root   4096 Aug  5 15:03 ..
-rw-r--r--. 1 root root  17202 Aug  5 15:04 base.cfg
-rw-r--r--. 1 root root    526 Aug  5 15:04 cdkeys.cfg
-rw-r--r--. 1 root root   8472 Aug  4 03:58 default_tests
-rw-r--r--. 1 root root    329 Aug  4 03:58 drivers.cfg
-rw-r--r--. 1 root root  13303 Aug  5 15:04 guest-hw.cfg
-rw-r--r--. 1 root root 295070 Aug  5 15:52 guest-os.cfg
-rw-r--r--. 1 root root   1008 Aug  5 15:04 machines.cfg
-rw-r--r--. 1 root root 947043 Aug  5 15:52 subtests.cfg
-rw-r--r--. 1 root root    688 Aug  4 03:58 tests.cfg
-rw-r--r--. 1 root root    989 Aug  4 03:58 tests-shared.cfg
-rw-r--r--. 1 root root   7595 Aug  5 15:04 virtio-win.cfg

Looks like I don't do anything wrong in the steps above, so probably it's an issue related to libvirt type in avocado?

Thank you



Discussion:
looks like it is expecting bootstrap of qemu by default, try doing below
avocado vt-bootstrap --vt-type qemu
Check if you can get rid of this error, in anycase, I guess this is issue to be looked at.
@lmr @adereis 

am using avocado version 27 and able to list the tests using the same
$ avocado --version
Avocado 0.27.0
$avocado list --verbose
....
.....
ACCESS_DENIED: 0
BROKEN_SYMLINK: 0
BUGGY: 0
FILTERED: 0
INSTRUMENTED: 52
MISSING: 0
NOT_A_TEST: 30
SIMPLE: 1
VT: 1907

Yes, I tried it also with --vt-type qemu and it was working without errors. The error occurs with --vt-type libvirt case

Thanks

@svirt I can't reproduce the error you're having, my setup goes on just fine.

And lists tests just fine as well

OK, I found a way to reproduce it. Hang on.


Resolving patch:
diff --git a/virttest/bootstrap.py b/virttest/bootstrap.py
--- a/virttest/bootstrap.py
+++ b/virttest/bootstrap.py
@@ -1,3 +1,4 @@
+import distutils
 import logging
 import os
 import glob
@@ -476,7 +477,11 @@ def is_file_tracked(fl):
                 else:
                     logging.debug("Preserving existing %s file", dst_file)
             else:
-                logging.debug("Config file %s exists, not touching", dst_file)
+                if force_update:
+                    update_msg = 'Config file %s exists, equal to sample'
+                else:
+                    update_msg = 'Config file %s exists, not touching'
+                logging.debug(update_msg, dst_file)
     return step
 
 
@@ -738,6 +743,12 @@ def bootstrap(options, interactive=False):
             logging.debug("Dir %s exists, not creating",
                           sub_dir_path)
 
+    base_backend_dir = data_dir.get_base_backend_dir()
+    local_backend_dir = data_dir.get_local_backend_dir()
+    logging.info("Syncing backend dirs %s -> %s", base_backend_dir,
+                 local_backend_dir)
+    distutils.dir_util.copy_tree(base_backend_dir, local_backend_dir)
+
     test_dir = data_dir.get_backend_dir(options.vt_type)
     if options.vt_type == 'libvirt':
         step = create_config_files(test_dir, shared_dir, interactive, step,
diff --git a/virttest/data_dir.py b/virttest/data_dir.py
--- a/virttest/data_dir.py
+++ b/virttest/data_dir.py
@@ -133,13 +133,18 @@ def get_shared_dir():
     return SHARED_DIR
 
 
+def get_base_backend_dir():
+    return BASE_BACKEND_DIR
+
+
+def get_local_backend_dir():
+    return os.path.join(get_data_dir(), 'backends')
+
+
 def get_backend_dir(backend_type):
     if backend_type not in os.listdir(BASE_BACKEND_DIR):
         raise UnknownBackendError(backend_type)
-    dst = os.path.join(get_data_dir(), 'backends')
-    if not os.path.isdir(dst):
-        shutil.copytree(BASE_BACKEND_DIR, dst)
-    return os.path.join(dst, backend_type)
+    return os.path.join(get_local_backend_dir(), backend_type)
 
 
 def get_backend_cfg_path(backend_type, cfg_basename):


Test patch: