Skip to content

Commit 8f17032

Browse files
lwshangclaude
andcommitted
test: add ignored integration test for canister logs --proxy
fetch_canister_logs is not yet available in replicated mode, so hide the --proxy flag from --help and mark the test as #[ignore] until the IC spec change lands (dfinity/portal#6106). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7a30ebf commit 8f17032

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

crates/icp-cli/src/commands/canister/logs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ pub(crate) struct LogsArgs {
5151
pub(crate) json: bool,
5252

5353
/// Principal of a proxy canister to route the management canister call through.
54-
#[arg(long)]
54+
///
55+
/// Hidden until the IC supports fetch_canister_logs in replicated mode.
56+
/// Tracking: https://github.com/dfinity/portal/pull/6106
57+
#[arg(long, hide = true)]
5558
pub(crate) proxy: Option<Principal>,
5659
}
5760

crates/icp-cli/tests/canister_logs_tests.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,82 @@ async fn canister_logs_filter_by_timestamp() {
365365
.success()
366366
.stdout(contains("Timestamped message"));
367367
}
368+
369+
// Ignored: fetch_canister_logs is not yet available in replicated mode.
370+
// Tracking: https://github.com/dfinity/portal/pull/6106
371+
#[ignore]
372+
#[cfg(unix)] // moc
373+
#[tokio::test]
374+
async fn canister_logs_through_proxy() {
375+
let ctx = TestContext::new();
376+
let project_dir = ctx.create_project_dir("canister_logs");
377+
378+
ctx.copy_asset_dir("canister_logs", &project_dir);
379+
380+
let pm = formatdoc! {r#"
381+
canisters:
382+
- name: logger
383+
recipe:
384+
type: "@dfinity/motoko@v4.0.0"
385+
configuration:
386+
main: main.mo
387+
args: ""
388+
389+
{NETWORK_RANDOM_PORT}
390+
{ENVIRONMENT_RANDOM_PORT}
391+
"#};
392+
393+
write_string(&project_dir.join("icp.yaml"), &pm).expect("failed to write project manifest");
394+
395+
let _g = ctx.start_network_in(&project_dir, "random-network").await;
396+
ctx.ping_until_healthy(&project_dir, "random-network");
397+
398+
let proxy_cid = ctx.get_proxy_cid(&project_dir, "random-network");
399+
400+
// Deploy logger through proxy
401+
ctx.icp()
402+
.current_dir(&project_dir)
403+
.args([
404+
"deploy",
405+
"logger",
406+
"--proxy",
407+
&proxy_cid,
408+
"--environment",
409+
"random-environment",
410+
])
411+
.assert()
412+
.success();
413+
414+
// Create some logs by calling through proxy
415+
ctx.icp()
416+
.current_dir(&project_dir)
417+
.args([
418+
"canister",
419+
"call",
420+
"--environment",
421+
"random-environment",
422+
"logger",
423+
"log",
424+
"(\"Proxy log message\")",
425+
"--proxy",
426+
&proxy_cid,
427+
])
428+
.assert()
429+
.success();
430+
431+
// Fetch logs through proxy
432+
ctx.icp()
433+
.current_dir(&project_dir)
434+
.args([
435+
"canister",
436+
"logs",
437+
"logger",
438+
"--environment",
439+
"random-environment",
440+
"--proxy",
441+
&proxy_cid,
442+
])
443+
.assert()
444+
.success()
445+
.stdout(contains("Proxy log message"));
446+
}

docs/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ Fetch and display canister logs
350350
* `--since-index <INDEX>` — Show logs at or after this log index (inclusive). Cannot be used with --follow
351351
* `--until-index <INDEX>` — Show logs before this log index (exclusive). Cannot be used with --follow
352352
* `--json` — Output command results as JSON
353-
* `--proxy <PROXY>` — Principal of a proxy canister to route the management canister call through
354353

355354

356355

0 commit comments

Comments
 (0)