diff --git a/tests_e2e/tests/agent_ext_workflow/extension_workflow.py b/tests_e2e/tests/agent_ext_workflow/extension_workflow.py index 3f25c6a6b..c52620c3f 100644 --- a/tests_e2e/tests/agent_ext_workflow/extension_workflow.py +++ b/tests_e2e/tests/agent_ext_workflow/extension_workflow.py @@ -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, @@ -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) @@ -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, @@ -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) diff --git a/tests_e2e/tests/scripts/agent_ext_workflow-assert_operation_sequence.py b/tests_e2e/tests/scripts/agent_ext_workflow-assert_operation_sequence.py index d01d27799..4817da30f 100755 --- a/tests_e2e/tests/scripts/agent_ext_workflow-assert_operation_sequence.py +++ b/tests_e2e/tests/scripts/agent_ext_workflow-assert_operation_sequence.py @@ -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") @@ -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