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

Create mechanism for plugging tests from the outside of core-admin repository #1800

Closed
marmarek opened this Issue Mar 2, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@marmarek
Member

marmarek commented Mar 2, 2016

It is really convenient to have a single test runner to launch all the Qubes tests. But some of them are barely related to core-admin repository (for example split GPG). Additionally (especially for qubes-app-*) it would be useful to have the same test running on any Qubes version (supported by such component).

This means that we need some API to allow tests from other repositories to be plugged into test runner (qubes.tests.run module). As discussed in #1368 we've settled on using entry points for that and providing some minimal stable API for creating VMs for the test purposes.

The API

External test case needs to expose entry point(s). Currently supported two of them:

  • qubes.tests.extra - test should be instantiated once
  • qubes.tests.extra.for_template - test should be instantiated for every template (generally should be used to testing some VM software)

Each of those entry points should be a function, which will return a list of classes derived from unittest.TestCase. This class will be mixed with Qubes-version specific class providing basic API for handling VMs:

  • create_vms(names) - create AppVMs with names given as a parameter (iterable of names); return list of created objects
  • enable_network() - created VMs should have access to the network (if available on the host)
  • qrexec_policy(service, source, destination) - allow qrexec calls described by parameters
  • shutdown_and_wait(vm, timeout=60) - ask given VM (VM object) to shutdown and wait for it to finish
  • remove_vms(vms) - remove VMs (list of VM objects)
  • save_and_reload_db() - ensure the changes are written to the disk (create_vms and remove_vms call it automatically, but if you make any additional changes, you need to call it on your own)

Additionally some useful functions are available:

  • wait_for_window(title, timeout=30, show=True) - wait for given window to show (or hide if show=False)
  • enter_keys_in_window(title, keys) - enter given keys into given window

Test case should take care of any other API compatibility on its own. In case of not supported API detected, it should call self.skipTest with appropriate message. For example:

try:
    vm.some_core_dependent_function(or_, core, dependent, params)
except (AttributeError, TypeError): 
    self.skip('core API mismatch')

@marmarek marmarek self-assigned this Mar 2, 2016

@marmarek marmarek added this to the Release 3.1 updates milestone Mar 2, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 3, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 3, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 3, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 7, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 7, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Mar 7, 2016

tests: move external test loader to qubes.tests.extra module
This way, tests will appear as from 'extra' module.

Besides the move, some minor changes:
 - add missing self.qc.unlock_db() in create_vms()
 - suffix per-template tests with template name

QubesOS/qubes-issues#1800
@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Mar 7, 2016

Member

Automated announcement from builder-github

The package qubes-core-dom0-3.1.14-1.fc20 has been pushed to the r3.1 testing repository for dom0.
To test this update, please install it with the following command:

sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing

Changes included in this update

Member

marmarek commented Mar 7, 2016

Automated announcement from builder-github

The package qubes-core-dom0-3.1.14-1.fc20 has been pushed to the r3.1 testing repository for dom0.
To test this update, please install it with the following command:

sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing

Changes included in this update

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Mar 13, 2016

Member

Automated announcement from builder-github

The package qubes-core-dom0-3.1.14-1.fc20 has been pushed to the r3.1 stable repository for dom0.
To install this update, please use the standard update command:

sudo qubes-dom0-update

Or update dom0 via Qubes Manager.

Changes included in this update

Member

marmarek commented Mar 13, 2016

Automated announcement from builder-github

The package qubes-core-dom0-3.1.14-1.fc20 has been pushed to the r3.1 stable repository for dom0.
To install this update, please use the standard update command:

sudo qubes-dom0-update

Or update dom0 via Qubes Manager.

Changes included in this update

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Apr 11, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue Apr 20, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue May 2, 2016

marmarek added a commit to marmarek/old-qubes-core-admin that referenced this issue May 2, 2016

tests: adjust 'extra' tests API to better design from core3
Do not force inheritance of ExtraTestMixin and QubesTestCase. Instead
provide 'qubes.tests.extra.ExtraTestCase' for external tests. This makes
the API less "magic", easier to understand and apply static analysis
tools on it.

QubesOS/qubes-issues#1800

marmarek added a commit to QubesOS/qubes-core-admin that referenced this issue Jun 25, 2016

marmarek added a commit to QubesOS/qubes-core-admin that referenced this issue Jun 25, 2016

tests: adjust 'extra' tests API to better design from core3
Do not force inheritance of ExtraTestMixin and QubesTestCase. Instead
provide 'qubes.tests.extra.ExtraTestCase' for external tests. This makes
the API less "magic", easier to understand and apply static analysis
tools on it.

QubesOS/qubes-issues#1800

(cherry picked from commit d88ff93)

marmarek added a commit to marmarek/qubes-core-admin that referenced this issue Dec 22, 2017

tests: resurrect extra tests loader
Load integration tests from outside of core-admin repository, through
entry points.
Create wrapper for VM object to keep very basic compatibility with tests
written for core2. This means if test use only basic functionality
(vm.start(), vm.run()), the same test will work for both core2 and
core3. This is especially important for app-* repositories, where the
same version serves multiple Qubes branches.
This also hides asyncio usage from tests writer.

See QubesOS/qubes-issues#1800 for details on original feature.

marmarek added a commit to marmarek/qubes-core-admin that referenced this issue Dec 23, 2017

tests: resurrect extra tests loader
Load integration tests from outside of core-admin repository, through
entry points.
Create wrapper for VM object to keep very basic compatibility with tests
written for core2. This means if test use only basic functionality
(vm.start(), vm.run()), the same test will work for both core2 and
core3. This is especially important for app-* repositories, where the
same version serves multiple Qubes branches.
This also hides asyncio usage from tests writer.

See QubesOS/qubes-issues#1800 for details on original feature.

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Jan 18, 2018

Closed

core-admin v4.0.16 (r4.0) #365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment