Skip to content

Commit 3774d13

Browse files
committed
test: improve ostree.sync to get more logs from the system
Improve the code according to Dusty's pointer: openshift/os#1720 (comment) Before doing the reboot, drop NFS port traffic on server to get more logs from client, instead of down the NIC.
1 parent 5419fb9 commit 3774d13

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

mantle/kola/tests/ostree/sync.go

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ storage:
4141
mode: 0777
4242
- path: /var/nfs/share4
4343
mode: 0777
44-
- path: /var/nfs/share5
45-
mode: 0777
46-
- path: /var/nfs/share6
47-
mode: 0777
4844
files:
4945
- path: "/etc/exports"
5046
overwrite: true
@@ -55,13 +51,20 @@ storage:
5551
/var/nfs/share2 *(rw,no_root_squash,insecure)
5652
/var/nfs/share3 *(rw,no_root_squash,insecure)
5753
/var/nfs/share4 *(rw,no_root_squash,insecure)
58-
/var/nfs/share5 *(rw,no_root_squash,insecure)
59-
/var/nfs/share6 *(rw,no_root_squash,insecure)
6054
- path: "/var/lib/nfs/etab"
6155
user:
6256
name: nfsnobody
6357
group:
6458
name: nfsnobody
59+
- path: /usr/local/bin/block-nfs.sh
60+
mode: 0755
61+
overwrite: true
62+
contents:
63+
inline: |
64+
#!/bin/bash
65+
nft add table inet nfs
66+
nft add chain inet nfs INPUT { type filter hook input priority filter \; policy accept \; }
67+
nft add rule inet nfs INPUT tcp dport 2049 drop
6568
systemd:
6669
units:
6770
- name: "nfs-server.service"
@@ -152,10 +155,6 @@ storage:
152155
mode: 0777
153156
- path: /var/tmp/data4
154157
mode: 0777
155-
- path: /var/tmp/data5
156-
mode: 0777
157-
- path: /var/tmp/data6
158-
mode: 0777
159158
files:
160159
- path: /etc/systemd/system.conf
161160
overwrite: true
@@ -169,13 +168,11 @@ storage:
169168
contents:
170169
inline: |
171170
#!/bin/bash
172-
for i in $(seq 6); do
173-
(while sudo rm -f /var/tmp/data$i/test; do
174-
for x in $(seq 6); do
175-
sudo dd if=/dev/urandom of=/var/tmp/data$i/test bs=4096 count=2048 conv=notrunc oflag=append &> /dev/null;
176-
sleep 0.5;
177-
done;
178-
done) &
171+
i=$1
172+
while true; do
173+
sudo dd if=/dev/urandom of=/var/tmp/data$i/test bs=4096 count=2048 conv=notrunc oflag=append &> /dev/null
174+
sleep 0.1
175+
sudo rm -f /var/tmp/data$i/test
179176
done`)
180177
opts := platform.MachineOptions{
181178
MinMemory: 2048,
@@ -197,12 +194,12 @@ storage:
197194
err = util.Retry(6, 10*time.Second, func() error {
198195
// entry point /var/nfs with fsid=0 will be root for clients
199196
// refer to https://access.redhat.com/solutions/107793
200-
_ = c.MustSSHf(nfs_client, `for i in $(seq 6); do
197+
_ = c.MustSSHf(nfs_client, `for i in $(seq 4); do
201198
sudo mount -t nfs4 %s:/share$i /var/tmp/data$i
202199
done`, nfs_server.MachineAddress)
203200

204201
mounts := c.MustSSH(nfs_client, "sudo df -Th | grep nfs | wc -l")
205-
if string(mounts) != "6" {
202+
if string(mounts) != "4" {
206203
c.Fatalf("Can not mount all nfs")
207204
}
208205
c.Log("Got NFS mount.")
@@ -212,34 +209,33 @@ storage:
212209
c.Fatalf("Timeout(1m) to get nfs mount: %v", err)
213210
}
214211

215-
doSyncTest(c, nfs_client)
212+
doSyncTest(c, nfs_client, nfs_server.Machine)
216213
}
217214

218-
func doSyncTest(c cluster.TestCluster, client platform.Machine) {
215+
func doSyncTest(c cluster.TestCluster, client platform.Machine, m platform.Machine) {
216+
// Do simple touch to make sure nfs server works
219217
c.RunCmdSync(client, "sudo touch /var/tmp/data3/test")
220218
// Continue writing while doing test
221-
go func() {
222-
_, err := c.SSH(client, "sudo sh /usr/local/bin/nfs-random-write.sh")
219+
// gets run using systemd unit
220+
for i := 1; i <= 4; i++ {
221+
cmd := fmt.Sprintf("sudo systemd-run --unit=nfs%d --no-block sh -c '/usr/local/bin/nfs-random-write.sh %d'", i, i)
222+
_, err := c.SSH(client, cmd)
223223
if err != nil {
224-
c.Fatalf("failed to start write-to-nfs: %v", err)
224+
c.Fatalf("failed to run nfs-random-write: %v", err)
225225
}
226-
}()
226+
}
227227

228+
// block NFS traffic on nfs server
229+
c.RunCmdSync(m, "sudo /usr/local/bin/block-nfs.sh")
228230
// Create a stage deploy using kargs while writing
229231
c.RunCmdSync(client, "sudo rpm-ostree kargs --append=test=1")
230232

231-
netdevices := c.MustSSH(client, "ls /sys/class/net | grep -v lo")
232-
netdevice := string(netdevices)
233-
if netdevice == "" {
234-
c.Fatalf("failed to get net device")
233+
err := client.Reboot()
234+
if err != nil {
235+
c.Fatalf("Couldn't reboot machine: %v", err)
235236
}
236-
c.Log("Set link down and rebooting.")
237-
// Skip the error check as it is expected
238-
cmd := fmt.Sprintf("sudo systemd-run sh -c 'ip link set %s down && sleep 2 && systemctl reboot'", netdevice)
239-
_, _ = c.SSH(client, cmd)
240237

241-
time.Sleep(5 * time.Second)
242-
err := util.Retry(8, 10*time.Second, func() error {
238+
err = util.Retry(12, 10*time.Second, func() error {
243239
// Look for the kernel argument test=1
244240
kernelArguments, err := c.SSH(client, "cat /proc/cmdline")
245241
if err != nil {

0 commit comments

Comments
 (0)