Exemplo n.º 1
0
def test_histogram():
    """
  test histogram
  """

    res = generateHistogram(filename, [2, 2, 3, 4, 5, 5], {})
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'histogram1.png'))
    assert res == 0.0

    res = generateHistogram(filename, [{
        'a': [1, 2, 3, 1, 2, 2, 4, 2]
    }, {
        'b': [2, 2, 2, 4, 4, 1, 1]
    }], {'plot_grid': '2:1'})
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'histogram2.png'))
    assert res == 0.0

    res = generateHistogram(filename, [{'a': [1]}, {'b': [2, 3, 3, 5, 5]}], {})
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'histogram3.png'))
    assert res == 0.0
Exemplo n.º 2
0
def test_histogram():
    """
    test histogram
    """

    res = generateHistogram(filename, [2, 2, 3, 4, 5, 5], {})
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "histogram1.png"))
    assert res == 0.0

    res = generateHistogram(filename, [{
        "a": [1, 2, 3, 1, 2, 2, 4, 2]
    }, {
        "b": [2, 2, 2, 4, 4, 1, 1]
    }], {"plot_grid": "2:1"})
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "histogram2.png"))
    assert res == 0.0

    res = generateHistogram(filename, [{"a": [1]}, {"b": [2, 3, 3, 5, 5]}], {})
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "histogram3.png"))
    assert res == 0.0
Exemplo n.º 3
0
def test_nodataplot():
    """
    Test no data plot
    """

    res = generateNoDataPlot(filename, {}, {"title": "Test plot"})
    assert res["OK"] is True
    res = compare(filename, os.path.join(plots_directory, "nodata.png"))
    assert res == 0.0
Exemplo n.º 4
0
def test_nodataplot():
    """
  Test no data plot
  """

    res = generateNoDataPlot(filename, {}, {'title': 'Test plot'})
    assert res['OK'] is True
    res = compare(filename, os.path.join(plots_directory, 'nodata.png'))
    assert res == 0.0
Exemplo n.º 5
0
def test_qualityplot():
    """
    Test quality plot
    """

    res = generateQualityPlot(
        filename,
        {
            "User": {
                1584543600: 37.5,
                1584547200: 37.5,
                1584619200: 33.33333333333333,
                1584601200: 36.53846153846153
            }
        },
        {},
    )
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "qualityplot1.png"))
    assert res == 0.0

    res = generateQualityPlot(
        filename,
        {
            "User": {
                1584543600: 37.5,
                1584547200: 37.5,
                1584619200: 33.33333333333333,
                1584601200: 36.53846153846153
            }
        },
        {
            "endtime": 1584627764,
            "span": 3600,
            "starttime": 1584541364,
            "title": "Job CPU efficiency by JobType"
        },
    )
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "qualityplot2.png"))
    assert res == 0.0
Exemplo n.º 6
0
def test_error():
    """
    Test error message plot
    """

    res = generateErrorMessagePlot("testing error message")
    with open(filename, "wb") as out:
        out.write(res)

    res = compare(filename, os.path.join(plots_directory, "error.png"))
    assert res == 0.0
Exemplo n.º 7
0
def test_stackedlineplots():
    """
    test stacked line plot
    """

    res = generateStackedLinePlot(
        filename,
        {
            "LCG.Zoltan.hu": {
                1584460800: 1.0,
                1584489600: 2.0,
                1584511200: 1.0,
                1584464400: 1.0,
                1584540000: 0.022222222222222223,
                1584500400: 2.2,
                1584529200: 1.2,
                1584468000: 0.0,
                1584486000: 1.1,
                1584518400: 0.2,
                1584471600: 1.0,
                1584532800: 0.0022222222222222222,
                1584507600: 0.3,
                1584475200: 1.2,
                1584482400: 0.4,
                1584496800: 5.0,
                1584525600: 0.5,
                1584536400: 0.012777777777777779,
                1584514800: 2.0,
                1584453600: 3.0,
                1584478800: 0.09,
                1584504000: 1.0,
                1584457200: 3.0,
                1584493200: 1.0,
                1584522000: 1.8,
            },
            "LCG.CERN.cern": {
                1584460800: 1.6,
                1584489600: 2.8,
                1584511200: 3.0,
                1584464400: 4.0,
                1584540000: 1.022222222222222223,
                1584500400: 3.2,
                1584529200: 0.2,
                1584468000: 1.0,
                1584486000: 1.1,
            },
        },
        {},
    )

    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "stackedline.png"))
    assert res == 0.0
