diff options
author | maopeng zhang <zhang.maopeng1@zte.com.cn> | 2018-09-17 01:48:18 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-17 01:48:18 +0000 |
commit | 0abc20b11ae5373e56eb77531bf9a6d15a3439a9 (patch) | |
tree | 794862e16f58a556bf8af676c075cc04716230fc | |
parent | 018b4aeebdb803e3e7cd1868fa915f7a9ed8bbff (diff) | |
parent | c1fe81ad4d177358243407ca9feabea8cfbec1aa (diff) |
Merge " update tests of test_ns_heal"
-rw-r--r-- | lcm/ns/tests/test_ns_heal.py | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/lcm/ns/tests/test_ns_heal.py b/lcm/ns/tests/test_ns_heal.py index 72d51f96..0707ebe1 100644 --- a/lcm/ns/tests/test_ns_heal.py +++ b/lcm/ns/tests/test_ns_heal.py @@ -75,6 +75,7 @@ class TestHealNsViews(TestCase): @mock.patch.object(NSHealService, 'run') def test_heal_vnf_url(self, mock_run): + data = { "healVnfData": { "vnfInstanceId": self.nf_inst_id, @@ -83,6 +84,35 @@ class TestHealNsViews(TestCase): "action": "restartvm", "actionvminfo": { "vmid": "33", + "vduid": "", + "vmname": "xgw-smp11" + } + } + } + } + + response = self.client.post("/api/nslcm/v1/ns/%s/heal" % self.ns_inst_id, data=data) + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.data) + self.assertIsNotNone(response.data) + self.assertIn("jobId", response.data) + self.assertNotIn("error", response.data) + + response = self.client.delete("/api/nslcm/v1/ns/%s" % self.ns_inst_id) + self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code) + + # add healNsData + @mock.patch.object(NSHealService, 'run') + def test_heal_ns_url(self, mock_run): + + data = { + "healNsData": { + "vnfInstanceId": self.nf_inst_id, + "cause": "", + "additionalParams": { + "action": "vmreset", + "actionvminfo": { + "vmid": "33", + "vduid": "", "vmname": "xgw-smp11" } } @@ -101,7 +131,7 @@ class TestHealNsViews(TestCase): @mock.patch.object(NFHealService, 'start') @mock.patch.object(NSHealService, 'wait_job_finish') @mock.patch.object(NSHealService, 'update_job') - def test_ns_manual_scale_thread(self, mock_start, mock_wait, mock_update): + def test_heal_vnf_thread(self, mock_start, mock_wait, mock_update): data = { "healVnfData": { @@ -111,6 +141,31 @@ class TestHealNsViews(TestCase): "action": "restartvm", "actionvminfo": { "vmid": "33", + "vduid": "", + "vmname": "xgw-smp11" + } + } + } + } + + NSHealService(self.ns_inst_id, data, self.job_id).run() + self.assertEqual(NSInstModel.objects.get(id=self.ns_inst_id).status, NS_INST_STATUS.HEALING) + + # add healNsData + @mock.patch.object(NFHealService, 'start') + @mock.patch.object(NSHealService, 'wait_job_finish') + @mock.patch.object(NSHealService, 'update_job') + def test_heal_ns_thread(self, mock_start, mock_wait, mock_update): + + data = { + "healNsData": { + "vnfInstanceId": self.nf_inst_id, + "cause": "", + "additionalParams": { + "action": "vmreset", + "actionvminfo": { + "vmid": "33", + "vduid": "", "vmname": "xgw-smp11" } } @@ -121,7 +176,7 @@ class TestHealNsViews(TestCase): self.assertEqual(NSInstModel.objects.get(id=self.ns_inst_id).status, NS_INST_STATUS.HEALING) @mock.patch.object(NSHealService, "start") - def test_ns_heal_non_existing_ns(self, mock_start): + def test_heal_vnf_non_existing_ns(self, mock_start): mock_start.side_effect = NSLCMException("NS Not Found") ns_inst_id = "2" @@ -145,8 +200,35 @@ class TestHealNsViews(TestCase): self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) self.assertIn("error", response.data) + # add healNsData + @mock.patch.object(NSHealService, "start") + def test_heal_ns_heal_non_existing_ns(self, mock_start): + mock_start.side_effect = NSLCMException("NS Not Found") + + ns_inst_id = "2" + + data = { + "healNsData": { + "vnfInstanceId": self.nf_inst_id, + "cause": "", + "additionalParams": { + "action": "vmreset", + "actionvminfo": { + "vmid": "33", + "vduid": "", + "vmname": "xgw-smp11" + } + } + } + } + + response = self.client.post("/api/nslcm/v1/ns/%s/heal" % ns_inst_id, data=data) + self.assertEqual(response.data["error"], "NS Not Found") + self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) + self.assertIn("error", response.data) + @mock.patch.object(NSHealService, "start") - def test_ns_heal_empty_post(self, mock_start): + def test_heal_vnf_empty_post(self, mock_start): mock_start.side_effect = NSLCMException("healVnfData parameter does not exist or value is incorrect.") data = {} |