Skip to content
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
ssh_username: cloud-user
neutron_plugin: ovs
OS_CLOUD: openstack
stackhpc_cloud_tests_version: ${{ github.ref }}
stackhpc_cloud_tests_version: ${{ github.head_ref || github.ref_name }}
repository: stackhpc/stackhpc-kayobe-config
github_ref: stackhpc/2024.1
runner: arc-aio-cloud-tests-runner
Expand All @@ -28,7 +28,7 @@ jobs:
ssh_username: ubuntu
neutron_plugin: ovn
OS_CLOUD: openstack
stackhpc_cloud_tests_version: ${{ github.ref }}
stackhpc_cloud_tests_version: ${{ github.head_ref || github.ref_name }}
repository: stackhpc/stackhpc-kayobe-config
github_ref: stackhpc/2024.1
runner: arc-aio-cloud-tests-runner
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
grafana-client==4.1.*
opensearch-py==2.5.*
prometheus-api-client==0.5.*
pytest-testinfra==10.1.*
pylint==3.3.*
pytest-testinfra==10.1.*
requests==2.31.*
13 changes: 13 additions & 0 deletions stackhpc_cloud_tests/monitoring/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 StackHPC Ltd.

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
40 changes: 40 additions & 0 deletions stackhpc_cloud_tests/monitoring/test_grafana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2024 StackHPC Ltd.

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# TODO: Check if we can validate that dashboards load correctly.

from grafana_client import GrafanaApi
import os
import pytest


@pytest.fixture
def grafana() -> GrafanaApi:
"""Pytest fixture that creates a Grafana API client."""
# https://github.com/grafana-toolbox/grafana-client
grafana_url = os.environ["GRAFANA_URL"]
grafana_username = os.environ["GRAFANA_USERNAME"]
grafana_password = os.environ["GRAFANA_PASSWORD"]
return GrafanaApi.from_url(
grafana_url,
credential=(grafana_username, grafana_password),
)


def test_grafana_api_stats(grafana):
"""Test that Grafana API stats are accessible."""
# https://grafana.com/docs/grafana/latest/developers/http_api/admin/#grafana-stats
result = grafana.admin.stats()
assert result["dashboards"] > 0
assert result["datasources"] > 0
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# under the License.

# TODO:
# * Dashboard login
# * Cluster health

from opensearchpy import OpenSearch
import os
import pytest
import requests

from stackhpc_cloud_tests import utils

Expand Down Expand Up @@ -60,3 +60,15 @@ def test_opensearch_has_info_logs(opensearch):
# https://opensearch-project.github.io/opensearch-py/api-ref/clients/opensearch_client.html#opensearchpy.OpenSearch.search
result = opensearch.search(body=query, index="flog-*", size=1)
assert len(result["hits"]["hits"]) == 1


def test_opensearch_dashboards_status():
"""Check that OpenSearch Dashboards is accessible and is in a green state."""
dashboard_url = os.environ["OPENSEARCH_DASHBOARDS_URL"]
dashboard_username = os.environ["OPENSEARCH_DASHBOARDS_USERNAME"]
dashboard_password = os.environ["OPENSEARCH_DASHBOARDS_PASSWORD"]
dashboard_url += "/api/status"
result = requests.get(dashboard_url, auth=(dashboard_username, dashboard_password))
assert result.ok
result = result.json()
assert result["status"]["overall"]["state"] == "green"