Need to rewire provider-specific tests in the storage charm

Bug #1368038 reported by Chris Glass
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
storage (Juju Charms Collection)
Triaged
High
Unassigned

Bug Description

After refactoring the code in the storage charm to be a little more straightforward, the tests had to be unwired.

They need to be rewired to the top-level MAkefile "test" target somehow.

Challenges:

I think the rewiring is the easy part of the problem: the provider-specific unit tests should probably live in the storage-providers.d/ subfolder, but that isn't a python module.
- We can always hack away, but running the tests there (cd storage-providers.d/blah/ && nosetests) will break imports since the common code is not in $PYTHONPATH in that case, and making "storage-providers.d/" a python module doesn't work either (import storage-providers.d.nfs.whatever ? See the problem dot there? :) )
- Another option would be to put the provider-specific tests in the top-level directories... but in this case we can't import the things we're trying to test.

So I guess we need to tweak $PYTHONPATH in the test runner invocation to include the provider-specific folders in $PYTHONPATH, then imports should by "jumping" into storage-providers.d/, like "from nfs.hooks import blah" (skipping storage-providers.d altogether).

Revision history for this message
Chris Glass (tribaal) wrote :

Of course, we can always use "imp", but then we can't argue that juju is distilling best practices anymore :)

Revision history for this message
David Britton (dpb) wrote :

Setting to High (in expectation of Chris' branch landing)

Changed in storage (Juju Charms Collection):
importance: Undecided → High
status: New → Confirmed
status: Confirmed → Triaged
Revision history for this message
Cory Johns (johnsca) wrote :

Why not have the `make test` target adjust PYTHONPATH to include the hooks directory before running the tests, and have all of the tests live in tests/unit/ or unit_tests/ off the top-level?

E.g., PYTHONPATH=hooks:$PYTHONPATH CHARM_DIR=`pwd` trial hooks

Revision history for this message
Cory Johns (johnsca) wrote :

Of course, that was supposed to be:

PYTHONPATH=hooks:$PYTHONPATH CHARM_DIR=`pwd` trial unit_tests

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.