mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 10:25:17 +00:00
Fix unit tests
This commit is contained in:
parent
59f17269a9
commit
39c2108cd9
@ -14,6 +14,7 @@ class JMeterPlugin(AbstractPlugin):
|
||||
''' JMeter tank plugin '''
|
||||
SECTION = 'jmeter'
|
||||
|
||||
|
||||
def __init__(self, core):
|
||||
AbstractPlugin.__init__(self, core)
|
||||
self.jmeter_process = None
|
||||
@ -25,9 +26,11 @@ class JMeterPlugin(AbstractPlugin):
|
||||
self.jmeter_path = None
|
||||
self.jmeter_log = None
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_key():
|
||||
return __file__
|
||||
|
||||
|
||||
def configure(self):
|
||||
self.original_jmx = self.get_option("jmx")
|
||||
@ -41,6 +44,7 @@ class JMeterPlugin(AbstractPlugin):
|
||||
self.jmeter_log = self.core.mkstemp('.log', 'jmeter_')
|
||||
self.core.add_artifact_file(self.jmeter_log, True)
|
||||
|
||||
|
||||
def prepare_test(self):
|
||||
self.args = [self.jmeter_path, "-n", "-t", self.jmx, '-j', self.jmeter_log, '-Jjmeter.save.saveservice.default_delimiter=\\t']
|
||||
self.args += tankcore.splitstring(self.user_args)
|
||||
@ -123,6 +127,7 @@ class JMeterPlugin(AbstractPlugin):
|
||||
return new_file
|
||||
|
||||
|
||||
|
||||
class JMeterReader(AbstractReader):
|
||||
''' JTL files reader '''
|
||||
KNOWN_EXC = {
|
||||
|
@ -44,7 +44,7 @@ class Custom_TestCase(unittest.TestCase):
|
||||
def test_custom_nodiff(self):
|
||||
tail_fd, tailfile = tempfile.mkstemp()
|
||||
tail = ["%s:%s:%s" % (base64.b64encode('lbl'), base64.b64encode(tailfile), 0)]
|
||||
call = ['ZGlmZkV4:aWZjb25maWcgLXMgZXRoMCB8IGF3ayAnJDE9PSJldGgwIiB7cHJpbnQgJDR9Jw==:0']
|
||||
call = ["%s:%s:%s" % (base64.b64encode('lbl2'), base64.b64encode("date +%s"), 0)]
|
||||
self.foo = Custom(call, tail)
|
||||
|
||||
x = self.foo.check()
|
||||
@ -59,7 +59,7 @@ class Custom_TestCase(unittest.TestCase):
|
||||
self.assertNotEquals(x[1], y[1])
|
||||
self.assertEquals(tailval, y[0])
|
||||
|
||||
time.sleep(0.5)
|
||||
time.sleep(2)
|
||||
tailval = str(time.time())
|
||||
os.write(tail_fd, "%s\n" % tailval)
|
||||
z = self.foo.check()
|
||||
@ -67,10 +67,13 @@ class Custom_TestCase(unittest.TestCase):
|
||||
self.assertNotEquals(y[1], z[1])
|
||||
|
||||
def test_custom_fail(self):
|
||||
custom_config = {'tail': [], 'call': ['cXVlcnkgY291bnQ=:cXVlcnlfY2xhc3NpZnlfY2xpZW50IGZzdGF0cyB8IGdyZXAgY2xhc3MtY21kIHwgY3V0IC1mIDM=:1']}
|
||||
self.foo = Custom(**custom_config)
|
||||
tail = ["%s:%s:%s" % (base64.b64encode('lbl'), base64.b64encode("notexistent"), 0)]
|
||||
call = ["%s:%s:%s" % (base64.b64encode('lbl2'), base64.b64encode("notexistent"), 0)]
|
||||
self.foo = Custom(call, tail)
|
||||
|
||||
x = self.foo.check()
|
||||
self.assertEquals("0", x[0])
|
||||
self.assertEquals("0", x[1])
|
||||
|
||||
def test_custom_fail2(self):
|
||||
custom_config = {'tail': [], 'call': ['TnVtUGhyYXNlcw==:Y2F0IC92YXIvdG1wL3N0YXQx:0']}
|
||||
|
Loading…
Reference in New Issue
Block a user