mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
test: require an existing kernel namespace block device
This commit is contained in:
1 parent
73c99f5a05
commit
f459e5c208
1 file changed
+13
-2
@@ -90,7 +90,18 @@ func TestProcedureKernelReadinessRetryDelay(t *testing.T) {
|
||||
for _, block := range blocks {
|
||||
got, _ := os.ReadFile(filepath.Join(block, "device", "subsysnqn"))
|
||||
if strings.TrimSpace(string(got)) == nqn {
|
||||
device = "/dev/" + filepath.Base(block)
|
||||
candidate := "/dev/" + filepath.Base(block)
|
||||
info, statErr := os.Stat(candidate)
|
||||
if os.IsNotExist(statErr) {
|
||||
continue
|
||||
} // hidden multipath component
|
||||
if statErr != nil {
|
||||
t.Fatalf("stat own namespace %s: %v", candidate, statErr)
|
||||
}
|
||||
if info.Mode()&os.ModeDevice == 0 || info.Mode()&os.ModeCharDevice != 0 {
|
||||
t.Fatalf("own namespace %s is not a block device: %s", candidate, info.Mode())
|
||||
}
|
||||
device = candidate
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -109,7 +120,7 @@ func TestProcedureKernelReadinessRetryDelay(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
started := time.Now()
|
||||
out, err := exec.CommandContext(ctx, "dd", "if="+source, "of="+device, "bs=4096", "count=1", "oflag=direct", "conv=fdatasync", "status=none").CombinedOutput()
|
||||
out, err := exec.CommandContext(ctx, "dd", "if="+source, "of="+device, "bs=4096", "count=1", "oflag=direct", "conv=nocreat,fdatasync", "status=none").CombinedOutput()
|
||||
elapsed := time.Since(started)
|
||||
t.Logf("kernel default retries=5 device=%s write_elapsed=%s err=%v output=%s", device, elapsed, err, out)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user