コード例 #1
0
ファイル: PhantomPluginTest.py プロジェクト: wd5/yandex-tank
 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)
コード例 #2
0
class UniversalPhoutShooterPlugin(AbstractPlugin, AggregateResultListener):
    '''     Plugin for running any script tool    '''

    OPTION_CONFIG = "config"
    SECTION = 'uniphout'

    def __init__(self, core):
        AbstractPlugin.__init__(self, core)
        self.buffered_seconds = 2
        self.process = None
        self.process_stderr = None
        self.process_start_time = None

    @staticmethod
    def get_key():
        return __file__

    def get_available_options(self):
        opts = [
            "cmdline",
            "buffered_seconds",
        ]
        return opts

    def configure(self):
        # plugin part
        self.cmdline = self.get_option("cmdline")
        self.buffered_seconds = int(
            self.get_option("buffered_seconds", self.buffered_seconds))

        self.phout = self.get_option("phout", "")
        if not self.phout:
            self.phout = self.core.mkstemp(".phout", "results_")
            # TODO: pass generated phout to the script

        self.core.add_artifact_file(self.phout)

    def prepare_test(self):
        aggregator = None
        try:
            aggregator = self.core.get_plugin_of_type(AggregatorPlugin)
        except Exception, ex:
            self.log.warning("No aggregator found: %s", ex)

        if aggregator:
            aggregator.reader = PhantomReader(aggregator, self)
            aggregator.reader.buffered_seconds = self.buffered_seconds
            aggregator.add_result_listener(self)
            aggregator.reader.phout_file = self.phout

        try:
            console = self.core.get_plugin_of_type(ConsoleOnlinePlugin)
        except Exception, ex:
            self.log.debug("Console not found: %s", ex)
            console = None
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
    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)