Merge upstream libjuju
[osm/N2VC.git] / tests / base.py
index 8b61461..3ae5f4f 100644 (file)
@@ -25,8 +25,7 @@ here = os.path.dirname(os.path.realpath(__file__))
 def is_bootstrapped():
     result = subprocess.run(['juju', 'switch'], stdout=subprocess.PIPE)
     return (
 def is_bootstrapped():
     result = subprocess.run(['juju', 'switch'], stdout=subprocess.PIPE)
     return (
-        result.returncode == 0 and
-        len(result.stdout.decode().strip()) > 0)
+        result.returncode == 0 and len(result.stdout.decode().strip()) > 0)
 
 
 bootstrapped = pytest.mark.skipif(
 
 
 bootstrapped = pytest.mark.skipif(
@@ -569,12 +568,17 @@ class TestN2VC(object):
                     )
                     subprocess.check_call(shlex.split(cmd))
 
                     )
                     subprocess.check_call(shlex.split(cmd))
 
-                self.artifacts[charm] = {
-                    'tmpdir': builds,
-                    'charm': "{}/builds/{}".format(builds, charm),
-                }
             except subprocess.CalledProcessError as e:
             except subprocess.CalledProcessError as e:
-                raise Exception("charm build failed: {}.".format(e))
+                # charm build will return error code 100 if the charm fails
+                # the auto-run of charm proof, which we can safely ignore for
+                # our CI charms.
+                if e.returncode != 100:
+                    raise Exception("charm build failed: {}.".format(e))
+
+            self.artifacts[charm] = {
+                'tmpdir': builds,
+                'charm': "{}/builds/{}".format(builds, charm),
+            }
 
         return self.artifacts[charm]['charm']
 
 
         return self.artifacts[charm]['charm']
 
@@ -587,6 +591,9 @@ class TestN2VC(object):
         if not self.n2vc:
             self.n2vc = get_n2vc(loop=loop)
 
         if not self.n2vc:
             self.n2vc = get_n2vc(loop=loop)
 
+        debug("Creating model for Network Service {}".format(self.ns_name))
+        await self.n2vc.CreateNetworkService(self.ns_name)
+
         application = self.n2vc.FormatApplicationName(
             self.ns_name,
             self.vnf_name,
         application = self.n2vc.FormatApplicationName(
             self.ns_name,
             self.vnf_name,
@@ -890,6 +897,8 @@ class TestN2VC(object):
                 try:
                     await self.n2vc.RemoveCharms(self.ns_name, application)
 
                 try:
                     await self.n2vc.RemoveCharms(self.ns_name, application)
 
+                    await self.n2vc.DestroyNetworkService(self.ns_name)
+
                     while True:
                         # Wait for the application to be removed
                         await asyncio.sleep(10)
                     while True:
                         # Wait for the application to be removed
                         await asyncio.sleep(10)
@@ -898,6 +907,7 @@ class TestN2VC(object):
                             application,
                         ):
                             break
                             application,
                         ):
                             break
+                    await self.n2vc.DestroyNetworkService(self.ns_name)
 
                     # Need to wait for the charm to finish, because native charms
                     if self.state[application]['container']:
 
                     # Need to wait for the charm to finish, because native charms
                     if self.state[application]['container']: