fix tests

This commit is contained in:
Alexey Lavrenuke 2015-02-05 17:45:17 +03:00
parent 6ab390cda6
commit af03121e0c
30 changed files with 96 additions and 95 deletions

View File

@ -1,7 +1,7 @@
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import unittest import unittest
from Tank.Plugins.ApacheBenchmark import ABReader, ApacheBenchmarkPlugin from yandextank.plugins.ApacheBenchmark import ABReader, ApacheBenchmarkPlugin
from Tank.Plugins.Aggregator import AggregatorPlugin from yandextank.plugins.Aggregator import AggregatorPlugin
class ABTestCase(TankTestCase): class ABTestCase(TankTestCase):
def setUp(self): def setUp(self):

View File

@ -1,9 +1,9 @@
import time import time
import unittest import unittest
from Tank.Plugins.Aggregator import AggregatorPlugin, AbstractReader, \ from yandextank.plugins.Aggregator import AggregatorPlugin, AbstractReader, \
SecondAggregateDataTotalItem SecondAggregateDataTotalItem
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
class AggregatorPluginTestCase(TankTestCase): class AggregatorPluginTestCase(TankTestCase):

View File

@ -1,6 +1,6 @@
from Tank.Plugins.Aggregator import SecondAggregateData from yandextank.plugins.Aggregator import SecondAggregateData
from Tank.Plugins.Autostop import AutostopPlugin from yandextank.plugins.Autostop import AutostopPlugin
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import tempfile import tempfile
import unittest import unittest

View File

@ -1,7 +1,7 @@
import unittest import unittest
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import tankcore import yandextank.core as tankcore
class CommonUtilsTest(TankTestCase): class CommonUtilsTest(TankTestCase):

View File

@ -1,6 +1,6 @@
from Tank.ConsoleWorker import ConsoleTank from yandextank.core.consoleworker import ConsoleTank
from Tests.TankTests import TankTestCase, FakeOptions from TankTests import TankTestCase, FakeOptions
from tankcore import ConfigManager from yandextank.core import ConfigManager
import tempfile import tempfile
import unittest import unittest

View File

@ -1,9 +1,9 @@
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget, \ from yandextank.plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget, \
RealConsoleMarkup RealConsoleMarkup
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import tempfile import tempfile
import unittest import unittest
from Tank.Plugins.ConsoleScreen import krutilka from yandextank.plugins.ConsoleScreen import krutilka
class FakeConsoleMarkup(RealConsoleMarkup): class FakeConsoleMarkup(RealConsoleMarkup):
clear = "\n[clear]\n" clear = "\n[clear]\n"

View File

@ -1,24 +1,25 @@
from Tank.ConsoleWorker import ConsoleTank from yandextank.core.consoleworker import ConsoleTank
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin from yandextank.plugins.ConsoleOnline import ConsoleOnlinePlugin
from Tests.ConsoleOnlinePluginTest import FakeConsoleMarkup from ConsoleOnlinePluginTest import FakeConsoleMarkup
from Tests.TankTests import FakeOptions from TankTests import FakeOptions
import TankTests import TankTests
import logging import logging
import unittest import unittest
import datetime import datetime
class ConsoleWorkerTestCase(TankTests.TankTestCase): class ConsoleWorkerTestCase(TankTests.TankTestCase):
def setUp(self): def setUp(self):
opts = FakeOptions() opts = FakeOptions()
opts.no_rc = False opts.no_rc = False
opts.scheduled_start=datetime.datetime.now().strftime('%H:%M:%S') opts.scheduled_start = datetime.datetime.now().strftime('%H:%M:%S')
self.foo = ConsoleTank(opts, None) self.foo = ConsoleTank(opts, None)
self.foo.set_baseconfigs_dir('full') self.foo.set_baseconfigs_dir('full')
def tearDown(self): def tearDown(self):
del self.foo del self.foo
self.foo = None self.foo = None
def test_perform(self): def test_perform(self):
self.foo.configure() self.foo.configure()
@ -28,11 +29,10 @@ class ConsoleWorkerTestCase(TankTests.TankTestCase):
console.console_markup = FakeConsoleMarkup() console.console_markup = FakeConsoleMarkup()
except: except:
pass pass
if self.foo.perform_test() != 0: if self.foo.perform_test() != 0:
raise RuntimeError() raise RuntimeError()
def test_option_override(self): def test_option_override(self):
options = FakeOptions() options = FakeOptions()
options.config = ["config/phantom.conf"] options.config = ["config/phantom.conf"]

View File

@ -1,4 +1,4 @@
from tankcore import AbstractPlugin from yandextank.core import AbstractPlugin
import time import time
class DummyPlugin(AbstractPlugin): class DummyPlugin(AbstractPlugin):

View File

