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 basic tests for mdatp #3511

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

atbagga
Copy link
Collaborator

@atbagga atbagga commented Nov 13, 2024

  • Adding new tests for mdatp which check for onboarding and basic eicar_detection test
  • Renaming the existing test which checks for clean state of the image as mdatp_clean

This change is based of the original PR - #3113

@@ -0,0 +1,135 @@
# Copyright (c) Microsoft Corporation.
Copy link
Member

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", "")
Copy link
Member

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():
Copy link
Member

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()
Copy link
Member

Choose a reason for hiding this comment

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

  1. Don't call the private method like _check_exists, call exists.
  2. 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():
Copy link
Member

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)
Copy link
Member

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.

@atbagga atbagga assigned atbagga and unassigned atbagga Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants