Skip to content

Commit

Permalink
add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
nagworld9 committed Aug 1, 2023
1 parent 09ffc8f commit de38171
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests_e2e/tests/scripts/agent_update-wait_for_rsm_gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import sys
import logging

from azurelinuxagent.common.exception import ProtocolError
from azurelinuxagent.common.protocol.util import get_protocol_util
from azurelinuxagent.common.protocol.goal_state import GoalState, GoalStateProperties
from azurelinuxagent.common.protocol.wire import WireProtocol
from tests_e2e.tests.lib.retry import retry_if_false
from tests_e2e.tests.lib.retry import retry_if_false, retry


def get_requested_version(gs: GoalState) -> str:
Expand All @@ -41,7 +42,7 @@ def get_requested_version(gs: GoalState) -> str:


def verify_rsm_requested_version(wire_protocol: WireProtocol, expected_version: str) -> bool:
wire_protocol.client.update_goal_state()
retry(wire_protocol.client.update_goal_state())
goal_state = wire_protocol.client.get_goal_state()
requested_version = get_requested_version(goal_state)
if requested_version == expected_version:
Expand All @@ -56,8 +57,8 @@ def verify_rsm_requested_version(wire_protocol: WireProtocol, expected_version:
args = parser.parse_args()

protocol = get_protocol_util().get_protocol(init_goal_state=False)
protocol.client.reset_goal_state(
goal_state_properties=GoalStateProperties.ExtensionsGoalState)
retry(protocol.client.reset_goal_state(
goal_state_properties=GoalStateProperties.ExtensionsGoalState))

found: bool = retry_if_false(lambda: verify_rsm_requested_version(protocol, args.version))

Expand All @@ -68,7 +69,11 @@ def verify_rsm_requested_version(wire_protocol: WireProtocol, expected_version:


except Exception as e:
print(f"{e}", file=sys.stderr)
msg = ""
if isinstance(e, ProtocolError):
msg = "The check agent log will report protocol errors if those can't be ignored and/or permanent failure, so no need to follow up test error in this case:\n"
msg += "{0}".format(e)
print(f"{msg}", file=sys.stderr)
sys.exit(1)

sys.exit(0)

0 comments on commit de38171

Please sign in to comment.