Ejemplo n.º 1
0
def test_metrics_with_summary_without_error():
  """
  Tests to verify that metric reports are generated if the metrics are not in error. Also a summary report should be created.
  """
  global output_directory
  global input_log_directory
  global resource_path
  rules = {}
  metrics = [Metric('MetricOne', 'TestOne.csv', 'HostnameOne', output_directory, resource_path, 'MetricOne', None, None, rules),
                 Metric('MetricTwo', 'TestTwo.csv', 'HostnameOne', output_directory, resource_path, 'MetricTwo', None, None, rules),
                 Metric('MetricThree', 'TestThree.csv', 'HostnameOne', output_directory, resource_path, 'MetricThree', None, None, rules)
                 ]
  for metric in metrics:
    files_list = [os.path.join(input_log_directory,'a.csv'), os.path.join(input_log_directory,'b.csv')]
    metric.csv_files = files_list
    metric.stats_files = files_list
    metric.timeseries_csv_list = files_list
    metric.important_stats_files = files_list
    metric.percentiles_files = files_list

  aggregate_metrics = []
  correlated_plots = []
  rpt = Report(None, output_directory, resource_directory, resource_path, metrics + aggregate_metrics, correlated_plots=correlated_plots)
  rpt.generate()
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricOne_report.html'))
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricTwo_report.html'))
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricThree_report.html'))
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'report.html'))
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'summary_report.html'))
  os.system('rm -rf tmp_report_test/*.*')
  os.system('rm -rf tmp_report_test/resources/*.*')
Ejemplo n.º 2
0
def test_metrics_without_summary_with_error():
    """
  Tests to verify that metric reports are not generated if the metrics are in error. Also no summary report should be created.
  """
    global output_directory
    global resource_path
    rules = {}
    metrics = get_three_metrics(output_directory, resource_path, rules)
    aggregate_metrics = []
    correlated_plots = []
    rpt = Report(None,
                 output_directory,
                 resource_directory,
                 resource_path,
                 metrics + aggregate_metrics,
                 correlated_plots=correlated_plots)
    rpt.generate()
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricOne_report.html'))
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricTwo_report.html'))
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricThree_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'report.html'))
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'summary_report.html'))
    os.system('rm -rf tmp_report_test/*.*')
    os.system('rm -rf tmp_report_test/resources/*.*')
Ejemplo n.º 3
0
def test_metrics_with_summary_with_partial_error():
    """
  Tests to verify that metric reports are generated for OK metrics if there are some metrics that are in error. Also a summary report should be created.
  """
    global output_directory
    global input_log_directory
    global resource_path
    rules = {}
    metrics = get_two_metrics(output_directory, resource_path, rules)
    files_list = [
        os.path.join(input_log_directory, 'a.csv'),
        os.path.join(input_log_directory, 'b.csv')
    ]
    for metric in metrics:
        metric.csv_files = files_list
        metric.stats_files = files_list
        metric.timeseries_csv_list = files_list
        metric.important_stats_files = files_list
        metric.percentiles_files = files_list

    metrics.append(
        Metric('MetricThree', 'TestThree.csv', 'HostnameOne', output_directory,
               resource_path, 'MetricThree', None, None, rules, None, None))

    aggregate_metrics = []
    correlated_plots = []
    rpt = Report(None,
                 output_directory,
                 resource_directory,
                 resource_path,
                 metrics + aggregate_metrics,
                 correlated_plots=correlated_plots)
    rpt.generate()
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricOne_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricTwo_report.html'))
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricThree_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'summary_report.html'))
    os.system('rm -rf tmp_report_test/*.*')
    os.system('rm -rf tmp_report_test/resources/*.*')
Ejemplo n.º 4
0
def test_metrics_without_summary_with_error():
  """
  Tests to verify that metric reports are not generated if the metrics are in error. Also no summary report should be created.
  """
  global output_directory
  global resource_path
  rules = {}
  metrics = get_three_metrics(output_directory, resource_path, rules)
  aggregate_metrics = []
  correlated_plots = []
  rpt = Report(None, output_directory, resource_directory, resource_path, metrics + aggregate_metrics, correlated_plots=correlated_plots)
  rpt.generate()
  assert not naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricOne_report.html'))
  assert not naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricTwo_report.html'))
  assert not naarad.utils.is_valid_file(os.path.join(output_directory, 'MetricThree_report.html'))
  assert naarad.utils.is_valid_file(os.path.join(output_directory, 'report.html'))
  assert not naarad.utils.is_valid_file(os.path.join(output_directory, 'summary_report.html'))
  os.system('rm -rf tmp_report_test/*.*')
  os.system('rm -rf tmp_report_test/resources/*.*')
Ejemplo n.º 5
0
def test_metrics_without_summary_without_error():
    """
  Tests to verify that metric reports are generated if the metrics are not in error. Also no summary report should be created.
  """
    global output_directory
    global input_log_directory
    global resource_path
    rules = {}
    metrics = get_three_metrics(output_directory, resource_path, rules)
    for metric in metrics:
        files_list = [
            os.path.join(input_log_directory, 'a.csv'),
            os.path.join(input_log_directory, 'b.csv')
        ]
        metric.csv_files = files_list
        metric.stats_files = files_list
        metric.timeseries_csv_list = files_list
        metric.percentiles_files = files_list

    aggregate_metrics = []
    correlated_plots = []
    rpt = Report(None,
                 output_directory,
                 resource_directory,
                 resource_path,
                 metrics + aggregate_metrics,
                 correlated_plots=correlated_plots)
    rpt.generate()
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricOne_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricTwo_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'MetricThree_report.html'))
    assert naarad.utils.is_valid_file(
        os.path.join(output_directory, 'report.html'))
    assert not naarad.utils.is_valid_file(
        os.path.join(output_directory, 'summary_report.html'))
    os.system('rm -rf tmp_report_test/*.*')
    os.system('rm -rf tmp_report_test/resources/*.*')
Ejemplo n.º 6
0
def main():
  init_logging('INFO')
  rpt = Report(report_name = 'test report', output_directory = '/tmp/naarad', metric_list = ['JMETER', 'GC', 'SAR-memory', 'SAR-device'] )
  rpt.generate()