Exemplo n.º 8
0
def test_error():
    """
  Test error message plot
  """

    res = generateErrorMessagePlot("testing error message")
    assert res['OK'] is True
    with open(filename, 'wb') as out:
        out.write(res['Value'])

    res = compare(filename, os.path.join(plots_directory, 'error.png'))
    assert res == 0.0
Exemplo n.º 9
0
def test_cumulativeplot():
    """
    test cumulative stracked line plot
    """

    res = generateCumulativePlot(
        filename,
        {
            "User": {
                1584460800: 0.0,
                1584489600: 0.0,
                1584511200: 0.0,
                1584464400: 0.0,
                1584540000: 16.0,
                1584500400: 0.0,
                1584529200: 0.0,
                1584468000: 0.0,
                1584457200: 0.0,
                1584518400: 0.0,
                1584471600: 0.0,
                1584507600: 0.0,
                1584475200: 0.0,
                1584496800: 0.0,
                1584525600: 0.0,
                1584536400: 6.0,
                1584486000: 0.0,
                1584514800: 0.0,
                1584482400: 0.0,
                1584478800: 0.0,
                1584504000: 0.0,
                1584532800: 1.0,
                1584543600: 21.0,
                1584493200: 0.0,
                1584522000: 0.0,
            }
        },
        {
            "span": 3600,
            "title": "Cumulative Jobs by JobType",
            "starttime": 1584457326,
            "ylabel": "jobs",
            "sort_labels": "max_value",
            "endtime": 1584543726,
        },
    )

    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory,
                                         "cumulativeplot.png"))
    assert res == 0.0
Exemplo n.º 10
0
def test_piechartplot():
    """
    test pie chart plots
    """
    res = generatePiePlot(filename, {
        "a": 16.0,
        "b": 56.0,
        "c": 15,
        "d": 20
    }, {})
    assert res["OK"] is True

    res = compare(filename, os.path.join(plots_directory, "piechart.png"))
    assert res == 0.0
Exemplo n.º 11
0
def test_piechartplot():
    """
  test pie chart plots
  """
    res = generatePiePlot(filename, {
        'a': 16.0,
        'b': 56.0,
        'c': 15,
        'd': 20
    }, {})
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'piechart.png'))
    assert res == 0.0
Exemplo n.º 12
0
def test_qualityplot():
    """
  Test quality plot
  """

    res = generateQualityPlot(
        filename, {
            'User': {
                1584543600: 37.5,
                1584547200: 37.5,
                1584619200: 33.33333333333333,
                1584601200: 36.53846153846153
            }
        }, {})
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'qualityplot1.png'))
    assert res == 0.0

    res = generateQualityPlot(
        filename, {
            'User': {
                1584543600: 37.5,
                1584547200: 37.5,
                1584619200: 33.33333333333333,
                1584601200: 36.53846153846153
            }
        }, {
            'endtime': 1584627764,
            'span': 3600,
            'starttime': 1584541364,
            'title': 'Job CPU efficiency by JobType'
        })
    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory, 'qualityplot2.png'))
    assert res == 0.0
Exemplo n.º 13
0
def test_cumulativeplot():
    """
  test cumulative stracked line plot
  """

    res = generateCumulativePlot(
        filename, {
            'User': {
                1584460800: 0.0,
                1584489600: 0.0,
                1584511200: 0.0,
                1584464400: 0.0,
                1584540000: 16.0,
                1584500400: 0.0,
                1584529200: 0.0,
                1584468000: 0.0,
                1584457200: 0.0,
                1584518400: 0.0,
                1584471600: 0.0,
                1584507600: 0.0,
                1584475200: 0.0,
                1584496800: 0.0,
                1584525600: 0.0,
                1584536400: 6.0,
                1584486000: 0.0,
                1584514800: 0.0,
                1584482400: 0.0,
                1584478800: 0.0,
                1584504000: 0.0,
                1584532800: 1.0,
                1584543600: 21.0,
                1584493200: 0.0,
                1584522000: 0.0
            }
        }, {
            'span': 3600,
            'title': 'Cumulative Jobs by JobType',
            'starttime': 1584457326,
            'ylabel': 'jobs',
            'sort_labels': 'max_value',
            'endtime': 1584543726
        })

    assert res['OK'] is True

    res = compare(filename, os.path.join(plots_directory,
                                         'cumulativeplot.png'))
    assert res == 0.0
