Skip to main content

A Robot Framework listener for reporting via Icinga2 API.

Project description

A Robot Framework listener for reporting via Icinga2 API.

  • Free software: Apache Software License 2.0

Installation

If used with rcc.exe see conda.yaml below. Else just install the regular way like this:

pip install robotframework-listener-icinga

You can also install the in-development version with:

pip install https://gitlab.com/dominik.riva/robotframework-listener-icinga/-/archive/main/robotframework-listener-icinga-main.zip

Documentation

The following example uses the rcc.exe from robocorp as a stable platform to run your robot framework scenarios. The robot scenario below is a simple test based on the example-windows-calculator (switched to python in newest commit).

conda.yaml (see - robotframework-listener-icinga)

channels:
# Define conda channels here.
- conda-forge

dependencies:
# Define conda packages here.
# If available, always prefer the conda version of a package, installation will be faster and more efficient.
# https://anaconda.org/search
- python=3.9.13                 # https://pyreadiness.org/3.9/
- pip=22.2.2                    # https://pip.pypa.io/en/stable/news/
- pip:
    # Define pip packages here.
    # https://pypi.org/
    - rpaframework==26.1.0        # https://rpaframework.org/releasenotes.html
    - pip-system-certs==4.0       # required to access system cert store
    - robotframework-listener-icinga==1.0.0

robot.yaml (see –listener icinga)

tasks:
Id Based Calculator Demo:
    command:
    - python
    - -m
    - robot
    - --report
    - NONE
    - --outputdir
    - output
    - --logtitle
    - Task log
    - --listener
    - icinga
    - tasks.robot
condaConfigFile: conda.yaml
ignoreFiles:
- .gitignore
artifactsDir: output
PATH:
- .
PYTHONPATH:
- .

Robots can be build with robot framework keywords or straight up Python.

tasks.robot (noting about the listener in this file)

*** Settings ***
Library           String
Library           RPA.Windows
Library           Collections
Task Teardown     Close Window     name:Rechner

*** Keywords ***
Open the Rechner
    Windows Search    Rechner
    #Foreground Window    Rechner

Compare result
    [Arguments]    ${first}
    ${result}=    Get Attribute    id:CalculatorResults    Name
    Should Contain    ${result}    ${first}

Add two numbers using app ids
    [Arguments]    ${first}    ${second}    ${third}
    Click    id:clearEntryButton
    Click    id:num${first}Button
    Click    id:plusButton
    Click    id:num${second}Button
    Click    id:equalButton
    Log results
    Compare result    ${third}

Approximate pi
    [Arguments]    ${first}    ${second}    ${third}
    Click    id:clearEntryButton
    Send Keys    Rechner    ${first}
    Click    id:divideButton
    Send Keys    Rechner    ${second}
    Click    id:equalButton
    Log results
    Compare result    ${third}

Log results
    ${result}=    Get Attribute    id:CalculatorResults    Name
    Log    ${result}
    Screenshot    Rechner   %{ROBOT_ARTIFACTS}${/}${TEST_NAME}id-based-result.png

*** Tasks ***
Addition
    Open the Rechner
    Add two numbers using app ids    9    5    14
Division
    Open the Rechner
    Approximate pi    355    113    3.14159292035

devdata\env.json (see ICINGA_* variables)

{
    "RPA_SECRET_MANAGER": "RPA.Robocorp.Vault.FileSecrets",
    "RPA_SECRET_FILE": "C:\\Users\\USER\\vault.json",
    "ICINGA_FQDN": "icinga.example.com",
    "ICINGA_HOST_NAME": "testrobot.example.com",
    "ICINGA_SERVICE_NAME": "Passive - Robot Framework - example-windows-calculator - Id-Based",
    "ICINGA_TTL": "900"
}

C:\Users\USER\vault.json (must match preconfigured Icinga2 API user - pull request for certificate based auth are welcomed)

{
    "icinga": {
        "api_user": "robotframework",
        "api_pass": "ADD_STRONG_PASSWORD"
    }
}

Icinga DSL generated by director preview of the host object. The Service “Passive - Robot Framework - example-windows-calculator - Id-Based” the above robot scenario listener is targeting. The variable “robot_framework_thresholds” allows to set thresholds and overwrite robot framework status.

zones.d/master/hosts.conf
object Host "vd418164.example.com" {
    import "tpl-host-windows"
    import "116-tpl-host-agent"

    display_name = "VD418164"
    address = "10.6.160.71"
    notes = "Robot Framework Entwicklungsroboter"
    groups = [ "Monitoring", "Robot Framework Robots" ]
    vars["_override_servicevars"] = {
        "Icingacli vSphereDB - VM Status" = {
            "116_check_icingacli_vspheredb_name" = "VD418164"
        }
        "Passive - Robot Framework - example-windows-calculator - Id-Based" = {
            robot_framework_thresholds = "{\"Tasks.Addition\": {\"warning\": \"0:14000\", \"critical\": \"0:16000\", \"status\": \"PASS\"}, \"Tasks.Division\": {\"warning\": \"0:15000\", \"critical\": \"0:18000\", \"status\": \"PASS\"}, \"Tasks\": {\"warning\": \"0:24000\", \"critical\": \"0:25000\", \"status\": \"PASS\"}}"
        }
        "Service - MSDTC" = {
            service_windows_starttype = "manual"
        }
        "Service - W32Time" = {
            service_windows_starttype = "manual"
        }
    }
    vars.custom_tags = [
        "robot-framework_sap",
        "robot-framework_isop",
        "vspheredb-vm",
        "robot-framework_kda",
        "robot-framework_meona-pflege",
        "robot-framework_meona-arzt",
        "robot-framework_patientenportal",
        "robot-framework_cardioapp",
        "robot-framework_patientenarchivviewer",
        "robot-framework_example-windows-calculator"
    ]
    vars.robot_framework_thresholds = "{\"Addition\": {\"warning\": \"0:12\", \"critical\": \"0:15\"}, \"Division\": {\"warning\": \"0:15\", \"critical\": \"0:18\"}, \"Tasks\": {\"warning\": \"0:20\", \"critical\": \"0:25\"}}"
    vars.tags = [ "windows" ]
    vars.teams = [ "Entwicklung_Monitoring" ]
}

zones.d/master/agent_endpoints.conf
object Endpoint "vd418164.example.com" {
    host = "10.6.160.71"
    log_duration = 0s
}

zones.d/master/agent_zones.conf
object Zone "vd418164.example.com" {
    parent = "master"
    endpoints = [ "vd418164.ms.uhbs.ch" ]
}

Screenshots

With ignore keywords set to True:

screenshot_with_ignore_keywords_ok.png screenshot_with_ignore_keywords_warn.png screenshot_with_ignore_keywords.png screenshot_with_ignore_keywords_performancedata.png

With ignore keywords set ot False:

screenshot_with_keywords.png screenshot_with_keywords_performancedata.png

Development

Pull request for Tox and pytest very welcomed!

To run all the tests run:

tox

Note, to combine the coverage data from all the tox environments run:

Windows

set PYTEST_ADDOPTS=--cov-append
tox

Other

PYTEST_ADDOPTS=--cov-append tox

Changelog

0.0.0 (2023-07-07)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_listener_icinga-1.0.3.tar.gz (18.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page