Skip to content

Commit

Permalink
Agent_ext_workflow scenario fix (Azure#3245)
Browse files Browse the repository at this point in the history
* Ignore extra ext operations for test case

* Fix expected ops in install scenarios

* Improve comment

* Improve comments
  • Loading branch information
maddieford authored Oct 24, 2024
1 parent d203447 commit facc242
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
54 changes: 28 additions & 26 deletions tests_e2e/tests/agent_ext_workflow/extension_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,25 @@ def run(self):
log.info("")
log.info("*******Verifying the extension update with install scenario*******")

# Record the time we start the test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Version 1.2.0 of the test extension has the same functionalities as 1.1.5 with
# "updateMode": "UpdateWithInstall" in HandlerManifest.json to test update case
new_version_update_mode_with_install = "1.2.0"
old_version = "1.1.5"

# Create DcrTestExtension with version 1.1 and 1.2
# Install test extension v1.1.5 on the VM and assert instance view before updating the start_time, since
# the previous test case removed v1.1.5 from the VM.
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Record the time we start the update with install scenario test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Create DcrTestExtension with version 1.2
dcr_test_ext_id_1_2 = VmExtensionIdentifier(
VmExtensionIds.GuestAgentDcrTestExtension.publisher,
VmExtensionIds.GuestAgentDcrTestExtension.type,
Expand All @@ -323,15 +333,6 @@ def run(self):
dcr_test_ext_id_1_2,
resource_name="GuestAgentDcrTestExt"
)
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)

# Install test extension v1.1.5 on the VM and assert instance view
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Update extension object & version to new version
dcr_ext.update_ext_version(dcr_test_ext_client_1_2, new_version_update_mode_with_install)
Expand Down Expand Up @@ -371,14 +372,24 @@ def run(self):
log.info("")
log.info("*******Verifying the extension update without install scenario*******")

# Record the time we start the test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Version 1.3.0 of the test extension has the same functionalities as 1.1.5 with
# "updateMode": "UpdateWithoutInstall" in HandlerManifest.json to test update case
new_version_update_mode_without_install = "1.3.0"

# Create DcrTestExtension with version 1.1 and 1.3
# Install test extension v1.1.5 on the VM and assert instance view before updating the start_time, since
# the previous test case removed v1.1.5 from the VM.
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Record the time we start the update without scenario test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Create DcrTestExtension with version 1.3
dcr_test_ext_id_1_3 = VmExtensionIdentifier(
VmExtensionIds.GuestAgentDcrTestExtension.publisher,
VmExtensionIds.GuestAgentDcrTestExtension.type,
Expand All @@ -388,15 +399,6 @@ def run(self):
dcr_test_ext_id_1_3,
resource_name="GuestAgentDcrTestExt"
)
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)

# Install test extension v1.1.5 on the VM and assert instance view
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Update extension object & version to new version
dcr_ext.update_ext_version(dcr_test_ext_client_1_3, new_version_update_mode_without_install)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ def parse_ops_log(ops_version: str, input_ops: List[str], start_time: str):

ops = []
with open(ops_file_name, 'r') as ops_log:
# we get the last len(input_ops) from the log file and ensure they match with the input_ops
# Example of a line in the log file - `Date:2019-07-30T21:54:03Z; Operation:install; SeqNo:0`
content = ops_log.readlines()[-len(input_ops):]
content = ops_log.readlines()
for op_log in content:
data = op_log.split(DELIMITER)
date = datetime.strptime(data[0].split("Date:")[1], "%Y-%m-%dT%H:%M:%SZ")
Expand All @@ -72,6 +71,13 @@ def parse_ops_log(ops_version: str, input_ops: List[str], start_time: str):
continue

ops.append({'date': date, 'op': op, 'seq_no': seq_no})

# Only parse the expected number of operations after the test case starts. There may be additional
# operations on the extension if the agent processes a goal state with additional extensions added by policy
# or otherwise (ConfigurationforLinux, for example)
if len(ops) == len(input_ops):
break

return ops


Expand Down

0 comments on commit facc242

Please sign in to comment.