Feature-9904: Enhancing NG-UI to enable Juju operational view dashboard
[osm/LCM.git] / osm_lcm / tests / test_ns.py
index fe2b652..4d3997e 100644 (file)
@@ -259,6 +259,12 @@ class TestMyNS(asynctest.TestCase):
 
         if not getenv("OSMLCMTEST_DB_NOMOCK"):
             self.assertTrue(self.db.set_one.called, "db.set_one not called")
+            db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+            db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id})
+            self.assertEqual(db_nsr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated")
+            for vnfr in db_vnfrs_list:
+                self.assertEqual(vnfr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated")
+
         if not getenv("OSMLCMTEST_VCA_NOMOCK"):
             # check intial-primitives called
             self.assertTrue(self.my_ns.n2vc.exec_primitive.called,
@@ -266,6 +272,7 @@ class TestMyNS(asynctest.TestCase):
             for _call in self.my_ns.n2vc.exec_primitive.call_args_list:
                 self.assertIn(_call[1]["primitive_name"], ("config", "touch"),
                               "called exec primitive with a primitive different than config or touch")
+
         # TODO add more checks of called methods
         # TODO add a terminate
 
@@ -350,6 +357,20 @@ class TestMyNS(asynctest.TestCase):
         self.assertEqual(return_value, expected_value)
         # print("scale_result: {}".format(self.db.get_one("nslcmops", {"_id": nslcmop_id}).get("detailed-status")))
 
+    async def test_vca_status_refresh(self):
+        nsr_id = descriptors.test_ids["TEST-A"]["ns"]
+        nslcmop_id = descriptors.test_ids["TEST-A"]["instantiate"]
+        await self.my_ns.vca_status_refresh(nsr_id, nslcmop_id)
+        for vnf_descriptor in self.db.get_list("vnfds"):
+            expected_value = dict()
+            return_value = dict()
+            if vnf_descriptor.get("vnf-configuration"):
+                if "juju" in vnf_descriptor["vnf-configuration"]:
+                    expected_value = self.db.get_list("nsrs")[0]["vcaStatus"]
+                    await self.my_ns._on_update_n2vc_db("nsrs", {"_id": nsr_id}, "_admin.deployed.VCA.0", {})
+                    return_value = self.db.get_list("nsrs")[0]["vcaStatus"]
+                self.assertEqual(return_value, expected_value)
+
     # Test _retry_or_skip_suboperation()
     # Expected result:
     # - if a suboperation's 'operationState' is marked as 'COMPLETED', SUBOPERATION_STATUS_SKIP is expected
@@ -607,6 +628,9 @@ class TestMyNS(asynctest.TestCase):
         self.assertEqual(db_nsr.get("currentOperationID"), None, "currentOperationID different than None")
         self.assertEqual(db_nsr.get("errorDescription "), None, "errorDescription different than None")
         self.assertEqual(db_nsr.get("errorDetail"), None, "errorDetail different than None")
+        db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id})
+        for vnfr in db_vnfrs_list:
+            self.assertEqual(vnfr["_admin"].get("nsState"), "NOT_INSTANTIATED", "Not instantiated")
 
     @asynctest.fail_on(active_handles=True)   # all async tasks must be completed
     async def test_terminate_primitive(self):