def test_from_json(self): item = { 'usage_perc_all_services': 1.22, 'all_services_time': 4360, 'time_perc_all_services': 17.64, 'mean_trend': '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,769,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'min_resp_time': 769.0, 'service_name': 'zato.stats.summary.create-summary-by-year', 'max_resp_time': 769.0, 'rate': 0.0, 'mean_all_services': '63', 'all_services_usage': 82, 'time': 769.0, 'usage': 1, 'usage_trend': '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'mean': 12.61 } stats_elem = StatsElem.from_json(item) for k, v in item.items(): value = getattr(stats_elem, k) eq_(v, value)
def test_from_json(self): item = {'usage_perc_all_services': 1.22, 'all_services_time': 4360, 'time_perc_all_services': 17.64, 'mean_trend': '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,769,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'min_resp_time': 769.0, 'service_name': 'zato.stats.summary.create-summary-by-year', 'max_resp_time': 769.0, 'rate': 0.0, 'mean_all_services': '63', 'all_services_usage': 82, 'time': 769.0, 'usage': 1, 'usage_trend': '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'mean': 12.61} stats_elem = StatsElem.from_json(item) for k, v in item.items(): value = getattr(stats_elem, k) eq_(v, value)
def _get_stats(client, start, stop, n, n_type, stats_type=None): """ Returns at most n statistics elements of a given n_type for the period between start and stop. """ out = [] input_dict = {'start':start, 'n':n, 'n_type':n_type} if stop: input_dict['stop'] = stop if stats_type == 'trends': service_name = 'zato.stats.trends.get-trends' else: service_name = 'zato.stats.summary.get-summary-by-range' response = client.invoke(service_name, input_dict) if response.has_data: for item in response.data: out.append(StatsElem.from_json(item)) return out
def _get_stats(client, start, stop, n, n_type, stats_type=None): """ Returns at most n statistics elements of a given n_type for the period between start and stop. """ out = [] input_dict = {'start': start, 'n': n, 'n_type': n_type} if stop: input_dict['stop'] = stop if stats_type == 'trends': service_name = 'zato.stats.trends.get-trends' else: service_name = 'zato.stats.summary.get-summary-by-range' response = client.invoke(service_name, input_dict) if response.has_data: for item in response.data: out.append(StatsElem.from_json(item)) return out