1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package sysfs
18
19 import (
20 "testing"
21
22 "github.com/google/go-cmp/cmp"
23 )
24
25 func TestMdraidStats(t *testing.T) {
26 fs, err := NewFS(sysTestFixtures)
27 if err != nil {
28 t.Fatal(err)
29 }
30
31 got, err := fs.Mdraids()
32 if err != nil {
33 t.Fatal(err)
34 }
35
36 want := []Mdraid{
37 {
38 Device: "md0",
39 Level: "raid0",
40 ArrayState: "clean",
41 MetadataVersion: "1.2",
42 Disks: 2,
43 Components: []MdraidComponent{
44 {Device: "sdg", State: "in_sync"},
45 {Device: "sdh", State: "in_sync"},
46 },
47 UUID: "155f29ff-1716-4107-b362-52307ef86cac",
48 ChunkSize: 524288,
49 },
50 {
51 Device: "md1",
52 Level: "raid1",
53 ArrayState: "clean",
54 MetadataVersion: "1.2",
55 Disks: 2,
56 Components: []MdraidComponent{
57 {Device: "sdi", State: "in_sync"},
58 {Device: "sdj", State: "in_sync"},
59 },
60 UUID: "0fbf5f2c-add2-43c2-bd78-a4be3ab709ef",
61 SyncAction: "idle",
62 },
63 {
64 Device: "md10",
65 Level: "raid10",
66 ArrayState: "clean",
67 MetadataVersion: "1.2",
68 Disks: 4,
69 Components: []MdraidComponent{
70 {Device: "sdu", State: "in_sync"},
71 {Device: "sdv", State: "in_sync"},
72 {Device: "sdw", State: "in_sync"},
73 {Device: "sdx", State: "in_sync"},
74 },
75 UUID: "0c15f7e7-b159-4b1f-a5cd-a79b5c04b6f5",
76 ChunkSize: 524288,
77 SyncAction: "idle",
78 },
79 {
80 Device: "md4",
81 Level: "raid4",
82 ArrayState: "clean",
83 MetadataVersion: "1.2",
84 Disks: 3,
85 Components: []MdraidComponent{
86 {Device: "sdk", State: "in_sync"},
87 {Device: "sdl", State: "in_sync"},
88 {Device: "sdm", State: "in_sync"},
89 },
90 UUID: "67f415d5-2c0c-4b69-8e0d-7e20ef553457",
91 ChunkSize: 524288,
92 SyncAction: "idle",
93 },
94 {
95 Device: "md5",
96 Level: "raid5",
97 ArrayState: "clean",
98 MetadataVersion: "1.2",
99 Disks: 3,
100 Components: []MdraidComponent{
101 {Device: "sdaa", State: "spare"},
102 {Device: "sdn", State: "in_sync"},
103 {Device: "sdo", State: "in_sync"},
104 {Device: "sdp", State: "faulty"},
105 },
106 UUID: "7615b98d-f2ba-4d99-bee8-6202d8e130b9",
107 ChunkSize: 524288,
108 DegradedDisks: 1,
109 SyncAction: "idle",
110 },
111 {
112 Device: "md6",
113 Level: "raid6",
114 ArrayState: "active",
115 MetadataVersion: "1.2",
116 Disks: 4,
117 Components: []MdraidComponent{
118 {Device: "sdq", State: "in_sync"},
119 {Device: "sdr", State: "in_sync"},
120 {Device: "sds", State: "in_sync"},
121 {Device: "sdt", State: "spare"},
122 },
123 UUID: "5f529b25-6efd-46e4-99a2-31f6f597be6b",
124 ChunkSize: 524288,
125 DegradedDisks: 1,
126 SyncAction: "recover",
127 SyncCompleted: 0.7500458659491194,
128 },
129 }
130
131 if diff := cmp.Diff(want, got); diff != "" {
132 t.Fatalf("unexpected Mdraid (-want +got):\n%s", diff)
133 }
134 }
135
View as plain text