Skip to content

Refactor virt module integration tests#57736

Closed
rst0git wants to merge 18 commits intosaltstack:masterfrom
rst0git:virt-integration-tests
Closed

Refactor virt module integration tests#57736
rst0git wants to merge 18 commits intosaltstack:masterfrom
rst0git:virt-integration-tests

Conversation

@rst0git
Copy link
Copy Markdown
Contributor

@rst0git rst0git commented Jun 19, 2020

What does this PR do?

This PR is rebased on #57431. It adds two integration test targets -- virt_minion_0 and virt_minion_1. These targets are based on a container image (https://github.com/rst0git/virt-minion) with pre-installed libvirt and qemu packages. This approach allows to run more than one libvirtd+minion instance on a single system to automate the testing of features such as live migration.

Previous Behavior

The virt module integration tests require a libvirt daemon to be running on the host system.

New Behavior

The virt module integration tests require a docker daemon to be running on the host system.

rst0git added 10 commits June 18, 2020 06:53
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
When get_profiles() fails, it returns a string with an error message.
This causes the integration tests to fail as follows:

-> integration.modules.test_virt.VirtTest.test_default_esxi_profile
	Traceback (most recent call last):
	File "/salt/tests/integration/modules/test_virt.py", line 38, in test_default_esxi_profile
		nicp = profiles["nic"]["default"]
	TypeError: string indices must be integers

By asserting the return type of get_profiles(), the error message would
indicate the actual reason for the failure:

-> integration.modules.test_virt.VirtTest.test_default_esxi_profile
	Traceback (most recent call last):
	File "/salt/tests/integration/modules/test_virt.py", line 39, in test_default_esxi_profile
		self.assertIsInstance(profiles, dict)
	AssertionError: 'ERROR: Sorry, localhost failed to open a connection to the hypervisor software at None' is not an instance of <class 'dict'>

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
The output from libvirt's virConnectGetCapabilities
might contain zero or more `guest` elements [1].

This commit introduces an appropriate error message shown
when the number of guest elements is 0.

[1] https://libvirt.org/formatcaps.html

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
In commit [1] the use of the 'esxi' hypervisor was replaced with
'vmware'. This commit updates the integration test and documentation
string to match this change.

A number of new arguments have been introduced to _disk_profile(),
however, get_profiles() assumes that both _disk_profile() and
_nic_profile() take as input the same arguments.

In particular, commit [2] introduced the `pool` argument and
commit [3] introduced `disks`, `vm_name` and `image`. In commit [4]
were removed the default values for the new arguments added to
_disk_profile(), which results in get_profiles() to fail with
'invalid arguments' error. The changes introduced in this commit
should resolve this error. In addition, the integration tests have
been updated to reflect this and other changes.

The integration tests require the Python bindings for libvirt to be
installed (`pip install libvirt-python`) and a local libvirt daemon
instance (`systemctl start libvirtd`).

The tests can be executed with:

	python tests/runtests.py -n integration.modules.test_virt

[1] saltstack@34d1b34
[2] saltstack@7555172
[3] saltstack@5479f88
[4] saltstack@8ed54cd

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
The bash autocomplete includes the utility functions check_remote and
download_remote. These are functions are not intended to be directly
used by users.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git force-pushed the virt-integration-tests branch 7 times, most recently from 634bb70 to 618a2d9 Compare June 22, 2020 08:44
The virt minion targets are used for integration testing of the virt
module. The targets are based on a container image with preinstalled
libvirt and qemu.

The salt source repository and configuration files are bind-mounted
within the container where a salt-minion instance is started.

The host's network stack (--network=host) is used to allow the
salt-minion inside the container to connect to the salt-master running
on the host.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Copy link
Copy Markdown
Contributor

@cbosdo cbosdo left a comment

Choose a reason for hiding this comment

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

LGTM, let's see how the CI digests it

@cbosdo
Copy link
Copy Markdown
Contributor

cbosdo commented Jun 22, 2020

@waynew @Ch3LL could you have a look at this PR and tell us how that could play with the CI?

cbosdo
cbosdo previously approved these changes Jun 22, 2020
Copy link
Copy Markdown
Contributor

@cbosdo cbosdo left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the code factorization.

The code used to start virt_minion_0 and virt_minion_1 is very similar
and can be abstracted into a function (start_virt_daemon).

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git force-pushed the virt-integration-tests branch from b0132e6 to 0ddd37a Compare June 22, 2020 17:03
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
cbosdo
cbosdo previously approved these changes Jun 24, 2020
Copy link
Copy Markdown
Contributor

@cbosdo cbosdo left a comment

Choose a reason for hiding this comment

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

👍

@rst0git rst0git force-pushed the virt-integration-tests branch 2 times, most recently from 7cf360e to f18ba22 Compare July 3, 2020 11:40
@rst0git rst0git force-pushed the virt-integration-tests branch from f18ba22 to bcf0b51 Compare July 3, 2020 12:45
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git force-pushed the virt-integration-tests branch 2 times, most recently from 034e807 to cf439c8 Compare July 3, 2020 13:45
rst0git added 2 commits July 3, 2020 14:46
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
`docker run` does not pull the latest version of an image if that image
already exists locally.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git force-pushed the virt-integration-tests branch 2 times, most recently from eecacdd to 86e1635 Compare July 6, 2020 12:52
When define_xml_path has caused libvirtError exception the output
format is of type string and using only equality assertion will not
show the actual error message.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git rst0git marked this pull request as ready for review July 6, 2020 13:34
@rst0git rst0git requested a review from a team as a code owner July 6, 2020 13:34
@ghost ghost requested review from krionbsd and removed request for a team July 6, 2020 13:34
@s0undt3ch
Copy link
Copy Markdown
Contributor

Please do not merge this PR, it's blocked on external changes happening first.
Please read #57897 (comment) for context.

I will reply once the issues have been resolved to unblock this PR.

@rst0git
Copy link
Copy Markdown
Contributor Author

rst0git commented Aug 20, 2020

Closing in favour of #57947

@rst0git rst0git closed this Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants