-
Notifications
You must be signed in to change notification settings - Fork 372
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
multi config scenario #2898
Merged
Merged
multi config scenario #2898
Changes from 33 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
da72c37
Update version to dummy 1.0.0.0'
maddieford 59dbd22
Revert version change
maddieford 633a826
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 14a743f
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 54ea0f3
Merge remote-tracking branch 'upstream/develop' into develop
maddieford e79c4c5
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 498b612
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 1e269f4
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 7b49e76
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 0a426cc
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 17fbf6a
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 995cbb9
Merge remote-tracking branch 'upstream/develop' into develop
maddieford eaadc83
Merge remote-tracking branch 'upstream/develop' into develop
maddieford fb03e07
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 6a8e0d6
Merge remote-tracking branch 'upstream/develop' into develop
maddieford b4951c8
Merge branch 'develop' of github.com:Azure/WALinuxAgent into develop
maddieford c6d9300
Merge branch 'develop' of github.com:maddieford/WALinuxAgent into dev…
maddieford f650fe4
Merge remote-tracking branch 'upstream/develop' into develop
maddieford a10bdfa
Merge branch 'develop' of github.com:maddieford/WALinuxAgent into dev…
maddieford 50dcec5
Merge remote-tracking branch 'upstream/develop' into develop
maddieford b87db37
merge changes
maddieford 56e84c1
Merge remote-tracking branch 'upstream/develop' into develop
maddieford fd5d0f5
Merge remote-tracking branch 'upstream/develop' into develop
maddieford b04fd81
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 20d9a34
Merge remote-tracking branch 'upstream/develop' into develop
maddieford 8502377
multi config scenario bare bones
maddieford e9175ac
multi config scenario bare bones
maddieford c4f32f7
Merge branch 'develop' of github.com:maddieford/WALinuxAgent into mut…
maddieford 4c2ff7c
Stash
maddieford 7ed06ad
Add multi config test
maddieford 1c6b34a
Run on arm64
maddieford 8f9cdc8
RCv2 is not supported on arm64
maddieford 79590e5
Merge branch 'develop' into mutli_config
maddieford 8e226c9
Test should own VM
maddieford 2d8ed8c
Add single config ext to test
maddieford dd69271
Add single config ext to test
maddieford c1a383f
Do not fail test if there are unexpected extensions on the vm
maddieford 94c5017
Update comment for accuracy
maddieford e18bb21
Make resource name parameter optional
maddieford 94b0966
Clean up code
maddieford bdd6389
Merge branch 'develop' into mutli_config
maddieford File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Multi-config extensions are no longer supported but there are still customers running RCv2 and we don't want to break | ||
# them. This test suite is used to verify that the agent processes RCv2 (a multi-config extension) as expected. | ||
# | ||
name: "MultiConfigExt" | ||
tests: | ||
- "multi_config_ext/multi_config_ext.py" | ||
images: | ||
- "endorsed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Microsoft Azure Linux Agent | ||
# | ||
# Copyright 2018 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# | ||
# This test adds multiple instances of RCv2 and verifies that the extensions are processed and deleted as expected. | ||
# | ||
import json | ||
import uuid | ||
from typing import Dict | ||
|
||
from assertpy import fail | ||
from azure.mgmt.compute.models import VirtualMachineInstanceView | ||
|
||
from tests_e2e.tests.lib.agent_test import AgentTest | ||
from tests_e2e.tests.lib.identifiers import VmExtensionIds | ||
from tests_e2e.tests.lib.logging import log | ||
from tests_e2e.tests.lib.virtual_machine_client import VirtualMachineClient | ||
from tests_e2e.tests.lib.virtual_machine_extension_client import VirtualMachineExtensionClient | ||
|
||
|
||
class MultiConfigExt(AgentTest): | ||
class TestCase: | ||
def __init__(self, extension: VirtualMachineExtensionClient): | ||
self.extension = extension | ||
self.test_guid: str = str(uuid.uuid4()) | ||
|
||
def enable_extensions(self, test_cases: Dict[str, TestCase]): | ||
for resource_name, test_case in test_cases.items(): | ||
log.info("") | ||
log.info("Adding {0} to the test VM. guid={1}".format(resource_name, test_case.test_guid)) | ||
test_case.extension.enable(settings={ | ||
"source": { | ||
"script": f"echo {test_case.test_guid}" | ||
} | ||
}) | ||
test_case.extension.assert_instance_view() | ||
|
||
def assert_expected_guids_in_ext_status(self, test_cases: Dict[str, TestCase]): | ||
for resource_name, test_case in test_cases.items(): | ||
log.info("") | ||
log.info("Checking {0} has expected status message with {1}".format(resource_name, test_case.test_guid)) | ||
test_case.extension.assert_instance_view(expected_message=f"{test_case.test_guid}") | ||
|
||
def run(self): | ||
# Create 3 different RCv2 extensions and assign each a unique guid. We will use this guid to verify the | ||
# extension status later | ||
test_cases: Dict[str, MultiConfigExt.TestCase] = { | ||
"MCExt1": MultiConfigExt.TestCase(VirtualMachineExtensionClient(self._context.vm, | ||
VmExtensionIds.RunCommandHandler, | ||
resource_name="MCExt1")), | ||
"MCExt2": MultiConfigExt.TestCase(VirtualMachineExtensionClient(self._context.vm, | ||
VmExtensionIds.RunCommandHandler, | ||
resource_name="MCExt2")), | ||
"MCExt3": MultiConfigExt.TestCase(VirtualMachineExtensionClient(self._context.vm, | ||
VmExtensionIds.RunCommandHandler, | ||
resource_name="MCExt3")) | ||
} | ||
|
||
# Add each extension to the VM and validate instance view has succeeded status. | ||
# Each extension will be added with settings to echo its assigned test_guid: | ||
# { | ||
# "source": { | ||
# "script": f"echo {t.test_guid}" | ||
# } | ||
# } | ||
log.info("") | ||
log.info("Add 3 instances of RCv2 to the VM. Each instance will echo a unique guid...") | ||
self.enable_extensions(test_cases=test_cases) | ||
log.info("") | ||
log.info("Check that each extension has the expected guid in its status message...") | ||
self.assert_expected_guids_in_ext_status(test_cases=test_cases) | ||
|
||
# Update MCExt3 with a new guid and add a new instance of RCv2 to the VM | ||
updated_test_cases: Dict[str, MultiConfigExt.TestCase] = { | ||
"MCExt3": MultiConfigExt.TestCase(VirtualMachineExtensionClient(self._context.vm, | ||
VmExtensionIds.RunCommandHandler, | ||
resource_name="MCExt3")), | ||
"MCExt4": MultiConfigExt.TestCase(VirtualMachineExtensionClient(self._context.vm, | ||
VmExtensionIds.RunCommandHandler, | ||
resource_name="MCExt4")) | ||
} | ||
test_cases.update(updated_test_cases) | ||
|
||
log.info("") | ||
log.info("Update MCExt3 with new guid and add a new instance of RCv2 to the VM...") | ||
self.enable_extensions(test_cases=updated_test_cases) | ||
log.info("") | ||
log.info("Check that each extension has the expected guid in its status message...") | ||
self.assert_expected_guids_in_ext_status(test_cases=test_cases) | ||
|
||
# Delete each extension on the VM and assert that there are no unexpected extensions left | ||
log.info("") | ||
log.info("Delete each instance of RCv2...") | ||
for resource_name, test_case in test_cases.items(): | ||
log.info("") | ||
log.info("Deleting {0} from the test VM".format(resource_name)) | ||
test_case.extension.delete() | ||
|
||
vm: VirtualMachineClient = VirtualMachineClient(self._context.vm) | ||
instance_view: VirtualMachineInstanceView = vm.get_instance_view() | ||
if instance_view.extensions is not None and any(instance_view.extensions): | ||
fail("Unwanted extension found: \n{0}".format(json.dumps(instance_view.serialize(), indent=2))) | ||
log.info("") | ||
log.info("All instances of RCv2 were successfully deleted, and no unexpected extensions were found in the " | ||
"instance view.") | ||
|
||
|
||
if __name__ == "__main__": | ||
MultiConfigExt.run_from_command_line() | ||
narrieta marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
when this test shares the test VM with other tests, there may be other extensions
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.
updated so this test owns the vm
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.
why should it own the VM? I think the test needs to adapt to sharing the VM
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.
You're right, I think it is enough to just check that the name of any found extension does not match the name of any extensions we've added for this test. I'll make the update
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.
yes, that would do it....
one thing, though, once an extension is added with a specific resource name (e.g. resource_name="CSE"), subsequent operations need to use the same name or CRP will give a really weird error. Maybe we should remove the resource_name parameter from VirtualMachineExtensionClient and set the resource name to be the same as the extension name when we call the SDK.
sharing VMs across multiple tests will for sure make writing those tests a little more complicated, but the trade-off is worth it, since creating a VM, adding a few extensions and then deleting the VM misses many scenarios that are real in prod VMs.
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.
updated