From: Pete Vander Giessen Date: Fri, 27 Jan 2017 23:32:50 +0000 (-0500) Subject: Create a new model for each test run of examples/add_model.py. X-Git-Tag: 0.2.0~1^2~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=46e8f6d89d009f5b16f451b05796875f4e82d4e8;p=osm%2FN2VC.git Create a new model for each test run of examples/add_model.py. --- diff --git a/examples/add_model.py b/examples/add_model.py index efa325b..e703450 100644 --- 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 +import uuid LOG = getLogger(__name__) @@ -21,7 +22,8 @@ async def main(): await controller.connect_current() try: - model_name = "quux" + model_name = "addmodeltest-{}".format(uuid.uuid4()) + print("Adding model {}".format(model_name)) model = await controller.add_model(model_name) print('Deploying ubuntu') @@ -49,6 +51,10 @@ async def main(): 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()