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

Method PowerFailure

tests/robustness/powerfailure_test.go:281–302  ·  view source on GitHub ↗

PowerFailure simulates power failure with drop all the writes.

(mntOpt string)

Source from the content-addressed store, hash-verified

279
280// PowerFailure simulates power failure with drop all the writes.
281func (f *flakeyT) PowerFailure(mntOpt string) error {
282 if err := f.DropWrites(); err != nil {
283 return fmt.Errorf("failed to drop_writes: %w", err)
284 }
285
286 if err := unmountAll(f.rootDir); err != nil {
287 return fmt.Errorf("failed to unmount rootfs %s: %w", f.rootDir, err)
288 }
289
290 if mntOpt == "" {
291 mntOpt = f.mntOpt
292 }
293
294 if err := f.AllowWrites(); err != nil {
295 return fmt.Errorf("failed to allow_writes: %w", err)
296 }
297
298 if err := unix.Mount(f.DevicePath(), f.rootDir, string(f.Filesystem()), 0, mntOpt); err != nil {
299 return fmt.Errorf("failed to mount rootfs %s (%s): %w", f.rootDir, mntOpt, err)
300 }
301 return nil
302}
303
304func unmountAll(target string) error {
305 for i := 0; i < 50; i++ {

Callers

nothing calls this directly

Calls 6

unmountAllFunction · 0.85
DropWritesMethod · 0.65
ErrorfMethod · 0.65
AllowWritesMethod · 0.65
DevicePathMethod · 0.65
FilesystemMethod · 0.65

Tested by

no test coverage detected