-
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
agent publish refactor #3091
agent publish refactor #3091
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3091 +/- ##
========================================
Coverage 71.89% 71.89%
========================================
Files 110 110
Lines 16395 16395
Branches 2342 2342
========================================
Hits 11788 11788
Misses 4055 4055
Partials 552 552 ☔ View full report in Codecov by Sentry. |
@@ -842,6 +846,18 @@ def _create_test_context(self,) -> AgentTestContext: | |||
username=self._user, | |||
identity_file=self._identity_file) | |||
|
|||
def _get_test_args(self) -> Dict[str, str]: |
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.
converting list of key=value to dictionary
tests_e2e/tests/lib/agent_test.py
Outdated
self._context: AgentTestContext = context | ||
self._test_args: Dict[str, str] = test_args |
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.
These args exposed to all tests
@@ -86,20 +129,6 @@ def _check_cse(self) -> None: | |||
) | |||
custom_script_2_1.assert_instance_view(expected_version="2.1", expected_message=message) | |||
|
|||
def get_ignore_error_rules(self) -> List[Dict[str, Any]]: |
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.
not needed in this test
@@ -146,64 +140,6 @@ def _prepare_agent(self) -> None: | |||
"update-waagent-conf AutoUpdate.UpdateToLatestVersion=y Debug.EnableGAVersioning=y AutoUpdate.GAFamily=Test", use_sudo=True) | |||
log.info('Successfully updated agent update config \n %s', output) | |||
|
|||
@staticmethod |
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.
moved to common helper
if not verify_agent_update_flag_enabled(vm): | ||
# enable the flag | ||
log.info("Attempting vm update to set the enableVMAgentPlatformUpdates flag") | ||
enable_agent_update_flag(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 is this necessary? How is it used vs. our waagent.conf flag
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.
This is different flag need to set in the vm model for CRP/RSM driving RSM updates
@@ -209,6 +211,7 @@ def _initialize(self, environment: Environment, variables: Dict[str, Any], lisa_ | |||
self._environment_name = variables["c_env_name"] | |||
|
|||
self._test_suites = variables["c_test_suites"] | |||
self._test_args = variables["test_args"] |
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.
looks like there may be inconsistency in type here. variables["test_argd"] is str while self._test_args is dict
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's still a string, later we convert to dict. The variables exposed to user in pipeline, runbook or command line is in string in the form of list of comma-separated key=value pair
Example
publihsedVersion=2.10.0.8,hostName=Test
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.
oh, you are right. It should be string. I just noticed
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
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.
Added some comments, could you also describe how you are planning to planning to pass the arguments to the publish test from the pipeline? If the new argument is required, we should probably create a new pipeline.yml for the publish pipeline.
if self._test_args == "": | ||
return test_args | ||
for arg in self._test_args.split(','): | ||
key, value = arg.split('=') |
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.
we should trim spaces after splitting on comma
@@ -565,6 +568,7 @@ def _execute(self) -> None: | |||
|
|||
try: | |||
test_context = self._create_test_context() | |||
test_args = self._get_test_args() |
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.
we should do the conversion in _initialize() and keep the result in self._test_args, to avoid adding more parameters to the execute method
@@ -645,7 +649,7 @@ def _execute_test_suite(self, suite: TestSuiteInfo, test_context: AgentTestConte | |||
|
|||
test_success: bool = True | |||
|
|||
test_instance = test.test_class(test_context) | |||
test_instance = test.test_class(test_context, test_args) |
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.
Rather than passing test_args as a new argument to the test, each test_arg should be added to the text_context as a new property (or if the property already exists in the context, the just set its value).
Then AgentPublishTest.run_from_command_line should read the new parameters from the command line and add them to the test context as well. That is, it would parse the publishedVersion argument, instead of the test_args argument
log.info("Modifying agent update related config flags and renaming the log file") | ||
self._run_remote_test(self._ssh_client, "sh -c 'agent-service stop && mv /var/log/waagent.log /var/log/waagent.$(date --iso-8601=seconds).log && update-waagent-conf AutoUpdate.UpdateToLatestVersion=y AutoUpdate.GAFamily=Test AutoUpdate.Enabled=y Extensions.Enabled=y'", use_sudo=True) | ||
log.info('Renamed log file and updated agent-update DownloadNewAgents GAFamily config flags') | ||
self._run_remote_test(self._ssh_client, "sh -c 'agent-service stop && mv /var/log/waagent.log /var/log/waagent.$(date --iso-8601=seconds).log && rm -rf /var/lib/waagent/WALinuxAgent-* && update-waagent-conf AutoUpdate.UpdateToLatestVersion=y AutoUpdate.GAFamily=Test AutoUpdate.Enabled=y Extensions.Enabled=y Debug.EnableGAVersioning=n'", use_sudo=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.
could you split this in multiple lines to make it more readable? thanks
My idea is to it would benefit for other test_suites(for dev runs etc) if we added to main pipeline because the internal implementation is going to be same regardless. When we run the pipeline, one need to pass like list of key=value pair in the pipeline arg. This converted to dict and added to agenttestcontext, so that all the tests access to dict. Whichever test needed, they read the keys to get value. For publish test when I run the pipeline with agent_publish as test_suite, I pass publishedVersion={version}, the publish test reads this key publihsedVersion |
Yes, I agree that it is useful and can be added as an optional parameter in the main pipeline
If this parameter is required by the publish test, then maybe should have a pipeline just for publish, |
Not sure I followed here. I wouldn't send this as parameter, rather I send this parameter as value in the new test_arg parameter. That way I don't have deal with separate code path just for agent publish |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3091 +/- ##
========================================
Coverage 71.87% 71.87%
========================================
Files 110 110
Lines 16406 16406
Branches 2344 2344
========================================
Hits 11791 11791
Misses 4064 4064
Partials 551 551 ☔ View full report in Codecov by Sentry. |
@narrieta Updated my pr. I added todo for reading it from cmd line. I couldn't get the flow right, maybe I'm missing something and also, I have different thought like we can directly use argparser for reading test specific arguments in the test itself. |
tests_e2e/tests/lib/agent_test.py
Outdated
@@ -73,6 +73,8 @@ def run_from_command_line(cls): | |||
""" | |||
Convenience method to execute the test when it is being invoked directly from the command line (as opposed as | |||
being invoked from a test framework or library.) | |||
|
|||
Todo: Need to implement for reading test specific arguments from command line |
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.
Let's use capitals: TODO. Then some tools highlight that comment
* agent publish refactor * support arm 64vm * convert dict to str * address comments * pylint * new comments * updated comment
Description
Added RSM update verification in agent publish test.
PR includes new pipeline parameter for passing test arguments. Passing all the way from pipeline to each test.
The expected format is comma-separated list of key=value pair like
publihsedVersion=2.10.0.8,hostName=Test
This is needed especially for agent publish test to know the published version to validate. This new parameter will be useful for other tests when you want to test something dynamically without needing to change tests locally.
Issue #
PR information
Quality of Code and Contribution Guidelines