summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-07-04 12:44:44 +0800
committerYun Huang <yun.huang@windriver.com>2018-07-04 12:44:44 +0800
commitfe66102f73458bedf9ec7da928cb2c5994964c0d (patch)
tree56e2302ea203e5b95d7e60094ca9e273acac32e5
parentc5b252f9926e6f26d157049f96d2f57b52beb3de (diff)
UT for vesagent failure case
Change-Id: I61c7bb5d7c1407be722ff560c04741fc5cb62b81 Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--windriver/titanium_cloud/vesagent/event_domain/tests_fault_vm.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/windriver/titanium_cloud/vesagent/event_domain/tests_fault_vm.py b/windriver/titanium_cloud/vesagent/event_domain/tests_fault_vm.py
index d300fe08..3bc346a7 100644
--- a/windriver/titanium_cloud/vesagent/event_domain/tests_fault_vm.py
+++ b/windriver/titanium_cloud/vesagent/event_domain/tests_fault_vm.py
@@ -35,6 +35,10 @@ MOCK_BACKLOG_INPUT_wo_tenant_id = {"backlog_uuid": "ce2d7597-22e1-4239-890f-bc30
"source": "onap-aaf",
"api_link": "/onaplab_RegionOne/compute/v2.1/0e148b76ee8c42f78d37013bf6b7b1ae/servers/c4b575fa-ed85-4642-ab4b-335cb5744721",
"domain": "fault", "type": "vm", "tenant": "VIM"}
+MOCK_BACKLOG_INPUT_wo_tenant = {"backlog_uuid": "ce2d7597-22e1-4239-890f-bc303bd67076",
+ "server_id": "c4b575fa-ed85-4642-ab4b-335cb5744721",
+ "source": "onap-aaf",
+ "domain": "fault", "type": "vm", }
MOCK_SERVER_GET_RESPONSE = {"server": {"wrs-res:topology": "node:0, 4096MB, pgsize:2M, vcpus:0,1, pol:sha", "OS-EXT-STS:task_state": None, "addresses": {"oam_onap_BTHY": [{"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:6c:0d:6b", "version": 4, "addr": "10.0.13.1", "OS-EXT-IPS:type": "fixed"}, {"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:6c:0d:6b", "version": 4, "addr": "10.12.5.185", "OS-EXT-IPS:type": "floating"}]}, "links": [], "image": {"id": "6e219e86-cd94-4989-9119-def29aa10b12", "links": []}, "wrs-if:nics": [], "wrs-sg:server_group": "", "OS-EXT-STS:vm_state": "active", "OS-SRV-USG:launched_at": "2018-04-26T08:01:28.000000", "flavor": {}, "id": "c4b575fa-ed85-4642-ab4b-335cb5744721", "security_groups": [{"name": "onap_sg_BTHY"}], "user_id": "ba76c94eb5e94bb7bec6980e5507aae2", "OS-DCF:diskConfig": "MANUAL", "accessIPv4": "", "accessIPv6": "", "progress": 0, "OS-EXT-STS:power_state": 1, "OS-EXT-AZ:availability_zone": "nova", "metadata": {}, "status": "ACTIVE", "updated": "2018-04-26T08:01:28Z", "hostId": "17acc9f2ae4f618c314e4cdf0c206585b895bc72a9ec57e57b254133", "OS-SRV-USG:terminated_at": None, "wrs-res:pci_devices": "", "wrs-res:vcpus": [2, 2, 2], "key_name": "onap_key_BTHY", "name": "onap-aaf", "created": "2018-04-26T08:01:20Z", "tenant_id": "0e148b76ee8c42f78d37013bf6b7b1ae", "os-extended-volumes:volumes_attached": [], "config_drive": ""}}
@@ -88,6 +92,19 @@ class FaultVMTest(unittest.TestCase):
self.assertIsNotNone(backlog)
pass
+
+ @mock.patch.object(restcall, '_call_req')
+ def test_buildBacklog_fault_vm_wo_tenant(self, mock_call_req):
+
+ mock_call_req.side_effect= [
+ (1, json.dumps(MOCK_TOKEN_RESPONSE), "MOCKED response body: failed"),
+ (0, json.dumps(MOCK_SERVERS_GET_RESPONSE), "MOCKED response body")
+ ]
+ backlog = fault_vm.buildBacklog_fault_vm(vimid="windriver-hudson-dc_RegionOne",
+ backlog_input = MOCK_BACKLOG_INPUT_wo_tenant)
+ self.assertIsNone(backlog)
+ pass
+
@mock.patch.object(vespublish, 'publishAnyEventToVES')
@mock.patch.object(restcall, '_call_req')
def test_processBacklog_fault_vm(self, mock_call_req, mock_publishAnyEventToVES):