Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece459-w23-a2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Lam
ece459-w23-a2
Commits
9f0e1a31
Commit
9f0e1a31
authored
2 years ago
by
Patrick Lam
Browse files
Options
Downloads
Patches
Plain Diff
fix tests
parent
c5ffced1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/packages/parser.rs
+22
-31
22 additions, 31 deletions
src/packages/parser.rs
with
22 additions
and
31 deletions
src/packages/parser.rs
+
22
−
31
View file @
9f0e1a31
...
...
@@ -124,7 +124,7 @@ fn apply_domain_specific_re(log_line: String, domain_specific_re:&Vec<Regex>) ->
#[test]
fn
test_apply_domain_specific_re
()
{
let
line
=
"q2.34.4.5 Jun 14 15:16:02 combo sshd(pam_unix)[19937]: check pass; Fri Jun 17 20:55:07 2005 user unknown"
.to_string
();
let
censored_line
=
apply_domain_specific_re
(
line
,
&
linux_
censored_regexps
());
let
censored_line
=
apply_domain_specific_re
(
line
,
&
censored_regexps
(
&
Linux
));
assert_eq!
(
censored_line
,
" q<*> Jun 14 <*> combo sshd(pam_unix)[19937]: check pass; <*> user unknown"
);
}
...
...
@@ -142,8 +142,8 @@ pub fn token_splitter(log_line: String, re:&Regex, domain_specific_re:&Vec<Regex
#[test]
fn
test_token_splitter
()
{
let
line
=
"Jun 14 15:16:02 combo sshd(pam_unix)[19937]: check pass; user unknown"
.to_string
();
let
re
=
regex_generator
(
linux_format
(
));
let
split_line
=
token_splitter
(
line
,
&
re
,
&
linux_
censored_regexps
());
let
re
=
regex_generator
(
format_string
(
&
Linux
));
let
split_line
=
token_splitter
(
line
,
&
re
,
&
censored_regexps
(
&
Linux
));
assert_eq!
(
split_line
,
vec!
[
"check"
,
"pass;"
,
"user"
,
"unknown"
]);
}
...
...
@@ -246,11 +246,11 @@ fn dictionary_builder(raw_fn: String, format: String, regexps: Vec<Regex>) -> (H
#[test]
fn
test_dictionary_builder_process_line_lookahead_is_none
()
{
let
line
=
"Jun 14 15:16:02 combo sshd(pam_unix)[19937]: check pass; user unknown"
.to_string
();
let
re
=
regex_generator
(
linux_format
(
));
let
re
=
regex_generator
(
format_string
(
&
Linux
));
let
mut
dbl
=
HashMap
::
new
();
let
mut
trpl
=
HashMap
::
new
();
let
mut
all_token_list
=
vec!
[];
let
(
last1
,
last2
)
=
process_dictionary_builder_line
(
line
,
None
,
&
re
,
&
linux_
censored_regexps
(),
&
mut
dbl
,
&
mut
trpl
,
&
mut
all_token_list
,
None
,
None
);
let
(
last1
,
last2
)
=
process_dictionary_builder_line
(
line
,
None
,
&
re
,
&
censored_regexps
(
&
Linux
),
&
mut
dbl
,
&
mut
trpl
,
&
mut
all_token_list
,
None
,
None
);
assert_eq!
((
last1
,
last2
),
(
Some
(
"unknown"
.to_string
()),
Some
(
"user"
.to_string
())));
let
mut
dbl_oracle
=
HashMap
::
new
();
...
...
@@ -269,11 +269,11 @@ fn test_dictionary_builder_process_line_lookahead_is_none() {
fn
test_dictionary_builder_process_line_lookahead_is_some
()
{
let
line
=
"Jun 14 15:16:02 combo sshd(pam_unix)[19937]: check pass; user unknown"
.to_string
();
let
next_line
=
"Jun 14 15:16:02 combo sshd(pam_unix)[19937]: baz bad"
.to_string
();
let
re
=
regex_generator
(
linux_format
(
));
let
re
=
regex_generator
(
format_string
(
&
Linux
));
let
mut
dbl
=
HashMap
::
new
();
let
mut
trpl
=
HashMap
::
new
();
let
mut
all_token_list
=
vec!
[];
let
(
last1
,
last2
)
=
process_dictionary_builder_line
(
line
,
Some
(
next_line
),
&
re
,
&
linux_
censored_regexps
(),
&
mut
dbl
,
&
mut
trpl
,
&
mut
all_token_list
,
Some
(
"foo"
.to_string
()),
Some
(
"bar"
.to_string
()));
let
(
last1
,
last2
)
=
process_dictionary_builder_line
(
line
,
Some
(
next_line
),
&
re
,
&
censored_regexps
(
&
Linux
),
&
mut
dbl
,
&
mut
trpl
,
&
mut
all_token_list
,
Some
(
"foo"
.to_string
()),
Some
(
"bar"
.to_string
()));
assert_eq!
((
last1
,
last2
),
(
Some
(
"unknown"
.to_string
()),
Some
(
"user"
.to_string
())));
let
mut
dbl_oracle
=
HashMap
::
new
();
...
...
@@ -302,34 +302,25 @@ pub fn parse_raw(raw_fn: String, lf:&LogFormat) -> (HashMap<String, i32>, HashMa
#[test]
fn
test_parse_raw_linux
()
{
let
(
double_dict
,
triple_dict
,
all_token_list
)
=
parse_raw_linux
(
"data/from_paper.log"
.to_string
());
let
all_token_list_oracle
=
vec!
[
"Found"
.to_string
(),
"block"
.to_string
(),
"rdd_42_20"
.to_string
(),
"locally"
.to_string
(),
"rdd_42_22"
.to_string
(),
"rdd_42_23"
.to_string
(),
"rdd_42_24"
.to_string
()];
let
(
double_dict
,
triple_dict
,
all_token_list
)
=
parse_raw
(
"data/from_paper.log"
.to_string
(),
&
Linux
);
let
all_token_list_oracle
=
vec!
[
"hdfs://hostname/2kSOSP.log:21876+7292"
.to_string
(),
"hdfs://hostname/2kSOSP.log:14584+7292"
.to_string
(),
"hdfs://hostname/2kSOSP.log:0+7292"
.to_string
(),
"hdfs://hostname/2kSOSP.log:7292+7292"
.to_string
(),
"hdfs://hostname/2kSOSP.log:29168+7292"
.to_string
()
];
assert_eq!
(
all_token_list
,
all_token_list_oracle
);
let
mut
double_dict_oracle
=
HashMap
::
new
();
double_dict_oracle
.insert
(
"Found^block"
.to_string
(),
4
);
double_dict_oracle
.insert
(
"block^rdd_42_20"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"block^rdd_42_22"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"block^rdd_42_23"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"block^rdd_42_24"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"rdd_42_20^locally"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"rdd_42_22^locally"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"rdd_42_23^locally"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"rdd_42_24^locally"
.to_string
(),
1
);
double_dict_oracle
.insert
(
"locally^Found"
.to_string
(),
6
);
double_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:14584+7292^hdfs://hostname/2kSOSP.log:0+7292"
.to_string
(),
2
);
double_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:21876+7292^hdfs://hostname/2kSOSP.log:14584+7292"
.to_string
(),
2
);
double_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:7292+7292^hdfs://hostname/2kSOSP.log:29168+7292"
.to_string
(),
2
);
double_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:0+7292^hdfs://hostname/2kSOSP.log:7292+7292"
.to_string
(),
2
);
assert_eq!
(
double_dict
,
double_dict_oracle
);
let
mut
triple_dict_oracle
=
HashMap
::
new
();
triple_dict_oracle
.insert
(
"block^rdd_42_20^locally"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"block^rdd_42_22^locally"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"block^rdd_42_23^locally"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"block^rdd_42_24^locally"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"rdd_42_20^locally^Found"
.to_string
(),
2
);
triple_dict_oracle
.insert
(
"rdd_42_22^locally^Found"
.to_string
(),
2
);
triple_dict_oracle
.insert
(
"rdd_42_23^locally^Found"
.to_string
(),
2
);
triple_dict_oracle
.insert
(
"Found^block^rdd_42_20"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"Found^block^rdd_42_22"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"Found^block^rdd_42_23"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"Found^block^rdd_42_24"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"locally^Found^block"
.to_string
(),
6
);
triple_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:0+7292^hdfs://hostname/2kSOSP.log:7292+7292^hdfs://hostname/2kSOSP.log:29168+7292"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:14584+7292^hdfs://hostname/2kSOSP.log:0+7292^hdfs://hostname/2kSOSP.log:7292+7292"
.to_string
(),
1
);
triple_dict_oracle
.insert
(
"hdfs://hostname/2kSOSP.log:21876+7292^hdfs://hostname/2kSOSP.log:14584+7292^hdfs://hostname/2kSOSP.log:0+7292"
.to_string
(),
1
);
assert_eq!
(
triple_dict
,
triple_dict_oracle
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment