Skip to content

Commit 3828c9d

Browse files
committed
Revert mgs_fs parsing function to not use top level parser and add unit tests
Signed-off-by: Gaurang Tapase <[email protected]>
1 parent 85c9111 commit 3828c9d

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[target.x86_64-unknown-linux-musl]
22
linker = "rust-lld"
33

4+
[target.aarch64-apple-darwin]
5+
linker = "rust-lld"
6+
47
[alias]
58
build-musl = "build --release --target x86_64-unknown-linux-musl"
69

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mgs.MGS.live.params
2+
mgs.MGS.live.testfs

lustre-collector/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn parse_lctl_output(lctl_output: &[u8]) -> Result<Vec<Record>, LustreCollec
6363
pub fn parse_mgs_fs_output(mgs_fs_output: &[u8]) -> Result<Vec<Record>, LustreCollectorError> {
6464
let mgs_fs = str::from_utf8(mgs_fs_output)?;
6565

66-
let (mgs_fs_record, state) = parser::parse()
66+
let (mgs_fs_record, state) = mgs::mgs_fs_parser::parse()
6767
.easy_parse(mgs_fs)
6868
.map_err(|err| err.map_position(|p| p.translate_position(mgs_fs)))?;
6969

@@ -89,7 +89,7 @@ pub fn parse_recovery_status_output(
8989

9090
#[cfg(test)]
9191
mod tests {
92-
use crate::{parse_lctl_output, parse_recovery_status_output};
92+
use crate::{parse_lctl_output, parse_mgs_fs_output, parse_recovery_status_output};
9393

9494
#[test]
9595
fn ex8761_job_stats() {
@@ -107,6 +107,14 @@ mod tests {
107107
insta::assert_debug_snapshot!(expected);
108108
}
109109

110+
#[test]
111+
fn test_parse_mgs_fs_output() {
112+
let xs = include_bytes!("./fixtures/mgs-fs.txt");
113+
let expected = parse_mgs_fs_output(xs).unwrap();
114+
115+
insta::assert_debug_snapshot!(expected);
116+
}
117+
110118
#[test]
111119
fn es_6_2_0_job_stats_unhealthy() {
112120
let xs = include_bytes!("./fixtures/valid/params-6.2.0-r9.txt");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
source: lustre-collector/src/lib.rs
3+
expression: expected
4+
---
5+
[
6+
Target(
7+
FsNames(
8+
TargetStat {
9+
kind: Mgt,
10+
param: Param(
11+
"fsnames",
12+
),
13+
target: Target(
14+
"MGS",
15+
),
16+
value: [
17+
FsName(
18+
"testfs",
19+
),
20+
],
21+
},
22+
),
23+
),
24+
]

0 commit comments

Comments
 (0)