"""Off-cluster (云外) conftest for openyuanrong SDK testing.
Usage:
export YR_SERVER_ADDRESS=100.111.54.22:38888
export YR_JWT_TOKEN=<jwt_token> # optional
pytest -s -vv conftest_off_cluster.py::test_connection test_off_cluster.py
"""
import os
import pytest
import yr
def _get_server_address():
return os.getenv("YR_SERVER_ADDRESS", "")
def _get_jwt_token():
return os.getenv("YR_JWT_TOKEN", "")
def _build_conf():
addr = _get_server_address()
if not addr:
raise ValueError("YR_SERVER_ADDRESS env is not set, e.g. export YR_SERVER_ADDRESS=1.2.3.4:38888")
return yr.Config(
server_address=addr,
ds_address=addr,
in_cluster=False,
enable_tls=True,
log_level="DEBUG",
auth_token=_get_jwt_token(),
)
@pytest.fixture(scope="session")
def init_yr():
"""Session-scoped yr init for off-cluster (云外) mode."""
conf = _build_conf()
yr.init(conf)
yield
yr.finalize()
@pytest.fixture()
def init_yr_per_test():
"""Per-test yr init/finalize for tests that need fresh runtime."""
conf = _build_conf()
yr.init(conf)
yield
yr.finalize()