Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
Added implementation and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludwig Richter committed Oct 12, 2019
1 parent 0f7bd0c commit 11f12e4
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 2 deletions.
7 changes: 7 additions & 0 deletions examples/mdstat/raid1wsb.mdstat.check.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Personalities : [raid1] [raid0] [linear] [multipath] [raid6] [raid5] [raid4] [raid10]
md127 : active raid1 sda1[1] sdb1[0]
3906783040 blocks super 1.2 [2/2] [UU]
[>....................] check = 0.9% (35327488/3906783040) finish=352.4min speed=183050K/sec
bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>
7 changes: 7 additions & 0 deletions examples/mdstat/raid1wsb.mdstat.check.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Personalities : [raid1] [raid0] [linear] [multipath] [raid6] [raid5] [raid4] [raid10]
md127 : active raid1 sda1[1] sdb1[0]
3906783040 blocks super 1.2 [2/2] [UU]
[==============>......] check = 73.9% (2502342341/3906783040) finish=52.7min speed=186040K/sec
bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ activity
}

activityType
= "recovery" / "resync"
= "recovery" / "resync" / "check"

progress
= progress:float "% " {
Expand Down
8 changes: 8 additions & 0 deletions tests/010-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ const TEST_DEFINITION = [
[
'recovering with 1 failed device phase 1',
'./examples/mdstat/raid1wsb.mdstat.faulty.0'
],
[
'checking with issued check command 1',
'./examples/mdstat/raid1wsb.mdstat.check.0'
],
[
'checking with issued check command 2',
'./examples/mdstat/raid1wsb.mdstat.check.1'
]
]
]
Expand Down
114 changes: 114 additions & 0 deletions tests/__snapshots__/010-parser.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,120 @@ Object {
}
`;

exports[`Test parser at different RAID1 definitions Test especially RAID1 with 2 devices and a bitmap should parse correctly a RAID1 definition checking with issued check command 1 1`] = `
Object {
"personalities": Array [
"raid1",
"raid0",
"linear",
"multipath",
"raid6",
"raid5",
"raid4",
"raid10",
],
"raids": Array [
Object {
"access": "rw",
"blocks": 3906783040,
"current": 2,
"devices": Array [
Object {
"index": 1,
"name": "sda1",
"status": "active",
},
Object {
"index": 0,
"name": "sdb1",
"status": "active",
},
],
"ideal": 2,
"name": "md127",
"options": Array [
Object {
"activityType": "check",
"finish": 352.4,
"processed": 35327488,
"progress": 0.9,
"speed": 183050,
"total": 3906783040,
"type": "activity",
},
Object {
"chunkSize": 65536,
"sizePages": 0,
"totalPages": 30,
"type": "bitmap",
"usedPages": 0,
},
],
"parameters": "super 1.2",
"state": "active",
"type": "raid1",
},
],
}
`;

exports[`Test parser at different RAID1 definitions Test especially RAID1 with 2 devices and a bitmap should parse correctly a RAID1 definition checking with issued check command 2 1`] = `
Object {
"personalities": Array [
"raid1",
"raid0",
"linear",
"multipath",
"raid6",
"raid5",
"raid4",
"raid10",
],
"raids": Array [
Object {
"access": "rw",
"blocks": 3906783040,
"current": 2,
"devices": Array [
Object {
"index": 1,
"name": "sda1",
"status": "active",
},
Object {
"index": 0,
"name": "sdb1",
"status": "active",
},
],
"ideal": 2,
"name": "md127",
"options": Array [
Object {
"activityType": "check",
"finish": 52.7,
"processed": 2502342341,
"progress": 73.9,
"speed": 186040,
"total": 3906783040,
"type": "activity",
},
Object {
"chunkSize": 65536,
"sizePages": 0,
"totalPages": 30,
"type": "bitmap",
"usedPages": 0,
},
],
"parameters": "super 1.2",
"state": "active",
"type": "raid1",
},
],
}
`;

exports[`Test parser at different RAID1 definitions Test especially RAID1 with 2 devices and a bitmap should parse correctly a RAID1 definition recovering with 1 failed device phase 1 1`] = `
Object {
"personalities": Array [
Expand Down

0 comments on commit 11f12e4

Please sign in to comment.