Mock tests for vROPs plugin receiver module 22/5822/3
authordhumal <kdhumal@vmware.com>
Tue, 23 Jan 2018 11:28:17 +0000 (03:28 -0800)
committerdhumal <kdhumal@vmware.com>
Mon, 29 Jan 2018 05:59:35 +0000 (21:59 -0800)
Correcting typo in sys path

Change-Id: Idc59055997e853edf7873c68c5e69f4acc60f69c
Signed-off-by: dhumal <kdhumal@vmware.com>
osm_mon/plugins/vRealiseOps/vROPs_Webservice/vrops_webservice
osm_mon/test/VMware/__init__.py [new file with mode: 0644]
osm_mon/test/VMware/test_plugin_receiver.py [new file with mode: 0644]

index 4a55e73..3f112eb 100755 (executable)
@@ -41,7 +41,7 @@ import os
 import json
 import sys
 import requests
-ys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..','..'))
+sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..','..'))
 from osm_mon.core.message_bus.producer import KafkaProducer
 #from core.message_bus.producer import KafkaProducer
 
diff --git a/osm_mon/test/VMware/__init__.py b/osm_mon/test/VMware/__init__.py
new file mode 100644 (file)
index 0000000..e2d83ed
--- /dev/null
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2017-2018 VMware Inc.
+# This file is part of ETSI OSM
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact:  osslegalrouting@vmware.com
+##
+
+"""VMware MON plugin tests."""
+
+import logging
+
+# Initialise a logger for tests
+logging.basicConfig(filename='vmware_mon_tests.log',
+                    format='%(asctime)s %(message)s',
+                    datefmt='%m/%d/%Y %I:%M:%S %p', filemode='a',
+                    level=logging.INFO)
+log = logging.getLogger(__name__)
+
diff --git a/osm_mon/test/VMware/test_plugin_receiver.py b/osm_mon/test/VMware/test_plugin_receiver.py
new file mode 100644 (file)
index 0000000..07bfa35
--- /dev/null
@@ -0,0 +1,655 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2017-2018 VMware Inc.
+# This file is part of ETSI OSM
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact:  osslegalrouting@vmware.com
+##
+
+""" Mock tests for VMware vROPs plugin recevier """
+
+import sys
+sys.path.append("/root/MON/")
+
+import json
+
+import logging
+
+import unittest
+
+import mock
+
+import requests
+
+from osm_mon.plugins.vRealiseOps import plugin_receiver as monPluginRec
+
+log = logging.getLogger(__name__)
+
+
+class Message(object):
+    """A class to mock a message object value for alarm and matric requests"""
+
+    def __init__(self):
+        """Initialize a mocked message instance"""
+        self.topic = "alarm_or_metric_request"
+        self.key = None
+        self.value = json.dumps({"mock_value": "mock_details"})
+        self.partition = 1
+        self.offset = 100
+
+
+class TestPluginReceiver(unittest.TestCase):
+    """Test class for Plugin Receiver class methods"""
+
+    def setUp(self):
+        """Setup the tests for plugin_receiver class methods"""
+        super(TestPluginReceiver, self).setUp()
+        self.plugin_receiver = monPluginRec.PluginReceiver()
+        #self.mon_plugin = monPlugin.MonPlugin()
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_create_alarm_status')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'create_alarm')
+    def test_consume_create_alarm_request_key(self, m_create_alarm, m_publish_create_alarm_status):
+        """Test functionality of consume for create_alarm_request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "alarm_request"
+        msg.key = "create_alarm_request"
+
+        msg.value = json.dumps({"alarm_create_request":"alarm_details"})
+        m_create_alarm.return_value = "test_alarm_id"
+
+        config_alarm_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # verify if create_alarm and publish methods called with correct params
+        m_create_alarm.assert_called_with("alarm_details")
+        m_publish_create_alarm_status.assert_called_with("test_alarm_id", config_alarm_info)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_update_alarm_status')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'update_alarm')
+    def test_consume_update_alarm_request_key(self, m_update_alarm, m_publish_update_alarm_status):
+        """Test functionality of consume for update_alarm_request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "alarm_request"
+        msg.key = "update_alarm_request"
+
+        msg.value = json.dumps({"alarm_update_request":"alarm_details"})
+
+        # set return value to mocked method
+        m_update_alarm.return_value = "test_alarm_id"
+
+        update_alarm_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # verify update_alarm and publish method called with correct params
+        m_update_alarm.assert_called_with("alarm_details")
+        m_publish_update_alarm_status.assert_called_with("test_alarm_id", update_alarm_info)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_delete_alarm_status')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'delete_alarm')
+    def test_consume_delete_alarm_request_key(self, m_delete_alarm, m_publish_delete_alarm_status):
+        """Test functionality of consume for delete_alarm_request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "alarm_request"
+        msg.key = "delete_alarm_request"
+
+        msg.value = json.dumps({"alarm_delete_request":"alarm_details"})
+        m_delete_alarm.return_value = "test_alarm_id"
+
+        delete_alarm_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver and check delete_alarm request
+        self.plugin_receiver.consume(msg)
+        m_delete_alarm.assert_called_with("alarm_details")
+
+        # Check if publish method called with correct parameters
+        m_publish_delete_alarm_status.assert_called_with("test_alarm_id", delete_alarm_info)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_list_alarm_response')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'list_alarms')
+    def test_consume_list_alarm_request_key(self, m_list_alarms, m_publish_list_alarm_response):
+        """ Test functionality of list alarm request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "alarm_request"
+        msg.key = "list_alarm_request"
+        test_alarm_list = [{"alarm_uuid":"alarm1_details"},{"alarm_uuid":"alarm2_details"}]
+
+        msg.value = json.dumps({"alarm_list_request":"alarm_details"})
+        m_list_alarms.return_value = test_alarm_list
+
+        list_alarms_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver and check delete_alarm request
+        self.plugin_receiver.consume(msg)
+        m_list_alarms.assert_called_with("alarm_details")
+
+        # Check if publish method called with correct parameters
+        m_publish_list_alarm_response.assert_called_with(test_alarm_list, list_alarms_info)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_access_update_response')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'update_access_credentials')
+    def test_consume_vim_access_request_key(self, m_update_access_credentials, m_publish_access_update_response):
+        """Test functionality of consume for vim_access_credentials request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "access_credentials"
+        msg.key = "vim_access_credentials"
+
+        msg.value = json.dumps({"access_config":"access_details"})
+        # set return value to mocked method
+        m_update_access_credentials.return_value = True
+
+        access_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # check if mocked method called with required parameters
+        m_update_access_credentials.assert_called_with("access_details")
+
+        # Check if publish method called with correct parameters
+        m_publish_access_update_response.assert_called_with(True, access_info)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_create_alarm_status')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'create_alarm')
+    def test_consume_invalid_alarm_request_key(self, m_create_alarm, m_publish_create_alarm_status):
+        """Test functionality of consume for vim_access_credentials invalid request key"""
+
+        # Mock a message with invalid alarm request key
+        msg = Message()
+        msg.topic = "alarm_request"
+        msg.key = "invalid_alarm_request" # invalid key
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # verify that create_alarm and publish_create_alarm_status methods not called
+        m_create_alarm.assert_not_called()
+        m_publish_create_alarm_status.assert_not_called()
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_metrics_data_status')
+    @mock.patch.object(monPluginRec.MonPlugin, 'get_metrics_data')
+    def test_consume_invalid_metric_request_key(self, m_get_metrics_data, m_publish_metric_data_status):
+        """Test functionality of invalid metric key request"""
+
+        # Mock a message with invalid metric request key
+        msg = Message()
+        msg.topic = "metric_request"
+        msg.key = "invalid_metric_data_request" #invalid key
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # verify that get martics data and publish methods not called
+        m_get_metrics_data.assert_not_called()
+        m_publish_metric_data_status.assert_not_called()
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_metrics_data_status')
+    @mock.patch.object(monPluginRec.MonPlugin, 'get_metrics_data')
+    def test_consume_read_metric_data_request_key(self, m_get_metrics_data, m_publish_metric_data_status):
+        """Test functionality of consume for read_metric_data_request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "metric_request"
+        msg.key = "read_metric_data_request"
+
+        msg.value = json.dumps({"metric_name":"metric_details"})
+        m_get_metrics_data.return_value = {"metrics_data":"metrics_details"}
+
+        metric_request_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+        m_get_metrics_data.assert_called_with(metric_request_info)
+
+        # Check if publish method called with correct parameters
+        m_publish_metric_data_status.assert_called_with({"metrics_data":"metrics_details"})
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_create_metric_response')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'verify_metric')
+    def test_consume_create_metric_request_key(self, m_verify_metric, m_publish_create_metric_response):
+        """Test functionality of consume for create_metric_request key"""
+
+        # Mock a message
+        msg = Message()
+        msg.topic = "metric_request"
+        msg.key = "create_metric_request"
+
+        msg.value = json.dumps({"metric_create":"metric_details"})
+
+        # set the return value
+        m_verify_metric.return_value = True
+
+        metric_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+        m_verify_metric.assert_called_with("metric_details")
+
+        # Check if publish method called with correct parameters
+        m_publish_create_metric_response.assert_called_with(metric_info, True)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_update_metric_response')
+    @mock.patch.object(monPluginRec.PluginReceiver, 'verify_metric')
+    def test_consume_update_metric_request_key(self, m_verify_metric, m_publish_update_metric_response):
+        """Test functionality of update metric request key"""
+        # Mock a message
+        msg = Message()
+        msg.topic = "metric_request"
+        msg.key = "update_metric_request"
+
+        msg.value = json.dumps({"metric_create":"metric_details"})
+
+        # set the return value
+        m_verify_metric.return_value = True
+
+        metric_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # verify mocked methods called with correct parameters
+        m_verify_metric.assert_called_with("metric_details")
+        m_publish_update_metric_response.assert_called_with(metric_info, True)
+
+
+    @mock.patch.object(monPluginRec.PluginReceiver, 'publish_delete_metric_response')
+    def test_consume_delete_metric_request_key(self, m_publish_delete_metric_response):
+        """Test functionality of consume for delete_metric_request key"""
+
+        # Note: vROPS doesn't support deleting metric data
+        # Mock a message
+        msg = Message()
+        msg.topic = "metric_request"
+        msg.key = "delete_metric_request"
+
+        msg.value = json.dumps({"metric_name":"metric_details"})
+
+        metric_info = json.loads(msg.value)
+
+        # Call the consume method of plugin_receiver
+        self.plugin_receiver.consume(msg)
+
+        # Check if publish method called with correct parameters
+        m_publish_delete_metric_response.assert_called_with(metric_info)
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'configure_alarm')
+    @mock.patch.object(monPluginRec.MonPlugin, 'configure_rest_plugin')
+    def test_create_alarm_successful(self, m_configure_rest_plugin, m_configure_alarm):
+        """ Test functionality of create alarm method-positive case"""
+
+        # Mock config_alarm_info
+        config_alarm_info = {"correlation_id": 1,
+                             "alarm_name": "CPU_Utilize_Threshold",
+                             "metric_name": "CPU_UTILIZATION",
+                             "tenant_uuid": "tenant_uuid",
+                             "resource_uuid": "resource_uuid",
+                             "description": "test_create_alarm",
+                             "severity": "CRITICAL",
+                             "operation": "GT",
+                             "threshold_value": 10,
+                             "unit": "%",
+                             "statistic": "AVERAGE"}
+
+        # set return value to plugin uuid
+        m_configure_rest_plugin.retrun_value = "plugin_uuid"
+        m_configure_alarm.return_value = "alarm_uuid"
+
+        # call create alarm method under test
+        self.plugin_receiver.create_alarm(config_alarm_info)
+
+        # verify mocked methods get called with correct params
+        m_configure_rest_plugin.assert_called_with()
+        m_configure_alarm.assert_called_with(config_alarm_info)
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'configure_alarm')
+    @mock.patch.object(monPluginRec.MonPlugin, 'configure_rest_plugin')
+    def test_create_alarm_failed(self, m_configure_rest_plugin, m_configure_alarm):
+        """ Test functionality of create alarm method negative case"""
+
+        # Mock config_alarm_info
+        config_alarm_info = {"correlation_id": 1,
+                             "alarm_name": "CPU_Utilize_Threshold",
+                             "metric_name": "CPU_UTILIZATION",
+                             "tenant_uuid": "tenant_uuid",
+                             "resource_uuid": "resource_uuid",
+                             "description": "test_create_alarm",
+                             "severity": "CRITICAL",
+                             "operation": "GT",
+                             "threshold_value": 10,
+                             "unit": "%",
+                             "statistic": "AVERAGE"}
+
+        # set return value to plugin uuid and alarm_uuid to None
+        m_configure_rest_plugin.retrun_value = "plugin_uuid"
+        m_configure_alarm.return_value = None
+
+        # call create alarm method under test
+        alarm_uuid = self.plugin_receiver.create_alarm(config_alarm_info)
+
+        # verify mocked method called with correct params
+        m_configure_rest_plugin.assert_called_with()
+        m_configure_alarm.assert_called_with(config_alarm_info)
+
+        # verify create alarm method returns None when failed
+        self.assertEqual(alarm_uuid, None)
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'update_alarm_configuration')
+    def test_update_alarm_successful(self, m_update_alarm_configuration):
+        """ Test functionality of update alarm method-positive case"""
+
+        # Mock update_alarm_info
+        update_alarm_info = {'alarm_uuid': 'abc', 'correlation_id': 14203}
+
+        # set return value to mocked method
+        m_update_alarm_configuration.return_value = "alarm_uuid"
+
+        # check update alarm gets called and returned correct value
+        ret_value = self.plugin_receiver.update_alarm(update_alarm_info)
+
+        # check mocked method get called with correct param
+        m_update_alarm_configuration.assert_called_with(update_alarm_info)
+
+        # check return value and passed values are correct
+        self.assertEqual(ret_value, "alarm_uuid")
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'update_alarm_configuration')
+    def test_update_alarm_failed(self, m_update_alarm_configuration):
+        """ Test functionality of update alarm method negative case"""
+
+        # Mock update_alarm_info
+        update_alarm_info = {'alarm_uuid': 'abc', 'correlation_id': 14203}
+
+        # set return value to mocked method
+        m_update_alarm_configuration.return_value = None
+
+        # check update alarm gets called and returned correct value
+        ret_value = self.plugin_receiver.update_alarm(update_alarm_info)
+
+        # check mocked method get called with correct param
+        m_update_alarm_configuration.assert_called_with(update_alarm_info)
+
+        # check return value and passed values are correct
+        self.assertEqual(ret_value, None)
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'delete_alarm_configuration')
+    def test_delete_alarm_successful(self, m_delete_alarm_configuration):
+        """ Test functionality of delete alarm method-positive case"""
+
+        # Mock delete_alarm_info
+        delete_alarm_info = {'alarm_uuid': 'abc', 'correlation_id': 14203}
+
+        # set return value to mocked method
+        m_delete_alarm_configuration.return_value = "alarm_uuid"
+
+        # check delete alarm gets called and returned correct value
+        ret_value = self.plugin_receiver.delete_alarm(delete_alarm_info)
+
+        # check mocked method get called with correct param
+        m_delete_alarm_configuration.assert_called_with(delete_alarm_info)
+
+        # check return value and passed values are correct
+        self.assertEqual(ret_value, "alarm_uuid")
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'delete_alarm_configuration')
+    def test_delete_alarm_failed(self, m_delete_alarm_configuration):
+        """ Test functionality of delete alarm method-negative case"""
+
+        # Mock update_alarm_info
+        delete_alarm_info = {'alarm_uuid': 'abc', 'correlation_id': 14203}
+
+        # set return value to mocked method
+        m_delete_alarm_configuration.return_value = None
+
+        # check delete alarm gets called and returned correct value
+        ret_value = self.plugin_receiver.delete_alarm(delete_alarm_info)
+
+        # check mocked method get called with correct param
+        m_delete_alarm_configuration.assert_called_with(delete_alarm_info)
+
+        # check return value to check failed status
+        self.assertEqual(ret_value, None)
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_create_alarm_status(self, m_publish):
+        """ Test functionality of publish create alarm status method"""
+
+        # Mock config_alarm_info
+        config_alarm_info = {'vim_type': 'VMware',
+                             'alarm_create_request': {'threshold_value': 0,
+                                                      'severity': 'CRITICAL',
+                                                      'alarm_name': 'CPU_Utilization_Above_Threshold',
+                                                      'resource_uuid': 'e14b203c-6bf2-4e2f-a91c-8c19d240eda4',
+                                                      'correlation_id': 1234,
+                                                      'statistic': 'AVERAGE',
+                                                      'metric_name': 'CPU_UTILIZATION'}
+                            }
+
+        alarm_uuid = "xyz"
+
+        # call publish create status method under test
+        self.plugin_receiver.publish_create_alarm_status(alarm_uuid, config_alarm_info)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='create_alarm_response', value=mock.ANY, topic='alarm_response')
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_update_alarm_status(self, m_publish):
+        """ Test functionality of publish update alarm status method"""
+
+        # Mock update_alarm_info
+        update_alarm_info = {'vim_type' : 'VMware',
+                             'alarm_update_request':{'alarm_uuid': '6486e69',
+                                                     'correlation_id': 14203,
+                                                     'operation': 'GT'
+                                                     },
+                             'schema_type': 'update_alarm_request'
+                            }
+
+        alarm_uuid = "xyz"
+
+        # call publish update alarm status method under test
+        self.plugin_receiver.publish_update_alarm_status(alarm_uuid, update_alarm_info)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='update_alarm_response', value=mock.ANY, topic='alarm_response')
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_delete_alarm_status(self, m_publish):
+        """ Test functionality of publish delete alarm status method"""
+
+        # Mock delete_alarm_info
+        delete_alarm_info = {'vim_type' : 'VMware',
+                             'alarm_delete_request':{'alarm_uuid': '6486e69',
+                                                     'correlation_id': 14203,
+                                                     'operation': 'GT'
+                                                     },
+                             'schema_type': 'delete_alarm_request'
+                            }
+
+        alarm_uuid = "xyz"
+
+        # call publish delete alarm status method under test
+        self.plugin_receiver.publish_delete_alarm_status(alarm_uuid, delete_alarm_info)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='delete_alarm_response', value=mock.ANY, topic='alarm_response')
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_metrics_data_status(self, m_publish):
+        """ Test functionality of publish metrics data status method"""
+
+        # Mock metrics data
+        metrics_data = {
+                        'metric_name': 'CPU_UTILIZATION', 'metric_uuid': '0',
+                        'resource_uuid': 'e14b20', 'correlation_id': 'e14b2',
+                        'metrics_data': {'time_series': [15162011, 15162044],
+                        'metrics_series': [0.1166666671, 0.1266666650]},
+                        'tenant_uuid': 123, 'unit': '%'
+                       }
+
+        # call publish metrics data status method under test
+        self.plugin_receiver.publish_metrics_data_status(metrics_data)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='read_metric_data_response', value=mock.ANY, topic='metric_response')
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'verify_metric_support')
+    def test_verify_metric_supported_metric(self, m_verify_metric_support):
+        """ Test functionality of verify matric method"""
+
+        # mock metric_info
+        metric_info = {'metric_unit': '%', 'metric_name': 'CPU_UTILIZATION', 'resource_uuid': 'e14b203'}
+
+        # set mocked function retrun value to true
+        m_verify_metric_support.return_value = True
+
+        # call verify_metric method under test
+        ret_value = self.plugin_receiver.verify_metric(metric_info)
+
+        # verify mocked method called with correct params
+        m_verify_metric_support.assert_called_with(metric_info)
+
+        # verify the return value
+        self.assertEqual(ret_value, True)
+
+
+    @mock.patch.object(monPluginRec.MonPlugin, 'verify_metric_support')
+    def test_verify_metric_unsupported_metric(self, m_verify_metric_support):
+        """ Test functionality of verify matric method-negative case"""
+
+        # mock metric_info with unsupported matrics name
+        metric_info = {'metric_unit': '%', 'metric_name': 'Invalid', 'resource_uuid': 'e14b203'}
+
+        # set mocked function retrun value to true
+        m_verify_metric_support.return_value = False
+
+        # call verify_metric method under test
+        ret_value = self.plugin_receiver.verify_metric(metric_info)
+
+        # verify mocked method called with correct params
+        m_verify_metric_support.assert_called_with(metric_info)
+
+        # verify the return value
+        self.assertEqual(ret_value, False)
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_create_metric_response(self, m_publish):
+        """ Test functionality of publish create metric response method"""
+
+        # Mock metric_info
+        metric_info = {'vim_type' : 'VMware','correlation_id': 'e14b203c',
+                       'metric_create':{
+                                        'resource_uuid': '6486e69',
+                                        'metric_name': 'CPU_UTILIZATION',
+                                        'metric_unit': '%'
+                                        },
+                        'schema_type': 'create_metric_request'
+                       }
+
+        metric_status = True
+
+        # call publish create metric method under test
+        self.plugin_receiver.publish_create_metric_response(metric_info, metric_status)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='create_metric_response', value=mock.ANY, topic='metric_response')
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_update_metric_response(self, m_publish):
+        """ Test functionality of publish update metric response method"""
+
+        # Mock metric_info
+        metric_info = {'vim_type' : 'VMware','correlation_id': 'e14b203c',
+                       'metric_create':{
+                                        'resource_uuid': '6486e69',
+                                        'metric_name': 'CPU_UTILIZATION',
+                                        'metric_unit': '%'
+                                        },
+                        'schema_type': 'update_metric_request'
+                       }
+
+        metric_status = True
+
+        # call publish update metric method under test
+        self.plugin_receiver.publish_update_metric_response(metric_info, metric_status)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='update_metric_response', value=mock.ANY, topic='metric_response')
+
+
+    @mock.patch.object(monPluginRec.KafkaProducer, 'publish')
+    def test_publish_delete_metric_response(self, m_publish):
+        """ Test functionality of publish delete metric response method"""
+
+        # Mock metric_info
+        metric_info = {'vim_type' : 'VMware','correlation_id': 'e14b203c',
+                       'metric_uuid': 'e14b203c', 'resource_uuid': '6486e69',
+                       'metric_name': 'CPU_UTILIZATION',
+                       'schema_type': 'delete_metric_request'}
+
+        metric_status = True
+
+        # call publish delete metric method under test-vROPS doesn't support
+        # delete metric,just returns responce with success
+        self.plugin_receiver.publish_delete_metric_response(metric_info)
+
+        # verify mocked method called with correct params
+        m_publish.assert_called_with(key='delete_metric_response', value=mock.ANY, topic='metric_response')
+
+
+# For testing purpose
+#if __name__ == '__main__':
+
+#    unittest.main()