Skip to content

Commit a4c18e3

Browse files
committed
move the random write to a separate systemd unit
Instead of calling c.ssh() in the goroutine move the code to a systemd service and enable that Maybe it's worth adding another `util.Retry` to wait for the service to complete before continuing ?
1 parent 7844077 commit a4c18e3

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

mantle/kola/tests/ostree/sync.go

+34-17
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,35 @@ storage:
157157
contents:
158158
inline: |
159159
[Manager]
160-
DefaultTimeoutStopSec=5s`)
160+
DefaultTimeoutStopSec=5s
161+
- path: /usr/local/bin/nfs-random-write.sh
162+
mode: 0755
163+
overwrite: true
164+
contents:
165+
inline: |
166+
#!/bin/bash
167+
for i in $(seq 6); do
168+
(while sudo rm -f /var/tmp/data$i/test; do \
169+
for x in $(seq 6); do \
170+
set -x; \
171+
sudo dd if=/dev/urandom of=/var/tmp/data$i/test bs=4096 count=2048 conv=notrunc oflag=append &> /dev/null; \
172+
set +x; \
173+
sleep 0.5; \
174+
done; \
175+
done) &
176+
done
177+
systemd:
178+
units:
179+
- name: write-to-nfs.service
180+
enabled: false
181+
contents: |
182+
[Unit]
183+
ConditionFirstBoot=true
184+
[Service]
185+
Type=oneshot
186+
RemainAfterExit=yes
187+
ExecStart=/usr/local/bin/nfs-random-write.sh
188+
Restart=on-failure`)
161189
opts := platform.MachineOptions{
162190
MinMemory: 2048,
163191
}
@@ -197,21 +225,10 @@ storage:
197225
func doSyncTest(c cluster.TestCluster, client platform.Machine) {
198226
c.RunCmdSync(client, "sudo touch /var/tmp/data3/test")
199227
// Continue write
200-
go func() {
201-
_, err := c.SSH(client, `for i in $(seq 6); do
202-
(while sudo rm -f /var/tmp/data$i/test; do \
203-
for x in $(seq 6); do \
204-
set -x; \
205-
sudo dd if=/dev/urandom of=/var/tmp/data$i/test bs=4096 count=2048 conv=notrunc oflag=append &> /dev/null; \
206-
set +x; \
207-
sleep 0.5; \
208-
done; \
209-
done) &
210-
done`)
211-
if err != nil {
212-
c.Fatalf("failed to run dd command: %v", err)
213-
}
214-
}()
228+
_, err := c.SSH(client, `sudo systemctl enable --now write-to-nfs.service`)
229+
if err != nil {
230+
c.Fatalf("failed to start service: %v", err)
231+
}
215232

216233
// Create a stage deploy using kargs while writing
217234
c.RunCmdSync(client, "sudo rpm-ostree kargs --append=test=1")
@@ -224,7 +241,7 @@ func doSyncTest(c cluster.TestCluster, client platform.Machine) {
224241
c.Log("Set link down and rebooting.")
225242
// Skip the error check as it is expected
226243
cmd := fmt.Sprintf("sudo systemd-run sh -c 'ip link set %s down && sleep 5 && systemctl reboot'", netdevice)
227-
_, err := c.SSH(client, cmd)
244+
_, err = c.SSH(client, cmd)
228245
if err != nil {
229246
c.Fatalf("failed to set down link and reboot: %v", err)
230247
}

0 commit comments

Comments
 (0)