def generate_series(): session = api.get_session() test_dict = {} if not CONF.start_date and not CONF.stop_date: tests = api.get_all_tests(session) for test in tests: if CONF.command.test_ids: if test.test_id in CONF.command.test_ids: test_dict[test.test_id] = { 'success': int(test.success), 'failure': int(test.failure), } else: test_dict[test.test_id] = { 'success': int(test.success), 'failure': int(test.failure), } else: start_date = None stop_date = None if CONF.start_date: start_date = date_parser.parse(CONF.start_date) if CONF.stop_date: stop_date = date_parser.parse(CONF.stop_date) if CONF.command.test_ids: ids = [api.get_id_from_test_id(x) for x in CONF.command.test_ids] else: ids = api.get_ids_for_all_tests(session) for test in ids: test_dict[test] = api.get_test_counts_in_date_range( test, start_date, stop_date, session) if CONF.command.no_success_graph: for test in test_dict: test_dict[test].pop('success') if CONF.command.skip_graph: for test in test_dict: if not test_dict[test].get('skips'): test_id = api.get_id_from_test_id(test) test_dict[test]['skips'] = api.get_skip_counts(test_id) session.close() if not CONF.title: title = "Test status counts" else: title = CONF.title df = pd.DataFrame.from_dict(test_dict, orient='index') plot = df.plot(kind='barh', stacked=True).set_title(title) fig = plot.get_figure() fig.savefig(CONF.output)
def generate_series(): session = api.get_session() test_id = api.get_id_from_test_id(CONF.command.test_id, session) if not test_id: print("The test_id %s was not found in the database" % CONF.command.test_id) exit(2) run_times = api.get_test_run_time_series(test_id, session) if not run_times: print("There was no data found in the database") exit(3) if not CONF.title: test = api.get_test_by_id(test_id, session) session.close() ts = pd.Series(run_times) ts = utils.filter_dates(ts) if ts.count() == 0: print("No data available. Check your query and try again.") exit(-1) mean = pd.rolling_mean(ts, 20) rolling_std = pd.rolling_std(ts, 20) plt.figure() if not CONF.title: plt.title(test.test_id) else: plt.title(CONF.title) plt.ylabel('Time (sec.)') # format x-axis with dates fig, ax = plt.subplots(1) fig.autofmt_xdate() xfmt = dates.DateFormatter("%b %d %Y") ax.xaxis_date() ax.xaxis.set_major_formatter(xfmt) plt.plot(ts.index, ts, 'k', label='Run Time') plt.plot(mean.index, mean, 'b', label='Avg. Run Time') upper_std_dev = mean + 2 * rolling_std lower_std_dev = mean - 2 * rolling_std # Set negative numbers to 0 lower_std_dev[lower_std_dev < 0] = 0 plt.fill_between(rolling_std.index, upper_std_dev, lower_std_dev, color='b', alpha=0.2, label='std dev') plt.legend() plt.savefig(CONF.output, dpi=900) return ts
def generate_series(): session = api.get_session() test_id = api.get_id_from_test_id(CONF.command.test_id, session) if not test_id: print("The test_id %s was not found in the database" % CONF.command.test_id) exit(2) run_times = api.get_test_run_time_series(test_id, session) if not run_times: print("There was no data found in the database") exit(3) if not CONF.title: test = api.get_test_by_id(test_id, session) session.close() ts = pd.Series(run_times) ts = utils.filter_dates(ts) if ts.count() == 0: print("No data available. Check your query and try again.") exit(-1) roll = ts.rolling(window=20, center=False) mean = roll.mean() rolling_std = roll.std() plt.figure() if not CONF.title: plt.title(test.test_id) else: plt.title(CONF.title) plt.ylabel('Time (sec.)') # format x-axis with dates fig, ax = plt.subplots(1) fig.autofmt_xdate() xfmt = dates.DateFormatter("%b %d %Y") ax.xaxis_date() ax.xaxis.set_major_formatter(xfmt) plt.plot(ts.index, ts, 'ko', label='Run Time', markersize=0.45) plt.plot(mean.index, mean, 'b', label='Avg. Run Time', linewidth=0.45) upper_std_dev = mean + 2 * rolling_std lower_std_dev = mean - 2 * rolling_std # Set negative numbers to 0 lower_std_dev[lower_std_dev < 0] = 0 plt.fill_between(rolling_std.index, upper_std_dev, lower_std_dev, color='b', alpha=0.2, label='std dev') plt.legend() plt.savefig(CONF.output, dpi=CONF.dpi) return ts
def generate_series(): session = api.get_session() test_id = api.get_id_from_test_id(CONF.command.test_id, session) test_statuses = api.get_test_status_time_series(test_id, session) if not CONF.title: test = api.get_test_by_id(test_id, session) session.close() ts = pd.Series(test_statuses) ts = utils.filter_dates(ts) run_count = len(ts) if run_count == 0: print("Query returned no data.") exit(-1) failures = ts[ts.isin(['fail', 'unxsuccess'])] successes = ts[ts.isin(['success', 'xfail'])] skips = ts[ts.isin(['skip'])] fail_count = len(failures) success_count = len(successes) skip_count = len(skips) fail_group = failures.groupby(failures.index.date).agg(len) success_group = successes.groupby(successes.index.date).agg(len) skip_group = skips.groupby(skips.index.date).agg(len) if not CONF.title: plot = fail_group.plot().set_title(test.test_id) else: plot = fail_group.plot().set_title(CONF.title) if CONF.command.success_graph: if success_count: success_group.plot() if CONF.command.skip_graph: if skip_count: skip_group.plot() def percent(count, total): count = float(count) total = float(total) return (count / total) * 100.0 print('Fail Percentage: %.4f%%' % percent(fail_count, run_count)) print('Success Percentage: %.4f%%' % percent(success_count, run_count)) print('Skip Percentage: %.4f%%' % percent(skip_count, run_count)) fig = plot.get_figure() fig.savefig(CONF.output) return ts
def test_get_id_from_test_id(self): test_a = api.create_test('fake_test') id_value = api.get_id_from_test_id('fake_test') self.assertEqual(test_a.id, id_value)