Exemplo n.º 14
0
def test_plotActivityRunningThreads():
    """ test for the method "_plotActivityRunningThreads"
  """

    plotName = "ComponentMonitoringPlotter_plotActivityRunningThreads"
    reportRequest = {
        'grouping': 'component',
        'groupingFields': ('%s', ['component']),
        'startTime': 1562796000,
        'endTime': 1562882400,
        'condDict': {
            'component': 'Monitoring_Monitoring'
        }
    }

    plotInfo = {
        'data': {
            'Monitoring_Monitoring': {
                1562853600: 0,
                1562857200: 6.866666666666666,
                1562861700: 6.0,
                1562854500: 5.6,
                1562855400: 6.2,
                1562856300: 6.538461538461538,
                1562858100: 6.333333333333333,
                1562849100: 0,
                1562860800: 6.153846153846154,
                1562850000: 0,
                1562848200: 0,
                1562859900: 6.2,
                1562850900: 0,
                1562851800: 0,
                1562847300: 0,
                1562852700: 0
            }
        },
        'unit': 'RunningThreads',
        'granularity': 900
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotActivityRunningThreads(reportRequest, plotInfo, plotName)
    assert res['OK'] is True
    assert res['Value'] == {'plot': True, 'thumbnail': False}

    res = compare('%s.png' % plotName,
                  '%s.png' % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 15
0
def test_plotMemoryUsage():
    """ test for the method "_plotMemoryUsage"
  """

    plotName = "ComponentMonitoringPlotter_plotMemoryUsage"
    reportRequest = {
        'grouping': 'component',
        'groupingFields': ('%s', ['component']),
        'startTime': 1562796000,
        'endTime': 1562882400,
        'condDict': {
            'component': 'Monitoring_Monitoring'
        }
    }

    plotInfo = {
        'data': {
            'Monitoring_Monitoring': {
                1562853600: 93.03776041666667,
                1562857200: 0,
                1562854500: 0,
                1562855400: 0,
                1562856300: 0,
                1562858100: 0,
                1562849100: 249.76318359375,
                1562860800: 0,
                1562850000: 165.26674107142858,
                1562848200: 260.68917410714283,
                1562859900: 0,
                1562850900: 180.12890625,
                1562851800: 186.35546875,
                1562847300: 121.13671875,
                1562852700: 186.35807291666666
            }
        },
        'unit': 'MB',
        'granularity': 900
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotMemoryUsage(reportRequest, plotInfo, plotName)
    assert res['OK'] is True
    assert res['Value'] == {'plot': True, 'thumbnail': False}

    res = compare('%s.png' % plotName,
                  '%s.png' % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 16
0
def test_plotActivityRunningThreads():
    """test for the method "_plotActivityRunningThreads" """

    plotName = "ComponentMonitoringPlotter_plotActivityRunningThreads"
    reportRequest = {
        "grouping": "component",
        "groupingFields": ("%s", ["component"]),
        "startTime": 1562796000,
        "endTime": 1562882400,
        "condDict": {
            "component": "Monitoring_Monitoring"
        },
    }

    plotInfo = {
        "data": {
            "Monitoring_Monitoring": {
                1562853600: 0,
                1562857200: 6.866666666666666,
                1562861700: 6.0,
                1562854500: 5.6,
                1562855400: 6.2,
                1562856300: 6.538461538461538,
                1562858100: 6.333333333333333,
                1562849100: 0,
                1562860800: 6.153846153846154,
                1562850000: 0,
                1562848200: 0,
                1562859900: 6.2,
                1562850900: 0,
                1562851800: 0,
                1562847300: 0,
                1562852700: 0,
            }
        },
        "unit": "RunningThreads",
        "granularity": 900,
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotActivityRunningThreads(reportRequest, plotInfo, plotName)
    assert res["OK"] is True
    assert res["Value"] == {"plot": True, "thumbnail": False}

    res = compare("%s.png" % plotName,
                  "%s.png" % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 17
0
def test_plotMemoryUsage():
    """test for the method "_plotMemoryUsage" """

    plotName = "ComponentMonitoringPlotter_plotMemoryUsage"
    reportRequest = {
        "grouping": "component",
        "groupingFields": ("%s", ["component"]),
        "startTime": 1562796000,
        "endTime": 1562882400,
        "condDict": {
            "component": "Monitoring_Monitoring"
        },
    }

    plotInfo = {
        "data": {
            "Monitoring_Monitoring": {
                1562853600: 93.03776041666667,
                1562857200: 0,
                1562854500: 0,
                1562855400: 0,
                1562856300: 0,
                1562858100: 0,
                1562849100: 249.76318359375,
                1562860800: 0,
                1562850000: 165.26674107142858,
                1562848200: 260.68917410714283,
                1562859900: 0,
                1562850900: 180.12890625,
                1562851800: 186.35546875,
                1562847300: 121.13671875,
                1562852700: 186.35807291666666,
            }
        },
        "unit": "MB",
        "granularity": 900,
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotMemoryUsage(reportRequest, plotInfo, plotName)
    assert res["OK"] is True
    assert res["Value"] == {"plot": True, "thumbnail": False}

    res = compare("%s.png" % plotName,
                  "%s.png" % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 18
0
def test_plotCpuUsage():
    """ test for the method "_plotCpuUsage"
  """

    plotName = "ComponentMonitoringPlotter_plotCpuUsage"
    reportRequest = {
        'grouping': 'component',
        'groupingFields': ('%s', ['component']),
        'startTime': 1562796000,
        'endTime': 1562882400,
        'condDict': {
            'component': 'Monitoring_Monitoring'
        }
    }

    plotInfo = {
        'data': {
            'Monitoring_Monitoring': {
                1562857200: 0,
                1562854500: 0,
                1562855400: 0,
                1562856300: 0,
                1562858100: 0,
                1562849100: 2.5875000450760126,
                1562850000: 0.9428571707436016,
                1562848200: 2.171428546309471,
                1562859900: 0,
                1562850900: 0.9428571473274913,
                1562851800: 0.10000000149011612,
                1562847300: 4.950000047683716,
                1562852700: 0.033333333830038704
            }
        },
        'unit': 'percentage',
        'granularity': 900
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotCpuUsage(reportRequest, plotInfo, plotName)
    assert res['OK'] is True
    assert res['Value'] == {'plot': True, 'thumbnail': False}

    res = compare('%s.png' % plotName,
                  '%s.png' % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 19
0
def test_plotCpuUsage():
    """test for the method "_plotCpuUsage" """

    plotName = "ComponentMonitoringPlotter_plotCpuUsage"
    reportRequest = {
        "grouping": "component",
        "groupingFields": ("%s", ["component"]),
        "startTime": 1562796000,
        "endTime": 1562882400,
        "condDict": {
            "component": "Monitoring_Monitoring"
        },
    }

    plotInfo = {
        "data": {
            "Monitoring_Monitoring": {
                1562857200: 0,
                1562854500: 0,
                1562855400: 0,
                1562856300: 0,
                1562858100: 0,
                1562849100: 2.5875000450760126,
                1562850000: 0.9428571707436016,
                1562848200: 2.171428546309471,
                1562859900: 0,
                1562850900: 0.9428571473274913,
                1562851800: 0.10000000149011612,
                1562847300: 4.950000047683716,
                1562852700: 0.033333333830038704,
            }
        },
        "unit": "percentage",
        "granularity": 900,
    }

    obj = ComponentMonitoringPlotter(None, None)
    res = obj._plotCpuUsage(reportRequest, plotInfo, plotName)
    assert res["OK"] is True
    assert res["Value"] == {"plot": True, "thumbnail": False}

    res = compare("%s.png" % plotName,
                  "%s.png" % os.path.join(plots_directory, plotName))
    assert res == 0.0
Exemplo n.º 20
0
def test_timestackedbarplot():
    """
  test timed stacked bar plot
  """
    res = generateTimedStackedBarPlot(
        filename, {
            'LCG.Cern.cern': {
                1584662400: 0.0,
                1584691200: 0.0,
                1584637200: 15.9593220339,
                1584666000: 0.0,
                1584694800: 0.0,
                1584626400: 31.867945823900005,
                1584669600: 0.0,
                1584644400: 0.0,
                1584615600: 0.0,
                1584673200: 0.0,
                1584633600: 14.0406779661,
                1584676800: 0.0,
                1584684000: 0.0,
                1584651600: 0.0,
                1584680400: 0.0,
                1584612000: 0.0,
                1584640800: 0.0,
                1584655200: 0.0,
                1584622800: 23.2293933044,
                1584698400: 0.0,
                1584630000: 9.5970654628,
                1584658800: 0.0,
                1584648000: 0.0,
                1584687600: 12.0,
                1584619200: 10.3055954089
            },
            'LCG.NCBJ.pl': {
                1584691200: 0.1,
                1584662400: 2.0,
                1584651600: 0.0,
                1584637200: 0.0,
                1584694800: 4.0,
                1584626400: 0.0,
                1584669600: 6.0,
                1584655200: 0.0,
                1584644400: 0.0,
                1584615600: 0.0,
                1584673200: 0.0,
                1584633600: 9.0,
                1584676800: 0.0,
                1584698400: 0.0,
                1584622800: 0.0,
                1584680400: 0.0,
                1584612000: 0.0,
                1584640800: 0.0,
                1584684000: 0.0,
                1584666000: 0.0,
                1584630000: 0.0,
                1584658800: 0.0,
                1584648000: 0.0,
                1584687600: 0.0,
                1584619200: 0.0
            }
        }, {
            'ylabel': 'jobs / hour',
            'endtime': 1584700844,
            'span': 3600,
            'starttime': 1584614444,
            'title': 'Jobs by Site'
        })
    assert res['OK'] is True

    res = compare(filename,
                  os.path.join(plots_directory, 'timedstackedbarplot.png'))
    assert res == 0.0
Exemplo n.º 21
0
def test_timestackedbarplot():
    """
    test timed stacked bar plot
    """
    res = generateTimedStackedBarPlot(
        filename,
        {
            "LCG.Cern.cern": {
                1584662400: 0.0,
                1584691200: 0.0,
                1584637200: 15.9593220339,
                1584666000: 0.0,
                1584694800: 0.0,
                1584626400: 31.867945823900005,
                1584669600: 0.0,
                1584644400: 0.0,
                1584615600: 0.0,
                1584673200: 0.0,
                1584633600: 14.0406779661,
                1584676800: 0.0,
                1584684000: 0.0,
                1584651600: 0.0,
                1584680400: 0.0,
                1584612000: 0.0,
                1584640800: 0.0,
                1584655200: 0.0,
                1584622800: 23.2293933044,
                1584698400: 0.0,
                1584630000: 9.5970654628,
                1584658800: 0.0,
                1584648000: 0.0,
                1584687600: 12.0,
                1584619200: 10.3055954089,
            },
            "LCG.NCBJ.pl": {
                1584691200: 0.1,
                1584662400: 2.0,
                1584651600: 0.0,
                1584637200: 0.0,
                1584694800: 4.0,
                1584626400: 0.0,
                1584669600: 6.0,
                1584655200: 0.0,
                1584644400: 0.0,
                1584615600: 0.0,
                1584673200: 0.0,
                1584633600: 9.0,
                1584676800: 0.0,
                1584698400: 0.0,
                1584622800: 0.0,
                1584680400: 0.0,
                1584612000: 0.0,
                1584640800: 0.0,
                1584684000: 0.0,
                1584666000: 0.0,
                1584630000: 0.0,
                1584658800: 0.0,
                1584648000: 0.0,
                1584687600: 0.0,
                1584619200: 0.0,
            },
        },
        {
            "ylabel": "jobs / hour",
            "endtime": 1584700844,
            "span": 3600,
            "starttime": 1584614444,
            "title": "Jobs by Site",
        },
    )
    assert res["OK"] is True

    res = compare(filename,
                  os.path.join(plots_directory, "timedstackedbarplot.png"))
    assert res == 0.0