Skip to content

Commit 1c044a4

Browse files
committed
test(e2e): stabilize branch checks
1 parent 2f83186 commit 1c044a4

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

e2e/python/test_sandbox_policy.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
# Standard proxy address inside the sandbox network namespace
3131
_PROXY_HOST = "10.200.0.1"
3232
_PROXY_PORT = 3128
33-
# sslip.io keeps the wildcard test on deterministic public DNS. Vendor-owned
34-
# telemetry subdomains can be NXDOMAIN or resolve to private ranges in CI.
35-
_PUBLIC_WILDCARD_SUFFIX = "1.1.1.1.sslip.io"
33+
# example.com keeps the wildcard test on public DNS while avoiding sslip.io
34+
# rewrites that can resolve to internal ranges in CI.
35+
_PUBLIC_WILDCARD_SUFFIX = "example.com"
3636
_PUBLIC_WILDCARD_PATTERN = f"*.{_PUBLIC_WILDCARD_SUFFIX}"
37+
_PUBLIC_WILDCARD_SUBDOMAIN = f"www.{_PUBLIC_WILDCARD_SUFFIX}"
3738

3839

3940
def _base_policy(
@@ -1865,19 +1866,13 @@ def test_host_wildcard_matches_subdomain(
18651866
)
18661867
spec = datamodel_pb2.SandboxSpec(policy=policy)
18671868
with sandbox(spec=spec, delete_on_exit=True) as sb:
1868-
first_subdomain = f"alpha.{_PUBLIC_WILDCARD_SUFFIX}"
1869-
result = sb.exec_python(_proxy_connect(), args=(first_subdomain, 443))
1870-
assert result.exit_code == 0, result.stderr
1871-
assert "200" in result.stdout, (
1872-
f"{_PUBLIC_WILDCARD_PATTERN} should match {first_subdomain}: "
1873-
f"{result.stdout}"
1869+
result = sb.exec_python(
1870+
_proxy_connect(), args=(_PUBLIC_WILDCARD_SUBDOMAIN, 443)
18741871
)
1875-
1876-
second_subdomain = f"beta.{_PUBLIC_WILDCARD_SUFFIX}"
1877-
result = sb.exec_python(_proxy_connect(), args=(second_subdomain, 443))
18781872
assert result.exit_code == 0, result.stderr
18791873
assert "200" in result.stdout, (
1880-
f"{_PUBLIC_WILDCARD_PATTERN} should match {second_subdomain}: "
1874+
f"{_PUBLIC_WILDCARD_PATTERN} should match "
1875+
f"{_PUBLIC_WILDCARD_SUBDOMAIN}: "
18811876
f"{result.stdout}"
18821877
)
18831878

e2e/rust/tests/driver_config_volume.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::fs;
77
use std::io::Write;
88
use std::os::unix::fs::PermissionsExt;
9-
use std::path::PathBuf;
9+
use std::path::{Path, PathBuf};
1010
use std::time::{SystemTime, UNIX_EPOCH};
1111

1212
use bollard::Docker;
@@ -121,9 +121,10 @@ async fn sandbox_mounts_enabled_driver_config_bind() {
121121
fs::set_permissions(&input_path, fs::Permissions::from_mode(0o666))
122122
.expect("make bind mount input readable by sandbox user");
123123

124+
let bind_source = bind_mount_source_path(&driver, host_dir.path());
124125
let bind_mount = serde_json::json!({
125126
"type": "bind",
126-
"source": host_dir.path(),
127+
"source": bind_source,
127128
"target": BIND_TARGET,
128129
"read_only": false
129130
});
@@ -427,3 +428,21 @@ fn driver_config_mount_json(driver: &str, mount: &Value) -> String {
427428
);
428429
Value::Object(root).to_string()
429430
}
431+
432+
fn bind_mount_source_path(driver: &str, path: &Path) -> PathBuf {
433+
if driver == "docker" {
434+
github_actions_host_work_path(path).unwrap_or_else(|| path.to_path_buf())
435+
} else {
436+
path.to_path_buf()
437+
}
438+
}
439+
440+
fn github_actions_host_work_path(path: &Path) -> Option<PathBuf> {
441+
if std::env::var("GITHUB_ACTIONS").ok().as_deref() != Some("true") {
442+
return None;
443+
}
444+
445+
let relative = path.strip_prefix("/__w").ok()?;
446+
let mapped = Path::new("/home/runner/_work").join(relative);
447+
mapped.exists().then_some(mapped)
448+
}

0 commit comments

Comments
 (0)