MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / display_format

Function display_format

vm-migration/src/context.rs:665–691  ·  view source on GitHub ↗

The display format is specifically crafted to be very insightful in logs. Therefore, we have a dedicated test for that format.

()

Source from the content-addressed store, hash-verified

663 /// The display format is specifically crafted to be very insightful in logs.
664 /// Therefore, we have a dedicated test for that format.
665 fn display_format() {
666 let s = Scenario::new();
667 let mut ctx = s.make_ctx();
668
669 // Iteration 0: 1 MiB in 1s
670 ctx.update_metrics_before_transfer(s.iteration_begin, &make_table(1024 * 1024));
671 ctx.update_metrics_after_transfer(s.transfer_begin, Duration::from_secs(1));
672 ctx.iteration += 1;
673
674 // Iteration 1: 512 KiB in 1s; fix migration_duration for deterministic elapsed/avg_bw
675 ctx.update_metrics_before_transfer(s.iteration_begin, &make_table(512 * 1024));
676 ctx.update_metrics_after_transfer(s.transfer_begin, Duration::from_secs(1));
677
678 ctx.migration_duration = Some(Duration::from_secs(2));
679 let out = ctx.to_string();
680
681 assert_eq!(
682 out,
683 "iter=1 curr=1MiB total=2MiB bw=0.50MiB/s transfer=1.00s overhead=8000ms est_downtime=500ms elapsed=2.00s avg_bw=0.15MiB/s"
684 );
685
686 // Should change elapsed() time!
687 // Since this is at least 10s, we never face timing issues in CI!
688 ctx.finalize();
689 let out2 = ctx.to_string();
690 assert_ne!(out2, out, "elapsed time should have changed! is={out2}");
691 }
692 }
693}

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
make_tableFunction · 0.85
make_ctxMethod · 0.80
finalizeMethod · 0.80

Tested by

no test coverage detected