Skip to content

Conversation

glehmann
Copy link
Member

@glehmann glehmann commented Oct 2, 2025

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.

@glehmann glehmann requested review from Nambrok and Wescoeur October 2, 2025 14:31
@glehmann glehmann changed the title Add coalesce integrity test on most SR types Add coalesce integrity tests on most SR types Oct 2, 2025


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
Copy link
Member

@stormi stormi Oct 2, 2025

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

Copy link
Member Author

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:
Copy link
Contributor

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.

Copy link
Member Author

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.

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')
Copy link
Contributor

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 :)

Copy link
Member Author

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

Copy link
Member Author

@glehmann glehmann Oct 8, 2025

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

try:
vm.start()
vm.wait_for_vm_running_and_ssh_up()
install_randstream(vm)
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member Author

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")
Copy link
Contributor

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.

Copy link
Member Author

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.

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})
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@glehmann glehmann force-pushed the gln/coalesce branch 3 times, most recently from 31d71e1 to 5ff2af9 Compare October 8, 2025 15:38
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:
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member Author

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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants