Support tests and tasks from bundle under test #26

Merged
merged 8 commits into from Nov 30, 2016

Conversation

Projects
None yet
3 participants

This generally LGTM, thanks. The handling of the config file was a little confusing to me at first, but after seeing the rest take the comments or not.

matrix/main.py
@@ -44,7 +45,10 @@ def setup(matrix, args=None):
parser.add_argument("-i", "--interval", default=5.0, type=float)
parser.add_argument("-p", "--path", default=Path.cwd() / "tests",
type=Path)
- parser.add_argument("config_file", type=open)
+ parser.add_argument("-c", "--config-file",
+ default=resource_filename(__name__, 'matrix.yaml'))
@bcsaller

bcsaller Nov 30, 2016

Contributor

Doesn't this favor thinking about the config file as residing as part of the matrix checkout? wouldn't cwd()/tests/matrix.yaml or just ./matrix.yaml be a better choice? Also does this interfere with the #!matrix style used in some of the tests? I don't know that we need to support that mode of operations but it would make having a single exec that BT can call simple.

If this should only represent the default tests then we might go about this another way, config_fiiles with type list(path) where the default includes the resource local one?

@johnsca

johnsca Nov 30, 2016

Owner

If it's not bundled as part of the Matrix, how does someone who wants to run the standard suite against their bundle under development run it?

I was also under the impression that we wanted to merge the in-bundle suite with the standard suite, rather than running it as a separate instance of Matrix nor in place of the standard suite. So, I'm not sure what the benefit of the she-bang line for matrix tests would be.

@johnsca

johnsca Nov 30, 2016

Owner

This also touches on the discussion we had about whether we wanted BT to be the thing that discovers and "combines" (in some way) the in-bundle test with the standard / default case, and my understanding was that we didn't want that.

If we do, we could rip out the bundle fetch code entirely and always assume we're deploying a local bundle, with BT being responsible for fetching it and running Matrix from within the bundle directory to ensure the right paths.

matrix/rules.py
@@ -345,7 +368,7 @@ def exception_handler(self, context, loop=None, exc_ctx=None):
async def __call__(self):
btask = self.loop.create_task(self.bus.notify(False))
- context = self.load_suite(self.config_file)
+ context = await self.load_suite()
@bcsaller

bcsaller Nov 30, 2016

Contributor

I appreciate the run_in_executor hurdle you jumped here (and we can keep it) but the setup code here doesn't strictly need to be async as nothing else can run when this is called.

@johnsca

johnsca Nov 30, 2016

Owner

Presumably, we don't want the UI or keyboard handling to hang while it's talking to the charm store. Apparently, the CS is hitting 10s timeouts just for metadata requests occasionally, so I'm a bit wary of it being blocking.

matrix/utils.py
- deepmerge(dest[k], v)
+ if isinstance(v, dict):
+ deepmerge(dest.setdefault(k, {}), v)
+ elif isinstance(v, list) and merge_lists:
@bcsaller

bcsaller Nov 30, 2016

Contributor

Merging lists is almost never a good idea, order and uniqueness are key reasons for using lists, here we'd have to give up one or the other.

- self.debug_view = urwid.ListBox(self.debug_walker)
- self.debug_watcher = asyncio.get_event_loop().create_task(
- self.debug_juju_log())
+ self.model_view = urwid.Terminal(['watch', '--color', '--',
@bcsaller

bcsaller Nov 30, 2016

Contributor

Nice, thanks

johnsca added some commits Nov 28, 2016

Support tests and tasks from bundle under test
Discover a matrix.yaml to be merged with the selected test plan from the
bundle being tested.  Also include that bundle in the path so that
custom tasks can be used.

The libjuju changes are for deploying local bundles and fixing placement.
Only run against local bundles, and merge tests by name
We'll rely on a higher level (bundletester) to fetch bundles from the
store, so we can assume we're always running against a local bundle.
We also want to merge tests by name, and if the name is already present,
it will be overwritten by the new test definition.  Also, support
pulling in additional suites besides the default suite and the bundle
suite, with the option to suppress the default or bundle suites entirely.

LGTM, thank you

matrix/main.py
+ "a matrix.yaml file which will be included as an "
+ "additional suite if present. All suites will be merged "
+ "together, and suites containing tests with the same name as a "
+ "test in a previous suite will override that test.",
@petevg

petevg Nov 30, 2016

Collaborator

This gets pretty complex, so it would be nice to see some examples in this doc string.

Basically, I'm looking for a "tar xvzf" or "ps aux" -- things that a newbie can run and have some success with, even if they don't understand all the options available to them.

Owner

johnsca commented Nov 30, 2016

Rendered --help:

usage: matrix [-h] [-l LOG_LEVEL] [-L [LOG_NAME [LOG_NAME ...]]]
              [-f [LOG_FILTER [LOG_FILTER ...]]] [-s {tui,raw}] [-x FILENAME]
              [-i INTERVAL] [-p PATH] [-D] [-B]
              [-t [TEST_PATTERN [TEST_PATTERN ...]]] [-g GLITCH_PLAN]
              [-n GLITCH_NUM] [-o GLITCH_OUTPUT]
              [additional_suites [additional_suites ...]]

Run a local bundle through a suite of tests to ensure that it can handle the
types of operations and failures that are common for all deployments.

positional arguments:
  additional_suites     Additional suites to be merged with the default suite
                        before running

optional arguments:
  -h, --help            show this help message and exit
  -l LOG_LEVEL, --log-level LOG_LEVEL
  -L [LOG_NAME [LOG_NAME ...]], --log-name [LOG_NAME [LOG_NAME ...]]
  -f [LOG_FILTER [LOG_FILTER ...]], --log-filter [LOG_FILTER [LOG_FILTER ...]]
  -s {tui,raw}, --skin {tui,raw}
  -x FILENAME, --xunit FILENAME
                        Create an XUnit report file
  -i INTERVAL, --interval INTERVAL
  -p PATH, --path PATH  Path to local bundle to test (defaults to current
                        directory)
  -D, --no-default-suite
                        Do not include the default suite as the first suite
  -B, --no-bundle-suite
                        Do not include the suite provided by the bundle
  -t [TEST_PATTERN [TEST_PATTERN ...]], --test_pattern [TEST_PATTERN [TEST_PATTERN ...]]
                        Pattern for selecting which tests from the suite(s)
                        are run
  -g GLITCH_PLAN, --glitch_plan GLITCH_PLAN
  -n GLITCH_NUM, --glitch_num GLITCH_NUM
  -o GLITCH_OUTPUT, --glitch_output GLITCH_OUTPUT

A default suite of tests will always be run, unless -D is given.  Additional
suites can be passed in as arguments.  Additionally, the bundle will be
checked for a tests/matrix.yaml file which will be included as an additional
suite if present.  All suites will be merged together, and suites containing
tests with the same name as a test in a previous suite will override that
test.

Examples:

    Run all normal tests (default suite and, if present, ./tests/matrix.yaml)
    on the bundle at ./:

        $ matrix

    Run only the default suite (ignore ./tests/matrix.yaml):

        $ matrix -B

    Run only ~/foo/tests/matrix.yaml on the bundle at ~/foo:

        $ matrix -Dp ~/foo

    Run all normal tests plus ./tests/matrix_extra.yaml on the bundle at ./:

        $ matrix tests/matrix_extra.yaml

    Run only ./tests/matrix_extra.yaml:

        $ matrix -DB tests/matrix_extra.yaml
Collaborator

petevg commented Nov 30, 2016

LGTM/+1

@petevg petevg merged commit c31ef9d into master Nov 30, 2016

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