-
Notifications
You must be signed in to change notification settings - Fork 179
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 basic tests for mdatp #3511
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,135 @@ | |||
# Copyright (c) Microsoft Corporation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put them under the vm_extensions folder, so we can manage vm extension cases easier. You can have a subfolder there.
class MDETest(TestSuite): | ||
def before_case(self, log: Logger, **kwargs: Any) -> None: | ||
variables = kwargs["variables"] | ||
self.onboarding_script_sas_uri = variables.get("onboarding_script_sas_uri", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it support non-sas uri? The extra requirement makes the test case skipped in most pipelines.
return True | ||
|
||
def _install(self) -> bool: | ||
if not self.get_mde_installer(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks the get_mde_installer
return true always. The code logic won't be hit.
def verify_mde(self, node: Node, log: Logger, result: TestResult) -> None: | ||
# Invoking tools first time, intalls the tool. | ||
try: | ||
output = node.tools[Mdatp]._check_exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't call the private method like
_check_exists
, callexists
. - But when you refer a tool like this, the check/install happens automatically. So, the code can be like
_ = node.tools[Mdatp]
, and capture the exception if there is.
return self._check_exists() | ||
|
||
def onboard(self, onboarding_script_sas_uri: str) -> bool: | ||
if not self._check_exists(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to check, when you have an instance of the tool, it means the check exists already passed.
force_run=True, | ||
) | ||
|
||
result.assert_exit_code(include_output=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error message for assertion, so the test case can bring more information, when it's failed.
This change is based of the original PR - #3113