Skip to content

Commit 2e464d9

Browse files
committed
test: skip container topology e2e by default
Gate explicit container-topology tests behind an opt-in environment flag or docker-backed topology settings so routine host-host e2e runs avoid the extra Docker setup cost. Keep the dedicated container e2e workflow and local container helper scripts opted in explicitly.
1 parent 048e182 commit 2e464d9

6 files changed

Lines changed: 81 additions & 2 deletions

File tree

.github/workflows/container-e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
env:
128128
E2E_CONTAINER_IMAGE: ghcr.io/swananan/ghostscope-e2e-runtime@sha256:d5df1b977c38f7a51bbf28b878f2246705a05b83ac6df7cb6be8f8a4de4105f4
129129
E2E_CHILD_CONTAINER_IMAGE: ghcr.io/swananan/ghostscope-e2e-runtime@sha256:d5df1b977c38f7a51bbf28b878f2246705a05b83ac6df7cb6be8f8a4de4105f4
130+
E2E_RUN_CONTAINER_TOPOLOGY: 1
130131
E2E_SANDBOX_SESSION: container-e2e-${{ github.run_id }}-${{ github.job }}-${{ matrix.name }}
131132
E2E_GHOSTSCOPE_SANDBOX: ${{ matrix.ghostscope_sandbox }}
132133
E2E_TARGET_SANDBOX: ${{ matrix.target_sandbox }}
@@ -136,6 +137,7 @@ jobs:
136137
sudo -E env \
137138
E2E_CONTAINER_IMAGE="$E2E_CONTAINER_IMAGE" \
138139
E2E_CHILD_CONTAINER_IMAGE="$E2E_CHILD_CONTAINER_IMAGE" \
140+
E2E_RUN_CONTAINER_TOPOLOGY="$E2E_RUN_CONTAINER_TOPOLOGY" \
139141
E2E_SANDBOX_SESSION="$E2E_SANDBOX_SESSION" \
140142
E2E_GHOSTSCOPE_SANDBOX="$E2E_GHOSTSCOPE_SANDBOX" \
141143
E2E_TARGET_SANDBOX="$E2E_TARGET_SANDBOX" \

docs/development.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ Test-framework environment variables:
209209
- `E2E_TARGET_MODE=same|child-container`
210210
Refines how the target is launched inside the selected target sandbox. Default: `same`.
211211
`child-container` currently means "launch the target in a nested child container inside the outer `docker-private` sandbox".
212+
- `E2E_RUN_CONTAINER_TOPOLOGY=1`
213+
Enables the explicit `container_topology_execution` tests. These tests are skipped in routine host-host e2e runs unless this flag is set or a docker-backed `E2E_GHOSTSCOPE_SANDBOX`/`E2E_TARGET_SANDBOX`/`E2E_TARGET_MODE` is requested.
212214
- `E2E_CHILD_CONTAINER_IMAGE=<image-ref>`
213215
Overrides the image used for nested `child-container` targets. By default it inherits `E2E_CONTAINER_IMAGE`, so the outer sandbox and nested child container use the same runtime image unless you explicitly split them.
214216
- `E2E_GHOSTSCOPE_LOG_LEVEL=error|warn|info|debug|trace`
@@ -293,7 +295,7 @@ Notes:
293295

294296
- These commands keep the Rust test harness on the host and move GhostScope plus the traced target into the requested container sandbox topology.
295297
- When GhostScope and target use the same sandbox kind, the topology-aware e2e helper automatically reuses the same sandbox instance.
296-
- The main `CI` workflow runs the full `ghostscope-e2e-tests` suite under the default host-host environment, including `container_topology_execution`.
298+
- Routine host-host e2e, including the main `CI` workflow, skips the explicit `container_topology_execution` cases by default.
297299
- `host -> docker-private`, `docker-private -> same docker-private`, and `docker-private -> child-container` are the explicit topology scenarios that currently run the full e2e suite in the dedicated `Container E2E` workflow.
298300
- `docker-private -> child-container` uses `E2E_TARGET_MODE=child-container` and launches the target in a nested Docker child container inside the outer private sandbox. The full suite now runs in CI for that topology, while nested child-container `-t` cases still follow the existing explicit skip path inside the Rust tests.
299301
- `docker-host -> same docker-host` remains a smoke run because it is close to the default host PID view.

docs/zh/development.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ curl -sS -X POST http://127.0.0.1:8788/runs \
210210
- `E2E_TARGET_MODE=same|child-container`
211211
进一步描述目标进程在所选 target sandbox 里的启动方式。默认:`same`
212212
目前 `child-container` 专指“在外层 `docker-private` sandbox 里再起一个子容器来运行目标进程”。
213+
- `E2E_RUN_CONTAINER_TOPOLOGY=1`
214+
启用显式的 `container_topology_execution` 测试。常规 host-host e2e 默认跳过这些用例;只有设置该变量,或显式请求 docker-backed `E2E_GHOSTSCOPE_SANDBOX`/`E2E_TARGET_SANDBOX`/`E2E_TARGET_MODE` 时才会运行。
213215
- `E2E_CHILD_CONTAINER_IMAGE=<image-ref>`
214216
覆盖 nested `child-container` 目标使用的镜像。默认会继承 `E2E_CONTAINER_IMAGE`,也就是外层 sandbox 和子容器默认共用同一张 runtime 镜像,除非你显式指定不同镜像。
215217
- `E2E_GHOSTSCOPE_LOG_LEVEL=error|warn|info|debug|trace`
@@ -294,7 +296,7 @@ done
294296

295297
- Rust 测试 harness 仍运行在宿主机上,GhostScope 和目标进程会按指定拓扑进入对应容器 sandbox。
296298
- 当 GhostScope 和目标使用同一种 sandbox 类型时,topology-aware e2e helper 会自动复用同一个 sandbox 实例。
297-
- `CI` workflow 会在默认 host-host 环境下跑完整的 `ghostscope-e2e-tests` 套件,其中也包括 `container_topology_execution`
299+
- 常规 host-host e2e,包括主 `CI` workflow,默认跳过显式的 `container_topology_execution` 用例
298300
- `host -> docker-private``docker-private -> same docker-private``docker-private -> child-container` 是当前在独立 `Container E2E` workflow 中按显式 topology 跑全量 e2e 的容器场景。
299301
- `docker-private -> child-container` 通过 `E2E_TARGET_MODE=child-container` 启用,表示目标进程运行在外层 private sandbox 里再启动的子容器中。这个拓扑现在已经进入 full-CI 矩阵,但 nested child-container 的 `-t` 用例在 Rust 测试内部仍然沿用现有的显式跳过路径。
300302
- `docker-host -> same docker-host` 仍保留为 smoke,因为它更接近默认的 host PID 视角。

