def test_single_value(self): expected = { 'slope_data': [[86.8, 65.36]], 'range_data': [65.36], 'average_data': [65.36] } data_series = [[86.8, 65.36]] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)
def test_float_int_mix(self): expected = { 'slope_data': [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]], 'range_data': [12.7, 7, 5.3, 6], 'average_data': [12.7, 7, 5.3, 6] } data_series = [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)
def test_integer_series(self): expected = { 'slope_data': [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]], 'range_data': [5, 2, 98, 669, 66], 'average_data': [5, 2, 98, 669, 66] } data_series = [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)
def data_event(self, executor): self.logger.debug("Event received") if executor.terminated: self._push_to_db(executor) else: workload = '.'.join(executor.current_workload.split('.')[1:6]) if 'metrics' not in executor.metadata: executor.metadata['metrics'] = {} steady_state = True metrics = {} for metric in ('lat_ns.mean', 'iops', 'bw'): metrics[metric] = {} for io_type in ('read', 'write'): metrics[metric][io_type] = {} series = self._lookup_prior_data(executor, metric, io_type) series = self._convert_timestamps_to_samples( executor, series) steady = self._evaluate_prior_data( series, executor.steady_state_samples) self.logger.debug("Steady state for %s %s: %s" % (io_type, metric, steady)) metrics[metric][io_type]['series'] = series metrics[metric][io_type]['steady_state'] = steady treated_data = DataTreatment.data_treatment(series) metrics[metric][io_type]['slope'] = \ math.slope(treated_data['slope_data']) metrics[metric][io_type]['range'] = \ math.range_value(treated_data['range_data']) average = math.average(treated_data['average_data']) metrics[metric][io_type]['average'] = average metrics_key = '%s.%s.%s' % (workload, io_type, metric) executor.metadata['metrics'][metrics_key] = average if not steady: steady_state = False if 'report_data' not in executor.metadata: executor.metadata['report_data'] = {} if 'steady_state' not in executor.metadata: executor.metadata['steady_state'] = {} executor.metadata['report_data'][workload] = metrics executor.metadata['steady_state'][workload] = steady_state workload_name = executor.current_workload.split('.')[1] if steady_state and not workload_name.startswith('_'): executor.terminate_current_run()
def test_negative_values(self): expected = { 'slope_data': [[-15, 5.56], [41.3, -278], [41.3, -98], [78.336, -0.12], [33.667, 66]], 'range_data': [5.56, -278, -98, -0.12, 66], 'average_data': [5.56, -278, -98, -0.12, 66] } data_series = [[-15, 5.56], [41.3, -278], [41.3, -98], [78.336, -0.12], [33.667, 66]] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)
def test_float_series(self): expected = { 'slope_data': [[5.6, 12.7], [96.66, 78.212], [639.568, 5.3], [4.65, 6.667]], 'range_data': [12.7, 78.212, 5.3, 6.667], 'average_data': [12.7, 78.212, 5.3, 6.667] } data_series = [[5.6, 12.7], [96.66, 78.212], [639.568, 5.3], [4.65, 6.667]] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)
def steady_state(data_series): """ This function seeks to detect steady state given on a measurement window given the data series of that measurement window following the pattern : [[x1,y1], [x2,y2], ..., [xm,ym]]. m represents the number of points recorded in the measurement window, x which represents the time, and y which represents the Volume performance variable being tested e.g. IOPS, latency... The function returns a boolean describing wether or not steady state has been reached with the data that is passed to it. """ logger = logging.getLogger('storperf.utilities.steady_state') # Pre conditioning the data to match the algorithms treated_data = DataTreatment.data_treatment(data_series) # Calculating useful values invoking dedicated functions slope_value = math.slope(treated_data['slope_data']) range_value = math.range_value(treated_data['range_data']) average_value = math.average(treated_data['average_data']) if (slope_value is not None and range_value is not None and average_value is not None): # Verification of the Steady State conditions following the SNIA # definition range_condition = abs(range_value) <= 0.20 * abs(average_value) slope_condition = abs(slope_value) <= 0.10 * abs(average_value) steady_state = range_condition and slope_condition logger.debug("Range %s <= %s?" % (abs(range_value), (0.20 * abs(average_value)))) logger.debug("Slope %s <= %s?" % (abs(slope_value), (0.10 * abs(average_value)))) logger.debug("Steady State? %s" % steady_state) else: steady_state = False return steady_state
def test_empty_series(self): expected = {'slope_data': [], 'range_data': [], 'average_data': []} data_series = [] actual = DataTreatment.data_treatment(data_series) self.assertEqual(expected, actual)