Skip to content

Commit

Permalink
Assert that a client in stress test actually did some work.
Browse files Browse the repository at this point in the history
Fix ugly assertion 'False is not true'.
Print warnings on higest verbose level about deprecated classes (#56).
  • Loading branch information
krizhanovsky committed Jun 24, 2019
1 parent dcb0085 commit ef04200
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions helpers/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class Wrk(Client):
"""
FAIL_ON_SOCK_ERR=False

def __new__(cls, *args, **kwargs):
tf_cfg.dbg(5, "%s must be used instead of deprecated %s"
% ("framework.Wrk", cls.__name__))
return super(Wrk, cls).__new__(cls, *args, **kwargs)

def __init__(self, threads=-1, uri='/', ssl=False, timeout=60):
Client.__init__(self, binary='wrk', uri=uri, ssl=ssl)
self.threads = threads
Expand Down
5 changes: 5 additions & 0 deletions testers/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class FunctionalTest(unittest.TestCase):

tfw_clnt_msg_otherr = False

def __new__(cls, *args, **kwargs):
tf_cfg.dbg(5, "%s must be used instead of deprecated %s"
% ("tester.TempestaTest", cls.__name__))
return super(FunctionalTest, cls).__new__(cls, *args, **kwargs)

def create_client(self):
""" Override to set desired list of benchmarks and their options. """
self.client = deproxy.Client()
Expand Down
10 changes: 9 additions & 1 deletion testers/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class StressTest(unittest.TestCase):
errors_write = 0
errors_timeout = 0

def __new__(cls, *args, **kwargs):
tf_cfg.dbg(5, "%s must be used instead of deprecated %s"
% ("tester.TempestaTest", cls.__name__))
return super(StressTest, cls).__new__(cls, *args, **kwargs)

def create_clients(self):
""" Override to set desired list of benchmarks and their options. """
self.wrk = control.Wrk()
Expand Down Expand Up @@ -162,6 +167,7 @@ def assert_client(self, req, err, statuses):
tf_cfg.dbg(2, "errors read: %i" % e_read)
tf_cfg.dbg(2, "errors write: %i" % e_write)
tf_cfg.dbg(2, "errors timeout: %i" % e_timeout)
self.assertGreater(req, 0, msg="No work was done by the client")
self.assertEqual(err, e_500 + e_502 + e_504 + e_connect, msg=msg)

def assert_clients(self):
Expand Down Expand Up @@ -189,7 +195,9 @@ def assert_clients(self):
exp_max = cl_req_cnt + cl_conn_cnt
self.assertTrue(
self.tempesta.stats.cl_msg_received >= exp_min and
self.tempesta.stats.cl_msg_received <= exp_max
self.tempesta.stats.cl_msg_received <= exp_max,
msg="Tempesta received bad number %d of messages, expected [%d:%d]"
% (self.tempesta.stats.cl_msg_received, exp_min, exp_max)
)

def assert_tempesta(self):
Expand Down

0 comments on commit ef04200

Please sign in to comment.