Skip to content

Commit 5fb8f07

Browse files
nix/tcl: a deeper Node, a Pair class and one wait helper
- homa::lc::waitFor ms interval condition replaces pause and the three polling loops (start, serial, exit): it checks an expression in the caller's scope, sleeps, and handles pending events, until it is true or the deadline passes. No shared flag, so nested waits each keep their own deadline. - Node phase id name script does the shell check and then Table phase; it replaces the need-then-phase pairs in dmesg, shutdown, the lifecycle smoke and cycles phases, and the pair driver. - Node takes its log directory, vm and timeouts as separate arguments, which removes the dict merge at both call sites. - bin/pair-lifecycle.tcl is a Pair class. traffic splits into Measure, Snapshot and report trafficDetail (pure, table-tested); the netem and OnBoth details come from node1 by name. New tables: waitFor, waitForNested (wait.test), nodePhase (node.test), trafficDetail (report.test). Phase lines and HOMA_* output are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent db3e193 commit 5fb8f07

8 files changed

Lines changed: 735 additions & 405 deletions

File tree

‎nix/microvms/tcl/bin/lifecycle.tcl‎

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,37 @@ proc main {configFile} {
3636
puts "lifecycle[dict get $config label]: logs in $logdir"
3737

3838
set table [homa::lc::Table new]
39-
set vm [homa::lc::Node new $table [dict merge [dict get $config vm] \
40-
[dict create dir . timeouts [dict get $config timeouts]]] ""]
39+
set vm [homa::lc::Node new $table . [dict get $config vm] [dict get $config timeouts]]
4140
try {
4241
$vm start 1
4342
$vm serial 2
4443
$vm virtio 2b
45-
if {[$vm need 3 smoke]} {
46-
$table phase 3 smoke {
47-
set result [$vm run smoke.log [dict get $config timeouts smoke] {homa-smoke 2>&1}]
48-
set text [dict get $result out]
49-
foreach line [lsearch -all -inline [split $text \n] *HOMA_SMOKE_*] {
50-
puts " $line"
51-
}
52-
list [dict get $result rc] [parse smokeDetail $text [dict get $result rc]]
44+
$vm phase 3 smoke {
45+
set result [$vm run smoke.log [dict get $config timeouts smoke] {homa-smoke 2>&1}]
46+
set text [dict get $result out]
47+
foreach line [lsearch -all -inline [split $text \n] *HOMA_SMOKE_*] {
48+
puts " $line"
5349
}
50+
list [dict get $result rc] [parse smokeDetail $text [dict get $result rc]]
5451
}
55-
if {[$vm need 4 cycles]} {
56-
# One line (a multi-line command would bring the shell's
57-
# continuation prompts), in a subshell, so a failure ends the
58-
# loop but not the shell.
59-
set count [dict get $config moduleCycles]
60-
set steps {
61-
{insmod "$HOMA_KO"}
62-
{ip netns add homa-lc}
63-
{ip netns exec homa-lc ip link set lo up}
64-
{ip netns del homa-lc}
65-
{rmmod homa}
66-
{echo cycle $i ok}
67-
}
68-
$table phase 4 cycles {
69-
set loop [format {(set -e; for i in $(seq %d); do %s; done) 2>&1} \
70-
$count [join $steps "; "]]
71-
set result [$vm run cycles.log [dict get $config timeouts cycles] $loop]
72-
set done [parse countLines {^cycle .* ok$} [dict get $result out]]
73-
list [dict get $result rc] "$done of $count"
74-
}
52+
# One line (a multi-line command would bring the shell's continuation
53+
# prompts), in a subshell, so a failure ends the loop but not the
54+
# shell.
55+
set count [dict get $config moduleCycles]
56+
set steps {
57+
{insmod "$HOMA_KO"}
58+
{ip netns add homa-lc}
59+
{ip netns exec homa-lc ip link set lo up}
60+
{ip netns del homa-lc}
61+
{rmmod homa}
62+
{echo cycle $i ok}
63+
}
64+
$vm phase 4 cycles {
65+
set loop [format {(set -e; for i in $(seq %d); do %s; done) 2>&1} \
66+
$count [join $steps "; "]]
67+
set result [$vm run cycles.log [dict get $config timeouts cycles] $loop]
68+
set done [parse countLines {^cycle .* ok$} [dict get $result out]]
69+
list [dict get $result rc] "$done of $count"
7570
}
7671
$vm dmesg 5
7772
$vm shutdown 6
@@ -80,6 +75,7 @@ proc main {configFile} {
8075
return [$table verdict]
8176
} finally {
8277
$vm destroy
78+
$table destroy
8379
}
8480
}
8581

0 commit comments

Comments
 (0)