From b7d32aebc880f3161b8f97ee56b729c0c54dd0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=A4rdian?= Date: Thu, 3 Sep 2020 12:44:58 +0200 Subject: [PATCH] tests: improve tunnels integration test, to make it non-flaky --- tests/integration/tunnels.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/tunnels.py b/tests/integration/tunnels.py index e10c575c1..dbbe07887 100644 --- a/tests/integration/tunnels.py +++ b/tests/integration/tunnels.py @@ -22,6 +22,7 @@ import sys import subprocess +import time import unittest from base import IntegrationTestsBase, test_backends @@ -110,6 +111,7 @@ def test_tunnel_wireguard(self): keepalive: 21 ''' % {'r': self.backend, 'ec': self.dev_e_client, 'e2c': self.dev_e2_client}) self.generate_and_settle() + time.sleep(2) # Give some time for handshake/connection between client & server # Verify server out = subprocess.check_output(['wg', 'show', 'wg0', 'private-key'], universal_newlines=True) self.assertIn("4GgaQCy68nzNsUE5aJ9fuLzHhB65tAlwbmA72MWnOm8=", out) @@ -121,7 +123,7 @@ def test_tunnel_wireguard(self): self.assertIn("fwmark: 0x2a", out) self.assertIn("peer: M9nt4YujIOmNrRmpIRTmYSfMdrpvE7u6WkG8FY8WjG4=", out) self.assertIn("allowed ips: 20.20.20.0/24", out) - self.assertRegex(out, r'latest handshake: \d+ seconds ago') + self.assertRegex(out, r'latest handshake: \d+ seconds? ago') self.assertRegex(out, r'transfer: \d+ B received, \d+ B sent') self.assert_iface('wg0', ['inet 10.10.10.20/24']) # Verify client @@ -135,7 +137,7 @@ def test_tunnel_wireguard(self): self.assertIn("endpoint: 10.10.10.20:51820", out) self.assertIn("allowed ips: 0.0.0.0/0", out) self.assertIn("persistent keepalive: every 21 seconds", out) - self.assertRegex(out, r'latest handshake: \d+ seconds ago') + self.assertRegex(out, r'latest handshake: \d+ seconds? ago') self.assertRegex(out, r'transfer: \d+ B received, \d+ B sent') self.assert_iface('wg1', ['inet 20.20.20.10/24'])