avocado
avocado copied to clipboard
bystatus.py: Use relative path to create symbolic link
bystatus.py: Use relative path to create symbolic link
The current design uses an absolute path to create symbolic link, this means no matter where the log files are moved/uploaded, the soft link always link to the original directory. This doesn't make sense, so replace it to use relative path, make them link to the correct path.
Signed-off-by: Yihuang Yu [email protected]
Example:
# Without the fix:
$ ll /tmp/log_path/test-results/by-status/FAIL/16-qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-libvirt.controller.functional.positive_tests.virtio_serial_0_vectors.arm64-pci
lrwxrwxrwx 1 root root 225 Aug 17 22:51 /tmp/log_path/test-results/by-status/FAIL/16-qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-libvirt.controller.functional.positive_tests.virtio_serial_0_vectors.arm64-pci -> /root/avocado/job-results/job-2022-08-17T05.03-3aa663a/test-results/16-qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-libvirt.controller.functional.positive_tests.virtio_serial_0_vectors.arm64-pci
# With the fix:
$ ll /tmp/log_path_fixed/test-results/by-status/PASS/1-qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-qemu.boot.arm64-pci
lrwxrwxrwx 1 root root 119 Aug 18 02:14 /tmp/log_path_fixed/test-results/by-status/PASS/1-qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-qemu.boot.arm64-pci -> ../../1-Host_RHEL.m9.u1.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.1.0.aarch64.io-github-autotest-qemu.boot.arm64-pci
The PR wants to fix the issue: If users upload the log files into NFS or somewhere, then the absolute path cannot be accessed in other hosts, so users cannot analyze results from by-status
Hello @beraldoleal, wish this solution is a reasonable fix, please help to review it, thanks.
The change to the plugin looks good, but you need to address the test error:
avocado-framework/avocado/runs/7892854243?check_suite_focus=true#step:10:2362
AFAICT, it's only about getting the fact that
os.readlink
expects you to do more to get a valid path when a link is relative:docs.python.org/3/library/os.html?highlight=readlink#os.readlink
if it is relative, it may be converted to an absolute pathname using
os.path.join(os.path.dirname(path), result)
.
Thank you @clebergnu. Leaving out unit tests is a bad habit, thanks for pointing it out, I already updated to cover it, and also add a new checkpoint os.path.samefile(logdir, link)
, to check if the symlink and the log dir are the same.
Merged as https://github.com/avocado-framework/avocado/pull/5542