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

Function TestErrorWritesExt4

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

Source from the content-addressed store, hash-verified

87}
88
89func TestErrorWritesExt4(t *testing.T) {
90 flakey, root := initFlakey(t, FSTypeEXT4)
91
92 // commit=1000 is to delay commit triggered by writeback thread
93 require.NoError(t, mount(root, flakey.DevicePath(), "commit=1000"))
94
95 // inject IO failure on write
96 assert.NoError(t, flakey.ErrorWrites())
97
98 f1 := filepath.Join(root, "f1")
99 err := writeFile(f1, []byte("hello, world during failpoint"), 0600, true)
100 assert.ErrorContains(t, err, "input/output error")
101
102 // resume
103 assert.NoError(t, flakey.AllowWrites())
104 err = writeFile(f1, []byte("hello, world"), 0600, true)
105 assert.NoError(t, err)
106
107 assert.NoError(t, unmount(root))
108 require.NoError(t, mount(root, flakey.DevicePath(), ""))
109
110 data, err := os.ReadFile(f1)
111 assert.NoError(t, err)
112 assert.Equal(t, "hello, world", string(data))
113}
114
115func initFlakey(t *testing.T, fsType FSType) (_ Flakey, root string) {
116 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 7

initFlakeyFunction · 0.85
mountFunction · 0.85
writeFileFunction · 0.85
unmountFunction · 0.85
DevicePathMethod · 0.65
ErrorWritesMethod · 0.65
AllowWritesMethod · 0.65

Tested by

no test coverage detected