@ -2,9 +2,9 @@ import logging
import time import time
import unittest import unittest
from Tank.Plugins.JMeter import JMeterPlugin, JMeterReader from yandextank.plugins.JMeter import JMeterPlugin, JMeterReader
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
from Tank.Plugins.Aggregator import AggregatorPlugin from yandextank.plugins.Aggregator import AggregatorPlugin
class JMeterPluginTestCase(TankTestCase): class JMeterPluginTestCase(TankTestCase):

View File

@ -1,16 +1,17 @@
from Tank.MonCollector.collector import MonitoringCollector, \ from yandextank.plugins.Monitoring.collector import MonitoringCollector, \
MonitoringDataListener, SSHWrapper MonitoringDataListener, SSHWrapper
from Tank.Plugins.ConsoleOnline import Screen from yandextank.plugins.ConsoleOnline import Screen
from Tank.Plugins.Monitoring import MonitoringPlugin, MonitoringWidget from yandextank.plugins.Monitoring import MonitoringPlugin, MonitoringWidget
from Tests.ConsoleOnlinePluginTest import FakeConsoleMarkup from ConsoleOnlinePluginTest import FakeConsoleMarkup
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import logging import logging
import time import time
import tempfile import tempfile
class MonitoringCollectorTestCase(TankTestCase): class MonitoringCollectorTestCase(TankTestCase):
data = None data = None
def test_collector(self): def test_collector(self):
mon = MonitoringCollector() mon = MonitoringCollector()
mon.config = "config/mon1.conf" mon.config = "config/mon1.conf"

View File

@ -2,9 +2,9 @@ import socket
import unittest import unittest
import logging import logging
from Tank.Plugins.Phantom import PhantomConfig, PhantomPlugin from yandextank.plugins.Phantom import PhantomConfig, PhantomPlugin
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
from Tank.Plugins.PhantomUtils import StepperWrapper, AddressWizard from yandextank.plugins.PhantomUtils import StepperWrapper, AddressWizard
class PhantomConfigTestCase(TankTestCase): class PhantomConfigTestCase(TankTestCase):

View File

@ -2,10 +2,10 @@ import os
import time import time
import unittest import unittest
from Tank.Plugins.Aggregator import AggregatorPlugin, SecondAggregateData from yandextank.plugins.Aggregator import AggregatorPlugin, SecondAggregateData
from Tank.Plugins.Phantom import PhantomPlugin, PhantomReader from yandextank.plugins.Phantom import PhantomPlugin, PhantomReader
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
from Tank.Plugins.PhantomUtils import StepperWrapper from yandextank.plugins.PhantomUtils import StepperWrapper
class PhantomPluginTestCase(TankTestCase): class PhantomPluginTestCase(TankTestCase):

View File

@ -1,6 +1,6 @@
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import unittest import unittest
from Tank.Plugins.RCAssert import RCAssertPlugin from yandextank.plugins.RCAssert import RCAssertPlugin
class RCAssertTestCase(TankTestCase): class RCAssertTestCase(TankTestCase):
def setUp(self): def setUp(self):

View File

@ -1,8 +1,8 @@
import unittest import unittest
from Tank.Plugins.ResourceCheck import ResourceCheckPlugin from yandextank.plugins.ResourceCheck import ResourceCheckPlugin
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
class RCheckTestCase(TankTestCase): class RCheckTestCase(TankTestCase):

View File

@ -1,6 +1,6 @@
from Tank.Plugins.ConsoleScreen import Screen, CurrentHTTPBlock, CurrentNetBlock from yandextank.plugins.ConsoleScreen import Screen, CurrentHTTPBlock, CurrentNetBlock
from Tests.ConsoleOnlinePluginTest import FakeConsoleMarkup from ConsoleOnlinePluginTest import FakeConsoleMarkup
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
class BlocksTestCase(TankTestCase): class BlocksTestCase(TankTestCase):
def test_HTTP(self): def test_HTTP(self):

View File

