juju-solutions / bundletester

A juju charm and bundle test runner
http://juju-solutions.github.io/bundletester
15 stars 20 forks source link

charm: "cs:foo" doesn't normalize #92

Open kwmonroe opened 7 years ago

kwmonroe commented 7 years ago

Bundletester creates tmp charm dirs, which seem to be where stuff like proof, lint, and test are run. If charms include a namespace or series in their bundle definition, BT normalizes that name to chop off the cs:~foo/bar prefix. If charms do something like cs:bar, BT does not do that normalization:

$ cat bundle.yaml
services:
  u:
    charm: cs:ubuntu
  z:
    charm: cs:xenial/zookeeper

$ bundletester -Fvl DEBUG
<blah>

When I check the bundletester temp dirs, here's what I see:

$ ls /tmp/tmp*
/tmp/tmpRvITS_:
zookeeper

/tmp/tmpz86CBO:
cs:ubuntu

That /tmp/tmpz86CBO/cs:ubuntu dir name is a problem for stuff like tox, which tries to fire up a venv:

ubuntu@e9b7c2b12a9a:/tmp/tmpz86CBO/cs:ubuntu$ virtualenv ohnoes
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/tmpz86CBO/cs:ubuntu/ohnoes/bin/python2
Also creating executable in /tmp/tmpz86CBO/cs:ubuntu/ohnoes/bin/python
ImportError: No module named site
ERROR: The executable /tmp/tmpz86CBO/cs:ubuntu/ohnoes/bin/python2 is not functioning
ERROR: It thinks sys.prefix is u'/tmp/tmpz86CBO/cs:ubuntu' (should be u'/tmp/tmpz86CBO/cs:ubuntu/ohnoes')
ERROR: virtualenv is not compatible with this system or executable

Maybe there's something in a python envar that could mitigate this, but I think it may be worthwhile to check the normalization code that BT uses to make sure charm: cs:bar comes out the other end into /tmp/tmpXyz/bar instead of /tmp/tmpXyz/cs:bar.