Example #1
0
 def test_make_plot(self):
   input_df = pd.DataFrame({
       'test_name': pd.Series(['test1', 'test2', 'test3']),
       'run_date': pd.Series(['2020-04-21', '2020-04-20', '2020-04-19']),
       'job_status': pd.Series(['success', 'success', 'failure']),
       'logs_link': pd.Series([SAMPLE_LOGS_LINK] * 3),
       'job_status_abbrev': pd.Series(['f', 'f', '']),
       'overall_status': pd.Series(['failure', 'success', 'failure']),
   })
   # Make sure nothing crashes and we are able generate some kind of plot.
   plot = main_heatmap.make_plot(input_df)
   self.assertTrue(plot is not None and len(plot.renderers) > 0)
Example #2
0
 def test_make_plot_empty_data(self):
     input_df = pd.DataFrame()
     # Make sure nothing crashes.
     plot = main_heatmap.make_plot(input_df)
    with concurrent.futures.ThreadPoolExecutor(
            max_workers=len(test_name_prefixes)) as executor:
        # Prepare the thread tasks.
        tasks = {}
        for test_name_prefix in test_name_prefixes:
            task = executor.submit(main_heatmap.fetch_data, test_name_prefix)
            tasks[task] = test_name_prefix

        # Run the tasks and collect results as they arrive.
        data = {}
        for task in concurrent.futures.as_completed(tasks):
            key = tasks[task]
            data[key] = task.result()
    # Return results once all tasks have been completed.
    t1 = time.time()
    timer.text = '(Execution time: %s seconds)' % round(t1 - t0, 4)
    return data


timer = Paragraph()

all_tabs = []
test_name_prefixes = os.environ.get('TEST_NAME_PREFIXES', '').split(',')
all_data = parallel_fetch_data(test_name_prefixes)
for test_prefix, data in all_data.items():
    plot = main_heatmap.make_plot(data)
    all_tabs.append(Panel(child=plot, title=test_prefix))

curdoc().title = "Test pass/fail Dashboard"
curdoc().add_root(column(children=[row(timer), row(Tabs(tabs=all_tabs))]))