Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat: add CLI integration tests, deduplicate oc2ov_test, and extend CI pipeline (#2061)
kaisonglid7ef4a04a147
diff --git a/.github/workflows/api_test.yml b/.github/workflows/api_test.ymlindex af0ff8edd..92470bc44 100644--- a/.github/workflows/api_test.yml+++ b/.github/workflows/api_test.yml@@ -1,4 +1,4 @@-name: 06. API Integration Tests+name: 06. API & CLI Integration Testson:workflow_dispatch:@@ -19,6 +19,8 @@ on:- '**.svg'- '.gitignore'- '.editorconfig'+ release:+ types: [published, prereleased]concurrency:group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}@@ -26,7 +28,7 @@ concurrency:jobs:api-tests:- name: API Integration Tests (${{ matrix.os }})+ name: API & CLI Integration Tests (${{ matrix.os }})runs-on: ${{ matrix.os }}timeout-minutes: 60if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.repository == 'volcengine/OpenViking'@@ -34,7 +36,7 @@ jobs:fail-fast: falsemax-parallel: 1matrix:- os: ${{ ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && fromJSON('["ubuntu-24.04", "macos-14", "windows-latest"]') || fromJSON('["ubuntu-24.04"]') }}+ os: ${{ ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'release') && fromJSON('["ubuntu-24.04", "macos-14", "windows-latest"]') || fromJSON('["ubuntu-24.04"]') }}steps:- uses: actions/checkout@v6@@ -445,15 +447,20 @@ jobs:export SERVER_URL=http://127.0.0.1:${{ env.SERVER_PORT }}if [ "${{ env.HAS_SECRETS }}" = "true" ]; then- echo "Running full test suite with VLM/Embedding"- uv run python -m pytest . -v --html=api-test-report.html --self-contained-html \- --ignore=scenarios/resources_retrieval_slow/+ echo "Running serial tests (filesystem + resource operations)..."+ uv run python -m pytest filesystem/ scenarios/resources_retrieval/ -v --tb=short+ echo "Running full test suite with VLM/Embedding (parallel, excluding serial tests)..."+ uv run python -m pytest . -v -n 4 --html=api-test-report.html --self-contained-html \+ --ignore=scenarios/resources_retrieval_slow/ --ignore=filesystem/ --ignore=scenarios/resources_retrieval/else- echo "Running basic tests only (no VLM/Embedding)"- uv run python -m pytest . -v --html=api-test-report.html --self-contained-html \+ echo "Running filesystem tests (serial)..."+ uv run python -m pytest filesystem/ -v --tb=short \+ --ignore=retrieval/ --ignore=resources/ --ignore=admin/ --ignore=skills/ --ignore=system/ --ignore=scenarios/+ echo "Running basic tests only (parallel, excluding filesystem)..."+ uv run python -m pytest . -v -n 4 --html=api-test-report.html --self-contained-html \--ignore=retrieval/ --ignore=resources/test_pack.py --ignore=resources/test_wait_processed.py \--ignore=admin/ --ignore=skills/ --ignore=system/test_system_status.py --ignore=system/test_is_healthy.py --ignore=system/test_system_wait.py \- --ignore=scenarios/ -k "not test_observer"+ --ignore=scenarios/ --ignore=filesystem/ -k "not test_observer"ficontinue-on-error: true@@ -468,13 +475,81 @@ jobs:if ($env:HAS_SECRETS -eq "true") {Write-Host "Running full test suite with VLM/Embedding (Windows: skipping filesystem tests)"- uv run python -m pytest . -v --html=api-test-report.html --self-contained-html --ignore=filesystem/ --ignore=scenarios/resources_retrieval_slow/+ uv run python -m pytest . -v -n 4 --html=api-test-report.html --self-contained-html --ignore=filesystem/ --ignore=scenarios/resources_retrieval_slow/ --ignore=scenarios/resources_retrieval/} else {Write-Host "Running basic tests only (no VLM/Embedding, Windows: skipping filesystem tests)"- uv run python -m pytest . -v --html=api-test-report.html --self-contained-html --ignore=retrieval/ --ignore=resources/test_pack.py --ignore=resources/test_wait_processed.py --ignore=admin/ --ignore=skills/ --ignore=system/test_system_status.py --ignore=system/test_is_healthy.py --ignore=system/test_system_wait.py --ignore=filesystem/ --ignore=scenarios/ -k "not test_observer"+ uv run python -m pytest . -v -n 4 --html=api-test-report.html --self-contained-html --ignore=retrieval/ --ignore=resources/test_pack.py --ignore=resources/test_wait_processed.py --ignore=admin/ --ignore=skills/ --ignore=system/test_system_status.py --ignore=system/test_is_healthy.py --ignore=system/test_system_wait.py --ignore=filesystem/ --ignore=scenarios/ -k "not test_observer"}continue-on-error: true+ - name: Install OpenViking CLI (Unix)+ if: runner.os != 'Windows'+ run: |+ echo "Installing OpenViking CLI..."+ curl -fsSL http://openviking.tos-cn-beijing.volces.com/cli/install.sh | bash++ echo "Verifying CLI installation..."+ if command -v openviking &> /dev/null; then+ openviking version+ echo "OPENVIKING_CLI_BIN=$(which openviking)" >> $GITHUB_ENV+ elif command -v ov &> /dev/null; then+ ov version+ echo "OPENVIKING_CLI_BIN=$(which ov)" >> $GITHUB_ENV+ else+ echo "WARNING: CLI binary not found after installation, CLI tests will be skipped"+ fi++ - name: Run CLI Compatibility Tests (Unix)+ if: runner.os != 'Windows'+ id: run-cli-compat-tests+ run: |+ if [ -z "$OPENVIKING_CLI_BIN" ]; then+ echo "CLI binary not available, skipping CLI compatibility tests"+ echo "cli_compat_outcome=skipped" >> $GITHUB_OUTPUT+ exit 0+ fi+ cd tests/cli+ export OPENVIKING_CLI_BIN="${OPENVIKING_CLI_BIN}"+ export OPENVIKING_URL="http://127.0.0.1:${{ env.SERVER_PORT }}"+ export OPENVIKING_API_KEY="test-root-api-key"+ export OPENVIKING_ACCOUNT="test-account"+ export OPENVIKING_USER="test-user"++ echo "Running CLI compatibility tests..."+ uv run python -m pytest test_cli_compatibility.py -v -n 4 --tb=short -m cli_remote || true+ continue-on-error: true++ - name: Run CLI Integration Tests (Unix)+ if: runner.os != 'Windows'+ id: run-cli-tests+ run: |+ if [ -z "$OPENVIKING_CLI_BIN" ]; then+ echo "CLI binary not available, skipping CLI integration tests"+ echo "cli_tests_outcome=skipped" >> $GITHUB_OUTPUT+ exit 0+ fi+ cd tests/cli+ export OPENVIKING_CLI_BIN="${OPENVIKING_CLI_BIN}"+ export OPENVIKING_URL="http://127.0.0.1:${{ env.SERVER_PORT }}"+ export OPENVIKING_API_KEY="test-root-api-key"+ export OPENVIKING_ACCOUNT="test-account"+ export OPENVIKING_USER="test-user"++ echo "Running CLI integration tests..."+ uv run python -m pytest \+ test_cli_filesystem.py \+ test_cli_content.py \+ test_cli_resources.py \+ test_cli_search.py \+ test_cli_sessions.py \+ test_cli_relations.py \+ test_cli_system.py \+ test_cli_skills.py \+ test_cli_observer.py \+ -v -n 4 --tb=short -m cli_remote \+ --html=cli-test-report.html --self-contained-html+ continue-on-error: true+- name: Upload test reportsuses: actions/upload-artifact@v7if: always()@@ -482,6 +557,7 @@ jobs:name: api-test-reports-${{ matrix.os }}-${{ github.run_id }}path: |tests/api_test/api-test-report.html+ tests/cli/cli-test-report.htmlopenviking-server.log- name: Stop OpenViking Server (Unix)@@ -502,10 +578,20 @@ jobs:Get-Process -Name python -ErrorAction SilentlyContinue | Stop-Process -Force- name: Check test results (Unix)- if: runner.os != 'Windows' && steps.run-tests-unix.outcome != 'success'+ if: runner.os != 'Windows' && (steps.run-tests-unix.outcome != 'success' || steps.run-cli-tests.outcome == 'failure')run: |- echo "API tests failed!"- exit 1+ FAILED=0+ if [ "${{ steps.run-tests-unix.outcome }}" != "success" ]; then+ echo "API tests failed!"+ FAILED=1+ fi+ if [ "${{ steps.run-cli-tests.outcome }}" == "failure" ]; then+ echo "CLI integration tests failed!"+ FAILED=1+ fi+ if [ "$FAILED" -eq 1 ]; then+ exit 1+ fi- name: Check test results (Windows)if: runner.os == 'Windows' && steps.run-tests-windows.outcome != 'success'diff --git a/.github/workflows/api_test_effect.yml b/.github/workflows/api_test_effect.ymlindex 3e6e8cab7..337fc3c87 100644--- a/.github/workflows/api_test_effect.yml+++ b/.github/workflows/api_test_effect.yml@@ -3,7 +3,9 @@ name: 07. API Effect Testson:workflow_dispatch:schedule:- - cron: '0 2 * * *'+ - cron: '0 1,10 * * *'+ release:+ types: [prereleased]concurrency:group: ${{ github.workflow }}-${{ github.ref }}@@ -196,7 +198,7 @@ jobs:cd tests/api_testexport OPENVIKING_API_KEY=test-root-api-keyexport SERVER_URL=http://127.0.0.1:${{ env.SERVER_PORT }}- uv run python -m pytest scenarios/resources_retrieval_slow/ -v --tb=short --durations=0 --html=api-effect-test-report.html --self-contained-html+ uv run python -m pytest scenarios/resources_retrieval_slow/ -v -n 4 --tb=short --durations=0 --html=api-effect-test-report.html --self-contained-htmlcontinue-on-error: true- name: Upload test reportsdiff --git a/.github/workflows/oc2ov_test.yml b/.github/workflows/oc2ov_test.ymlindex 427e3fa27..805ee6f9c 100644--- a/.github/workflows/oc2ov_test.yml+++ b/.github/workflows/oc2ov_test.yml@@ -2,7 +2,7 @@ name: 05. OpenClaw2OpenViking Memory Testson:release:- types: [prereleased, released]+ types: [prereleased]schedule:- cron: '0 2,10 * * *'workflow_dispatch:diff --git a/pyproject.toml b/pyproject.tomlindex 5c008436c..c81845a27 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -90,6 +90,7 @@ dependencies = [test = ["pytest>=7.0.0","pytest-asyncio>=0.21.0",+ "pytest-xdist>=3.5.0","boto3>=1.42.44","pytest-cov>=4.0.0","ragas>=0.1.0",diff --git a/tests/api_test/conftest.py b/tests/api_test/conftest.pyindex 56692f76b..708e69d16 100644--- a/tests/api_test/conftest.py+++ b/tests/api_test/conftest.py@@ -332,6 +332,24 @@ def api_client():return client[email protected](scope="session", autouse=True)+def ensure_resources_dir(api_client):+ try:+ resp = api_client.fs_mkdir("viking://resources")+ if resp.status_code in (200, 409):+ print("viking://resources 目录已就绪")+ else:+ stat_resp = api_client.fs_stat("viking://resources")+ if stat_resp.status_code == 200:+ print("viking://resources 目录已存在")+ else:+ print(+ f"警告: 无法确保 viking://resources 存在 (mkdir={resp.status_code}, stat={stat_resp.status_code})"+ )+ except Exception as e:+ print(f"警告: ensure_resources_dir 异常: {e}")++def pytest_collection_modifyitems(config, items):cache = config.cachelastfailed = cache.get("cache/lastfailed", {})diff --git a/tests/api_test/requirements.txt b/tests/api_test/requirements.txtindex 656a41dbb..e4d6ddc4a 100644--- a/tests/api_test/requirements.txt+++ b/tests/api_test/requirements.txt@@ -1,5 +1,6 @@pytest>=7.0.0pytest-asyncio>=0.21.0+pytest-xdist>=3.5.0pytest-html>=4.0.0requests>=2.28.0psutil>=5.9.0diff --git a/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_github.py b/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_github.pyindex d1e31d535..1329b42f9 100644--- a/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_github.py+++ b/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_github.py@@ -1,71 +1,30 @@-from build_test_helpers import assert_resource_indexed, assert_root_uri_valid, assert_source_format---class TestBuildPlatformGithub:- """TC-P01~P04 GitHub 平台 URL 构建测试"""-- def test_build_github_repo(self, api_client):- """TC-P01 GitHub仓库构建:验证 github.com/org/repo 走 CodeRepositoryParser 且 root_uri 含 org/repo"""- repo_url = "https://github.com/volcengine/OpenViking"-- response = api_client.add_resource(path=repo_url, wait=True)- assert response.status_code == 200-- data = response.json()- assert data.get("status") == "ok"-- result = data.get("result", {})- root_uri = result.get("root_uri")- assert_root_uri_valid(root_uri)- assert "volcengine" in root_uri and "OpenViking" in root_uri, (- f"GitHub仓库 root_uri 应含 volcengine/OpenViking, 实际: {root_uri}"- )-- meta = result.get("meta", {})- assert meta.get("url_type") in ("code_repository", None), (- f"meta.url_type 应为 code_repository, 实际: {meta.get('url_type')}"- )-- assert_source_format(api_client, root_uri, ["repository", "markdown"])+import time- stat_resp = api_client.fs_stat(root_uri)- assert stat_resp.status_code == 200-- print(f"✓ TC-P01 GitHub仓库构建通过, root_uri: {root_uri}")-- def test_build_github_repo_with_branch(self, api_client):- """TC-P02 GitHub指定分支构建:验证 github.com/org/repo/tree/branch 走 ZIP API 且 meta 含 repo_ref"""- repo_url = "https://github.com/volcengine/OpenViking/tree/main"-- response = api_client.add_resource(path=repo_url, wait=True)- assert response.status_code == 200-- data = response.json()- assert data.get("status") == "ok"-- result = data.get("result", {})- root_uri = result.get("root_uri")- assert_root_uri_valid(root_uri)- assert "volcengine" in root_uri and "OpenViking" in root_uri, (- f"GitHub仓库 root_uri 应含 volcengine/OpenViking, 实际: {root_uri}"- )+from build_test_helpers import assert_resource_indexed, assert_root_uri_valid, assert_source_format- meta = result.get("meta", {})- if "repo_ref" in meta:- assert meta["repo_ref"] == "main", f"meta.repo_ref 应为 main, 实际: {meta['repo_ref']}"- assert_source_format(api_client, root_uri, ["repository", "markdown"])+def _add_resource_with_retry(api_client, path, max_retries=3, delay=10):+ last_response = None+ for attempt in range(max_retries):+ response = api_client.add_resource(path=path, wait=True)+ if response.status_code == 200:+ return response+ last_response = response+ if response.status_code >= 500 and attempt < max_retries - 1:+ print(f" retry {attempt + 1}/{max_retries}: {path} got {response.status_code}, waiting {delay}s...")+ time.sleep(delay)+ delay *= 2+ return last_response- stat_resp = api_client.fs_stat(root_uri)- assert stat_resp.status_code == 200- print(f"✓ TC-P02 GitHub指定分支构建通过, root_uri: {root_uri}")+class TestBuildPlatformGithub:+ """TC-P01~P04 GitHub 平台 URL 构建测试"""def test_build_github_raw_file(self, api_client):"""TC-P03 GitHub原始文件下载:验证 raw.githubusercontent.com URL 走 download_markdown 路由且内容可检索"""raw_url = "https://raw.githubusercontent.com/volcengine/OpenViking/main/README.md"- response = api_client.add_resource(path=raw_url, wait=True)+ response = _add_resource_with_retry(api_client, raw_url)assert response.status_code == 200data = response.json()@@ -97,7 +56,7 @@ class TestBuildPlatformGithub:"""TC-P04 GitHub Blob页面构建:验证 github.com/org/repo/blob/branch/file 被转为 raw URL 下载且内容可检索"""blob_url = "https://github.com/volcengine/OpenViking/blob/main/README.md"- response = api_client.add_resource(path=blob_url, wait=True)+ response = _add_resource_with_retry(api_client, blob_url)assert response.status_code == 200data = response.json()diff --git a/tests/cli/conftest.py b/tests/cli/conftest.pyindex 9019ff3bb..6ea4801ae 100644--- a/tests/cli/conftest.py+++ b/tests/cli/conftest.py@@ -4,10 +4,13 @@import jsonimport os+import shutilimport socketimport subprocessimport sys+import tempfileimport time+import uuidfrom pathlib import Pathfrom typing import Generator@@ -18,7 +21,6 @@ from openviking_cli.utils.config import OPENVIKING_CONFIG_ENVdef _get_free_port() -> int:- """Reserve a free port for the test server."""sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.bind(("127.0.0.1", 0))port = sock.getsockname()[1]@@ -27,7 +29,6 @@ def _get_free_port() -> int:def _wait_for_health(url: str, timeout_s: float = 20.0) -> None:- """Poll the health endpoint until the server is ready."""deadline = time.time() + timeout_slast_error = Nonewhile time.time() < deadline:@@ -43,11 +44,9 @@ def _wait_for_health(url: str, timeout_s: float = 20.0) -> None:@pytest.fixture(scope="session")def openviking_server(tmp_path_factory: pytest.TempPathFactory) -> Generator[str, None, None]:- """Start a real OpenViking server for CLI tests."""storage_dir = tmp_path_factory.mktemp("openviking_cli_data")port = _get_free_port()- # Load the base example config and override storage path + server portbase_conf_path = Path("examples/ov.conf").resolve()with open(base_conf_path) as f:conf_data = json.load(f)@@ -63,7 +62,6 @@ def openviking_server(tmp_path_factory: pytest.TempPathFactory) -> Generator[strconf_data["storage"].setdefault("agfs", {})conf_data["storage"]["agfs"]["backend"] = "local"- # Write temporary ov.conftmp_conf = storage_dir / "ov.conf"with open(tmp_conf, "w") as f:json.dump(conf_data, f)@@ -94,7 +92,6 @@ def openviking_server(tmp_path_factory: pytest.TempPathFactory) -> Generator[str_wait_for_health(url)yield urlexcept RuntimeError:- # Capture server output for debuggingstdout, stderr = "", ""if proc.poll() is not None:stdout, stderr = proc.communicate(timeout=5)@@ -112,3 +109,261 @@ def openviking_server(tmp_path_factory: pytest.TempPathFactory) -> Generator[strexcept subprocess.TimeoutExpired:proc.kill()proc.wait(timeout=10)+++# ---------------------------------------------------------------------------+# Remote CLI test infrastructure+# ---------------------------------------------------------------------------++OPENVIKING_BIN = os.getenv("OPENVIKING_CLI_BIN", "")+BASE_URL = os.getenv(+ "OPENVIKING_URL",+ os.getenv("SERVER_URL", "https://api.vikingdb.cn-beijing.volces.com/openviking"),+)+API_KEY = os.getenv("OPENVIKING_API_KEY", "")+++def _resolve_bin():+ if OPENVIKING_BIN:+ if os.path.isfile(OPENVIKING_BIN):+ return OPENVIKING_BIN+ import sys as _sys+ bin_dir = os.path.dirname(_sys.executable)+ for name in ("openviking", "ov"):+ for d in [bin_dir, "/usr/local/bin", "/usr/bin", os.path.expanduser("~/.local/bin")]:+ candidate = os.path.join(d, name)+ if os.path.isfile(candidate):+ return candidate+ for name in ("openviking", "ov"):+ found = shutil.which(name)+ if found:+ return found+ try:+ result = subprocess.run(+ ["bash", "-lc", "command -v openviking || command -v ov"],+ capture_output=True, text=True, timeout=10,+ )+ path = result.stdout.strip()+ if path and os.path.isfile(path):+ return path+ except Exception:+ pass+ return None+++CLI_BIN = _resolve_bin()+++def _write_cli_config():+ config_dir = os.path.join(tempfile.gettempdir(), "openviking_cli_test_config")+ os.makedirs(config_dir, exist_ok=True)+ config_path = os.path.join(config_dir, "ovcli.conf")+ config = {+ "url": BASE_URL,+ "api_key": API_KEY,+ "account": "test-account",+ "user": "test-user",+ "timeout": 120.0,+ "output": "table",+ "echo_command": True,+ "upload": {},+ }+ with open(config_path, "w", encoding="utf-8") as f:+ json.dump(config, f, indent=2)+ return config_path+++CLI_CONFIG_PATH = _write_cli_config()+++def _env():+ env = os.environ.copy()+ env["OPENVIKING_CLI_CONFIG_FILE"] = CLI_CONFIG_PATH+ env["OPENVIKING_URL"] = BASE_URL+ env["OPENVIKING_API_KEY"] = API_KEY+ return env+++def _check_cli_compatible():+ if CLI_BIN is None:+ return False+ try:+ result = subprocess.run(+ [CLI_BIN, "version"], capture_output=True, text=True, timeout=10, env=_env(),+ )+ if result.returncode != 0 and "GLIBC" in result.stderr:+ return False+ return True+ except Exception:+ return False+++CLI_COMPATIBLE = _check_cli_compatible()+++def pytest_collection_modifyitems(config, items):+ if not CLI_COMPATIBLE:+ reason = "openviking CLI not available"+ if CLI_BIN is None:+ reason = "openviking CLI binary not found. Install via: curl -fsSL http://openviking.tos-cn-beijing.volces.com/cli/install.sh | bash"+ else:+ try:+ result = subprocess.run(+ [CLI_BIN, "version"], capture_output=True, text=True, timeout=10, env=_env(),+ )+ if "GLIBC" in result.stderr:+ reason = "openviking CLI binary is not compatible with this system (GLIBC version mismatch)"+ except Exception:+ pass+ skip_cli = pytest.mark.skip(reason=reason)+ for item in items:+ if item.get_closest_marker("cli_remote"):+ item.add_marker(skip_cli)+++def _parse_cli_json(stdout):+ json_start = stdout.find("{")+ if json_start == -1:+ return None+ json_str = stdout[json_start:]+ try:+ return json.loads(json_str)+ except json.JSONDecodeError:+ pass+ depth = 0+ for i, ch in enumerate(json_str):+ if ch == "{":+ depth += 1+ elif ch == "}":+ depth -= 1+ if depth == 0:+ try:+ return json.loads(json_str[: i + 1])+ except json.JSONDecodeError:+ break+ return None+++CLI_ACCOUNT = os.getenv("OPENVIKING_ACCOUNT", "test-account")+CLI_USER = os.getenv("OPENVIKING_USER", "test-user")+++def _inject_global_args(args):+ global_args = []+ if CLI_ACCOUNT:+ global_args.extend(["--account", CLI_ACCOUNT])+ if CLI_USER:+ global_args.extend(["--user", CLI_USER])+ if not args or args[0] in ("version", "--version", "-V", "help", "--help", "-h"):+ return args+ return global_args + args+++def ov(args, timeout=120):+ cmd = [CLI_BIN] + _inject_global_args(args)+ result = subprocess.run(+ cmd, capture_output=True, text=True, timeout=timeout, env=_env(),+ )+ stdout = result.stdout.strip()+ data = _parse_cli_json(stdout)+ return {+ "exit_code": result.returncode,+ "json": data,+ "stdout": stdout,+ "stderr": result.stderr.strip(),+ }+++def _wait_for_resource_ready(uri, retries=20, interval=10):+ for attempt in range(retries):+ r = ov(["read", uri, "-o", "json"], timeout=30)+ if r["exit_code"] == 0 and len(r["stdout"]) > 0:+ return True+ time.sleep(interval)+ return False+++def _find_file_in_pack(pack_uri, retries=10, interval=5):+ for attempt in range(retries):+ ls_r = ov(["ls", pack_uri, "-o", "json"])+ if ls_r["json"] and "result" in ls_r["json"]:+ items = ls_r["json"]["result"]+ for item in items:+ if isinstance(item, dict) and item.get("isDir") is False:+ return item["uri"]+ time.sleep(interval)+ return None++[email protected](scope="session", autouse=True)+def ensure_resources_dir():+ r = ov(["mkdir", "viking://resources", "-o", "json"], timeout=120)+ if r["exit_code"] != 0 and "already exists" not in r["stderr"].lower():+ r2 = ov(["stat", "viking://resources", "-o", "json"])+ if r2["exit_code"] != 0:+ pass++[email protected](scope="session")+def test_dir_uri(ensure_resources_dir):+ uri = f"viking://resources/cli_test_{uuid.uuid4().hex[:8]}"+ r = None+ for attempt in range(5):+ r = ov(["mkdir", uri, "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(5)+ assert r["exit_code"] == 0, f"mkdir failed after retries: {r['stderr']}"+ yield uri+ for attempt in range(10):+ r = ov(["rm", uri, "-r", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(5)++[email protected](scope="session")+def test_pack_uri(test_dir_uri):+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("# CLI Test\n\nThis is a test file for CLI automation.")+ temp_path = f.name+ try:+ pack_uri = f"{test_dir_uri}/test_pack"+ r = None+ for attempt in range(5):+ r = ov(["add-resource", temp_path, "--to", pack_uri, "--wait", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(5)+ assert r["exit_code"] == 0, f"add-resource failed after retries: {r['stderr']}"+ finally:+ os.unlink(temp_path)+ file_uri = _find_file_in_pack(pack_uri, retries=15, interval=5)+ if file_uri:+ ready = _wait_for_resource_ready(file_uri, retries=20, interval=10)+ assert ready, f"Resource {file_uri} did not become ready in time"+ return pack_uri++[email protected](scope="session")+def test_file_uri(test_pack_uri):+ file_uri = _find_file_in_pack(test_pack_uri, retries=10, interval=5)+ assert file_uri is not None, (+ f"Could not find file inside pack {test_pack_uri}. "+ f"ls result: {ov(['ls', test_pack_uri, '-o', 'json'])['stdout'][:300]}"+ )+ return file_uri++[email protected](scope="session")+def test_session_id():+ r = None+ for attempt in range(5):+ r = ov(["session", "new", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(5)+ assert r["exit_code"] == 0, f"session new failed: {r['stderr']}"+ session_id = r["json"]["result"]["session_id"]+ yield session_id+ ov(["session", "delete", session_id, "-o", "json"])diff --git a/tests/cli/pytest.ini b/tests/cli/pytest.ininew file mode 100644index 000000000..ef192720a--- /dev/null+++ b/tests/cli/pytest.ini@@ -0,0 +1,12 @@+[pytest]+testpaths = .+python_files = test_*.py+python_classes = Test*+python_functions = test_*+asyncio_mode = auto+log_cli = true+log_cli_level = INFO+addopts = -rA --tb=short -v+pythonpath = .+markers =+ cli_remote: tests that require a remote OpenViking CLI binary and server connectiondiff --git a/tests/cli/test_cli_compatibility.py b/tests/cli/test_cli_compatibility.pynew file mode 100644index 000000000..dd5cd2617--- /dev/null+++ b/tests/cli/test_cli_compatibility.py@@ -0,0 +1,135 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI compatibility checks: binary availability, version, GLIBC, config, server connectivity."""++import json+import os+import platform+import subprocess++import pytest++from conftest import CLI_BIN, CLI_COMPATIBLE, CLI_CONFIG_PATH, _env, ov++pytestmark = pytest.mark.cli_remote+++class TestCLIBinaryAvailability:+ def test_binary_exists(self):+ assert CLI_BIN is not None, (+ "openviking CLI binary should be found. "+ "Install via: curl -fsSL http://openviking.tos-cn-beijing.volces.com/cli/install.sh | bash"+ )++ def test_binary_is_executable(self):+ assert os.path.isfile(CLI_BIN), f"CLI binary path should be a file: {CLI_BIN}"+ assert os.access(CLI_BIN, os.X_OK), f"CLI binary should be executable: {CLI_BIN}"+++class TestCLIVersion:+ def test_version_command(self):+ r = ov(["version"])+ assert r["exit_code"] == 0, (+ f"ov version should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert len(r["stdout"]) > 0, "version output should not be empty"++ def test_version_flag(self):+ r = ov(["--version"])+ assert r["exit_code"] == 0, (+ f"ov --version should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert len(r["stdout"]) > 0, "--version output should not be empty"++ def test_version_format(self):+ r = ov(["version", "-o", "json"])+ if r["exit_code"] == 0 and r["json"] is not None:+ data = r["json"]+ assert data.get("ok") is True or "version" in str(data).lower(), (+ f"version JSON should contain version info, got: {r['stdout'][:200]}"+ )+++class TestCLIGlibcCompat:+ def test_no_glibc_error(self):+ result = subprocess.run(+ [CLI_BIN, "version"], capture_output=True, text=True, timeout=10, env=_env(),+ )+ assert "GLIBC" not in result.stderr, (+ f"CLI should not have GLIBC compatibility issues. stderr: {result.stderr[:300]}"+ )+++class TestCLIConfigCompat:+ def test_config_file_exists(self):+ assert os.path.isfile(CLI_CONFIG_PATH), (+ f"CLI config file should exist at {CLI_CONFIG_PATH}"+ )++ def test_config_file_valid_json(self):+ with open(CLI_CONFIG_PATH, "r") as f:+ config = json.load(f)+ assert "url" in config, "config should contain 'url' field"+ assert "api_key" in config, "config should contain 'api_key' field"+ assert "timeout" in config, "config should contain 'timeout' field"++ def test_config_url_set(self):+ with open(CLI_CONFIG_PATH, "r") as f:+ config = json.load(f)+ assert config["url"], "config 'url' should not be empty"+++class TestCLIServerConnectivity:+ def test_health_check(self):+ r = ov(["health", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov health should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )++ def test_server_reachable(self):+ r = ov(["health", "-o", "json"])+ assert r["exit_code"] != 3, (+ "CLI exit code 3 means connection error - server is unreachable"+ )+++class TestCLIOutputFormats:+ def test_json_output(self, test_dir_uri):+ r = ov(["ls", test_dir_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov ls -o json should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert r["json"] is not None, "JSON output should be parseable"++ def test_table_output(self, test_dir_uri):+ r = ov(["ls", test_dir_uri, "-o", "table"])+ assert r["exit_code"] == 0, (+ f"ov ls -o table should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+++class TestCLIExitCodes:+ def test_success_exit_code(self):+ r = ov(["health", "-o", "json"])+ assert r["exit_code"] == 0, "successful command should exit with code 0"++ def test_error_exit_code_for_invalid_uri(self):+ r = ov(["stat", "viking://nonexistent/path/xyz", "-o", "json"])+ assert r["exit_code"] != 0, "invalid URI should return non-zero exit code"+++class TestCLIPlatformCompat:+ def test_platform_info(self):+ system = platform.system()+ machine = platform.machine()+ assert system in ("Linux", "Darwin", "Windows"), (+ f"Unsupported platform: {system}"+ )+ if system == "Linux":+ assert machine in ("x86_64", "aarch64"), (+ f"Unsupported Linux architecture: {machine}"+ )+ elif system == "Darwin":+ assert machine in ("x86_64", "arm64"), (+ f"Unsupported macOS architecture: {machine}"+ )diff --git a/tests/cli/test_cli_content.py b/tests/cli/test_cli_content.pynew file mode 100644index 000000000..e7cb46469--- /dev/null+++ b/tests/cli/test_cli_content.py@@ -0,0 +1,125 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI content operation tests (read, abstract, overview, download, write, reindex)."""++import os+import tempfile+import time+import uuid++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestContentRead:+ def test_read(self, test_file_uri):+ r = ov(["read", test_file_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov read should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert len(r["stdout"]) > 0, "read output should not be empty"+ assert "CLI Test" in r["stdout"] or "test" in r["stdout"].lower(), (+ f"read output should contain test content, got: {r['stdout'][:200]}"+ )+++class TestContentAbstract:+ def test_abstract(self, test_pack_uri):+ r = ov(["abstract", test_pack_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov abstract should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert len(r["stdout"]) > 0, "abstract output should not be empty"+++class TestContentOverview:+ def test_overview(self, test_pack_uri):+ r = ov(["overview", test_pack_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov overview should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert len(r["stdout"]) > 0, "overview output should not be empty"+++class TestContentDownload:+ def test_get_download(self, test_file_uri, tmp_path):+ local_path = str(tmp_path / "downloaded.txt")+ r = ov(["get", test_file_uri, local_path, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov get should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert os.path.exists(local_path), "downloaded file should exist"+ assert os.path.getsize(local_path) > 0, "downloaded file should not be empty"+++class TestContentWrite:+ def test_write_replace(self, test_file_uri):+ time.sleep(15)+ r = None+ for attempt in range(15):+ r = ov(["write", test_file_uri, "--content", "Updated via CLI write.", "--mode", "replace", "--wait", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ if "busy" in r["stderr"].lower() or "internal" in r["stderr"].lower():+ time.sleep(20)+ continue+ time.sleep(10)+ assert r["exit_code"] == 0, (+ f"ov write replace should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"++ def test_write_append(self, test_file_uri):+ time.sleep(15)+ r = None+ for attempt in range(15):+ r = ov(["write", test_file_uri, "--content", "\nAppended via CLI.", "--append", "--wait", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ if "busy" in r["stderr"].lower() or "internal" in r["stderr"].lower():+ time.sleep(20)+ continue+ time.sleep(10)+ assert r["exit_code"] == 0, (+ f"ov write append should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+++class TestContentReindex:+ def test_reindex(self, test_dir_uri):+ reindex_pack = f"{test_dir_uri}/reindex_{uuid.uuid4().hex[:6]}"+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("# Reindex Test\n\nThis is an independent resource for reindex testing.")+ temp_path = f.name+ try:+ r = None+ for attempt in range(5):+ r = ov(["add-resource", temp_path, "--to", reindex_pack, "--wait", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(5)+ assert r["exit_code"] == 0, f"add-resource for reindex failed: {r['stderr'][:300]}"+ finally:+ os.unlink(temp_path)++ time.sleep(15)+ r = None+ for attempt in range(15):+ r = ov(["reindex", reindex_pack, "--wait", "true", "-o", "json"], timeout=120)+ if r["exit_code"] == 0:+ break+ if "INTERNAL" in r["stderr"]:+ time.sleep(20)+ continue+ time.sleep(15)+ assert r["exit_code"] == 0, (+ f"ov reindex should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"diff --git a/tests/cli/test_cli_filesystem.py b/tests/cli/test_cli_filesystem.pynew file mode 100644index 000000000..904a732fb--- /dev/null+++ b/tests/cli/test_cli_filesystem.py@@ -0,0 +1,149 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI filesystem operation tests (ls, tree, stat, mkdir, rm, mv)."""++import os+import tempfile+import time+import uuid++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestFsLs:+ def test_ls_root(self):+ r = ov(["ls", "viking://", "-o", "json"])+ if r["exit_code"] != 0:+ r = ov(["ls", "viking://resources", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov ls should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov ls should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ assert isinstance(data["result"], list), "'result' should be a list"++ def test_ls_resources(self):+ r = ov(["ls", "viking://resources", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov ls viking://resources should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"++ def test_ls_simple(self):+ r = ov(["ls", "viking://resources", "-s", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov ls --simple should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )++ def test_ls_recursive(self):+ r = ov(["ls", "viking://resources", "-r", "-o", "json", "-n", "5"])+ assert r["exit_code"] == 0, (+ f"ov ls --recursive should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+++class TestFsTree:+ def test_tree_resources(self, test_dir_uri):+ r = ov(["tree", test_dir_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov tree should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ assert "result" in data, "'result' field should exist"+++class TestFsStat:+ def test_stat_root(self):+ r = ov(["stat", "viking://", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov stat should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov stat should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ assert "isDir" in result, f"'isDir' should exist in stat result, got keys: {list(result.keys())}"+ assert result["isDir"] is True, "root should be a directory"++ def test_stat_file(self, test_file_uri):+ r = ov(["stat", test_file_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov stat on file should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ result = data["result"]+ assert result.get("isDir") is False, "file stat should have isDir=false"+++class TestFsMkdir:+ def test_mkdir(self, test_dir_uri):+ sub_dir = f"{test_dir_uri}/mkdir_test"+ r = ov(["mkdir", sub_dir, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov mkdir should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert "Directory created" in r["stdout"] or (r["json"] and r["json"].get("ok")), (+ f"mkdir should confirm creation, got: {r['stdout'][:200]}"+ )+ ov(["rm", sub_dir, "-r", "-o", "json"])++ def test_mkdir_with_description(self, test_dir_uri):+ sub_dir = f"{test_dir_uri}/mkdir_desc"+ r = ov(["mkdir", sub_dir, "--description", "CLI test directory", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov mkdir with description should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ ov(["rm", sub_dir, "-r", "-o", "json"])+++class TestFsRm:+ def test_rm_directory(self, test_dir_uri):+ sub_dir = f"{test_dir_uri}/rm_test"+ ov(["mkdir", sub_dir, "-o", "json"])+ time.sleep(2)+ r = None+ for attempt in range(5):+ r = ov(["rm", sub_dir, "-r", "-o", "json"])+ if r["exit_code"] == 0:+ break+ time.sleep(3)+ assert r["exit_code"] == 0, (+ f"ov rm should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ assert "Removed" in r["stdout"] or (r["json"] and r["json"].get("ok")), (+ f"rm should confirm removal, got: {r['stdout'][:200]}"+ )+++class TestFsMv:+ def test_mv_directory(self, test_dir_uri):+ src_uri = f"{test_dir_uri}/mv_src_{uuid.uuid4().hex[:6]}"+ dst_uri = f"{test_dir_uri}/mv_dst_{uuid.uuid4().hex[:6]}"+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("move me")+ temp_path = f.name+ try:+ ov(["add-resource", temp_path, "--to", src_uri, "--wait", "-o", "json"], timeout=120)+ finally:+ os.unlink(temp_path)+ time.sleep(15)+ r = None+ for attempt in range(20):+ r = ov(["mv", src_uri, dst_uri, "-o", "json"])+ if r["exit_code"] == 0:+ break+ time.sleep(15)+ assert r["exit_code"] == 0, (+ f"ov mv should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ ov(["rm", dst_uri, "-r", "-o", "json"])diff --git a/tests/cli/test_cli_observer.py b/tests/cli/test_cli_observer.pynew file mode 100644index 000000000..f488a87d5--- /dev/null+++ b/tests/cli/test_cli_observer.py@@ -0,0 +1,42 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI observer endpoint tests (queue, models, system status)."""++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestObserverQueue:+ def test_queue_status(self):+ r = ov(["observer", "queue", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov observer queue should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"observer queue should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+++class TestObserverModels:+ def test_models_status(self):+ r = ov(["observer", "models", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov observer models should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"observer models should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+++class TestObserverSystem:+ def test_system_status(self):+ r = ov(["observer", "system", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov observer system should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"observer system should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"diff --git a/tests/cli/test_cli_relations.py b/tests/cli/test_cli_relations.pynew file mode 100644index 000000000..4da1df53a--- /dev/null+++ b/tests/cli/test_cli_relations.py@@ -0,0 +1,52 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI relations operation tests (relations, link, unlink)."""++import os+import tempfile+import uuid++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestRelations:+ def test_relations(self, test_pack_uri):+ r = ov(["relations", test_pack_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov relations should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+++class TestLinkUnlink:+ def test_link_and_unlink(self, test_dir_uri, test_pack_uri):+ second_pack_uri = f"{test_dir_uri}/link_{uuid.uuid4().hex[:6]}"+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("# Link Target\n\nThis is a link target file.")+ temp_path = f.name+ try:+ ov(["add-resource", temp_path, "--to", second_pack_uri, "--wait", "-o", "json"], timeout=120)+ finally:+ os.unlink(temp_path)++ link_r = ov(["link", test_pack_uri, second_pack_uri, "--reason", "CLI test link", "-o", "json"])+ assert link_r["exit_code"] == 0, (+ f"ov link should exit 0, got {link_r['exit_code']}: {link_r['stderr'][:300]}"+ )+ link_data = link_r["json"]+ assert link_data.get("ok") is True, f"Expected ok=true, got {link_data.get('ok')}"++ unlink_r = ov(["unlink", test_pack_uri, second_pack_uri, "-o", "json"])+ assert unlink_r["exit_code"] == 0, (+ f"ov unlink should exit 0, got {unlink_r['exit_code']}: {unlink_r['stderr'][:300]}"+ )+ unlink_data = unlink_r["json"]+ assert unlink_data.get("ok") is True, f"Expected ok=true, got {unlink_data.get('ok')}"++ ov(["rm", second_pack_uri, "-r", "-o", "json"])diff --git a/tests/cli/test_cli_resources.py b/tests/cli/test_cli_resources.pynew file mode 100644index 000000000..2bcfa930d--- /dev/null+++ b/tests/cli/test_cli_resources.py@@ -0,0 +1,77 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI resource operation tests (add-resource, add-skill)."""++import os+import tempfile+import uuid++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestAddResource:+ def test_add_resource_local_file(self, test_dir_uri):+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("CLI test: add resource via local file upload")+ temp_path = f.name+ try:+ to_uri = f"{test_dir_uri}/res_{uuid.uuid4().hex[:6]}"+ r = ov(["add-resource", temp_path, "--to", to_uri, "--wait", "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"add-resource should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"add-resource should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ assert "root_uri" in result, (+ f"result should contain root_uri, got keys: {sorted(result.keys())}"+ )+ assert result["root_uri"] == to_uri, (+ f"root_uri should match to_uri, expected {to_uri}, got {result['root_uri']}"+ )+ finally:+ os.unlink(temp_path)+++class TestAddSkill:+ def test_add_skill_from_file(self):+ with tempfile.NamedTemporaryFile(suffix=".md", delete=False, mode="w") as f:+ f.write("---\nname: cli_test_skill\ndescription: A test skill for CLI automation\n---\n# CLI Test Skill\n\nThis is a test skill for CLI automation.")+ temp_path = f.name+ try:+ r = ov(["add-skill", temp_path, "--wait", "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"add-skill from file should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"add-skill should return JSON"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ assert "root_uri" in result, (+ f"add-skill result should contain root_uri, got keys: {sorted(result.keys())}"+ )+ finally:+ os.unlink(temp_path)++ def test_add_resource_with_reason(self, test_dir_uri):+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:+ f.write("CLI test: add resource with reason")+ temp_path = f.name+ try:+ to_uri = f"{test_dir_uri}/reason_{uuid.uuid4().hex[:6]}"+ r = ov(["add-resource", temp_path, "--to", to_uri, "--reason", "CLI test reason", "--wait", "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"add-resource with reason should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"add-resource should return JSON"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ finally:+ os.unlink(temp_path)diff --git a/tests/cli/test_cli_search.py b/tests/cli/test_cli_search.pynew file mode 100644index 000000000..0ce02980c--- /dev/null+++ b/tests/cli/test_cli_search.py@@ -0,0 +1,118 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI search operation tests (find, search, grep, glob)."""++import time++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestSearchFind:+ def test_find_basic(self):+ r = ov(["find", "test", "-o", "json", "-n", "5"], timeout=180)+ assert r["exit_code"] == 0, (+ f"ov find should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov find should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ assert "memories" in result, "'memories' field should exist in result"+ assert "resources" in result, "'resources' field should exist in result"+ assert "skills" in result, "'skills' field should exist in result"+ assert isinstance(result["resources"], list), "'resources' should be a list"++ def test_find_with_uri(self, test_dir_uri):+ r = ov(["find", "test", "-u", test_dir_uri, "-o", "json", "-n", "5"], timeout=180)+ assert r["exit_code"] == 0, (+ f"ov find with uri should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+++class TestSearchSearch:+ def test_search_basic(self):+ r = ov(["search", "test", "-o", "json", "-n", "5"], timeout=180)+ assert r["exit_code"] == 0, (+ f"ov search should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov search should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"++ def test_search_with_session(self, test_session_id):+ r = ov(["search", "test", "--session-id", test_session_id, "-o", "json", "-n", "5"], timeout=180)+ assert r["exit_code"] == 0, (+ f"ov search with session should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+++class TestSearchGrep:+ def test_grep_basic(self, test_pack_uri):+ r = None+ for attempt in range(5):+ r = ov(["grep", "-u", test_pack_uri, "CLI", "-o", "json", "-n", "10"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(10)+ assert r["exit_code"] == 0, (+ f"ov grep should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov grep should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"++ def test_grep_case_insensitive(self, test_pack_uri):+ r = None+ for attempt in range(5):+ r = ov(["grep", "-u", test_pack_uri, "-i", "cli", "-o", "json", "-n", "10"], timeout=120)+ if r["exit_code"] == 0:+ break+ time.sleep(10)+ assert r["exit_code"] == 0, (+ f"ov grep --ignore-case should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+++class TestSearchGlob:+ def test_glob_basic(self):+ r = ov(["glob", "**/*.md", "-o", "json", "-n", "10"])+ assert r["exit_code"] == 0, (+ f"ov glob should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"ov glob should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ if isinstance(result, dict):+ assert "matches" in result, f"'matches' field should exist in glob result dict, got keys: {list(result.keys())}"+ assert isinstance(result["matches"], list), "'matches' should be a list"+ assert "count" in result, "'count' field should exist in glob result"+ assert isinstance(result["count"], int), "'count' should be an integer"+ else:+ assert isinstance(result, list), f"'result' should be dict or list, got {type(result)}"++ def test_glob_with_uri(self, test_dir_uri):+ r = None+ for attempt in range(5):+ r = ov(["glob", "*.md", "-u", test_dir_uri, "-o", "json"])+ if r["exit_code"] == 0:+ break+ time.sleep(10)+ assert r["exit_code"] == 0, (+ f"ov glob with uri should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"diff --git a/tests/cli/test_cli_sessions.py b/tests/cli/test_cli_sessions.pynew file mode 100644index 000000000..1feb231a8--- /dev/null+++ b/tests/cli/test_cli_sessions.py@@ -0,0 +1,95 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI session operation tests (new, list, get, get-context, delete, add-message, commit)."""++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestSessionNew:+ def test_session_new(self):+ r = ov(["session", "new", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session new should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ result = data["result"]+ assert "session_id" in result, f"'session_id' should exist in result, got keys: {list(result.keys())}"+ assert isinstance(result["session_id"], str), "session_id should be a string"+ assert len(result["session_id"]) > 0, "session_id should not be empty"+ ov(["session", "delete", result["session_id"], "-o", "json"])+++class TestSessionList:+ def test_session_list(self):+ r = ov(["session", "list", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session list should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ assert isinstance(data["result"], list), "'result' should be a list"+++class TestSessionGet:+ def test_session_get(self, test_session_id):+ r = ov(["session", "get", test_session_id, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session get should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ result = data["result"]+ assert result["session_id"] == test_session_id, (+ f"session_id should match, expected {test_session_id}, got {result.get('session_id')}"+ )+++class TestSessionGetContext:+ def test_session_get_context(self, test_session_id):+ r = ov(["session", "get-session-context", test_session_id, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session get-session-context should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ assert "result" in data, "'result' field should exist"+++class TestSessionDelete:+ def test_session_delete(self):+ create_r = ov(["session", "new", "-o", "json"])+ assert create_r["exit_code"] == 0, (+ f"session new failed: {create_r['stderr'][:300]}"+ )+ assert create_r["json"] is not None, f"session new should return JSON, got: {create_r['stdout'][:200]}"+ session_id = create_r["json"]["result"]["session_id"]+ r = ov(["session", "delete", session_id, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session delete should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+++class TestSessionAddMessage:+ def test_session_add_message(self, test_session_id):+ r = ov(["session", "add-message", test_session_id, "--role", "user", "--content", "CLI test message", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov session add-message should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+++class TestSessionCommit:+ def test_session_commit(self, test_session_id):+ ov(["session", "add-message", test_session_id, "--role", "user", "--content", "commit test", "-o", "json"])+ r = ov(["session", "commit", test_session_id, "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"ov session commit should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"diff --git a/tests/cli/test_cli_skills.py b/tests/cli/test_cli_skills.pynew file mode 100644index 000000000..25efb7bb8--- /dev/null+++ b/tests/cli/test_cli_skills.py@@ -0,0 +1,100 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI skills endpoint tests (add-skill, list skills, skill CRUD)."""++import os+import tempfile+import uuid++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestSkillAdd:+ def test_add_skill_from_file(self):+ skill_name = f"cli_test_skill_{uuid.uuid4().hex[:6]}"+ with tempfile.NamedTemporaryFile(suffix=".md", delete=False, mode="w") as f:+ f.write(+ f"---\nname: {skill_name}\ndescription: A test skill for CLI automation\n---\n"+ f"# {skill_name}\n\nThis is a test skill for CLI automation."+ )+ temp_path = f.name+ try:+ r = ov(["add-skill", temp_path, "--wait", "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"add-skill from file should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"add-skill should return JSON"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist"+ result = data["result"]+ assert "root_uri" in result, (+ f"add-skill result should contain root_uri, got keys: {sorted(result.keys())}"+ )+ finally:+ os.unlink(temp_path)++ def test_add_skill_with_reason(self):+ skill_name = f"cli_test_skill_reason_{uuid.uuid4().hex[:6]}"+ with tempfile.NamedTemporaryFile(suffix=".md", delete=False, mode="w") as f:+ f.write(+ f"---\nname: {skill_name}\ndescription: A test skill with reason\n---\n"+ f"# {skill_name}\n\nThis is a test skill with reason."+ )+ temp_path = f.name+ try:+ r = ov(["add-skill", temp_path, "--wait", "-o", "json"], timeout=120)+ assert r["exit_code"] == 0, (+ f"add-skill should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ finally:+ os.unlink(temp_path)+++class TestSkillList:+ def test_list_skills(self):+ r = ov(["ls", "viking://agent/skills/", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov ls skills should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None and data.get("ok") is True, f"Expected ok=true"+ assert "result" in data, "'result' field should exist"+ assert isinstance(data["result"], list), "'result' should be a list"+++class TestSkillRead:+ def test_read_skill(self):+ ls_r = ov(["ls", "viking://agent/skills/", "-o", "json"])+ if ls_r["exit_code"] != 0 or not ls_r["json"] or not ls_r["json"].get("result"):+ pytest.skip("No skills available to test read")+ return+ skills = ls_r["json"]["result"]+ if not isinstance(skills, list) or len(skills) == 0:+ pytest.skip("No skills available to test read")+ return+ for skill_entry in skills:+ if not isinstance(skill_entry, dict):+ continue+ skill_uri = skill_entry.get("uri", "")+ if not skill_uri:+ continue+ ls_skill_r = ov(["ls", skill_uri, "-o", "json"])+ if ls_skill_r["exit_code"] != 0 or not ls_skill_r["json"] or not ls_skill_r["json"].get("result"):+ continue+ items = ls_skill_r["json"]["result"]+ for item in items:+ if isinstance(item, dict) and item.get("isDir") is False:+ file_uri = item.get("uri", "")+ if file_uri:+ r = ov(["read", file_uri, "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov read skill file should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ returndiff --git a/tests/cli/test_cli_system.py b/tests/cli/test_cli_system.pynew file mode 100644index 000000000..5ae615428--- /dev/null+++ b/tests/cli/test_cli_system.py@@ -0,0 +1,42 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""CLI system endpoint tests (health, status, wait)."""++import pytest++from conftest import ov++pytestmark = pytest.mark.cli_remote+++class TestSystemHealth:+ def test_health(self):+ r = ov(["health", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov health should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ if data is not None:+ assert data.get("ok") is True or "healthy" in str(data).lower(), (+ f"health check should indicate healthy, got: {r['stdout'][:200]}"+ )+++class TestSystemStatus:+ def test_status(self):+ r = ov(["status", "-o", "json"])+ assert r["exit_code"] == 0, (+ f"ov status should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )+ data = r["json"]+ assert data is not None, f"status should return JSON, got stdout: {r['stdout'][:200]}"+ assert data.get("ok") is True, f"Expected ok=true, got {data.get('ok')}"+ assert "result" in data, "'result' field should exist in status response"+++class TestSystemWait:+ def test_wait_with_timeout(self):+ r = ov(["wait", "--timeout", "30", "-o", "json"], timeout=60)+ assert r["exit_code"] == 0, (+ f"ov wait should exit 0, got {r['exit_code']}: {r['stderr'][:300]}"+ )diff --git a/tests/oc2ov_test/conftest.py b/tests/oc2ov_test/conftest.pyindex 0be8b0e0a..dcf9462ac 100644--- a/tests/oc2ov_test/conftest.py+++ b/tests/oc2ov_test/conftest.py@@ -132,40 +132,18 @@ def pytest_html_results_table_row(report, cells):description = "暂无描述"test_descriptions = {- "test_memory_write_basic_info": "测试组A:写入小明的基本信息(姓名、年龄、地区、职业),验证记忆写入完整性与正确性",- "test_memory_write_rich_info": "测试组B:写入小红的详细信息(姓名、年龄、地址、职业、喜好、生日),验证多维度记忆存储",- "test_memory_read_verify": "逐项验证记忆读取功能(姓名、年龄、地区、职业),确保信息准确读取","test_memory_update_verify": "验证记忆更新功能(年龄、职业、地址),确保更新正确生效","test_memory_delete_verify": "验证记忆删除功能,写入临时信息后删除并验证","test_memory_persistence_group_a": "跨会话读取验证-组A:我喜欢吃樱桃,日常喜欢喝美式咖啡,验证记忆持久化存储","test_memory_persistence_group_b": "跨会话读取验证-组B:我喜欢吃芒果,日常喜欢喝拿铁咖啡,验证记忆持久化存储","test_memory_persistence_group_c": "跨会话读取验证-组C:我喜欢吃草莓,日常喜欢喝抹茶拿铁,验证记忆持久化存储","test_memory_update_overwrite_group_a": "更新覆盖验证-组A:初始信息30岁→更新为31岁+生日8月,验证旧记忆被覆盖",- "test_memory_update_overwrite_group_b": "更新覆盖验证-组B:初始信息26岁→更新为27岁+生日11月,验证旧记忆被覆盖",- "test_memory_update_overwrite_group_c": "更新覆盖验证-组C:初始信息32岁→更新为33岁+生日5月,验证旧记忆被覆盖",- "test_skill_experience_group_a": "技能经验沉淀-组A:销售数据查询参数格式验证,错误→正确→简化,验证经验记忆",- "test_skill_experience_group_b": "技能经验沉淀-组B:销售数据查询参数格式验证,错误→正确→简化,验证经验记忆",- "test_skill_experience_group_c": "技能经验沉淀-组C:销售数据查询参数格式验证,错误→正确→简化,验证经验记忆",- "test_skill_log_group_a": "技能日志验证-组A:查询销售数据后检查OpenClaw日志,验证memory-openviking inject记录",- "test_skill_log_group_b": "技能日志验证-组B:查询销售数据后检查OpenClaw日志,验证memory-openviking inject记录",- "test_skill_log_group_c": "技能日志验证-组C:查询销售数据后检查OpenClaw日志,验证memory-openviking inject记录",- "test_long_term_target_group_a": "长程记忆目标-组A:插入50轮干扰对话后验证核心目标不丢失(销售数据库优化方案)",- "test_long_term_target_group_b": "长程记忆目标-组B:插入50轮干扰对话后验证核心目标不丢失(OpenClaw安装适配)",- "test_long_term_target_group_c": "长程记忆目标-组C:插入50轮干扰对话后验证核心目标不丢失(OpenViking记忆模块)",- "test_summary_generation_group_a": "长程总结生成-组A:OpenViking自动化测试平台项目,整合背景+讨论+闲聊生成完整总结",- "test_summary_generation_group_b": "长程总结生成-组B:OpenClaw跨平台适配项目,整合背景+讨论+闲聊生成完整总结",- "test_summary_generation_group_c": "长程总结生成-组C:OpenViking记忆优化项目,整合背景+讨论+闲聊生成完整总结",- "test_auto_session_basic": "自动Session ID测试:使用自动生成的session_id进行基本记忆写入和读取,验证Session ID自动管理功能",- "test_custom_session_prefix": "自定义Session ID测试:使用自定义前缀的session_id进行记忆写入和读取,验证自定义Session功能","test_memory_v2_preferences": "Memory V2偏好设置记忆:对话写入编程语言/编辑器/咖啡偏好→commit→验证preferences目录下新增记忆文件","test_memory_v2_entities": "Memory V2实体信息记忆:对话写入姓名/年龄/职业/公司/住址→commit→验证entities目录下新增记忆文件",- "test_memory_v2_events": "Memory V2事件记录记忆:对话写入技术分享会事件→commit→验证events目录下新增记忆文件","test_memory_v2_profile": "Memory V2用户画像记忆:对话写入技术负责人画像→commit→验证profile.md文件新增或更新","test_memory_v2_skills": "Memory V2技能记忆(Agent scope):对话写入Docker/K8s/CI-CD技能→commit→验证agent memories/skills目录下新增记忆文件",- "test_memory_v2_tools": "Memory V2工具记忆(Agent scope):对话写入Git/Jenkins/Prometheus工具使用→commit→验证agent memories/tools目录下新增记忆文件","test_assemble_replays_archive_summary": "assemble()历史组装验证:写入信息→commit生成archive→新session→验证archive summary被加载回放","test_compact_produces_archive_on_threshold": "compact()压缩归档验证:持续对话超阈值→验证archive生成+记忆文件生成+上下文被压缩",- "test_cross_session_recall_works": "跨session recall验证:session A写入→commit+记忆提取→session B查询→验证recall注入+记忆文件存在","test_memory_recall_explicit_search": "memory_recall显式搜索验证:写入独特信息→commit+记忆提取→新session用模糊提示触发显式搜索→验证搜索结果","test_archive_expand_restores_details": "ov_archive_expand展开验证:写入含细节信息→commit生成archive→询问细节触发展开→验证原始细节被还原","test_session_isolation_no_cross_contamination": "session对话上下文隔离验证:session A写入甲信息→session B写入乙信息→分别查询对话上下文→验证互不干扰",diff --git a/tests/oc2ov_test/tests/p0/test_context_engine.py b/tests/oc2ov_test/tests/p0/test_context_engine.pyindex 5d34f0917..8c11f3741 100644--- a/tests/oc2ov_test/tests/p0/test_context_engine.py+++ b/tests/oc2ov_test/tests/p0/test_context_engine.py@@ -612,78 +612,3 @@ class TestCompactArchiveGeneration(BaseOpenClawCLITest):[["8", "八"], ["年底"]],case_sensitive=False,)---class TestCrossSessionRecall(BaseOpenClawCLITest):- """- 跨 session recall 验证- 测试目标:验证在 session A 写入的记忆,能在全新的 session B 中通过 auto-recall 检索到- 测试路径:session A 写入 → commit + 记忆提取 → session B 查询 → 验证 recall 注入 + 记忆文件存在- """-- def test_cross_session_recall_works(self):- """session A 写入的信息应能在 session B 中通过 recall 检索到"""- unique_marker = "星云数据库"- unique_detail = "使用分布式架构"-- session_a = self.generate_unique_session_id(prefix="recall_source")- session_b = self.generate_unique_session_id(prefix="recall_target")- verifier = OVSessionVerifier()-- self.logger.info("[1/7] 记录 OV session 快照 + 记忆文件 mtime 快照")- before_sessions = verifier.list_session_ids()- before_files = OVSessionVerifier.snapshot_memory_files()-- self.logger.info("[2/7] 在 session A 中写入独特信息")- self.send_and_log(- f"我正在开发{unique_marker},{unique_detail},支持PB级存储",- session_id=session_a,- )-- self.smart_wait_for_sync(- check_message=f"{unique_marker}用什么架构",- keywords=["分布式"],- timeout=30.0,- session_id=session_a,- )-- self.logger.info("[3/7] 显式 commit 并等待记忆提取完成")- ov_session_id = verifier.find_new_session_id(before_sessions)- if ov_session_id:- task_id = verifier.commit_session(ov_session_id)- if task_id:- result = verifier.poll_task_until_done(task_id)- if result:- extracted = result.get("result", {}).get("memories_extracted", {})- self.logger.info(f" 记忆提取结果: {extracted}")-- self.logger.info("[4/7] 验证记忆文件已新增或更新且包含关键信息(文件级别断言)")- memory_found = OVSessionVerifier.find_new_or_updated_files(- before_files, keyword=unique_marker- )- self.logger.info(f" 本次新增/更新且包含'{unique_marker}'的记忆文件数: {len(memory_found)}")- for mf in memory_found:- self.logger.info(f" [{mf['status']}] {mf['path']}")- if "content_preview" in mf:- self.logger.info(f" 内容预览: {mf['content_preview'][:100]}")- if not memory_found:- self.logger.warning(f" 未找到本次新增/更新且包含'{unique_marker}'的记忆文件")-- self.logger.info("[5/7] 验证记忆提取成功(API 级别断言)")- if ov_session_id:- has_memories = verifier.assert_memories_extracted(ov_session_id)- self.logger.info(f" 记忆提取成功: {has_memories}")-- self.logger.info("[6/7] 在全新的 session B 中查询相同信息")- response = self.send_and_retry_on_timeout(- f"我之前提到的{unique_marker}是什么?有什么特点?",- session_id=session_b,- timeout=300,- )-- self.logger.info("[7/7] 验证 session B 通过 auto-recall 获取到 session A 的记忆")- self.assertAnyKeywordInResponse(- response,- [[unique_marker]],- case_sensitive=False,- )diff --git a/tests/oc2ov_test/tests/p0/test_memory_crud.py b/tests/oc2ov_test/tests/p0/test_memory_crud.pyindex 9cb705c55..1f8907ca7 100644--- a/tests/oc2ov_test/tests/p0/test_memory_crud.py+++ b/tests/oc2ov_test/tests/p0/test_memory_crud.py@@ -1,70 +1,12 @@"""记忆 CRUD 操作测试-测试目标:验证记忆的增删改查功能+测试目标:验证记忆的增删改查功能(读取验证已由 test_memory_v2_full_suite 覆盖)"""-import time-from tests.base_cli_test import BaseOpenClawCLITestfrom tests.p0.test_context_engine import OVSessionVerifier-class TestMemoryRead(BaseOpenClawCLITest):- """- 记忆读取验证测试- 测试目标:验证记忆读取功能是否正常- 测试场景:写入用户信息后,逐项验证各字段的读取- """-- def test_memory_read_verify(self):- """测试场景:逐项信息读取验证"""- session_id = self.generate_unique_session_id(prefix="read_verify")- verifier = OVSessionVerifier()-- self.logger.info("[1/4] 记录 OV session 快照")- before_sessions = verifier.list_session_ids()-- self.logger.info("[2/4] 写入用户信息")- message = "我叫测试用户-读取验证,今年40岁,住在华南区,职业是前端工程师"- self.send_and_retry_on_timeout(message, session_id=session_id)-- self.smart_wait_for_sync(- check_message="我叫什么名字",- keywords=["测试用户", "读取验证"],- timeout=30.0,- session_id=session_id,- )-- self.logger.info("[3/4] 显式 commit 确保新信息写入记忆文件,覆盖旧数据")- ov_session_id = verifier.find_new_session_id(before_sessions)- if ov_session_id:- task_id = verifier.commit_session(ov_session_id)- if task_id:- result = verifier.poll_task_until_done(task_id)- if result:- self.logger.info(f" Commit 状态: {result.get('status')}")- time.sleep(5)-- self.logger.info("[4/4] 逐项验证记忆读取")- queries = [- (- "根据我刚才告诉你的信息,我住在哪里?请只根据我们当前对话中我告诉你的信息回答",- [["华南", "华南区", "华北", "北京"]],- "地区验证",- ),- (- "根据我刚才告诉你的信息,我的职业是什么?请只根据我们当前对话中我告诉你的信息回答",- [["前端", "工程师", "前端工程师", "产品经理"]],- "职业验证",- ),- ]-- for query, expected_keywords, desc in queries:- self.logger.info(f" 查询: {query} (场景: {desc})")- resp = self.send_and_retry_on_timeout(query, session_id=session_id)- self.assertAnyKeywordInResponse(resp, expected_keywords, case_sensitive=False)--class TestMemoryUpdate(BaseOpenClawCLITest):"""记忆更新验证测试diff --git a/tests/oc2ov_test/tests/p0/test_memory_v2_full_suite.py b/tests/oc2ov_test/tests/p0/test_memory_v2_full_suite.pyindex f499af5c7..d665e01a5 100644--- a/tests/oc2ov_test/tests/p0/test_memory_v2_full_suite.py+++ b/tests/oc2ov_test/tests/p0/test_memory_v2_full_suite.py@@ -278,12 +278,6 @@ class MemoryV2TestSuite:"test_message": "我叫李明,今年28岁,是一名软件工程师,在字节跳动工作,住在北京海淀区","memory_type": "entities",},- {- "name": "events",- "description": "测试事件记录记忆",- "test_message": "昨天我参加了公司的技术分享会,主题是微服务架构,会议持续了2小时,有50多人参加",- "memory_type": "events",- },{"name": "profile","description": "测试用户画像记忆",@@ -296,12 +290,6 @@ class MemoryV2TestSuite:"test_message": "我擅长使用Docker进行容器化部署,熟练掌握Kubernetes集群管理,有丰富的CI/CD流水线搭建经验","memory_type": "skills",},- {- "name": "tools",- "description": "测试工具记忆",- "test_message": "我经常使用Git进行版本控制,用Jenkins做持续集成,用Prometheus和Grafana监控服务",- "memory_type": "tools",- },]def run_openclaw_command(self, message: str, session_id: str) -> Dict[str, Any]:@@ -873,12 +861,6 @@ SCENARIO_MAP = {"test_message": "我叫李明,今年28岁,是一名软件工程师,在字节跳动工作,住在北京海淀区","memory_type": "entities",},- "events": {- "name": "events",- "description": "测试事件记录记忆",- "test_message": "昨天我参加了公司的技术分享会,主题是微服务架构,会议持续了2小时,有50多人参加",- "memory_type": "events",- },"profile": {"name": "profile","description": "测试用户画像记忆",@@ -891,12 +873,6 @@ SCENARIO_MAP = {"test_message": "我擅长使用Docker进行容器化部署,熟练掌握Kubernetes集群管理,有丰富的CI/CD流水线搭建经验","memory_type": "skills",},- "tools": {- "name": "tools",- "description": "测试工具记忆",- "test_message": "我经常使用Git进行版本控制,用Jenkins做持续集成,用Prometheus和Grafana监控服务",- "memory_type": "tools",- },}@@ -915,10 +891,6 @@ def test_memory_v2_entities():_run_single_memory_test("entities")-def test_memory_v2_events():- _run_single_memory_test("events")--def test_memory_v2_profile():_run_single_memory_test("profile")@@ -927,10 +899,6 @@ def test_memory_v2_skills():_run_single_memory_test("skills")-def test_memory_v2_tools():- _run_single_memory_test("tools")--if __name__ == "__main__":"""直接运行测试"""tester = MemoryV2TestSuite()diff --git a/tests/oc2ov_test/tests/p0/test_memory_write.py b/tests/oc2ov_test/tests/p0/test_memory_write.pydeleted file mode 100644index 901024b64..000000000--- a/tests/oc2ov_test/tests/p0/test_memory_write.py+++ /dev/null@@ -1,73 +0,0 @@-"""-P0 - 记忆结构化写入验证测试-测试目标:验证OpenViking能正确接收、存储OpenClaw传入的用户信息-"""--from tests.base_cli_test import BaseOpenClawCLITest-from utils.test_utils import TestData---class TestMemoryWriteGroupA(BaseOpenClawCLITest):- """- 测试组A(小明):基本记忆结构化写入验证- 测试目标:验证OpenViking能正确接收、存储OpenClaw传入的用户信息,无数据丢失- 测试场景:写入小明的基本信息(姓名、年龄、地区、职业),然后验证信息正确性- """-- def test_memory_write_basic_info(self):- """测试场景:基本信息写入与验证"""- self.logger.info("[1/4] 发送记忆写入指令")-- self.run_with_test_data("user_xiaoming")-- self.logger.info("测试组A执行完成")---class TestMemoryWriteGroupB(BaseOpenClawCLITest):- """- 测试组B(小红):更多维度信息写入- 测试目标:多维度丰富信息写入验证- 测试场景:写入小红的详细信息(姓名、年龄、地址、职业、喜好、生日)- """-- def test_memory_write_rich_info(self):- """测试场景:丰富信息写入与验证"""- self.logger.info("[1/3] 发送丰富信息记忆写入")-- self.run_with_test_data("user_xiaohong")-- self.logger.info("测试组B执行完成")---class TestMemoryWriteAutoSession(BaseOpenClawCLITest):- """- 测试自动 Session ID 管理功能- 测试目标:验证自动生成的 session_id 功能正常工作- """-- def test_auto_session_basic(self):- """测试场景:使用自动生成的 session_id 进行基本记忆写入和读取"""- self.logger.info("测试自动 Session ID 功能")-- message = "我叫自动测试用户,今年28岁"- self.send_and_log(message)-- self.smart_wait_for_sync(- check_message="我是谁",- keywords=["自动测试用户", "28"],- timeout=30.0,- )-- def test_custom_session_prefix(self):- """测试场景:使用自定义前缀的 session_id 进行记忆写入和读取"""- custom_session = self.generate_unique_session_id(prefix="custom_write")- self.logger.info(f"使用自定义 session: {custom_session}")-- message = "我叫自定义用户,职业是测试工程师"- self.send_and_log(message, session_id=custom_session)-- self.smart_wait_for_sync(- check_message="我的职业是什么",- keywords=["测试工程师"],- timeout=30.0,- )