Skip to content

Commit 923daea

Browse files
experiment explicitly attempt to retain the logs
1 parent d8b37d4 commit 923daea

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
echo "ICP_CLI_NETWORK_LAUNCHER_PATH=$DEST/icp-cli-network-launcher" >> "$GITHUB_ENV"
172172
173173
- name: Run ${{ matrix.test }}
174-
run: cargo test --test ${{ matrix.test }} -- ${{ contains(matrix.os, 'macos') && '--skip :docker:' || '' }} --test-threads=4
174+
run: cargo test --test ${{ matrix.test }} -- ${{ contains(matrix.os, 'macos') && '--skip :docker:' || '' }}
175175

176176
aggregate:
177177
name: test:required

crates/icp-cli/tests/common/context.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl TestContext {
198198
cmd.env("HOME", self.home_path()).env_remove("ICP_HOME");
199199
#[cfg(windows)]
200200
cmd.env("ICP_HOME", self.home_path().join("icp"));
201-
cmd.arg("network").arg("start").arg(name).arg("--debug");
201+
cmd.arg("network").arg("start").arg(name);
202202
#[cfg(unix)]
203203
{
204204
let launcher_path = self.launcher_path().await;
@@ -448,9 +448,20 @@ impl TestContext {
448448
}
449449
}
450450
if elapsed > timeout {
451-
panic!(
451+
eprintln!(
452452
"Timed out waiting for network descriptor at {descriptor_path} after {elapsed}s"
453453
);
454+
let cid = std::fs::read_to_string(project_dir.join("container_id.txt")).unwrap();
455+
let logs = std::process::Command::new("docker")
456+
.args(["logs", cid.trim()])
457+
.output()
458+
.unwrap();
459+
let logs = format!(
460+
"{}\n{}",
461+
String::from_utf8_lossy(&logs.stdout),
462+
String::from_utf8_lossy(&logs.stderr)
463+
);
464+
eprintln!("Container logs:\n{logs}");
454465
}
455466
std::thread::sleep(std::time::Duration::from_millis(100));
456467
};

crates/icp/src/network/managed/docker.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ use bollard::{
66
Docker,
77
errors::Error as BollardError,
88
query_parameters::{
9-
CreateContainerOptions, CreateImageOptions, InspectContainerOptions,
10-
RemoveContainerOptions, StartContainerOptions, StopContainerOptions, WaitContainerOptions,
9+
CreateContainerOptions,
10+
CreateImageOptions,
11+
InspectContainerOptions,
12+
// RemoveContainerOptions,
13+
StartContainerOptions,
14+
StopContainerOptions,
15+
WaitContainerOptions,
1116
},
1217
secret::{ContainerCreateBody, HostConfig, Mount, MountTypeEnum, PortBinding},
1318
};
@@ -200,6 +205,7 @@ pub async fn spawn_docker_launcher(
200205
.try_collect()?,
201206
),
202207
shm_size: *shm_size,
208+
203209
..<_>::default()
204210
}),
205211
..<_>::default()
@@ -209,6 +215,7 @@ pub async fn spawn_docker_launcher(
209215
.context(CreateContainerSnafu { image_name: image })?;
210216
let container_id = container_resp.id;
211217
eprintln!("Created container {}", &container_id[..12]);
218+
std::fs::write("container_id.txt", &container_id).unwrap();
212219
let guard = AsyncDropper::new(DockerDropGuard {
213220
container_id: Some(container_id),
214221
docker: Some(docker),
@@ -341,18 +348,18 @@ pub async fn stop_docker_launcher(
341348
async fn stop(
342349
docker: &Docker,
343350
container_id: &str,
344-
rm_on_exit: bool,
351+
_rm_on_exit: bool,
345352
) -> Result<(), StopContainerError> {
346353
docker
347354
.stop_container(container_id, None::<StopContainerOptions>)
348355
.await
349356
.context(StopSnafu { container_id })?;
350-
if rm_on_exit {
351-
docker
352-
.remove_container(container_id, None::<RemoveContainerOptions>)
353-
.await
354-
.context(RemoveSnafu { container_id })?;
355-
}
357+
// if rm_on_exit {
358+
// docker
359+
// .remove_container(container_id, None::<RemoveContainerOptions>)
360+
// .await
361+
// .context(RemoveSnafu { container_id })?;
362+
// }
356363
Ok(())
357364
}
358365

0 commit comments

Comments
 (0)