Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements in stress testing. #105

Merged
merged 4 commits into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ['tf_cfg', 'deproxy', 'nginx', 'tempesta', 'error', 'flacky',
'analyzer', 'stateful', 'dmesg', 'wrk', 'prepare']
'analyzer', 'stateful', 'dmesg', 'wrk', 'prepare', 'util']

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
2 changes: 2 additions & 0 deletions helpers/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import asyncore
import multiprocessing.dummy as multiprocessing
from . import tf_cfg, remote, error, nginx, tempesta, deproxy, stateful, dmesg
from . import util

__author__ = 'Tempesta Technologies, Inc.'
__copyright__ = 'Copyright (C) 2017 Tempesta Technologies, Inc.'
Expand Down Expand Up @@ -114,6 +115,7 @@ def set_user_agent(self, ua):
self.options.append('-H \'User-Agent: %s\'' % ua)


@util.deprecated("framework.Wrk")
i-rinat marked this conversation as resolved.
Show resolved Hide resolved
class Wrk(Client):
""" wrk - HTTP benchmark utility.

Expand Down
33 changes: 33 additions & 0 deletions helpers/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Utils for the testing framework.
"""
from . import tf_cfg

__author__ = 'Tempesta Technologies, Inc.'
__copyright__ = 'Copyright (C) 2019 Tempesta Technologies, Inc.'
__license__ = 'GPL2'


def deprecated(alt_impl_name):
"""
Decorator to declare a class and its descendants as deprecated.
Example ('Foo' is a new alternative implementation which should be used
instead):

@deprecated("Foo")
class A(...):
...
"""
def decorator(cls):

def deprecated_new(new_func):
def wrap(cls_arg, *args, **kwargs):
tf_cfg.dbg(5, "%s must be used instead of deprecated %s"
% (alt_impl_name, cls_arg.__name__))
return new_func(cls_arg, *args, **kwargs)
return wrap

setattr(cls, '__new__', staticmethod(deprecated_new(cls.__new__)))
return cls

return decorator
2 changes: 2 additions & 0 deletions testers/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import copy
import asyncore
from helpers import dmesg, tf_cfg, control, tempesta, deproxy, stateful, remote
from helpers import util
from helpers.deproxy import ParseError

__author__ = 'Tempesta Technologies, Inc.'
__copyright__ = 'Copyright (C) 2017 Tempesta Technologies, Inc.'
__license__ = 'GPL2'

@util.deprecated("tester.TempestaTest")
class FunctionalTest(unittest.TestCase):

tfw_clnt_msg_otherr = False
Expand Down
7 changes: 6 additions & 1 deletion testers/stress.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import print_function
import unittest
from helpers import tf_cfg, control, tempesta, stateful, dmesg, remote
from helpers import util

__author__ = 'Tempesta Technologies, Inc.'
__copyright__ = 'Copyright (C) 2017-2018 Tempesta Technologies, Inc.'
__license__ = 'GPL2'

@util.deprecated("tester.TempestaTest")
class StressTest(unittest.TestCase):
""" Test Suite to use HTTP benchmarks as a clients. Can be used for
functional testing of schedulers and stress testing for other components.
Expand Down Expand Up @@ -162,6 +164,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 +192,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