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

Design a way to pass some configuration to integration tests #1489

Open
marmarek opened this Issue Dec 4, 2015 · 1 comment

Comments

Projects
None yet
3 participants
@marmarek
Member

marmarek commented Dec 4, 2015

Example things we may want to configure:

  • which PCI device (on particular test machine) can be used for PCI passthrough tests
  • path to the Windows installation image and/or installed disk image (for Windows tests)

We've already considered some command line options and it doesn't work with python unittest framework (which isn't surprising for unit test framework...). I can think of some environment variables, or separate config file.
cc @woju

@woju

This comment has been minimized.

Show comment
Hide comment
@woju

woju Dec 7, 2015

Member

On Fri, Dec 04, 2015 at 01:39:48PM -0800, Marek Marczykowski-Górecki wrote:

Example things we may want to configure:

  • which PCI device (on particular test machine) can be used for PCI passthrough tests
  • path to the Windows installation image and/or installed disk image (for Windows tests)

We've already considered some command line options and it doesn't work
with python unittest framework (which isn't surprising for unit test
framework...). I can think of some environment variables, or separate
config file.

Config file would be hard, I think it's better to stick to
environment variables. Environment is in os.environ directory, which
can be queried like this:

import os
print(os.envion.get('QTB_CONFIG_OPTION', 'default value'))

which basically makes this a one-liner. If you'd like to skip the test
instead:

import os

class TC_00_MyTestCase(...):
    def test_000_test(self):
        try:
            conf = os.environ['QTB_CONFIG_OPTION']
        except KeyError:
            self.skip() # raises unittest.case.SkipTest

However, when many of those will pop up, I think it is better to get
those under one helper function, maybe in qubes.tests module:

import os
import unittest

def get_config_mandatory(key):
    try:
        return os.environ[key]
    except KeyError:
        raise unittest.SkipTest(
            'skipping because environment variable {!r} is unset'.format(key))

My .02 eurocents.

regards, .-.
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>

Member

woju commented Dec 7, 2015

On Fri, Dec 04, 2015 at 01:39:48PM -0800, Marek Marczykowski-Górecki wrote:

Example things we may want to configure:

  • which PCI device (on particular test machine) can be used for PCI passthrough tests
  • path to the Windows installation image and/or installed disk image (for Windows tests)

We've already considered some command line options and it doesn't work
with python unittest framework (which isn't surprising for unit test
framework...). I can think of some environment variables, or separate
config file.

Config file would be hard, I think it's better to stick to
environment variables. Environment is in os.environ directory, which
can be queried like this:

import os
print(os.envion.get('QTB_CONFIG_OPTION', 'default value'))

which basically makes this a one-liner. If you'd like to skip the test
instead:

import os

class TC_00_MyTestCase(...):
    def test_000_test(self):
        try:
            conf = os.environ['QTB_CONFIG_OPTION']
        except KeyError:
            self.skip() # raises unittest.case.SkipTest

However, when many of those will pop up, I think it is better to get
those under one helper function, maybe in qubes.tests module:

import os
import unittest

def get_config_mandatory(key):
    try:
        return os.environ[key]
    except KeyError:
        raise unittest.SkipTest(
            'skipping because environment variable {!r} is unset'.format(key))

My .02 eurocents.

regards, .-.
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>

@marmarek marmarek modified the milestones: Release 4.0, Release 3.1 Feb 8, 2016

andrewdavidwong added a commit that referenced this issue May 31, 2016

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