def test_gluster_brick_utilization(self, gethostbyname, client, brick_host, dirname, ismount, statvfs, communicate, ini2json, execu): gethostbyname.return_value = "10.70.41.169" client.return_value = etcd.Client() brick_host.return_value = "10.70.41.169" gluster_state = mock_gluster_state.gluster_state() execu.return_value = ("pytest", "") ini2json.ini_to_dict.return_value = gluster_state obj = brick_utilization.TendrlBrickUtilizationPlugin() obj.CLUSTER_TOPOLOGY = utils.get_gluster_cluster_topology() obj.parse_proc_mounts = MagicMock( return_value=self.parse_proc_mounts()) communicate.return_value = self.communicate() ismount.return_value = True dirname.return_value = (['/']) mock_obj = MagicMock() mock_obj.f_bsize = 4096 mock_obj.f_frsize = 4096 mock_obj.f_blocks = 2093568 mock_obj.f_bfree = 1351644 mock_obj.f_bavail = 1351644 mock_obj.f_files = 4192256 mock_obj.f_ffree = 4101251 mock_obj.f_favail = 4101251 mock_obj.f_flag = 4096 mock_obj.f_namemax = 255 statvfs.return_value = mock_obj with open("tendrl/node_agent/tests/output/" "tendrl_glusterfs_brick_utilization_output.json") as f: assert obj.get_metrics() == json.loads(f.read())
def test_gluster_health_counters(self, ini2json, execu): gluster_state = mock_gluster_state.gluster_state() execu.return_value = ("pytest", "") ini2json.ini_to_dict.return_value = gluster_state obj = health_counters.TendrlGlusterfsHealthCounters() obj.CLUSTER_TOPOLOGY = utils.get_gluster_cluster_topology() with open("tendrl/node_agent/tests/output/" "tendrl_glusterfs_health_counters_outpout.json") as f: assert obj.get_metrics() == json.loads(f.read())
def test_gluster_profile_info(self, ini2json, execu): profile_info.tendrl_gluster_heal_info = MagicMock() profile_info.TendrlHealInfoAndProfileInfoPlugin.etcd_client = \ MagicMock() gluster_state = mock_gluster_state.gluster_state() execu.return_value = self.volume_profile() ini2json.ini_to_dict.return_value = gluster_state utils.find_brick_host = MagicMock(return_value="10.70.43.214") obj = profile_info.TendrlHealInfoAndProfileInfoPlugin() obj.CLUSTER_TOPOLOGY = utils.get_gluster_cluster_topology() with open("tendrl/node_agent/tests/output/" "tendrl_glusterfs_profile_info_output.json") as f: assert obj.get_metrics() == json.loads(f.read())