Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Update to Grafana 8.5.21 and 9.4.3 #44

Merged
merged 4 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.7", "3.11" ]
grafana-version: [ "6.7.6", "7.5.17", "8.5.15", "9.2.7" ]
grafana-version: [ "6.7.6", "7.5.17", "8.5.21", "9.4.3" ]

env:
OS_TYPE: ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ in progress
===========
- Caching: Set cache filename to appname. Thanks, @gtirloni.
- Update to pandas 2.0 and requests 2.26
- CI: Update to Grafana 8.5.21 and 9.4.3
- Grafana 9.3: Work around delete folder operation returning empty body
- Grafana 9.4.3: Accept numeric user identifiers in log responses

2023-07-30 0.15.2
=================
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. image:: https://github.com/panodata/grafana-wtf/workflows/Tests/badge.svg
:target: https://github.com/panodata/grafana-wtf/actions?workflow=Tests
.. image:: https://github.com/panodata/grafana-wtf/actions/workflows/tests.yml/badge.svg
:target: https://github.com/panodata/grafana-wtf/actions/workflows/tests.yml

.. image:: https://img.shields.io/pypi/pyversions/grafana-wtf.svg
:target: https://pypi.org/project/grafana-wtf/
Expand All @@ -10,7 +10,7 @@
.. image:: https://img.shields.io/pypi/v/grafana-wtf.svg
:target: https://pypi.org/project/grafana-wtf/

.. image:: https://pepy.tech/badge/grafana-wtf/month
.. image:: https://static.pepy.tech/badge/grafana-wtf/month
:target: https://pypi.org/project/grafana-wtf/

.. image:: https://img.shields.io/pypi/l/grafana-wtf.svg
Expand Down
4 changes: 2 additions & 2 deletions tests/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#GRAFANA_VERSION=6.7.6
#GRAFANA_VERSION=7.5.17
#GRAFANA_VERSION=8.5.15
GRAFANA_VERSION=9.2.7
#GRAFANA_VERSION=8.5.21
GRAFANA_VERSION=9.4.3
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import re
from io import StringIO
from json import JSONDecodeError
from pathlib import Path
from typing import List, Optional, Union

Expand Down Expand Up @@ -216,7 +217,13 @@ def _create_folder(title: str, uid: str = None):
if CLEANUP_RESOURCES:
if folder_uids:
for folder_uid in folder_uids:
grafana.folder.delete_folder(uid=folder_uid)
# Grafana 9.3 introduced a regression.
# It returns 200 OK with an empty response body on delete operations.
# https://github.com/panodata/grafana-wtf/pull/44
try:
grafana.folder.delete_folder(uid=folder_uid)
except JSONDecodeError:
pass


@pytest.fixture
Expand Down
16 changes: 11 additions & 5 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def test_log_json_success(ldi_resources, capsys, caplog):
reference = {
"version": 1,
# "datetime": "2021-09-29T17:32:23Z",
"user": "admin",
"message": "",
"folder": "Testdrive",
"title": "luftdaten.info generic trend v27",
Expand All @@ -274,13 +273,15 @@ def test_log_json_success(ldi_resources, capsys, caplog):

history = json.loads(captured.out)
item = history[-1]
assert item["user"] in ["admin", 1]
del item["datetime"]
del item["id"]
del item["user"]

assert item == reference


def test_log_tabular_success(ldi_resources, capsys, caplog):
def test_log_tabular_success(ldi_resources, capsys, caplog, grafana_version):
# Only provision specific dashboard(s).
ldi_resources(dashboards=["tests/grafana/dashboards/ldi-v27.json", "tests/grafana/dashboards/ldi-v33.json"])

Expand All @@ -293,9 +294,14 @@ def test_log_tabular_success(ldi_resources, capsys, caplog):
# Verify output.
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz"' in caplog.text

reference = """
| Notes: n/a<br/>[Testdrive » luftdaten.info generic trend v27](http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27) | User: admin<br/>Date: xxxx-xx-xxTxx:xx:xxZ |
""".strip()
if version.parse(grafana_version) >= version.parse("9.4.3"):
reference = """
| Notes: n/a<br/>[Testdrive » luftdaten.info generic trend v27](http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27) | User: 1<br/>Date: xxxx-xx-xxTxx:xx:xxZ |
""".strip()
else:
reference = """
| Notes: n/a<br/>[Testdrive » luftdaten.info generic trend v27](http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27) | User: admin<br/>Date: xxxx-xx-xxTxx:xx:xxZ |
""".strip()

first_item_raw = str.splitlines(captured.out)[-1]
first_item_normalized = re.sub("(.*)Date: .+|(.*)", r"\1Date: xxxx-xx-xxTxx:xx:xxZ |\2", first_item_raw, 1)
Expand Down