@ -1,12 +1,12 @@
from Tank.Plugins.ShellExec import ShellExecPlugin from yandextank.plugins.ShellExec import ShellExecPlugin
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import logging import logging
import select import select
import subprocess import subprocess
import tempfile
import unittest import unittest
class ShellExecPluginTestCase(TankTestCase):
class ShellExecPluginTestCase(TankTestCase):
def setUp(self): def setUp(self):
core = self.get_core() core = self.get_core()
core.load_configs(['config/shellexec.conf']) core.load_configs(['config/shellexec.conf'])
@ -21,11 +21,11 @@ class ShellExecPluginTestCase(TankTestCase):
self.foo.prepare_test() self.foo.prepare_test()
self.foo.start_test() self.foo.start_test()
self.foo.end_test(0) self.foo.end_test(0)
def test_select(self): def test_select(self):
pipes = subprocess.Popen(["pwd"], stdout=subprocess.PIPE) pipes = subprocess.Popen(["pwd"], stdout=subprocess.PIPE)
r, w, x = select.select([pipes.stdout], [], [], 1) r, w, x = select.select([pipes.stdout], [], [], 1)
logging.info("selected: %s %s %s", r, w, x) logging.info("selected: %s %s %s", r, w, x)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -1,9 +1,9 @@
import tempfile import tempfile
import os import os
from Tank.stepper import Stepper from yandextank.stepper import Stepper
from Tank.stepper.format import StpdReader from yandextank.stepper.format import StpdReader
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
class StepperTestCase(TankTestCase): class StepperTestCase(TankTestCase):
@ -94,7 +94,7 @@ class StepperTestCase(TankTestCase):
).write(stpd_file) ).write(stpd_file)
res = open(temp_stpd, 'r').read() res = open(temp_stpd, 'r').read()
self.assertNotEquals("", res) self.assertNotEquals("", res)
self.assertEquals(1900, os.path.getsize(temp_stpd)) self.assertEquals(1904, os.path.getsize(temp_stpd))
def test_manual_inst(self): def test_manual_inst(self):
@ -126,7 +126,7 @@ class StepperTestCase(TankTestCase):
).write(stpd_file) ).write(stpd_file)
res = open(temp_stpd, 'r').read() res = open(temp_stpd, 'r').read()
self.assertNotEquals("", res) self.assertNotEquals("", res)
self.assertEquals(258, os.path.getsize(temp_stpd)) self.assertEquals(262, os.path.getsize(temp_stpd))
def test_default(self): def test_default(self):
temp_stpd = tempfile.mkstemp()[1] temp_stpd = tempfile.mkstemp()[1]
@ -161,7 +161,7 @@ class StepperTestCase(TankTestCase):
self.assertEquals(1459, os.path.getsize(temp_stpd)) self.assertEquals(1459, os.path.getsize(temp_stpd))
def test_empty_uri(self): def test_empty_uri(self):
from Tank.stepper.module_exceptions import AmmoFileError from yandextank.stepper.module_exceptions import AmmoFileError
temp_stpd = tempfile.mkstemp()[1] temp_stpd = tempfile.mkstemp()[1]
with open(temp_stpd, 'w') as stpd_file: with open(temp_stpd, 'w') as stpd_file:
with self.assertRaises(AmmoFileError): with self.assertRaises(AmmoFileError):
@ -196,7 +196,7 @@ class StepperTestCase(TankTestCase):
self.assertEquals(len(list(sr)), 10) self.assertEquals(len(list(sr)), 10)
def test_bad_stpd_reader(self): def test_bad_stpd_reader(self):
from Tank.stepper.module_exceptions import StpdFileError from yandextank.stepper.module_exceptions import StpdFileError
sr = StpdReader("data/bad.ammo.stpd") sr = StpdReader("data/bad.ammo.stpd")
with self.assertRaises(StpdFileError): with self.assertRaises(StpdFileError):
list(sr) list(sr)

View File

