@@ -50,7 +50,20 @@ RUN echo test content > /usr/share/blah.txt
50
50
let orig_root_mtime = ls - Dl /ostree/bootc | get modified
51
51
52
52
# Now, fetch it back into the bootc storage!
53
- bootc switch -- transport containers-storage localhost/bootc-derived
53
+ # We also test the progress API here
54
+ let tmpdir = mktemp - d - t bootc-progress.XXXXXX
55
+ let progress_fifo = $" ($tmpdir )/progress.fifo"
56
+ let progress_json = $" ($tmpdir )/progress.json"
57
+ mkfifo $progress_fifo
58
+ # nushell doesn't support & (for good reasons) so fork off a copy task via systemd-run
59
+ # which reads from the fifo and writes to a file
60
+ try { systemctl kill test-cat-progress }
61
+ systemd-run - u test-cat-progress - - /bin/bash - c $" exec cat ($progress_fifo ) > ($progress_json )"
62
+ # nushell doesn't do fd passing right now either, so run via bash
63
+ bash - c $" bootc switch --json-fd 3 --transport containers-storage localhost/bootc-derived 3>($progress_fifo )"
64
+ # Now, let's do some checking of the progress json
65
+ let progress = open -- raw $progress_json | from json - o
66
+ sanity_check_switch_progress_json $progress
54
67
55
68
# Also test that the mtime changes on modification
56
69
let new_root_mtime = ls - Dl /ostree/bootc | get modified
@@ -60,6 +73,31 @@ RUN echo test content > /usr/share/blah.txt
60
73
tmt-reboot
61
74
}
62
75
76
+ # This just does some basic verification of the progress JSON
77
+ def sanity_check_switch_progress_json [data ] {
78
+ let first = $data.0 ;
79
+ let event_count = $data | length
80
+ assert equal $first.type ProgressBytes
81
+ let steps = $first.stepsTotal
82
+ mut i = 0
83
+ for elt in $data {
84
+ if $elt.type != " ProgressBytes" {
85
+ break
86
+ }
87
+ # Bounds check steps
88
+ assert ($elt.steps <= $elt.stepsTotal )
89
+ assert equal $elt.stepsTotal $steps
90
+ $i += 1
91
+ }
92
+ let deploy = $data | get ($event_count - 1 )
93
+ assert equal $deploy.steps 3
94
+ assert equal $deploy.stepsTotal 3
95
+ let deploy_tasks = $deploy.subtasks
96
+ assert equal ($deploy_tasks | length ) 5
97
+ let deploy_names = $deploy_tasks | get subtask
98
+ assert equal $deploy_names [" merging" , " deploying" , " bound_images" , " cleanup" , " cleanup" ]
99
+ }
100
+
63
101
# The second boot; verify we're in the derived image
64
102
def second_boot [] {
65
103
print " verifying second boot"
0 commit comments