Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing for escaped log messages #7219

Merged
merged 26 commits into from
May 20, 2024
Merged

Add testing for escaped log messages #7219

merged 26 commits into from
May 20, 2024

Conversation

nnshah1
Copy link
Contributor

@nnshah1 nnshah1 commented May 14, 2024

  • Test for escaped and unescaped log formats
  • Test for log injection
  • Minor updates to test search patterns

qa/L0_logging/log_injection_test.py Fixed Show fixed Hide fixed
qa/L0_logging/log_injection_test.py Fixed Show fixed Hide fixed
qa/L0_logging/log_injection_test.py Fixed Show fixed Hide fixed
@rmccorm4 rmccorm4 changed the title Updates to use table log macros Add testing for escaped log messages May 17, 2024
qa/L0_logging/log_format_test.py Fixed Show fixed Hide fixed
qa/L0_logging/log_format_test.py Fixed Show fixed Hide fixed
qa/L0_logging/log_format_test.py Fixed Show fixed Hide fixed
qa/L0_logging/log_format_test.py Fixed Show resolved Hide resolved
@nnshah1 nnshah1 requested a review from rmccorm4 May 19, 2024 22:08
Comment on lines +298 to +301
if match:
validate_table(obj)
elif escaped:
validate_protobuf(obj)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred to follow-up PR, but would be nice to have some comments explaining the validations that the only acceptable multi-line logs will be tables/protobuf (perhaps json?), but will otherwise be restricted to single-line logs if escaped correctly.

@@ -148,7 +155,7 @@ for BACKEND in $BACKENDS; do
RET=1
fi

grep "] pinned" ${ENSEMBLE_NAME}.nonpinned.server.log
grep "] \"Pinned memory pool is created" ${ENSEMBLE_NAME}.nonpinned.server.log
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is checking that the following line is not found in the log. This was previously "passing" because "pinned" is never found, this is updating the check to be more correct to look for the correct pinned memory message, and assert it's not found when disabled.

else:
# Make sure the max resource limit is never set to 3 when
# explicit limit of 10 is set.
self.assertNotIn("Resource: R1\t Count: 3", f.read())
self.assertNotIn("Resource: R1\\t Count: 3", f.read())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for possible follow-up, if these end up poorly escaped, maybe we can consider embedding some something like 4 spaces " " literally in the string rather than using \t.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was also thinking these could be a table - or a json instead

qa/L0_logging/test.sh Outdated Show resolved Hide resolved
self._server_process.wait()

def _launch_server(self, escaped=None):
cmd = ["tritonserver"]
Copy link
Collaborator

@rmccorm4 rmccorm4 May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow-up - Why not one of the following?:

  1. Start server in test.sh like other tests
  2. Use in-process python API within python test (See Iman's iterative scheduling test)
  3. Do it this way with subprocess in python, but move it into a common util we can start to re-use in other tests if reducing bash usage.

Copy link
Contributor Author

@nnshah1 nnshah1 May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking #3 - reason to do it here was to easily name the logs to match the test cases - and to also control escaping / non escaping via environment variable. Would have been difficult to reuse the start server / seperate out the cases there in bash.

in process api is an option - but log injection was specifically a network issue - so wanted to also stay true to the original intent - I haven't tried to verify if the same holds true if accessing the in process api directly

Co-authored-by: Ryan McCormick <[email protected]>

module_directory = os.path.split(os.path.abspath(__file__))[0]

test_model_directory = os.path.abspath(os.path.join(module_directory, "log_models"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow-up: unused?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised the codeql scanner didn't complain about this

self._server_options["log-warning"] = 1
self._server_options["log-format"] = "default"
self._server_options["model-repository"] = os.path.abspath(
os.path.join(module_directory, "log_models")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow-up: Use test_model_directory defined at top?

Copy link
Collaborator

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally LGTM - nits/suggestions for future follow-up

@nnshah1 nnshah1 merged commit ee89135 into main May 20, 2024
3 checks passed
@nnshah1 nnshah1 deleted the nnshah1-log-format branch May 20, 2024 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants