Skip to content

Commit

Permalink
tests: failovering: wait for more time, since default number of conne…
Browse files Browse the repository at this point in the history
…ctions increased
  • Loading branch information
vankoven committed Mar 10, 2017
1 parent 1addc3f commit dbe5b58
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tempesta_fw/t/functional/regression/test_srv_failovering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest
import random
import socket
import asyncore
from helpers import deproxy, tf_cfg, tempesta, remote
from testers import functional

Expand All @@ -19,6 +20,8 @@ class FailoveringTest(functional.FunctionalTest):
TODO: Check that TempestaFW keeps configured failovering intervals.
"""

timeout_limit = 5.0

def create_servers(self):
self.create_servers_helper(tempesta.servers_in_group())

Expand All @@ -38,17 +41,25 @@ def init(self):

def test_on_close(self):
self.init()
self.tester.run()
self.tester.loop(self.timeout_limit)
self.assertTrue(self.tester.is_srvs_ready())

self.tester.random_close()
self.assertFalse(self.tester.is_srvs_ready())
self.tester.run()
# Wait for connections failovering.
self.tester.loop(self.timeout_limit)
self.assertTrue(self.tester.is_srvs_ready())

def test_on_shutdown(self):
self.init()
self.tester.run()
self.tester.loop(self.timeout_limit)
self.assertTrue(self.tester.is_srvs_ready())

self.tester.random_shutdown()
self.assertFalse(self.tester.is_srvs_ready())
self.tester.run()
# Wait for connections failovering.
self.tester.loop(self.timeout_limit)
self.assertTrue(self.tester.is_srvs_ready())


class FailoverTester(deproxy.Deproxy):
Expand All @@ -57,8 +68,11 @@ def __init__(self, *args, **kwargs):
deproxy.Deproxy.__init__(self, *args, **kwargs)
self.expected_conns_n = sum([s.conns_n for s in self.servers])

def check_expectations(self):
assert self.is_srvs_ready()
def register_srv_connection(self, connection):
deproxy.Deproxy.register_srv_connection(self, connection)
# Brake the loop wait if all connections are online.
if self.expected_conns_n == len(self.srv_connections):
raise asyncore.ExitNow

def random_close(self):
for i in range (self.expected_conns_n // 4):
Expand Down

0 comments on commit dbe5b58

Please sign in to comment.