RBAC permission storage in MongoDB
[osm/NBI.git] / osm_nbi / tests / test.py
index 884c08c..6bb04d9 100755 (executable)
@@ -1002,6 +1002,29 @@ class TestDeployHackfestCirros(TestDeploy):
         self.users = {'1': "cirros", '2': "cirros"}
         self.passwords = {'1': "cubswin:)", '2': "cubswin:)"}
 
+    def terminate(self, engine):
+        # Make a delete in one step, overriding the normal two step of TestDeploy that launched terminate and delete
+        if test_osm:
+            engine.test("Terminate and delete NS in one step", "DELETE", "/nslcm/v1/ns_instances_content/{}".
+                        format(self.ns_id), headers_yaml, None, 202, None, "yaml")
+
+            engine .wait_until_delete("/nslcm/v1/ns_instances/{}".format(self.ns_id), timeout_deploy)
+        else:
+            engine.test("Delete NS with FORCE", "DELETE", "/nslcm/v1/ns_instances/{}?FORCE=True".format(self.ns_id),
+                        headers_yaml, None, 204, None, 0)
+
+        # check all it is deleted
+        engine.test("Check NS is deleted", "GET", "/nslcm/v1/ns_instances/{}".format(self.ns_id), headers_yaml, None,
+                    404, None, "yaml")
+        r = engine.test("Check NSLCMOPs are deleted", "GET",
+                        "/nslcm/v1/ns_lcm_op_occs?nsInstanceId={}".format(self.ns_id), headers_json, None,
+                        200, None, "json")
+        if not r:
+            return
+        nslcmops = r.json()
+        if not isinstance(nslcmops, list) or nslcmops:
+            raise TestException("NS {} deleted but with ns_lcm_op_occ active: {}".format(self.ns_id, nslcmops))
+
 
 class TestDeployHackfest1(TestDeploy):
     description = "Load and deploy Hackfest_1_vnfd example"
@@ -1168,52 +1191,49 @@ class TestDeployHackfest4(TestDeploy):
         self.commands = {'1': ['ls -lrt', ], '2': ['ls -lrt', ]}
         self.users = {'1': "ubuntu", '2': "ubuntu"}
         self.passwords = {'1': "osm4u", '2': "osm4u"}
-
-    def create_descriptors(self, engine):
-        super().create_descriptors(engine)
         # Modify VNFD to add scaling
-        self.descriptor_edit = {
-            "vnfd0": {
-                'vnf-configuration': {
-                    'config-primitive': [{
-                        'name': 'touch',
-                        'parameter': [{
-                            'name': 'filename',
-                            'data-type': 'STRING',
-                            'default-value': '/home/ubuntu/touched'
-                        }]
-                    }]
-                },
-                'scaling-group-descriptor': [{
-                    'name': 'scale_dataVM',
-                    'scaling-policy': [{
-                        'threshold-time': 0,
-                        'name': 'auto_cpu_util_above_threshold',
-                        'scaling-type': 'automatic',
-                        'scaling-criteria': [{
-                            'name': 'cpu_util_above_threshold',
-                            'vnf-monitoring-param-ref': 'all_aaa_cpu_util',
-                            'scale-out-relational-operation': 'GE',
-                            'scale-in-threshold': 15,
-                            'scale-out-threshold': 60,
-                            'scale-in-relational-operation': 'LE'
-                        }],
-                        'cooldown-time': 60
-                    }],
-                    'max-instance-count': 10,
-                    'scaling-config-action': [
-                        {'vnf-config-primitive-name-ref': 'touch',
-                         'trigger': 'post-scale-out'},
-                        {'vnf-config-primitive-name-ref': 'touch',
-                         'trigger': 'pre-scale-in'}
-                    ],
-                    'vdu': [{
-                        'vdu-id-ref': 'dataVM',
-                        'count': 1
-                    }]
-                }]
-            }
-        }
+        self.descriptor_edit = {
+            "vnfd0": {
+                'vnf-configuration': {
+                    'config-primitive': [{
+                        'name': 'touch',
+                        'parameter': [{
+                            'name': 'filename',
+                            'data-type': 'STRING',
+                            'default-value': '/home/ubuntu/touched'
+                        }]
+                    }]
+                },
+                'scaling-group-descriptor': [{
+                    'name': 'scale_dataVM',
+                    'scaling-policy': [{
+                        'threshold-time': 0,
+                        'name': 'auto_cpu_util_above_threshold',
+                        'scaling-type': 'automatic',
+                        'scaling-criteria': [{
+                            'name': 'cpu_util_above_threshold',
+                            'vnf-monitoring-param-ref': 'all_aaa_cpu_util',
+                            'scale-out-relational-operation': 'GE',
+                            'scale-in-threshold': 15,
+                            'scale-out-threshold': 60,
+                            'scale-in-relational-operation': 'LE'
+                        }],
+                        'cooldown-time': 60
+                    }],
+                    'max-instance-count': 10,
+                    'scaling-config-action': [
+                        {'vnf-config-primitive-name-ref': 'touch',
+                         'trigger': 'post-scale-out'},
+                        {'vnf-config-primitive-name-ref': 'touch',
+                         'trigger': 'pre-scale-in'}
+                    ],
+                    'vdu': [{
+                        'vdu-id-ref': 'dataVM',
+                        'count': 1
+                    }]
+                }]
+            }
+        }
 
 
 class TestDeployHackfest3Charmed(TestDeploy):
