@@ -35,8 +35,8 @@ var panicFailpoints = []string{
35
35
"unmapError" ,
36
36
}
37
37
38
- // TestRestartFromPowerFailure is to test data after unexpected power failure.
39
- func TestRestartFromPowerFailure (t * testing.T ) {
38
+ // TestRestartFromPowerFailureExt4 is to test data after unexpected power failure on ext4 .
39
+ func TestRestartFromPowerFailureExt4 (t * testing.T ) {
40
40
for _ , tc := range []struct {
41
41
name string
42
42
du time.Duration
@@ -78,13 +78,69 @@ func TestRestartFromPowerFailure(t *testing.T) {
78
78
},
79
79
} {
80
80
t .Run (tc .name , func (t * testing.T ) {
81
- doPowerFailure (t , tc .du , tc .fsMountOpt , tc .useFailpoint )
81
+ doPowerFailure (t , tc .du , dmflakey . FSTypeEXT4 , "" , tc .fsMountOpt , tc .useFailpoint )
82
82
})
83
83
}
84
84
}
85
85
86
- func doPowerFailure (t * testing.T , du time.Duration , fsMountOpt string , useFailpoint bool ) {
87
- flakey := initFlakeyDevice (t , strings .Replace (t .Name (), "/" , "_" , - 1 ), dmflakey .FSTypeEXT4 , fsMountOpt )
86
+ func TestRestartFromPowerFailureXFS (t * testing.T ) {
87
+ for _ , tc := range []struct {
88
+ name string
89
+ mkfsOpt string
90
+ fsMountOpt string
91
+ useFailpoint bool
92
+ }{
93
+ {
94
+ name : "xfs_no_opts" ,
95
+ mkfsOpt : "" ,
96
+ fsMountOpt : "" ,
97
+ useFailpoint : true ,
98
+ },
99
+ {
100
+ name : "lazy-log" ,
101
+ mkfsOpt : "-l lazy-count=1" ,
102
+ fsMountOpt : "" ,
103
+ useFailpoint : true ,
104
+ },
105
+ {
106
+ name : "odd-allocsize" ,
107
+ mkfsOpt : "" ,
108
+ fsMountOpt : "allocsize=" + fmt .Sprintf ("%d" , 4096 * 5 ),
109
+ useFailpoint : true ,
110
+ },
111
+ {
112
+ name : "nolargeio" ,
113
+ mkfsOpt : "" ,
114
+ fsMountOpt : "nolargeio" ,
115
+ useFailpoint : true ,
116
+ },
117
+ {
118
+ name : "odd-alignment" ,
119
+ mkfsOpt : "-d sunit=1024,swidth=1024" ,
120
+ fsMountOpt : "noalign" ,
121
+ useFailpoint : true ,
122
+ },
123
+ {
124
+ name : "openshift-sno-options" ,
125
+ mkfsOpt : "-m bigtime=1,finobt=1,rmapbt=0,reflink=1 -i sparse=1 -l lazy-count=1" ,
126
+ // openshift also supplies seclabel,relatime,prjquota on RHEL, but that's not supported on our CI
127
+ // prjquota is only unsupported on our ARM runners.
128
+ // You can find more information in either the man page with `man xfs` or `man mkfs.xfs`.
129
+ // Also refer to https://man7.org/linux/man-pages/man8/mkfs.xfs.8.html.
130
+ fsMountOpt : "rw,attr2,inode64,logbufs=8,logbsize=32k" ,
131
+ useFailpoint : true ,
132
+ },
133
+ } {
134
+ t .Run (tc .name , func (t * testing.T ) {
135
+ t .Logf ("mkfs opts: %s" , tc .mkfsOpt )
136
+ t .Logf ("mount opts: %s" , tc .fsMountOpt )
137
+ doPowerFailure (t , 5 * time .Second , dmflakey .FSTypeXFS , tc .mkfsOpt , tc .fsMountOpt , tc .useFailpoint )
138
+ })
139
+ }
140
+ }
141
+
142
+ func doPowerFailure (t * testing.T , du time.Duration , fsType dmflakey.FSType , mkfsOpt string , fsMountOpt string , useFailpoint bool ) {
143
+ flakey := initFlakeyDevice (t , strings .Replace (t .Name (), "/" , "_" , - 1 ), fsType , mkfsOpt , fsMountOpt )
88
144
root := flakey .RootFS ()
89
145
90
146
dbPath := filepath .Join (root , "boltdb" )
@@ -185,10 +241,10 @@ type FlakeyDevice interface {
185
241
}
186
242
187
243
// initFlakeyDevice returns FlakeyDevice instance with a given filesystem.
188
- func initFlakeyDevice (t * testing.T , name string , fsType dmflakey.FSType , mntOpt string ) FlakeyDevice {
244
+ func initFlakeyDevice (t * testing.T , name string , fsType dmflakey.FSType , mkfsOpt string , mntOpt string ) FlakeyDevice {
189
245
imgDir := t .TempDir ()
190
246
191
- flakey , err := dmflakey .InitFlakey (name , imgDir , fsType )
247
+ flakey , err := dmflakey .InitFlakey (name , imgDir , fsType , mkfsOpt )
192
248
require .NoError (t , err , "init flakey %s" , name )
193
249
t .Cleanup (func () {
194
250
assert .NoError (t , flakey .Teardown ())
@@ -239,7 +295,7 @@ func (f *flakeyT) PowerFailure(mntOpt string) error {
239
295
}
240
296
241
297
if err := unix .Mount (f .DevicePath (), f .rootDir , string (f .Filesystem ()), 0 , mntOpt ); err != nil {
242
- return fmt .Errorf ("failed to mount rootfs %s: %w" , f .rootDir , err )
298
+ return fmt .Errorf ("failed to mount rootfs %s (%s) : %w" , f .rootDir , mntOpt , err )
243
299
}
244
300
return nil
245
301
}
0 commit comments