示例#1
0
 def setUp(self):
     core = self.get_core()
     core.load_configs(['config/phantom.conf'])
     core.load_plugins()
     core.plugins_configure()
     core.plugins_prepare_test()
     self.foo = PhantomPlugin(core)
示例#2
0
 def setUp(self):
     core = self.get_core()
     core.load_configs(['config/phantom.conf'])
     core.load_plugins()
     core.plugins_configure()
     core.plugins_prepare_test()
     self.phantom_plugin_instance = PhantomPlugin(core)
     self.phantom_plugin_instance.core.set_option(
         PhantomPlugin.SECTION, "phantom_path",
         os.path.dirname(__file__) + "/phantom_emul.sh")
示例#3
0
 def setUp(self):
     core = self.get_core()
     core.load_configs(['config/phantom.conf'])
     core.load_plugins()
     core.plugins_configure()
     core.plugins_prepare_test()
     self.foo = PhantomPlugin(core)
示例#4
0
 def setUp(self):
     core = self.get_core()
     core.load_configs(['config/phantom.conf'])
     core.load_plugins()
     core.plugins_configure()
     core.plugins_prepare_test()
     self.phantom_plugin_instance = PhantomPlugin(core)
     self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "phantom_path",
                                                  os.path.dirname(__file__) + "/phantom_emul.sh")
