2013-01-28 13:20:57 +00:00
|
|
|
from Tank.Plugins.Phantom import PhantomConfig, PhantomPlugin
|
2013-01-27 15:56:23 +00:00
|
|
|
from Tests.TankTests import TankTestCase
|
|
|
|
import unittest
|
|
|
|
import logging
|
2013-01-28 13:20:57 +00:00
|
|
|
from Tank.Plugins.PhantomUtils import StepperWrapper
|
2013-01-27 15:56:23 +00:00
|
|
|
|
|
|
|
class PhantomConfigTestCase(TankTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
core = self.get_core()
|
|
|
|
core.load_configs(['config/phantom.conf'])
|
|
|
|
core.load_plugins()
|
|
|
|
core.plugins_configure()
|
|
|
|
core.plugins_prepare_test()
|
|
|
|
|
|
|
|
foo = PhantomConfig(core)
|
|
|
|
foo.read_config()
|
|
|
|
config = foo.compose_config()
|
2013-01-28 12:24:01 +00:00
|
|
|
conf_str = open(config).read()
|
2013-01-27 15:56:23 +00:00
|
|
|
logging.info(conf_str)
|
|
|
|
self.assertEquals(conf_str.count("io_benchmark_t"), 1)
|
|
|
|
|
|
|
|
def test_double(self):
|
|
|
|
core = self.get_core()
|
|
|
|
core.load_configs(['config/phantom_double.conf'])
|
|
|
|
core.load_plugins()
|
|
|
|
core.plugins_configure()
|
|
|
|
core.plugins_prepare_test()
|
|
|
|
|
|
|
|
foo = PhantomConfig(core)
|
|
|
|
foo.read_config()
|
|
|
|
config = foo.compose_config()
|
2013-01-28 15:50:21 +00:00
|
|
|
info=foo.get_info()
|
|
|
|
logging.info(info.steps)
|
|
|
|
self.assertEquals(len(info.steps), 450)
|
|
|
|
|
2013-01-28 12:24:01 +00:00
|
|
|
conf_str = open(config).read()
|
2013-01-27 15:56:23 +00:00
|
|
|
logging.info(conf_str)
|
2013-01-28 15:50:21 +00:00
|
|
|
self.assertEquals(conf_str.count("io_benchmark_t"), 3)
|
2013-01-28 13:20:57 +00:00
|
|
|
self.assertEquals(conf_str.count("benchmark_io "), 2)
|
|
|
|
self.assertEquals(conf_str.count("benchmark_io1 "), 2)
|
2013-01-28 15:50:21 +00:00
|
|
|
self.assertEquals(conf_str.count("benchmark_io2 "), 2)
|
|
|
|
|
2013-01-27 15:56:23 +00:00
|
|
|
|
2013-01-28 12:24:01 +00:00
|
|
|
def test_multiload_parsing(self):
|
|
|
|
core = self.get_core()
|
2013-01-28 13:20:57 +00:00
|
|
|
foo = StepperWrapper(core, PhantomPlugin.SECTION)
|
2013-01-28 12:24:01 +00:00
|
|
|
foo.core.set_option('phantom', 'rps_schedule', 'const(1,1) line(1,100,60)\nstep(1,10,1,10)')
|
|
|
|
foo.read_config()
|
|
|
|
self.assertEquals(['const(1,1)', 'line(1,100,60)', 'step(1,10,1,10)'], foo.rps_schedule)
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-27 15:56:23 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|