Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nagworld9 committed Aug 4, 2023
1 parent c20a841 commit fae814e
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from assertpy import fail

from azurelinuxagent.common.utils import shellutil
from tests_e2e.tests.lib.logging import log
from tests_e2e.tests.lib.remote_test import run_remote_test

Expand Down Expand Up @@ -84,6 +85,9 @@ def get_non_root_drop_rule(command: str) -> List[str]:


def execute_cmd(cmd: List[str]):
"""
Note: The shellutil.run_command don't return the exit code of the command. So using subprocess.Popen
"""
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down Expand Up @@ -279,7 +283,7 @@ def verify_non_root_accept_rule():
log.info("Stop Guest Agent service")
# agent-service is script name and stop is argument
stop_agent = ["agent-service", "stop"]
execute_cmd(stop_agent)
shellutil.run_command(stop_agent)

# deleting non root accept rule
non_root_accept_delete_cmd = get_non_root_accept_rule("-D")
Expand All @@ -299,7 +303,7 @@ def verify_non_root_accept_rule():
log.info("Restart Guest Agent service to re-add the deleted rules")
# agent-service is script name and start is argument
start_agent = ["agent-service", "start"]
execute_cmd(start_agent)
shellutil.run_command(start_agent)

verify_all_rules_exist()
log.info("** Current IP table rules \n")
Expand Down Expand Up @@ -327,7 +331,7 @@ def verify_root_accept_rule():
log.info("Stop Guest Agent service")
# agent-service is script name and stop is argument
stop_agent = ["agent-service", "stop"]
execute_cmd(stop_agent)
shellutil.run_command(stop_agent)

# deleting root accept rule
root_accept_delete_cmd = get_root_accept_rule("-D")
Expand All @@ -346,7 +350,7 @@ def verify_root_accept_rule():
log.info("Restart Guest Agent service to re-add the deleted rules")
# agent-service is script name and start is argument
start_agent = ["agent-service", "start"]
execute_cmd(start_agent)
shellutil.run_command(start_agent)

verify_all_rules_exist()
log.info("** Current IP table rules \n")
Expand All @@ -371,7 +375,7 @@ def verify_non_root_dcp_rule():
log.info("Stop Guest Agent service")
# agent-service is script name and stop is argument
stop_agent = ["agent-service", "stop"]
execute_cmd(stop_agent)
shellutil.run_command(stop_agent)

# deleting non root delete rule
non_root_drop_delete_cmd = get_non_root_drop_rule("-D")
Expand All @@ -390,7 +394,7 @@ def verify_non_root_dcp_rule():
log.info("Restart Guest Agent service to re-add the deleted rules")
# agent-service is script name and start is argument
start_agent = ["agent-service", "start"]
execute_cmd(start_agent)
shellutil.run_command(start_agent)

verify_all_rules_exist()
log.info("** Current IP table rules\n")
Expand Down

0 comments on commit fae814e

Please sign in to comment.