@ -1,7 +1,7 @@
import unittest import unittest
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import tankcore import yandextank.core as tankcore
class TankCoreTestCase(TankTestCase): class TankCoreTestCase(TankTestCase):
@ -43,4 +43,3 @@ class TankCoreTestCase(TankTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -3,9 +3,9 @@ import sys
import tempfile import tempfile
import unittest import unittest
from Tank.Plugins.Aggregator import SecondAggregateData, \ from yandextank.plugins.Aggregator import SecondAggregateData, \
SecondAggregateDataTotalItem SecondAggregateDataTotalItem
from tankcore import TankCore from yandextank.core import TankCore
class TankTestCase(unittest.TestCase): class TankTestCase(unittest.TestCase):

View File

@ -1,9 +1,9 @@
from Tank.Plugins.Aggregator import SecondAggregateData, \ from yandextank.plugins.Aggregator import SecondAggregateData, \
SecondAggregateDataTotalItem SecondAggregateDataTotalItem
from Tank.Plugins.TotalAutostop import TotalFracTimeCriteria, TotalHTTPCodesCriteria, TotalNegativeHTTPCodesCriteria, TotalNetCodesCriteria, TotalNegativeNetCodesCriteria, TotalHTTPTrendCriteria, QuantileOfSaturationCriteria from yandextank.plugins.TotalAutostop import TotalFracTimeCriteria, TotalHTTPCodesCriteria, TotalNegativeHTTPCodesCriteria, TotalNetCodesCriteria, TotalNegativeNetCodesCriteria, TotalHTTPTrendCriteria, QuantileOfSaturationCriteria
from Tests.TankTests import TankTestCase from TankTests import TankTestCase
import unittest import unittest
from Tank.Plugins.Autostop import AutostopPlugin from yandextank.plugins.Autostop import AutostopPlugin
class TotalCriteriasTest(TankTestCase): class TotalCriteriasTest(TankTestCase):
def setUp(self): def setUp(self):

View File

@ -1,5 +1,5 @@
[tank] [tank]
#plugin_console=Tank/Plugins/ConsoleOnline.py #plugin_console=yandextank.plugins.ConsoleOnline
[phantom] [phantom]
cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users' cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users'

View File

@ -1,7 +1,7 @@
[tank] [tank]
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
plugin_phantom=Tank/Plugins/Phantom.py plugin_phantom=yandextank.plugins.Phantom
plugin_console=Tank/Plugins/ConsoleOnline.py plugin_console=yandextank.plugins.ConsoleOnline
[phantom] [phantom]
cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users' cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users'

View File

@ -1,5 +1,5 @@
[tank] [tank]
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
[phantom] [phantom]
cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users' cases = 'search_%D0%BF%D0%BE%D1%80%D0%BD%D0%BE_users' 'search' 'search_%D0%BD%D1%8E_users' 'search_%D1%8D%D1%80%D0%BE%D1%82%D0%B8%D0%BA%D0%B0_users' 'search_%D1%86%D0%B2%D0%B5%D1%82%D1%8B_users' 'search_%D0%B1%D0%B5%D0%B7%20%D1%82%D1%80%D1%83%D1%81%D0%B8%D0%BA%D0%BE%D0%B2_users'

View File

@ -3,8 +3,7 @@ dotted.test=passed
[tank] [tank]
someoption=somevalue someoption=somevalue
plugin_ShellExec=Tank/Plugins/ShellExec.py plugin_ShellExec=yandextank.plugins.ShellExec
plugin_ShellExec2=Tests/Dummy.py
plugin_disabled= plugin_disabled=
someoption=somevalue someoption=somevalue

View File

@ -1,7 +1,8 @@
[tank] [tank]
plugin_phantom=Tank/Plugins/Phantom.py plugin_phantom=yandextank.plugins.Phantom
plugin_console=Tank/Plugins/ConsoleOnline.py plugin_console=yandextank.plugins.ConsoleOnline
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
[phantom] [phantom]
ammofile=data/dummy.ammo ammofile=data/dummy.ammo
connection_test=0

View File

@ -1,6 +1,6 @@
[tank] [tank]
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
plugin_console=Tank/Plugins/ConsoleOnline.py plugin_console=yandextank.plugins.ConsoleOnline
[phantom] [phantom]
phantom_path=phantom phantom_path=phantom

View File

@ -1,6 +1,6 @@
[tank] [tank]
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
plugin_console=Tank/Plugins/ConsoleOnline.py plugin_console=yandextank.plugins.ConsoleOnline
[phantom] [phantom]
phantom_path=phantom phantom_path=phantom

View File

@ -1,4 +1,4 @@
[tank] [tank]
plugin_ShellExec=Tank/Plugins/ShellExec.py plugin_ShellExec=yandextank.plugins.ShellExec
plugin_Dummy=Tank/Plugins/Dummy.py plugin_Dummy=Dummy
plugin_ShellExec3=Tank/Plugins/ShellExec3.py plugin_ShellExec3=yandextank.plugins.ShellExec3

View File

@ -1,8 +1,8 @@
[tank] [tank]
plugin_ShellExec=Tank/Plugins/ShellExec.py plugin_ShellExec=yandextank.plugins.ShellExec
plugin_phantom=Tank/Plugins/Phantom.py plugin_phantom=yandextank.plugins.Phantom
plugin_aggreg=Tank/Plugins/Aggregator.py plugin_aggreg=yandextank.plugins.Aggregator
plugin_console=Tank/Plugins/ConsoleOnline.py plugin_console=yandextank.plugins.ConsoleOnline
[aggregator] [aggregator]
time_periods=1 5 10 50 100ms 500 1s time_periods=1 5 10 50 100ms 500 1s
@ -11,9 +11,10 @@ time_periods=1 5 10 50 100ms 500 1s
ammofile=data/dummy.ammo ammofile=data/dummy.ammo
instances_schedule=line(1,10,1m) instances_schedule=line(1,10,1m)
#loop=100 #loop=100
ammo_limit=100 ammo_limit=10
load=const(1,1) line(1,50,10) load=const(1,1) line(1,50,10)
use_caching=1 use_caching=1
connection_test=0
[shellexec] [shellexec]
prepare=uname -a prepare=uname -a

View File

@ -5,7 +5,7 @@ import time
import unittest import unittest
import base64 import base64
from Tank.MonCollector.agent.agent import CpuStat, Custom, Disk, NetTcp, NetTxRx from yandextank.plugins.Monitoring.agent.agent import CpuStat, Custom, Disk, NetTcp, NetTxRx
if __name__ == '__main__': if __name__ == '__main__':