Replace lexical Rust fragments with real modules
This commit is contained in:
parent
f8849cdb5f
commit
247819250b
1 changed files with 3302 additions and 2671 deletions
|
|
@ -1,25 +1,40 @@
|
|||
struct Fixture {
|
||||
use super::{
|
||||
Arc, AwaitingAttachedRunsc, BENCHMARK_GUEST, BTreeMap, BundleDigest, CommittedSandboxRuntime,
|
||||
ConfigurationLoadRequest, ContainerId, CoordinatorId, DnsProbeTarget, DnsQueryExpectation,
|
||||
Domain, DomainStoreMutation, DurableDecision, Generation, GenerationId,
|
||||
HostCoordinatorDomainStore, HostProcessOwnershipSlot, IpAddress, Ipv4Addr, MatrixError,
|
||||
NETWORK_NAMESPACE_PATH, NetworkCoordinator, NetworkProbeRequest, NetworkSidecarId, Path,
|
||||
PathBuf, ProcessOwnershipContext, ReachabilityExpectation, ResolvedDomainConfiguration,
|
||||
RootProcess, RunscCommand, RuntimeNetworkLaunch, RuntimeSupervisorLaunch,
|
||||
SANDBOX_NETWORK_PROBE, SandboxBuildRequest, SandboxBundle, SandboxCoordinator, SandboxId,
|
||||
SocketAddr, SocketAddrExt, TcpListener, TcpProbeTarget, TempDir, UnixListener,
|
||||
build_sandbox_bundle, current_mount_identity, current_process_identity, default_sandbox_layout,
|
||||
derive_ipv4_policy, failure, fs, hex, host_path, load_trusted_configuration, lock_file,
|
||||
stage_benchmark_rootfs_and_control, stage_rootfs_and_control, try_exclusive_flock,
|
||||
};
|
||||
|
||||
pub(super) struct Fixture {
|
||||
_tree: Option<TempDir>,
|
||||
configuration: ResolvedDomainConfiguration,
|
||||
store: Arc<HostCoordinatorDomainStore>,
|
||||
bundle: SandboxBundle,
|
||||
activity: PathBuf,
|
||||
benchmark_results: Option<PathBuf>,
|
||||
pub(super) configuration: ResolvedDomainConfiguration,
|
||||
pub(super) store: Arc<HostCoordinatorDomainStore>,
|
||||
pub(super) bundle: SandboxBundle,
|
||||
pub(super) activity: PathBuf,
|
||||
pub(super) benchmark_results: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Fixture {
|
||||
fn new() -> Result<Self, MatrixError> {
|
||||
pub(super) fn new() -> Result<Self, MatrixError> {
|
||||
let tree = tempfile::tempdir()?;
|
||||
let root = tree.path().to_path_buf();
|
||||
Self::build(&root, Some(tree))
|
||||
}
|
||||
|
||||
fn in_directory(root: &Path) -> Result<Self, MatrixError> {
|
||||
pub(super) fn in_directory(root: &Path) -> Result<Self, MatrixError> {
|
||||
Self::build(root, None)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn build_benchmark(
|
||||
pub(super) fn build_benchmark(
|
||||
root: &Path,
|
||||
workspace: &Path,
|
||||
host_root: &Path,
|
||||
|
|
@ -239,11 +254,11 @@ impl Fixture {
|
|||
})
|
||||
}
|
||||
|
||||
fn launch_pending(&self) -> Result<AwaitingAttachedRunsc, MatrixError> {
|
||||
pub(super) fn launch_pending(&self) -> Result<AwaitingAttachedRunsc, MatrixError> {
|
||||
self.launch_pending_with_command(self.bundle.command())
|
||||
}
|
||||
|
||||
fn launch_pending_with_command(
|
||||
pub(super) fn launch_pending_with_command(
|
||||
&self,
|
||||
command: &RunscCommand,
|
||||
) -> Result<AwaitingAttachedRunsc, MatrixError> {
|
||||
|
|
@ -260,7 +275,7 @@ impl Fixture {
|
|||
.map_err(failure)
|
||||
}
|
||||
|
||||
fn alternate_bundle(&self) -> Result<SandboxBundle, MatrixError> {
|
||||
pub(super) fn alternate_bundle(&self) -> Result<SandboxBundle, MatrixError> {
|
||||
let namespace =
|
||||
lazaret_linux::filesystem::namespace_identity(Path::new(NETWORK_NAMESPACE_PATH))?;
|
||||
build_sandbox_bundle(SandboxBuildRequest {
|
||||
|
|
@ -282,7 +297,7 @@ impl Fixture {
|
|||
.map_err(failure)
|
||||
}
|
||||
|
||||
fn launch_committed(&self) -> Result<CommittedSandboxRuntime, MatrixError> {
|
||||
pub(super) fn launch_committed(&self) -> Result<CommittedSandboxRuntime, MatrixError> {
|
||||
let handoff = self
|
||||
.bundle
|
||||
.capture_handoff_authority(&self.configuration)
|
||||
|
|
@ -299,19 +314,19 @@ impl Fixture {
|
|||
}
|
||||
}
|
||||
|
||||
struct NetworkFixture {
|
||||
pub(super) struct NetworkFixture {
|
||||
_tree: TempDir,
|
||||
_host_loopback: TcpListener,
|
||||
_host_abstract: UnixListener,
|
||||
configuration: ResolvedDomainConfiguration,
|
||||
store: HostCoordinatorDomainStore,
|
||||
bundle: SandboxBundle,
|
||||
policy: lazaret_core::network::CanonicalDerivedNetworkPolicy,
|
||||
probe_result: PathBuf,
|
||||
pub(super) configuration: ResolvedDomainConfiguration,
|
||||
pub(super) store: HostCoordinatorDomainStore,
|
||||
pub(super) bundle: SandboxBundle,
|
||||
pub(super) policy: lazaret_core::network::CanonicalDerivedNetworkPolicy,
|
||||
pub(super) probe_result: PathBuf,
|
||||
}
|
||||
|
||||
impl NetworkFixture {
|
||||
fn new() -> Result<Self, MatrixError> {
|
||||
pub(super) fn new() -> Result<Self, MatrixError> {
|
||||
let tree = tempfile::tempdir()?;
|
||||
let root = tree.path();
|
||||
let workspace = root.join("workspace");
|
||||
|
|
@ -375,11 +390,11 @@ impl NetworkFixture {
|
|||
})
|
||||
}
|
||||
|
||||
fn launch(&self) -> Result<CommittedSandboxRuntime, MatrixError> {
|
||||
pub(super) fn launch(&self) -> Result<CommittedSandboxRuntime, MatrixError> {
|
||||
self.launch_with_permitted([1, 1, 1, 1], 443)
|
||||
}
|
||||
|
||||
fn launch_with_permitted(
|
||||
pub(super) fn launch_with_permitted(
|
||||
&self,
|
||||
permitted_address: [u8; 4],
|
||||
permitted_port: u16,
|
||||
|
|
@ -517,4 +532,3 @@ fn network_store(
|
|||
.map_err(failure)?;
|
||||
Ok(store)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue