【问题标题】:Selenium Allure report data to show on Grafana dashboardSelenium Allure 报告数据显示在 Grafana 仪表板上
【发布时间】:2021-03-19 13:33:56
【问题描述】:

我正在尝试在我的 pytest (python + selenium) 自动化项目的 Grafana 仪表板上显示 Allure 报告数据。我正在通过詹金斯的跑步生成一份魅力报告。需要一些关于如何向 grafana 显示我的 jenkins 运行报告的提示。是否有任何 API/插件可以将诱惑结果发送到任何时间序列数据库(Influxdb 或 Prometheus)?

【问题讨论】:

    标签: jenkins-plugins pytest prometheus grafana allure


    【解决方案1】:

    Allure 在导出目录中生成 influxdb 和 prometheus 文件。我即将编写 pytest 'plugin' 将此文件提供给 influxDB 数据库。之后,您将 Grafana 设置为从该数据库中提取数据并显示数据。

    编辑:我不使用 selenium 或 jenkins,所以对于控制台 pytest 运行,我只是将此代码(pytest 挂钩)添加到 conftest.py 文件中:

    from influxdb_client import InfluxDBClient
    from influxdb_client.client.write_api import SYNCHRONOUS
    
    
    def pytest_terminal_summary(terminalreporter, exitstatus, config):
        influx_db_file = open('allure-html/export/influxDbData.txt', 'r')
        lines = influx_db_file.readlines()
        token = "MyToken"
        org = "MyOrg"
        bucket = "MyBucket"
        client = InfluxDBClient(url="http://localhost:8086", token=token)
        write_api = client.write_api(write_options=SYNCHRONOUS)
    
        for line in lines:
            write_api.write(bucket, org, line.strip())
    

    这个钩子在 pytest 完成时执行。您必须注意您的流入网址,以及您的令牌、组织和存储桶值。

    【讨论】:

    • 这太棒了@pera。完成“插件”后,请在此处更新。
    • 我为我的本地 pytest 插件添加了代码(它是一个插件挂钩,只是放在 conftest.py 文件中)。此代码读取 allure 导出的文件,并将其逐行提供给 influx db。
    猜你喜欢
    • 1970-01-01
    • 2022-08-10
    • 1970-01-01
    • 2022-11-01
    • 2010-10-24
    • 2010-10-18
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    相关资源
    最近更新 更多