4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
94 lines
3.0 KiB
Python
94 lines
3.0 KiB
Python
import os
|
|
from contextlib import contextmanager
|
|
|
|
import pytest
|
|
|
|
from config.grafana_cloud import (
|
|
apply_otel_env_defaults,
|
|
configure_grafana_cloud,
|
|
validate_grafana_cloud_config,
|
|
)
|
|
|
|
|
|
@contextmanager
|
|
def temp_env(values: dict[str, str]):
|
|
original = os.environ.copy()
|
|
keys_to_clear = [
|
|
"GCLOUD_HOSTED_METRICS_ID",
|
|
"GCLOUD_HOSTED_METRICS_URL",
|
|
"GCLOUD_HOSTED_LOGS_ID",
|
|
"GCLOUD_HOSTED_LOGS_URL",
|
|
"GCLOUD_RW_API_KEY",
|
|
"GCLOUD_OTLP_ENDPOINT",
|
|
"GCLOUD_OTLP_AUTH_HEADER",
|
|
"OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
"OTEL_EXPORTER_OTLP_HEADERS",
|
|
"OTEL_EXPORTER_OTLP_PROTOCOL",
|
|
]
|
|
for key in keys_to_clear:
|
|
os.environ.pop(key, None)
|
|
os.environ.update({"GRAFANA_CONFIG_SKIP_ENV_FILE": "1", **values})
|
|
try:
|
|
yield
|
|
finally:
|
|
os.environ.clear()
|
|
os.environ.update(original)
|
|
|
|
|
|
def test_configure_grafana_cloud_sets_otel_vars():
|
|
with temp_env(
|
|
{
|
|
"GCLOUD_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
"GCLOUD_OTLP_AUTH_HEADER": "Basic abc123",
|
|
}
|
|
):
|
|
configure_grafana_cloud()
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") == "https://example.grafana.net/otlp"
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_PROTOCOL") == "http/protobuf"
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_HEADERS") == "Authorization=Basic abc123"
|
|
|
|
|
|
def test_apply_otel_env_defaults_sets_when_missing():
|
|
with temp_env(
|
|
{
|
|
"GCLOUD_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
"GCLOUD_OTLP_AUTH_HEADER": "Basic abc123",
|
|
}
|
|
):
|
|
os.environ.pop("OTEL_EXPORTER_OTLP_ENDPOINT", None)
|
|
os.environ.pop("OTEL_EXPORTER_OTLP_HEADERS", None)
|
|
os.environ.pop("OTEL_EXPORTER_OTLP_PROTOCOL", None)
|
|
apply_otel_env_defaults()
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") == "https://example.grafana.net/otlp"
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_PROTOCOL") == "http/protobuf"
|
|
assert os.getenv("OTEL_EXPORTER_OTLP_HEADERS") == "Authorization=Basic abc123"
|
|
|
|
|
|
def test_validate_grafana_cloud_config_flags_missing():
|
|
with (
|
|
temp_env(
|
|
{
|
|
"GCLOUD_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
}
|
|
),
|
|
pytest.raises(ValueError, match="missing env vars"),
|
|
):
|
|
validate_grafana_cloud_config()
|
|
|
|
|
|
def test_validate_grafana_cloud_config_passes_when_present():
|
|
with temp_env(
|
|
{
|
|
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
"GCLOUD_HOSTED_METRICS_ID": "1",
|
|
"GCLOUD_HOSTED_METRICS_URL": "https://metrics",
|
|
"GCLOUD_HOSTED_LOGS_ID": "2",
|
|
"GCLOUD_HOSTED_LOGS_URL": "https://logs",
|
|
"GCLOUD_RW_API_KEY": "token",
|
|
"GCLOUD_OTLP_ENDPOINT": "https://example.grafana.net/otlp",
|
|
"GCLOUD_OTLP_AUTH_HEADER": "Basic abc123",
|
|
}
|
|
):
|
|
assert validate_grafana_cloud_config() is True
|