MCPcopy
hub / github.com/etcd-io/bbolt / TestDropWritesExt4

Function TestDropWritesExt4

tests/dmflakey/dmflakey_test.go:57–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestDropWritesExt4(t *testing.T) {
58 flakey, root := initFlakey(t, FSTypeEXT4)
59
60 // commit=1000 is to delay commit triggered by writeback thread
61 require.NoError(t, mount(root, flakey.DevicePath(), "commit=1000"))
62
63 // ensure testdir/f1 is synced.
64 target := filepath.Join(root, "testdir")
65 require.NoError(t, os.MkdirAll(target, 0600))
66
67 f1 := filepath.Join(target, "f1")
68 assert.NoError(t, writeFile(f1, []byte("hello, world from f1"), 0600, false))
69 require.NoError(t, syncfs(f1))
70
71 // testdir/f2 is created but without fsync
72 f2 := filepath.Join(target, "f2")
73 assert.NoError(t, writeFile(f2, []byte("hello, world from f2"), 0600, false))
74
75 // simulate power failure
76 assert.NoError(t, flakey.DropWrites())
77 assert.NoError(t, unmount(root))
78 assert.NoError(t, flakey.AllowWrites())
79 require.NoError(t, mount(root, flakey.DevicePath(), ""))
80
81 data, err := os.ReadFile(f1)
82 assert.NoError(t, err)
83 assert.Equal(t, "hello, world from f1", string(data))
84
85 _, err = os.ReadFile(f2)
86 assert.True(t, errors.Is(err, os.ErrNotExist))
87}
88
89func TestErrorWritesExt4(t *testing.T) {
90 flakey, root := initFlakey(t, FSTypeEXT4)

Callers

nothing calls this directly

Calls 8

initFlakeyFunction · 0.85
mountFunction · 0.85
writeFileFunction · 0.85
syncfsFunction · 0.85
unmountFunction · 0.85
DevicePathMethod · 0.65
DropWritesMethod · 0.65
AllowWritesMethod · 0.65

Tested by

no test coverage detected