avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
336 stars 335 forks source link

converting utilitie to object oriented support. #5948

Open Naresh-ibm opened 3 weeks ago

Naresh-ibm commented 3 weeks ago

Moving the utilities to OOPs supported way to make them more useful and Robust.

Naresh-ibm commented 3 weeks ago

Hi @Naresh-ibm thank you for your contribution. This is a huge change and I think I don't know the whole story behind this, therefore I have a couple of questions and comments which I need to discuss.

1. I don't see any substitution for `distro` utility, what are the reasons for removing that?

2. Why are you creating the `block_devices` package? Are you planing to add more utils to that? Because if not, IMO the disk util cans stay where it is. If yes, certainly the `block_devices`  should be in separated commit with the explanation of future plans.

3. Even tho I understand the benefits of moving this to OOPs I am not sure about it, because it breaks the API which is used by our users, and it will definitely break many test suites. Therefore, I would propose together with this change keep the old API with the warning about deprecation in future releases and remove it after a release 107.

4. Maybe we should wait a little bit with this change and do it during the [migration to autils](https://avocado-framework.readthedocs.io/en/latest/blueprints/BP005.html). Because we would avoid the compatibility issues between new and old API.

Hi @richtja Thanks for your review points

  1. That was a mistake while removing other files. I have re-added it
  2. Yes, we are planning to add all disk/block device related libraries under this. for now we have moved disk.py.
  3. I have kept the existing disk.py and will be adding a deprecation massage as you suggest and after few days we can completely move to new package path.
Naresh-ibm commented 2 weeks ago

sample logs


>>> disk.freespace('/dev/nvme0n1')
4194304
>>> obj = disk.DiskUtils('/dev/nvme0n1', '/mnt')
>>> obj.freespace()
4194304
>>> 

>>> obj.get_disk_blocksize()
65536
>>> disk.get_disk_blocksize('/dev/nvme0n1')
65536
>>>

>>> obj = disk.DiskUtils('/dev/nvme0n1', '/mnt')
>>> obj.delete_loop_device('/dev/loop0')
True
>>> 
>>> 
>>> disk.create_loop_device(512)
'/dev/loop0'
>>> obj.delete_loop_device('/dev/loop0')
True
>>> 
>>> disk
disk
>>> disk.create_loop_device(512)
'/dev/loop0'
>>> 
>>> disk.delete_loop_device('/dev/loop0')
True
>>> 

>>> obj.get_absolute_disk_path()
'/dev/nvme0n1'
>>> disk.get_absolute_disk_path('/dev/nvme0n1')
'/dev/nvme0n1'
>>> 
>>> disk.get_absolute_disk_path('nvme0n1')
'/dev/nvme0n1'
>>> 
>>> obj.get_absolute_disk_path()
'/dev/nvme0n1'
>>> 
>>> obj.get_available_filesystems()
['autofs', 'pstore', 'proc', 'btrfs', 'fuseblk', 'bdev', 'fuse', 'tracefs', 'mqueue', 'tmpfs', 'ramfs', 'sockfs', 'configfs', 'cpuset', 'cgroup2', 'cgroup', 'hugetlbfs', 'securityfs', 'fusectl', 'pipefs', 'debugfs', 'sysfs', 'devpts', 'devtmpfs', 'bpf']
>>> 
>>> obj.get_available_filesystems()
['autofs', 'pstore', 'proc', 'btrfs', 'fuseblk', 'bdev', 'fuse', 'tracefs', 'mqueue', 'tmpfs', 'ramfs', 'sockfs', 'configfs', 'cpuset', 'cgroup2', 'cgroup', 'hugetlbfs', 'securityfs', 'fusectl', 'pipefs', 'debugfs', 'sysfs', 'devpts', 'devtmpfs', 'bpf']
>>> 

>>> obj.get_filesystem_type()
'btrfs'
>>> 
>>> disk.get_filesystem_type()
'btrfs'
>>>