e2e-tests/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ Typical local flow:
1313
cargo build -p ghostscope -p dwarf-tool --all-features
1414
sudo cargo test -p ghostscope-e2e-tests --tests --all-features -- --nocapture
1515
```
16+
17+
Routine host-host e2e skips the explicit container-topology cases. Run them by
18+
setting `E2E_RUN_CONTAINER_TOPOLOGY=1` or by using one of the docker-backed
19+
`E2E_GHOSTSCOPE_SANDBOX`/`E2E_TARGET_SANDBOX` topology settings.

e2e-tests/tests/container_topology_execution.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ use common::sandbox::{DockerSpec, SandboxHandle};
66
use common::targets::{TargetHandle, TargetLauncher};
77
use serial_test::serial;
88

9+
const ENV_RUN_CONTAINER_TOPOLOGY: &str = "E2E_RUN_CONTAINER_TOPOLOGY";
10+
const ENV_GHOSTSCOPE_SANDBOX: &str = "E2E_GHOSTSCOPE_SANDBOX";
11+
const ENV_TARGET_SANDBOX: &str = "E2E_TARGET_SANDBOX";
12+
const ENV_TARGET_MODE: &str = "E2E_TARGET_MODE";
13+
914
fn pid_filter_script() -> &'static str {
1015
r#"
1116
trace calculate_something {
@@ -14,6 +19,54 @@ trace calculate_something {
1419
"#
1520
}
1621

22+
fn env_flag_enabled(name: &str) -> bool {
23+
std::env::var(name).ok().is_some_and(|value| {
24+
matches!(
25+
value.trim().to_ascii_lowercase().as_str(),
26+
"1" | "true" | "yes" | "on"
27+
)
28+
})
29+
}
30+
31+
fn env_value_is_container_sandbox(name: &str) -> bool {
32+
std::env::var(name).ok().is_some_and(|value| {
33+
matches!(
34+
value.trim().to_ascii_lowercase().as_str(),
35+
"docker-private"
36+
| "private"
37+
| "container-private"
38+
| "docker-host"
39+
| "host-pid"
40+
| "docker-host-pid"
41+
| "container-host"
42+
)
43+
})
44+
}
45+
46+
fn explicit_container_topology_requested() -> bool {
47+
env_flag_enabled(ENV_RUN_CONTAINER_TOPOLOGY)
48+
|| env_value_is_container_sandbox(ENV_GHOSTSCOPE_SANDBOX)
49+
|| env_value_is_container_sandbox(ENV_TARGET_SANDBOX)
50+
|| std::env::var(ENV_TARGET_MODE).ok().is_some_and(|value| {
51+
matches!(
52+
value.trim().to_ascii_lowercase().as_str(),
53+
"child-container" | "child" | "nested" | "descendant"
54+
)
55+
})
56+
}
57+
58+
fn skip_if_container_topology_not_requested() -> bool {
59+
if explicit_container_topology_requested() {
60+
false
61+
} else {
62+
eprintln!(
63+
"skipping explicit container-topology test: set {ENV_RUN_CONTAINER_TOPOLOGY}=1 \
64+
or run with docker-backed E2E_GHOSTSCOPE_SANDBOX/E2E_TARGET_SANDBOX"
65+
);
66+
true
67+
}
68+
}
69+
1770
fn skip_if_docker_unavailable() -> bool {
1871
if SandboxHandle::docker_available() {
1972
false
@@ -69,6 +122,9 @@ fn target_diagnostics(target: &TargetHandle) -> String {
69122
#[serial]
70123
async fn test_attach_from_host_to_private_container_target() -> anyhow::Result<()> {
71124
init();
125+
if skip_if_container_topology_not_requested() {
126+
return Ok(());
127+
}
72128
if skip_if_docker_unavailable() {
73129
return Ok(());
74130
}
@@ -108,6 +164,9 @@ async fn test_attach_from_host_to_private_container_target() -> anyhow::Result<(
108164
#[serial]
109165
async fn test_attach_from_host_pid_container_to_host_target() -> anyhow::Result<()> {
110166
init();
167+
if skip_if_container_topology_not_requested() {
168+
return Ok(());
169+
}
111170
if skip_if_docker_unavailable() {
112171
return Ok(());
113172
}
@@ -148,6 +207,9 @@ async fn test_attach_from_host_pid_container_to_host_target() -> anyhow::Result<
148207
async fn test_attach_from_private_container_to_host_target_fails_when_pid_invisible(
149208
) -> anyhow::Result<()> {
150209
init();
210+
if skip_if_container_topology_not_requested() {
211+
return Ok(());
212+
}
151213
if skip_if_docker_unavailable() {
152214
return Ok(());
153215
}
@@ -183,6 +245,9 @@ async fn test_attach_from_private_container_to_host_target_fails_when_pid_invisi
183245
#[serial]
184246
async fn test_child_container_runtime_reuses_single_nested_container() -> anyhow::Result<()> {
185247
init();
248+
if skip_if_container_topology_not_requested() {
249+
return Ok(());
250+
}
186251
if skip_if_docker_unavailable() {
187252
return Ok(());
188253
}
@@ -238,6 +303,9 @@ async fn test_child_container_runtime_reuses_single_nested_container() -> anyhow
238303
#[serial]
239304
async fn test_attach_from_private_container_to_child_container_target() -> anyhow::Result<()> {
240305
init();
306+
if skip_if_container_topology_not_requested() {
307+
return Ok(());
308+
}
241309
if skip_if_docker_unavailable() {
242310
return Ok(());
243311
}

scripts/e2e/container/common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ execute_topology_cargo() {
196196
E2E_SANDBOX_SESSION="$E2E_SANDBOX_SESSION"
197197
E2E_CONTAINER_IMAGE="${E2E_CONTAINER_IMAGE:-$DEFAULT_RUNTIME_IMAGE}"
198198
E2E_CHILD_CONTAINER_IMAGE="${E2E_CHILD_CONTAINER_IMAGE:-${E2E_CONTAINER_IMAGE:-$DEFAULT_RUNTIME_IMAGE}}"
199+
E2E_RUN_CONTAINER_TOPOLOGY=1
199200
E2E_GHOSTSCOPE_SANDBOX="$ghostscope_sandbox"
200201
E2E_TARGET_SANDBOX="$target_sandbox"
201202
E2E_TARGET_MODE="$target_mode"

0 commit comments

Comments
 (0)