Skip to content

Commit

Permalink
Merge pull request #1 from smitterl/avocado_list
Browse files Browse the repository at this point in the history
[filter_avocado_list] add script to integrate with avocado list
  • Loading branch information
smitterl authored Mar 4, 2021
2 parents a38d863 + 19b2a74 commit 96b40b2
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,45 @@ https://github.com/avocado-framework/avocado-vt/ uses cartesian_config to create
The `pairwise` takes a list of test case names (p1.p2.p3, e.g. virsh.domstats.argument) and filters out test cases whose test parameter values, represented by the variant name, have already been covered in another test case earlier in the list.

An example of what will be filtered can be seen in the unit test.

Example:

A filtered output could look like:
```bash
# python3 filter_avocado_list.py -s virsh.boot,boot_integration
virsh.boot.loadparm
virsh.boot.by_seabios.positive_test.options.boot.hd.file_disk.boot_dev.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.file_disk.boot_dev.os_loader.valid_loader_type.no_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.file_disk.boot_dev.os_loader.no_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.file_disk.boot_order.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.block_disk.boot_dev.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.network_disk.ceph.boot_dev.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.network_disk.ceph.boot_dev.os_loader.valid_loader_type.no_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.network_disk.ceph.boot_dev.os_loader.no_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.network_disk.ceph.boot_order.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.hd.network_disk.glusterfs.boot_dev.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.cdrom.boot_dev.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.cdrom.boot_dev.os_loader.valid_loader_type.no_readonly
virsh.boot.by_seabios.positive_test.options.boot.cdrom.boot_dev.os_loader.no_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.boot.cdrom.boot_order.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.options.no_boot.os_loader.valid_loader_type.valid_readonly
virsh.boot.by_seabios.positive_test.boot_order_big_integer
virsh.boot.by_seabios.positive_test.two_same_boot_dev
virsh.boot.by_seabios.negative_test.not_existing_loader
virsh.boot.by_seabios.negative_test.not_existing_loader_type
virsh.boot.by_seabios.negative_test.not_existing_boot_dev
virsh.boot.by_seabios.negative_test.special_boot_order.negative
virsh.boot.by_seabios.negative_test.special_boot_order.character
virsh.boot.by_seabios.negative_test.special_boot_order.zero
boot_integration.by_qemu_on_s390.boot_dev.check_menu
boot_integration.by_qemu_on_s390.boot_dev.boot_non_default

The number of test cases was reduced from 52 to 26.
```

The filter can be double checked by
```bash
# python3 filter_avocado_list.py -t virsh.boot,boot_integration > original.list
# python3 filter_avocado_list.py virsh.boot,boot_integration > filtered.list
diff -y filtered.list original.list
```
File renamed without changes.
65 changes: 65 additions & 0 deletions filter_avocado_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import re
import subprocess
import sys
from filter import pairwise

# holds the vt only filter
ONLY = []
PRINT_ORIGINAL = False
SHOW_STATS = False

def print_help(exit_code):
print(sys.argv[0] + " [-t] [-s] <--vt-only-filter argument>")
print()
print(" <vt-only-filter> is a comma separated list of test names")
print(" by passing flag -t the avocado command result is printed and not filtered")
print(" by passing flag -s the number of original test names and filtered ones are shown")
sys.exit(exit_code)

def parse_args():
if len(sys.argv) == 1:
print_help(1)

global ONLY
ONLY = sys.argv[-1]

if ONLY.startswith("-h"):
print_help(0)

if "-t" in sys.argv:
global PRINT_ORIGINAL
PRINT_ORIGINAL = True

if "-s" in sys.argv:
global SHOW_STATS
SHOW_STATS = True

def get_avocado_list():
test_names = []
command = ("avocado list --vt-type libvirt --vt-machine-type s390-virtio"
" --vt-only-filter %s --paginator off" % ONLY)
output = subprocess.check_output(command, shell=True).decode()
for row in output.split('\n'):
if not row.startswith("VT"):
continue
test_names.append(re.sub("VT\\s+.*autotest-libvirt.", "", row))
return test_names


if __name__ == '__main__':
parse_args()
test_names = get_avocado_list()
if PRINT_ORIGINAL:
for name in test_names:
print(name)
sys.exit(0)

filtered_test_names = pairwise(test_names)
for name in filtered_test_names:
print(name)

if SHOW_STATS:
print()
print("The number of test cases was reduced"
" from %s to %s." % (len(test_names),
len(filtered_test_names)))

0 comments on commit 96b40b2

Please sign in to comment.