Skip to content

Commit 85c9111

Browse files
committed
Address CR comments
Signed-off-by: Gaurang Tapase <gtapase@ddn.com>
1 parent f38cbf3 commit 85c9111

File tree

5 files changed

+4897
-22
lines changed

5 files changed

+4897
-22
lines changed

lustre-collector/src/lib.rs

Lines changed: 6 additions & 15 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) = mgs::mgs_fs_parser::parse()
66+
let (mgs_fs_record, state) = parser::parse()
6767
.easy_parse(mgs_fs)
6868
.map_err(|err| err.map_position(|p| p.translate_position(mgs_fs)))?;
6969

@@ -78,7 +78,7 @@ pub fn parse_recovery_status_output(
7878
let recovery_status = str::from_utf8(recovery_status_output)?;
7979
let recovery_status = recovery_status.trim();
8080

81-
let (recovery_statuses, state) = recovery_status_parser::parse()
81+
let (recovery_statuses, state) = parser::parse()
8282
.easy_parse(recovery_status)
8383
.map_err(|err| err.map_position(|p| p.translate_position(recovery_status)))?;
8484

@@ -89,39 +89,30 @@ pub fn parse_recovery_status_output(
8989

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

9494
#[test]
9595
fn ex8761_job_stats() {
9696
let xs = include_bytes!("./fixtures/valid/ex8761-lctl.txt");
9797
let expected = parse_lctl_output(xs).unwrap();
9898

99-
let y = serde_json::to_string(&expected).unwrap();
100-
let z: Vec<Record> = serde_json::from_str(&y).unwrap();
101-
102-
assert_eq!(expected, z);
99+
insta::assert_debug_snapshot!(expected);
103100
}
104101

105102
#[test]
106103
fn test_parse_recovery_status_output() {
107104
let xs = include_bytes!("./fixtures/recovery-multiple.txt");
108105
let expected = parse_recovery_status_output(xs).unwrap();
109106

110-
let y = serde_json::to_string(&expected).unwrap();
111-
let z: Vec<Record> = serde_json::from_str(&y).unwrap();
112-
113-
assert_eq!(expected, z);
107+
insta::assert_debug_snapshot!(expected);
114108
}
115109

116110
#[test]
117111
fn es_6_2_0_job_stats_unhealthy() {
118112
let xs = include_bytes!("./fixtures/valid/params-6.2.0-r9.txt");
119113
let expected = parse_lctl_output(xs).unwrap();
120114

121-
let y = serde_json::to_string(&expected).unwrap();
122-
let z: Vec<Record> = serde_json::from_str(&y).unwrap();
123-
124-
assert_eq!(expected, z);
115+
insta::assert_debug_snapshot!(expected);
125116
}
126117

127118
#[test]

lustre-collector/src/recovery_status_parser.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,11 @@ where
229229
I: Stream<Token = char>,
230230
I::Error: ParseError<I::Token, I::Range, I::Position>,
231231
{
232-
many1(
233-
(
234-
target_status(),
235-
skip_until(attempt(ost_or_mdt().map(drop)).or(eof())),
236-
)
237-
.map(|(x, _)| x),
232+
(
233+
target_status(),
234+
skip_until(attempt(ost_or_mdt().map(drop)).or(eof())),
238235
)
239-
.map(|xs: Vec<Vec<TargetStats>>| xs.into_iter().flatten().map(Record::Target).collect())
236+
.map(|(x, _)| x.into_iter().map(Record::Target).collect())
240237
}
241238

242239
#[cfg(test)]

0 commit comments

Comments
 (0)