示例#5
0
class PhantomPluginTestCase(TankTestCase):
    def setUp(self):
        core = self.get_core()
        core.load_configs(['config/phantom.conf'])
        core.load_plugins()
        core.plugins_configure()
        core.plugins_prepare_test()
        self.phantom_plugin_instance = PhantomPlugin(core)
        self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "phantom_path",
                                                     os.path.dirname(__file__) + "/phantom_emul.sh")

    def tearDown(self):
        del self.phantom_plugin_instance
        self.phantom_plugin_instance = None
        if os.path.exists("ready_conf_phout.txt"):
            os.remove("ready_conf_phout.txt")

    def test_run(self):
        self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "config", '')
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        reader = PhantomReader(AggregatorPlugin(self.phantom_plugin_instance.core), self.phantom_plugin_instance)
        reader.phout_file = self.phantom_plugin_instance.phantom.phout_file
        self.phantom_plugin_instance.start_test()

        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            reader.check_open_files()
            reader.get_next_sample(False)
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
        self.phantom_plugin_instance.end_test(0)
        reader.get_next_sample(True)


    def test_run_ready_conf(self):
        self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "config", 'data/phantom_ready.conf')
        self.phantom_plugin_instance.core.add_artifact_file("ready_conf_phout.txt")
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
        #self.assertTrue(os.path.getsize("ready_conf_phout.txt") > 0)
        self.phantom_plugin_instance.end_test(0)


    def test_run_uri_style(self):
        self.phantom_plugin_instance.set_option("ammofile", "")
        self.phantom_plugin_instance.set_option("uris", "/")
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
        self.phantom_plugin_instance.end_test(0)

    def test_run_interrupt(self):
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        time.sleep(2)
        self.phantom_plugin_instance.end_test(0)

    def test_run_stepper_cache(self):
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.prepare_test()

    def test_domain_name(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', 'yandex.ru:443')
        self.phantom_plugin_instance.configure()
        self.assertEqual(443, self.phantom_plugin_instance.get_info().port)
        self.assertEqual("yandex.ru", self.phantom_plugin_instance.get_info().address)

    def test_domain_name_and_port(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', 'yandex.ru:80')
        self.phantom_plugin_instance.configure()

    def test_ipv4(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', '127.0.0.1')
        self.phantom_plugin_instance.configure()

    def test_ipv6(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', '2a02:6b8:0:c1f::161:cd')
        self.phantom_plugin_instance.configure()

    def test_ipv4_and_port(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', '127.0.0.1:80')
        self.phantom_plugin_instance.configure()

    def test_domain_name_fail(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address', 'ya.ru')
        try:
            self.phantom_plugin_instance.configure()
            raise RuntimeError()
        except:
            pass


    def test_reader(self):
        self.phantom_plugin_instance.phantom_start_time = time.time()
        reader = PhantomReader(AggregatorPlugin(self.phantom_plugin_instance.core), self.phantom_plugin_instance)
        reader.phout_file = 'data/phout_timeout_mix.txt'
        reader.check_open_files()

        data = reader.get_next_sample(False)
        while data:
            times_sum = 0
            for timing in data.overall.times_dist:
                times_sum += timing['count']
            # FIXME: kinda strange problem here
            #self.assertEquals(sum(data.overall.net_codes.values()), times_sum)
            data = reader.get_next_sample(False)


    def test_stepper_no_steps(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', '')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.ammo_file = 'data/dummy.ammo'
        wrapper.prepare_stepper()
        wrapper.prepare_stepper()

    def test_stepper_instances_sched(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'use_caching', '0')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(100, wrapper.instances)

    def test_stepper_instances_override(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'instances', '20000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', 'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'use_caching', '0')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(20000, wrapper.instances)


    def test_cached_stepper_instances_sched(self):
        # Making cache file
        self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.tearDown()

        self.setUp()
        self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(100, wrapper.instances)

    def test_phout_import(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'phout_file', 'data/phout_timeout_mix.txt')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_count', '1')
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
        sec = SecondAggregateData()
        sec.overall.rps = 1
        self.phantom_plugin_instance.aggregate_second(sec)
        self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
        self.phantom_plugin_instance.end_test(0)
        self.phantom_plugin_instance.post_process(0)

    def test_cached_stpd_info(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'stpd_file', 'data/dummy.ammo.stpd')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(10, wrapper.instances)
        self.assertEqual(60, wrapper.duration)
示例#6
0
class  PhantomPluginTestCase(TankTestCase):
    def setUp(self):
        core = self.get_core()
        core.load_configs(['config/phantom.conf'])
        core.load_plugins()
        core.plugins_configure()
        core.plugins_prepare_test()
        self.foo = PhantomPlugin(core)

    def tearDown(self):
        del self.foo
        self.foo = None
        if os.path.exists("ready_conf_phout.txt"):
            os.remove("ready_conf_phout.txt")

    def test_run(self):
        self.foo.core.set_option(PhantomPlugin.SECTION, "config", '')
        self.foo.configure()
        self.foo.prepare_test()
        reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
        self.foo.start_test()
        
        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            reader.check_open_files()
            reader.get_next_sample(False)
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.foo.end_test(0)
        reader.get_next_sample(True)

    def test_run_ready_conf(self):
        self.foo.core.add_artifact_file("ready_conf_phout.txt")
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.foo.end_test(0)
        
    def test_run_uri_style(self):
        self.foo.set_option("ammofile", "")
        self.foo.set_option("uris", "/")
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.foo.end_test(0)

    def test_run_interrupt(self):
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        time.sleep(2)
        self.foo.end_test(0)

    def test_run_stepper_cache(self):
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.prepare_test()
        
    def test_domain_name(self):
        self.foo.core.set_option('phantom', 'address', 'yandex.ru')
        self.foo.configure()


    def test_domain_name_fail(self):
        self.foo.core.set_option('phantom', 'address', 'ya.ru')
        try:
            self.foo.configure()
            raise RuntimeError()
        except:
            pass
    
    
    def test_multiload_parsing(self):
        self.foo.core.set_option('phantom', 'rps_schedule', 'const(1,1) line(1,100,60)\nstep(1,10,1,10)')
        self.foo.configure()
        self.assertEquals(['const(1,1)', 'line(1,100,60)', 'step(1,10,1,10)'], self.foo.stepper.rps_schedule)
    
    
    def test_reader(self):
        self.foo.phout_file = 'data/phout_timeout_mix.txt'
        self.foo.phantom_start_time = time.time()
        reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
        reader.check_open_files()
        
        data = reader.get_next_sample(False)
        while data:
            times_sum = 0
            for timing in data.overall.times_dist:
                times_sum += timing['count']
            self.assertEquals(sum(data.overall.net_codes.values()), times_sum)
            data = reader.get_next_sample(False)

    def test_stepper_no_steps(self):
        self.foo.core.set_option('phantom', 'rps_schedule', '')
        self.foo.core.set_option('phantom', 'instances_schedule', '')
        wrapper = StepperWrapper(self.foo)
        wrapper.ammo_file = 'data/dummy.ammo'
        wrapper.prepare_stepper()
        wrapper.prepare_stepper()
        
    def test_phout_import(self):
        self.foo.core.set_option('phantom', 'phout_file', 'data/phout_timeout_mix.txt')
        self.foo.core.set_option('phantom', 'instances', '1')
        self.foo.core.set_option('phantom', 'ammo_count', '1')
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        self.assertEqual(self.foo.is_test_finished(), -1)
        sec = SecondAggregateData()
        sec.overall.RPS = 1
        self.foo.aggregate_second(sec)
        self.assertEqual(self.foo.is_test_finished(), -1)
        self.assertEqual(self.foo.is_test_finished(), 0)
        self.foo.end_test(0)
        self.foo.post_process(0)
示例#7
0
class PhantomPluginTestCase(TankTestCase):
    def setUp(self):
        core = self.get_core()
        core.load_configs(['config/phantom.conf'])
        core.load_plugins()
        core.plugins_configure()
        core.plugins_prepare_test()
        self.foo = PhantomPlugin(core)

    def tearDown(self):
        del self.foo
        self.foo = None
        if os.path.exists("ready_conf_phout.txt"):
            os.remove("ready_conf_phout.txt")

    def test_run(self):
        self.foo.core.set_option(PhantomPlugin.SECTION, "config", '')
        self.foo.configure()
        self.foo.prepare_test()
        reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
        reader.phout_file = self.foo.phantom.phout_file
        self.foo.start_test()

        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            reader.check_open_files()
            reader.get_next_sample(False)
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.foo.end_test(0)
        reader.get_next_sample(True)

    def test_run_ready_conf(self):
        self.foo.core.set_option(PhantomPlugin.SECTION, "config",
                                 'data/phantom_ready.conf')
        self.foo.core.add_artifact_file("ready_conf_phout.txt")
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.assertTrue(os.path.getsize("ready_conf_phout.txt") > 0)
        self.foo.end_test(0)

    def test_run_uri_style(self):
        self.foo.set_option("ammofile", "")
        self.foo.set_option("uris", "/")
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        while self.foo.is_test_finished() < 0:
            self.foo.log.debug("Not finished")
            time.sleep(1)
        if self.foo.is_test_finished() != 0:
            raise RuntimeError("RC: %s" % self.foo.is_test_finished())
        self.foo.end_test(0)

    def test_run_interrupt(self):
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        time.sleep(2)
        self.foo.end_test(0)

    def test_run_stepper_cache(self):
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.prepare_test()

    def test_domain_name(self):
        self.foo.core.set_option('phantom', 'address', 'yandex.ru')
        self.foo.configure()

    def test_domain_name_fail(self):
        self.foo.core.set_option('phantom', 'address', 'ya.ru')
        try:
            self.foo.configure()
            raise RuntimeError()
        except:
            pass

    def test_reader(self):
        self.foo.phantom_start_time = time.time()
        reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
        reader.phout_file = 'data/phout_timeout_mix.txt'
        reader.check_open_files()

        data = reader.get_next_sample(False)
        while data:
            times_sum = 0
            for timing in data.overall.times_dist:
                times_sum += timing['count']
            # FIXME: kinda strange problem here
            #self.assertEquals(sum(data.overall.net_codes.values()), times_sum)
            data = reader.get_next_sample(False)

    def test_stepper_no_steps(self):
        self.foo.core.set_option('phantom', 'rps_schedule', '')
        self.foo.core.set_option('phantom', 'instances_schedule', '')
        wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
        wrapper.ammo_file = 'data/dummy.ammo'
        wrapper.prepare_stepper()
        wrapper.prepare_stepper()

    def test_phout_import(self):
        self.foo.core.set_option('phantom', 'phout_file',
                                 'data/phout_timeout_mix.txt')
        self.foo.core.set_option('phantom', 'instances', '1')
        self.foo.core.set_option('phantom', 'ammo_count', '1')
        self.foo.configure()
        self.foo.prepare_test()
        self.foo.start_test()
        self.assertEqual(self.foo.is_test_finished(), -1)
        sec = SecondAggregateData()
        sec.overall.RPS = 1
        self.foo.aggregate_second(sec)
        self.assertEqual(self.foo.is_test_finished(), -1)
        self.assertEqual(self.foo.is_test_finished(), 0)
        self.foo.end_test(0)
        self.foo.post_process(0)
示例#8
0
class PhantomPluginTestCase(TankTestCase):
    def setUp(self):
        core = self.get_core()
        core.load_configs(['config/phantom.conf'])
        core.load_plugins()
        core.plugins_configure()
        core.plugins_prepare_test()
        self.phantom_plugin_instance = PhantomPlugin(core)
        self.phantom_plugin_instance.core.set_option(
            PhantomPlugin.SECTION, "phantom_path",
            os.path.dirname(__file__) + "/phantom_emul.sh")

    def tearDown(self):
        del self.phantom_plugin_instance
        self.phantom_plugin_instance = None
        if os.path.exists("ready_conf_phout.txt"):
            os.remove("ready_conf_phout.txt")

    def test_run(self):
        self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION,
                                                     "config", '')
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        reader = PhantomReader(
            AggregatorPlugin(self.phantom_plugin_instance.core),
            self.phantom_plugin_instance)
        reader.phout_file = self.phantom_plugin_instance.phantom.phout_file
        self.phantom_plugin_instance.start_test()

        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            reader.check_open_files()
            reader.get_next_sample(False)
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" %
                               self.phantom_plugin_instance.is_test_finished())
        self.phantom_plugin_instance.end_test(0)
        reader.get_next_sample(True)

    def test_run_ready_conf(self):
        self.phantom_plugin_instance.core.set_option(
            PhantomPlugin.SECTION, "config", 'data/phantom_ready.conf')
        self.phantom_plugin_instance.core.add_artifact_file(
            "ready_conf_phout.txt")
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" %
                               self.phantom_plugin_instance.is_test_finished())
        #self.assertTrue(os.path.getsize("ready_conf_phout.txt") > 0)
        self.phantom_plugin_instance.end_test(0)

    def test_run_uri_style(self):
        self.phantom_plugin_instance.set_option("ammofile", "")
        self.phantom_plugin_instance.set_option("uris", "/")
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        while self.phantom_plugin_instance.is_test_finished() < 0:
            self.phantom_plugin_instance.log.debug("Not finished")
            time.sleep(1)
        if self.phantom_plugin_instance.is_test_finished() != 0:
            raise RuntimeError("RC: %s" %
                               self.phantom_plugin_instance.is_test_finished())
        self.phantom_plugin_instance.end_test(0)

    def test_run_interrupt(self):
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        time.sleep(2)
        self.phantom_plugin_instance.end_test(0)

    def test_run_stepper_cache(self):
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.prepare_test()

    def test_domain_name(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     'yandex.ru:443')
        self.phantom_plugin_instance.configure()
        self.assertEqual(443, self.phantom_plugin_instance.get_info().port)
        self.assertEqual("yandex.ru",
                         self.phantom_plugin_instance.get_info().address)

    def test_domain_name_and_port(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     'yandex.ru:80')
        self.phantom_plugin_instance.configure()

    def test_ipv4(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     '127.0.0.1')
        self.phantom_plugin_instance.configure()

    def test_ipv6(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     '2a02:6b8:0:c1f::161:cd')
        self.phantom_plugin_instance.configure()

    def test_ipv4_and_port(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     '127.0.0.1:80')
        self.phantom_plugin_instance.configure()

    def test_domain_name_fail(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'address',
                                                     'ya.ru')
        try:
            self.phantom_plugin_instance.configure()
            raise RuntimeError()
        except:
            pass

    def test_reader(self):
        self.phantom_plugin_instance.phantom_start_time = time.time()
        reader = PhantomReader(
            AggregatorPlugin(self.phantom_plugin_instance.core),
            self.phantom_plugin_instance)
        reader.phout_file = 'data/phout_timeout_mix.txt'
        reader.check_open_files()

        data = reader.get_next_sample(False)
        while data:
            times_sum = 0
            for timing in data.overall.times_dist:
                times_sum += timing['count']
            # FIXME: kinda strange problem here
            #self.assertEquals(sum(data.overall.net_codes.values()), times_sum)
            data = reader.get_next_sample(False)

    def test_stepper_no_steps(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule',
                                                     '')
        self.phantom_plugin_instance.core.set_option('phantom',
                                                     'instances_schedule', '')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.ammo_file = 'data/dummy.ammo'
        wrapper.prepare_stepper()
        wrapper.prepare_stepper()

    def test_stepper_instances_sched(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'instances',
                                                     '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule',
                                                     '')
        self.phantom_plugin_instance.core.set_option('phantom',
                                                     'instances_schedule',
                                                     'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'use_caching',
                                                     '0')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file',
                                                     'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(100, wrapper.instances)

    def test_stepper_instances_override(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'instances',
                                                     '20000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule',
                                                     'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'use_caching',
                                                     '0')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file',
                                                     'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(20000, wrapper.instances)

    def test_cached_stepper_instances_sched(self):
        # Making cache file
        self.phantom_plugin_instance.core.set_option('phantom', 'instances',
                                                     '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule',
                                                     '')
        self.phantom_plugin_instance.core.set_option('phantom',
                                                     'instances_schedule',
                                                     'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file',
                                                     'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.tearDown()

        self.setUp()
        self.phantom_plugin_instance.core.set_option('phantom', 'instances',
                                                     '1000')
        self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule',
                                                     '')
        self.phantom_plugin_instance.core.set_option('phantom',
                                                     'instances_schedule',
                                                     'line(1,100,1m)')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file',
                                                     'data/dummy.ammo')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(100, wrapper.instances)

    def test_phout_import(self):
        self.phantom_plugin_instance.core.set_option(
            'phantom', 'phout_file', 'data/phout_timeout_mix.txt')
        self.phantom_plugin_instance.core.set_option('phantom', 'instances',
                                                     '1')
        self.phantom_plugin_instance.core.set_option('phantom', 'ammo_count',
                                                     '1')
        self.phantom_plugin_instance.configure()
        self.phantom_plugin_instance.prepare_test()
        self.phantom_plugin_instance.start_test()
        self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
        sec = SecondAggregateData()
        sec.overall.rps = 1
        self.phantom_plugin_instance.aggregate_second(sec)
        self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
        self.phantom_plugin_instance.end_test(0)
        self.phantom_plugin_instance.post_process(0)

    def test_cached_stpd_info(self):
        self.phantom_plugin_instance.core.set_option('phantom', 'stpd_file',
                                                     'data/dummy.ammo.stpd')
        wrapper = StepperWrapper(self.phantom_plugin_instance.core,
                                 PhantomPlugin.SECTION)
        wrapper.read_config()
        wrapper.prepare_stepper()
        self.assertEqual(10, wrapper.instances)
        self.assertEqual(60, wrapper.duration)