Skip to content

Commit

Permalink
tests: improve tunnels integration test, to make it non-flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
slyon committed Sep 3, 2020
1 parent 5c688e3 commit b7d32ae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/integration/tunnels.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import sys
import subprocess
import time
import unittest

from base import IntegrationTestsBase, test_backends
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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'])

Expand Down

0 comments on commit b7d32ae

Please sign in to comment.