-
Notifications
You must be signed in to change notification settings - Fork 6
Add coalesce integrity tests on most SR types #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
|
||
def install_randstream(vm: 'VM'): | ||
vm.ssh("wget -nv https://github.com/xcp-ng/randstream/releases/download/0.3.1/randstream-0.3.1-x86_64-unknown-linux-musl.tar.gz -O - | tar -xzC /usr/bin/ ./randstream") # noqa: E501 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something we should package instead? It's inside the VM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add it to the Alpine image, but it seems simpler this way
lib/sr.py
Outdated
return self._type | ||
|
||
def create_vdi(self, name_label: str, virtual_size: int = 64, image_format: Optional[str] = None) -> VDI: | ||
def create_vdi(self, name_label: str, virtual_size: int | str = 64, image_format: Optional[str] = None) -> VDI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to choose between int or string. String make sense with how you want to use it 1GiB
, so we could replace the default value to be a string and check caller to change them to use a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree if create_vdi()
wasn't used in some untyped code. For now, using it this way seems safer in order not to break existing code.
tests/storage/ext/conftest.py
Outdated
def vdi_on_ext_sr(ext_sr): | ||
vdi = ext_sr.create_vdi('EXT-local-VDI-test') | ||
def vdi_on_ext_sr(ext_sr: 'SR'): | ||
vdi = ext_sr.create_vdi('EXT-local-VDI-test', virtual_size='1GiB') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change it in the default value of the function if you intend to change it everywhere :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it could be better. I haven't checked if it's used somewhere else, where it wouldn't make sense to require a larger disk though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems ok, I'll use 1GiB
by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/storage/ext/test_ext_sr.py
Outdated
from lib.fistpoint import FistPoint | ||
from lib.vdi import VDI | ||
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open | ||
from tests.storage.storage import install_randstream, operation_on_vdi, wait_for_vdi_coalesce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add them in the tests/storage/__init__.py
import to avoid the double storage like it's done for vdi_is_open
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/storage/ext/test_ext_sr.py
Outdated
try: | ||
vm.start() | ||
vm.wait_for_vm_running_and_ssh_up() | ||
install_randstream(vm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best to do it in a fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make us either:
- start the vm, install randstream and stop the vm
- attach/detach the vdi on the running vm
Is that ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your fixture could give the VM powered on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and attaching a VDI to a running VM if it has the PV drivers is ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
vm.wait_for_vm_running_and_ssh_up() | ||
install_randstream(vm) | ||
vm.ssh("randstream generate -v /dev/xvdb") | ||
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you getting the expected checksum that is hardcoded?
There is a seed on the second generate call a few lines later but not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generate a first stream with the same size and copy/paste it.
This run uses the default seed (0
). The second one uses a different seed to write something different on the disk.
tests/storage/ext/test_ext_sr.py
Outdated
new_vdi = operation_on_vdi(vm.host, vdi.uuid, vdi_op) | ||
vm.ssh("randstream generate -v --seed 1 --size 128Mi /dev/xvdb") | ||
vm.ssh("randstream validate -v --expected-checksum ad2ca9af /dev/xvdb") | ||
vm.host.xe("vdi-destroy", {"uuid": new_vdi.uuid}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just do new_vdi.destroy()
like you do in the finally
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests/storage/lvm/test_lvm_sr.py
Outdated
from lib.fistpoint import FistPoint | ||
from lib.vdi import VDI | ||
from tests.storage import try_to_create_sr_with_missing_device, vdi_is_open | ||
from tests.storage.storage import install_randstream, operation_on_vdi, wait_for_vdi_coalesce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, adding the import in __init__.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
31d71e1
to
5ff2af9
Compare
lib/sr.py
Outdated
return self._type | ||
|
||
def create_vdi(self, name_label: str, virtual_size: int = 64, image_format: Optional[str] = None) -> VDI: | ||
def create_vdi(self, name_label: str, virtual_size: int | str = '1GiB', image_format: Optional[str] = None) -> VDI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of type unions except in special cases. Here, I think we should define an alias because I'm afraid we'll have to specify the union in several places in the tests in the future like resize tests.
For example:
Size = int | str
...
def create_vdi(self, name_label: str, virtual_size: Size = '1GiB', image_format: Optional[str] = None) -> VDI:
Otherwise it's fine to use: 2**30 directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why it would propagate to other types, and 2**30
is not clear at all for me.
Would you be ok if I define some constants KiB
, GiB
, TiB
that can be used as 2 * GiB
, instead of passing a string for virtual_size
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
So we have something to write to. 1GiB seems small enough to not impact performance or request all the resources Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Signed-off-by: Gaëtan Lehmann <[email protected]>
Not sure if others should be covered as well.
I've removed the coalesce tests based on
dom0
, because they seemed redundant, but we could also keep them. Just let me know.