projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add integration tests.
[osm/N2VC.git]
/
examples
/
add_model.py
diff --git
a/examples/add_model.py
b/examples/add_model.py
index
323b6ec
..
e703450
100644
(file)
--- a/
examples/add_model.py
+++ b/
examples/add_model.py
@@
-11,6
+11,7
@@
from juju import utils
from juju.controller import Controller
import asyncio
from logging import getLogger
from juju.controller import Controller
import asyncio
from logging import getLogger
+import uuid
LOG = getLogger(__name__)
LOG = getLogger(__name__)
@@
-21,7
+22,9
@@
async def main():
await controller.connect_current()
try:
await controller.connect_current()
try:
- model = await controller.add_model("quux")
+ model_name = "addmodeltest-{}".format(uuid.uuid4())
+ print("Adding model {}".format(model_name))
+ model = await controller.add_model(model_name)
print('Deploying ubuntu')
application = await model.deploy(
print('Deploying ubuntu')
application = await model.deploy(
@@
-38,7
+41,8
@@
async def main():
for unit in application.units))
print("Verifying that we can ssh into the created model")
for unit in application.units))
print("Verifying that we can ssh into the created model")
- ret = utils.execute_process('juju', 'ssh', 'ls /', log=LOG)
+ ret = await utils.execute_process(
+ 'juju', 'ssh', '-m', model_name, 'ubuntu/0', 'ls /', log=LOG)
assert ret
print('Removing ubuntu')
assert ret
print('Removing ubuntu')
@@
-47,6
+51,10
@@
async def main():
print("Destroying model")
await controller.destroy_model(model.info.uuid)
print("Destroying model")
await controller.destroy_model(model.info.uuid)
+ except Exception as e:
+ LOG.exception(
+ "Test failed! Model {} may not be cleaned up".format(model_name))
+
finally:
print('Disconnecting from controller')
await model.disconnect()
finally:
print('Disconnecting from controller')
await model.disconnect()