On 09/08/2016 05:44 PM, Cleber Rosa wrote:
On 09/08/2016 11:34 AM, Marcos E. Matsunaga wrote:
Hi Cleber,
Thanks for your quick reply. That's exactly what I understood, but here
is what is happening
I have a directory ~/avocado/xen/tests where I have the xentest.py
script. When I execute it, it does create the directory
~/avocado/xen/tests/xentest.py.data with stderr.expected and
stdout.expected (empty). It also creates the two files (stdout and
stderr) in the job-results/latest directory, but also empty.
The weird thing is that instead of saving, it reports to the job.log as
an error "L0151 ERROR| [stderr] Parsing config from /VM/guest1/vm.cf".
That's why I think I am missing something.
Can you post the full test code and the resulting `job.log` file?
Sure.. It is attached.
And the multiplex file I am using is:
xentest:
guest1:
action: !mux
start:
run_action: "create"
domain_name: "perf1"
sleep_time: 1
stop:
run_action: "shutdown"
domain_name: "perf1"
sleep_time: 60
guest_cfg: /Repo/VM/perf1/vm.cfg
Thanks again for your help.
On 09/08/2016 02:59 PM, Cleber Rosa wrote:
On 09/08/2016 10:25 AM, Marcos E. Matsunaga wrote:
Hi All,
I am new to avocado and have just started to look into it.
I have been playing with avocado on Fedora 24 for a few weeks. I wrote a
small script to run commands and was exploring the option
"--output-check-record", but it never populate the files stderr.expected
and stdout.expected. Instead, it prints an error with "[stderr]" in the
job.log file. My understanding is that the output (stderr and stdout)
of commands/scripts executed by avocado would be captured and saved on
those files (like on synctest.py example), but it doesn't. I want to
know if I am doing something wrong or it is a bug.
Hi Marcos,
Avocado creates the `stdout` and `stderr` files in the test result
directory. In the synctest example, for instance, my contains:
$ avocado run examples/tests/synctest.py
$ cat
~/avocado/job-results/latest/test-results/1-examples_tests_synctest.py\:SyncTest.test/stdout
PAR : waiting
PASS : sync interrupted
`stderr` is actually empty for that test:
$ wc -l
~/avocado/job-results/latest/test-results/1-examples_tests_synctest.py\:SyncTest.test/stderr
0
/home/cleber/avocado/job-results/latest/test-results/1-examples_tests_synctest.py:SyncTest.test/stderr
What you have to do is, once you're satisfied with those outputs, and
they're considered "the gold standard", you'd move those to the test
*data directory*.
So, if you test is hosted at, `/tests/xl.py`, you'd created the
`/tests/xl.py.data`, and put those files there, named `stdout.expected`
and `stderr.expected`.
Whenever you run `avocado run --output-check-record all /tests/xl.py`,
those files will be used and the output of the *current* test execution
will be compared to those "gold standards".
The script is very simple and the way I execute the command is:
cmd = ('/usr/sbin/xl create /VM/guest1/vm.cfg')
if utils.system(cmd) == "0":
pass
else:
return False
The command send to stdout:
Parsing config from /VM/guest1/vm.cfg
I run the test as:
avocado run --output-check-record all xentest.py
The job.log file contains:
2016-09-07 13:04:48,015 test L0214 INFO | START
1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1
2016-09-07 13:04:48,051 xentest L0033 INFO |
1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1:
Running action create
2016-09-07 13:04:49,067 utils L0151 ERROR| [stderr] Parsing
config from /VM/guest1/vm.cfg
2016-09-07 13:04:49,523 test L0586 INFO | PASS
1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1
Thanks for your time and help.
Let me know if it's clear now! And thanks for trying Avocado out!
--
Regards,
Marcos Eduardo Matsunaga
Oracle USA
Linux Engineering
“The statements and opinions expressed here are my own and do not
necessarily represent those of Oracle Corporation.”
#!/usr/bin/env python
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
import os
import sys
import string
import logging
import commands
import time
from avocado import Test
from avocado import main
from autotest.client import utils
from autotest.client import xen
progress_log = logging.getLogger("progress")
class xentest(Test):
"""
Test
"""
def exec_xl(self):
"""
Start xen Guest
"""
sleeptime = self.params.get('sleep_time')
guestdef = self.params.get('guest_cfg')
runaction = self.params.get('run_action')
domname = self.params.get('domain_name')
progress_log.info('%s: Runninc action %s', self.name, runaction)
time.sleep(sleeptime)
if runaction == 'create':
cmd = ('/usr/sbin/xl %s %s' % (runaction, guestdef))
if utils.system(cmd, ignore_status=False) == "0":
pass
else:
return False
else:
cmd = ('/usr/sbin/xl %s %s' % (runaction, domname))
if utils.system(cmd, ignore_status=False) == "0":
pass
else:
return False
def test_xen_start_stop(self):
"""
Get Xen version
"""
fd = open('/tmp/xenver.log', 'w')
fd.write('### %s\n' % time.time())
cmd = "xl info|grep xen_version| awk '{print $3}'"
xenversion = utils.system_output(cmd, ignore_status=False)
utils.system('ls -la /usr/share/avocado/tests 2>&1')
print('Xen Version = %s.\n' % xenversion)
fd.write('Xen Version = %s.\n' % xenversion)
fd.write('### %s\n' % time.time())
if self.exec_xl() == "0":
pass
else:
return False
fd.close()
if __name__ == "__main__":
main()
2016-09-08 12:46:28,850 job L0343 INFO | Command line: /usr/bin/avocado run --output-check-record all /root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py --multiplex /root/avocado-vt/io-fs-autotest-xen/xen/cfg/xentest1.cfg
2016-09-08 12:46:28,850 job L0344 INFO |
2016-09-08 12:46:28,850 job L0349 INFO | Avocado version: 40.0
2016-09-08 12:46:28,850 job L0361 INFO |
2016-09-08 12:46:28,850 job L0366 INFO | Config files read (in order):
2016-09-08 12:46:28,850 job L0368 INFO | /etc/avocado/avocado.conf
2016-09-08 12:46:28,850 job L0368 INFO | /etc/avocado/conf.d/gdb.conf
2016-09-08 12:46:28,850 job L0368 INFO | /etc/avocado/conf.d/vt.conf
2016-09-08 12:46:28,850 job L0368 INFO | /root/.config/avocado/avocado.conf
2016-09-08 12:46:28,850 job L0373 INFO |
2016-09-08 12:46:28,850 job L0375 INFO | Avocado config:
2016-09-08 12:46:28,851 job L0384 INFO | Section.Key Value
2016-09-08 12:46:28,851 job L0384 INFO | datadir.paths.base_dir /usr/share/avocado
2016-09-08 12:46:28,851 job L0384 INFO | datadir.paths.test_dir /usr/share/avocado/tests
2016-09-08 12:46:28,851 job L0384 INFO | datadir.paths.data_dir /usr/share/avocado/data
2016-09-08 12:46:28,851 job L0384 INFO | datadir.paths.logs_dir ~/avocado/job-results
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collect.enabled False
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collect.installed_packages False
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collect.profiler False
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collectibles.commands /etc/avocado/sysinfo/commands
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collectibles.files /etc/avocado/sysinfo/files
2016-09-08 12:46:28,851 job L0384 INFO | sysinfo.collectibles.profilers /etc/avocado/sysinfo/profilers
2016-09-08 12:46:28,851 job L0384 INFO | runner.output.colored True
2016-09-08 12:46:28,851 job L0384 INFO | runner.output.utf8
2016-09-08 12:46:28,851 job L0384 INFO | runner.behavior.keep_tmp_files False
2016-09-08 12:46:28,851 job L0384 INFO | remoter.behavior.reject_unknown_hosts False
2016-09-08 12:46:28,851 job L0384 INFO | remoter.behavior.disable_known_hosts False
2016-09-08 12:46:28,851 job L0384 INFO | job.output.loglevel info
2016-09-08 12:46:28,851 job L0384 INFO | restclient.connection.hostname localhost
2016-09-08 12:46:28,851 job L0384 INFO | restclient.connection.port 9405
2016-09-08 12:46:28,851 job L0384 INFO | restclient.connection.username
2016-09-08 12:46:28,851 job L0384 INFO | restclient.connection.password
2016-09-08 12:46:28,852 job L0384 INFO | plugins.skip_broken_plugin_notification []
2016-09-08 12:46:28,852 job L0384 INFO | plugins.loaders ['file', '@DEFAULT']
2016-09-08 12:46:28,852 job L0384 INFO | gdb.paths.gdb /usr/bin/gdb
2016-09-08 12:46:28,852 job L0384 INFO | gdb.paths.gdbserver /usr/bin/gdbserver
2016-09-08 12:46:28,852 job L0384 INFO | vt.setup.backup_image_before_test True
2016-09-08 12:46:28,852 job L0384 INFO | vt.setup.restore_image_after_test True
2016-09-08 12:46:28,852 job L0384 INFO | vt.setup.keep_guest_running False
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.data_dir
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.type_specific_only False
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.mem 1024
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.arch
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.machine_type
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.nettype
2016-09-08 12:46:28,852 job L0384 INFO | vt.common.netdst virbr0
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.qemu_bin
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.qemu_dst_bin
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.accel kvm
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.vhost off
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.monitor human
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.smp 2
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.image_type qcow2
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.nic_model virtio_net
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.disk_bus virtio_blk
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.sandbox on
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.defconfig yes
2016-09-08 12:46:28,852 job L0384 INFO | vt.qemu.malloc_perturb yes
2016-09-08 12:46:28,852 job L0384 INFO | vt.libvirt.connect_uri qemu:///session
2016-09-08 12:46:28,853 job L0384 INFO | vt.debug.no_cleanup False
2016-09-08 12:46:28,853 job L0385 INFO |
2016-09-08 12:46:28,853 job L0390 INFO | Avocado Data Directories:
2016-09-08 12:46:28,853 job L0391 INFO |
2016-09-08 12:46:28,853 job L0392 INFO | Avocado replaces config dirs that can't be accessed
2016-09-08 12:46:28,853 job L0393 INFO | with sensible defaults. Please edit your local config
2016-09-08 12:46:28,853 job L0394 INFO | file to customize values
2016-09-08 12:46:28,853 job L0395 INFO |
2016-09-08 12:46:28,853 job L0396 INFO | base /usr/share/avocado
2016-09-08 12:46:28,853 job L0397 INFO | tests /usr/share/avocado/tests
2016-09-08 12:46:28,853 job L0398 INFO | data /usr/share/avocado/data
2016-09-08 12:46:28,853 job L0399 INFO | logs /root/avocado/job-results
2016-09-08 12:46:28,853 job L0400 INFO |
2016-09-08 12:46:28,853 job L0407 INFO | Multiplex tree representation:
2016-09-08 12:46:28,853 job L0409 INFO | \-- run
2016-09-08 12:46:28,853 job L0409 INFO | \-- xentest
2016-09-08 12:46:28,853 job L0409 INFO | \-- guest1
2016-09-08 12:46:28,854 job L0409 INFO | | -> guest_cfg: /Repo/VM/perf1/vm.cfg
2016-09-08 12:46:28,854 job L0409 INFO | \-- action
2016-09-08 12:46:28,854 job L0409 INFO | #== start
2016-09-08 12:46:28,854 job L0409 INFO | # -> domain_name: perf1
2016-09-08 12:46:28,854 job L0409 INFO | # -> run_action: create
2016-09-08 12:46:28,854 job L0409 INFO | # -> sleep_time: 1
2016-09-08 12:46:28,854 job L0409 INFO | #== stop
2016-09-08 12:46:28,854 job L0409 INFO | -> domain_name: perf1
2016-09-08 12:46:28,854 job L0409 INFO | -> run_action: shutdown
2016-09-08 12:46:28,854 job L0409 INFO | -> sleep_time: 60
2016-09-08 12:46:28,854 job L0410 INFO |
2016-09-08 12:46:28,854 job L0414 INFO | Temporary dir: /var/tmp/avocado_uMObhD
2016-09-08 12:46:28,854 job L0415 INFO |
2016-09-08 12:46:28,854 job L0422 INFO | Variant 1: /run/xentest/guest1/action/start
2016-09-08 12:46:28,854 job L0422 INFO | Variant 2: /run/xentest/guest1/action/stop
2016-09-08 12:46:28,854 job L0425 INFO |
2016-09-08 12:46:28,854 job L0334 INFO | Job ID: c5a01246a29ca221ca9d865e4afcbb63c511983d
2016-09-08 12:46:28,854 job L0337 INFO |
2016-09-08 12:46:28,884 sysinfo L0338 INFO | Commands configured by file: /etc/avocado/sysinfo/commands
2016-09-08 12:46:28,884 sysinfo L0345 INFO | Files configured by file: /etc/avocado/sysinfo/files
2016-09-08 12:46:28,884 sysinfo L0362 INFO | Profilers configured by file: /etc/avocado/sysinfo/profilers
2016-09-08 12:46:28,884 sysinfo L0363 INFO | Profilers declared: ['vmstat 1', 'journalctl -f']
2016-09-08 12:46:28,884 sysinfo L0371 INFO | Profiler disabled
2016-09-08 12:46:28,885 test L0214 INFO | START 1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1
2016-09-08 12:46:28,922 xentest L0030 INFO | 1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1: Runninc action create
2016-09-08 12:46:29,938 utils L0151 ERROR| [stderr] Parsing config from /Repo/VM/perf1/vm.cfg
2016-09-08 12:46:30,414 test L0586 INFO | PASS 1-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;1
2016-09-08 12:46:30,414 test L0567 INFO |
2016-09-08 12:46:30,538 sysinfo L0338 INFO | Commands configured by file: /etc/avocado/sysinfo/commands
2016-09-08 12:46:30,538 sysinfo L0345 INFO | Files configured by file: /etc/avocado/sysinfo/files
2016-09-08 12:46:30,539 sysinfo L0362 INFO | Profilers configured by file: /etc/avocado/sysinfo/profilers
2016-09-08 12:46:30,539 sysinfo L0363 INFO | Profilers declared: ['vmstat 1', 'journalctl -f']
2016-09-08 12:46:30,539 sysinfo L0371 INFO | Profiler disabled
2016-09-08 12:46:30,540 test L0214 INFO | START 2-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;2
2016-09-08 12:46:30,578 xentest L0030 INFO | 2-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;2: Runninc action shutdown
2016-09-08 12:47:30,656 utils L0151 ERROR| [stderr] Shutting down domain 55
2016-09-08 12:47:30,658 test L0586 INFO | PASS 2-/root/avocado-vt/io-fs-autotest-xen/xen/tests/xentest.py:xentest.test_xen_start_stop;2
2016-09-08 12:47:30,659 test L0567 INFO |
2016-09-08 12:47:30,767 job L0506 INFO | Test results available in /root/avocado/job-results/job-2016-09-08T12.46-c5a0124