Skip to content

.2059806565729300:323b1b60faa062879e446db1ae76ec60_69e3499ab13256d09ece8088.69e3a8ffb13256d09ece82eb.69e3a8ff7afba9383018b938:Trae CN.T(2026/4/18 23:53:35)#1273

Closed
Wpc-121 wants to merge 1 commit intoActivityWatch:masterfrom
Wpc-121:test_code_01
Closed

.2059806565729300:323b1b60faa062879e446db1ae76ec60_69e3499ab13256d09ece8088.69e3a8ffb13256d09ece82eb.69e3a8ff7afba9383018b938:Trae CN.T(2026/4/18 23:53:35)#1273
Wpc-121 wants to merge 1 commit intoActivityWatch:masterfrom
Wpc-121:test_code_01

Conversation

@Wpc-121
Copy link
Copy Markdown
Contributor

@Wpc-121 Wpc-121 commented Apr 18, 2026

重构集成测试脚本,增加健康检查轮询机制替代固定等待时间
添加详细的测试帮助文档和环境变量配置说明
改进日志记录和错误检测功能

重构集成测试脚本,增加健康检查轮询机制替代固定等待时间
添加详细的测试帮助文档和环境变量配置说明
改进日志记录和错误检测功能
if path and os.path.exists(path):
try:
os.remove(path)
except Exception:
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR refactors scripts/tests/integration_tests.py from a minimal sleep-based script into a structured test suite with health-check polling, environment-variable configuration, and detailed log diagnostics on failure. The Makefile test-integration target is updated accordingly, but it silently drops aw-server/tests/ from the pytest invocation, removing aw-server's own test suite from the integration run.

  • P1 – Missing test suite: aw-server/tests/ is no longer passed to pytest in make test-integration, so those tests will not run at all under this target.

Confidence Score: 4/5

Not safe to merge as-is — aw-server/tests/ is silently dropped from make test-integration, removing an existing test suite from CI.

One P1 finding: the Makefile change omits aw-server/tests/ from the pytest command, meaning those tests stop running under the integration target. Remaining issues are P2 (type annotation mismatch, fragile -p substring check, redundant communicate() call).

Makefile line 193 — missing aw-server/tests/ argument to pytest.

Important Files Changed

Filename Overview
Makefile Adds test-integration-help target and expands test-integration with env var display; silently drops aw-server/tests/ from the pytest command, removing an existing test suite from the CI target.
scripts/tests/integration_tests.py Full rewrite replacing a simple sleep-and-check script with a structured ServerConfig/ServerProcess class hierarchy featuring health polling, env-var configuration, and detailed log diagnostics; minor issues with port-flag detection substring check and get_api_buckets return type annotation.

Sequence Diagram

sequenceDiagram
    participant Make as make test-integration
    participant Pytest as pytest
    participant SF as server_process fixture
    participant SC as ServerConfig
    participant SP as ServerProcess
    participant AW as aw-server binary

    Make->>Pytest: pytest scripts/tests/integration_tests.py -v
    Pytest->>SF: setup fixture (scope=session)
    SF->>SC: ServerConfig() (reads env vars)
    SF->>SP: ServerProcess(config)
    SP->>AW: subprocess.Popen([bin, --testing, --port, 5666])
    loop Poll every poll_interval until timeout
        SP->>AW: GET /api/0/info
        AW-->>SP: 200 OK (ready) or error
    end
    SP-->>SF: server ready
    SF-->>Pytest: yield server
    Pytest->>SP: test_server_starts → is_alive()
    Pytest->>SP: test_api_info_endpoint → get_api_info()
    SP->>AW: GET /api/0/info
    AW-->>SP: {version, hostname, ...}
    Pytest->>SP: test_api_buckets_endpoint → get_api_buckets()
    SP->>AW: GET /api/0/buckets
    AW-->>SP: {} or []
    Pytest->>SP: test_no_error_indicators_in_logs → check_for_errors()
    SP->>SP: scan stdout/stderr log files
    SF->>SP: cleanup() — kill process, remove temp logs
Loading

Reviews (1): Last reviewed commit: "test: 重构集成测试并添加详细文档" | Re-trigger Greptile

Comment thread Makefile
@echo ""
@echo "For help: make test-integration-help"
@echo ""
@pytest scripts/tests/integration_tests.py -v
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 aw-server/tests/ silently dropped from integration run

The original command passed ./aw-server/tests/ as a second pytest argument, so aw-server's own test suite ran as part of the integration target. The new command omits it entirely, meaning those tests are no longer executed when make test-integration is called.

Suggested change
@pytest scripts/tests/integration_tests.py -v
@pytest scripts/tests/integration_tests.py aw-server/tests/ -v

Comment on lines +107 to +108
if "--port" not in " ".join(self.args) and "-p" not in " ".join(self.args):
self.args.extend(["--port", str(self.port)])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fragile substring check for -p flag

"-p" not in " ".join(self.args) performs a plain substring search on the joined argument string. Any arg that happens to contain the two-character sequence -p (e.g. --split-page, --type=temp) would incorrectly suppress appending --port, silently using whatever default port the server picks rather than the configured one.

A safer approach is to check the args list directly:

if not any(a in ("--port", "-p") for a in self.args):
    self.args.extend(["--port", str(self.port)])

Comment on lines +261 to +270
def get_api_buckets(self) -> Dict[str, Any]:
if not HAS_URLLIB:
pytest.skip("urllib not available")

status, data = self._make_request("buckets")
if status != 200:
self._print_log_summary(f"API /buckets request failed (status: {status})")
pytest.fail(f"GET /api/0/buckets failed with status {status}")

return data
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Return type annotation doesn't match actual response shape

get_api_buckets is annotated as -> Dict[str, Any], but test_api_buckets_endpoint explicitly checks isinstance(buckets, list) — meaning the API can return a JSON array. The mismatched annotation can mislead callers and type checkers.

Suggested change
def get_api_buckets(self) -> Dict[str, Any]:
if not HAS_URLLIB:
pytest.skip("urllib not available")
status, data = self._make_request("buckets")
if status != 200:
self._print_log_summary(f"API /buckets request failed (status: {status})")
pytest.fail(f"GET /api/0/buckets failed with status {status}")
return data
def get_api_buckets(self) -> Any:

Comment on lines +286 to +287
self.process.wait(timeout=5)
self.process.communicate(timeout=5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant communicate() after wait()

process.wait() blocks until the process exits, so calling process.communicate() afterwards is a no-op — it will immediately return (b'', b'') because the process has already terminated and stdout/stderr are redirected to files (not PIPE). The redundant call can be removed to simplify cleanup.

Suggested change
self.process.wait(timeout=5)
self.process.communicate(timeout=5)
self.process.wait(timeout=5)
print(f"[INFO] Server stopped with code: {self.process.returncode}")

@ErikBjare ErikBjare closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants