Skip to content

Commit 954e9b3

Browse files
committed
Check if peers are connected
1 parent 4b4fab8 commit 954e9b3

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

test/qa/lib/meshnet.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
from enum import Enum
77

8+
import pytest
89
import sh
910

1011
from . import daemon, info, logging, login, ssh
@@ -666,3 +667,30 @@ def is_connect_successful(output:str, peer_hostname: str):
666667
def get_lines_with_keywords(lines: list[str], keywords: list[str]) -> list:
667668
"""Returns list with elements, that contain specified `keywords`."""
668669
return [line.strip() for line in lines if all(keyword in line for keyword in keywords)]
670+
671+
def are_peers_connected(ssh_client: ssh.Ssh = None, retry: int = 3) -> None:
672+
"""
673+
Verifies if local and remote NordVPN mesh peers see each other as connected in peer list.
674+
675+
Args:
676+
ssh_client (ssh.Ssh): SSH client to execute commands on the remote system.
677+
678+
Raises:
679+
pytest.fail: If peers are not connected after `retry` attempts.
680+
"""
681+
682+
for refresh_count in range(retry):
683+
local_peer_list = sh.nordvpn.mesh.peer.list(_tty_out=False)
684+
remote_peer_list = ssh_client.exec_command("nordvpn mesh peer list")
685+
686+
if "Status: connected" in local_peer_list and \
687+
"Status: connected" in remote_peer_list:
688+
logging.log(f"peer list refresh count: {refresh_count}")
689+
break
690+
691+
if refresh_count == retry - 1:
692+
logging.log(f"=== local_peer_list ===\n{local_peer_list}\n")
693+
logging.log(f"=== remote_peer_list ===\n{remote_peer_list}\n")
694+
pytest.fail("Peers do not see each other as connected.")
695+
696+
time.sleep(2)

test/qa/test_update.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def setup_function(function): # noqa: ARG001
5555
ssh_client.exec_command("nordvpn set notify off")
5656
ssh_client.exec_command("nordvpn set mesh on")
5757

58-
sh.nordvpn.mesh.peer.list()
59-
ssh_client.exec_command("nordvpn mesh peer list")
58+
meshnet.are_peers_connected(ssh_client)
6059

6160

6261
def teardown_function(function): # noqa: ARG001

0 commit comments

Comments
 (0)