@@ -1347,7 +1367,7 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed):
     def __init__(self):
         super().__init__()
         self.test_name = "HACKFEST3v3-"
-        self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch-1'], '2': ['ls -lrt /home/ubuntu/first-touch-1']}
+        self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch-1'], '2': ['ls -lrt /home/ubuntu/first-touch-2']}
         self.descriptor_edit = {
             "vnfd0": yaml.load(
                 """
@@ -1393,18 +1413,18 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed):
                             parameter:
                                 "$[0]":
                                     value: "<touch-filename>"   # default-value: /home/ubuntu/first-touch
-                    config-primitive:
-                        "$[0]":
-                            parameter:
-                                "$[0]":
-                                    default-value: "<touch-filename2>"
+                    config-primitive:
+                        "$[0]":
+                            parameter:
+                                "$[0]":
+                                    default-value: "<touch-filename2>"
                 """)
         }
         self.ns_params = {
             "additionalParamsForVnf": [
                 {"member-vnf-index": "1", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-1",
-                                                               "touch-filename2": "/home/ubuntu/second-touch-2"}},
-                {"member-vnf-index": "2", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-1",
+                                                               "touch-filename2": "/home/ubuntu/second-touch-1"}},
+                {"member-vnf-index": "2", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-2",
                                                                "touch-filename2": "/home/ubuntu/second-touch-2"}},
             ]
         }
@@ -1423,9 +1443,9 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed):
         nslcmop2_scale_out = engine.last_id
         engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy)
         if manual_check:
-            input('NS scale out done. Check that file /home/ubuntu/touched is present and new VM is created')
+            input('NS scale out done. Check that file /home/ubuntu/second-touch-1 is present and new VM is created')
         if test_osm:
-            commands = {'1': ['ls -lrt /home/ubuntu/touched', ]}
+            commands = {'1': ['ls -lrt /home/ubuntu/second-touch-1', ]}
             self.test_ns(engine, test_osm, commands=commands)
             # TODO check automatic connection to scaled VM
 
@@ -1438,7 +1458,7 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed):
         nslcmop2_scale_in = engine.last_id
         engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy)
         if manual_check:
-            input('NS scale in done. Check that file /home/ubuntu/touched is updated and new VM is deleted')
+            input('NS scale in done. Check that file /home/ubuntu/second-touch-1 is updated and new VM is deleted')
         # TODO check automatic