コード例 #1
0
 def test_diagnostics(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({
         "iterations": 1,
         "scenario": {
             "requests": ["http://blazedemo.com"]
         }
     })
     obj.prepare()
     try:
         obj.startup()
         while not obj.check():
             time.sleep(obj.engine.check_interval)
     finally:
         obj.shutdown()
     obj.post_process()
     self.assertIsNotNone(obj.get_error_diagnostics())
コード例 #2
0
ファイル: test_Siege.py プロジェクト: ipaste/taurus
class TestSiegeExecutor(BZTestCase):
    def setUp(self):
        super(TestSiegeExecutor, self).setUp()
        self.obj = SiegeExecutor()
        self.obj.engine = EngineEmul()
        self.obj.engine.aggregator = ConsolidatingAggregator()
        self.obj.settings.merge({"path": TOOL_PATH})

    def tearDown(self):
        if self.obj.stdout_file:
            self.obj.stdout_file.close()
        if self.obj.stderr_file:
            self.obj.stderr_file.close()
        close_reader_file(self.obj.reader)
        super(TestSiegeExecutor, self).tearDown()

    def test_iter(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "think-time": "1s",
                "requests": ["http://blazedemo.com", "http://ya.ru"]
            }
        })
        self.obj.prepare()
        self.obj.get_widget()
        self.obj.startup()

    def test_hold(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {
                "headers": {
                    'h1': 'value1',
                    'h2': 'value2'
                },
                "variables": {
                    'v1': 1,
                    'v2': 'TWO'
                },
                "script": join(RESOURCES_DIR, "siege", "url-file")
            }
        })
        self.obj.prepare()
        self.assertNotEqual(len(self.obj.resource_files()), 0)
        self.obj.get_widget()
        self.obj.startup()

    def test_url_exceptions(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {}
        })
        self.assertRaises(TaurusConfigError, self.obj.prepare)

    def test_check_install_exceptions(self):
        self.obj.settings.merge({"path": '*'})
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {}
        })
        self.assertRaises(ToolError, self.obj.prepare)

    def test_repetition_exceptions(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "scenario": {
                "requests": ["http://blazedemo.com", "http://ya.ru"]
            }
        })
        self.obj.prepare()
        self.assertEqual(len(self.obj.resource_files()), 0)
        self.assertRaises(TaurusConfigError, self.obj.startup)

    def test_full_execution(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "requests": ["http://blazedemo.com", "http://ya.ru"]
            }
        })
        self.obj.prepare()
        try:
            self.obj.startup()
            self.obj.engine.aggregator.check()
            while not self.obj.check():
                time.sleep(self.obj.engine.check_interval)
        finally:
            self.obj.shutdown()

        self.obj.post_process()
        self.assertNotEquals(self.obj.process, None)

    def test_diagnostics(self):
        self.obj.execution.merge({
            "iterations": 1,
            "scenario": {
                "requests": ["http://blazedemo.com"]
            }
        })
        self.obj.prepare()
        try:
            self.obj.startup()
            while not self.obj.check():
                time.sleep(self.obj.engine.check_interval)
        finally:
            self.obj.shutdown()
        self.obj.post_process()
        self.assertIsNotNone(self.obj.get_error_diagnostics())
コード例 #3
0
ファイル: test_Siege.py プロジェクト: keithmork/taurus
class TestSiegeExecutor(BZTestCase):
    def setUp(self):
        super(TestSiegeExecutor, self).setUp()
        self.obj = SiegeExecutor()
        self.obj.engine = EngineEmul()
        self.obj.env = self.obj.engine.env
        self.obj.engine.aggregator = ConsolidatingAggregator()
        self.obj.settings.merge({"path": TOOL_PATH})

    def tearDown(self):
        if self.obj.stdout_file:
            self.obj.stdout_file.close()
        if self.obj.stderr_file:
            self.obj.stderr_file.close()
        close_reader_file(self.obj.reader)
        super(TestSiegeExecutor, self).tearDown()

    def test_iter(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "think-time": "1s",
                "requests": [
                    "http://blazedemo.com",
                    "http://ya.ru"]}})
        self.obj.prepare()
        self.obj.get_widget()
        self.obj.startup()

    def test_hold(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {
                "headers": {
                    'h1': 'value1',
                    'h2': 'value2'},
                "variables": {
                    'v1': 1,
                    'v2': 'TWO'},
                "script": join(RESOURCES_DIR, "siege", "url-file")}})
        self.obj.prepare()
        self.assertNotEqual(len(self.obj.resource_files()), 0)
        self.obj.get_widget()
        self.obj.startup()

    def test_url_exceptions(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {}})
        self.assertRaises(TaurusConfigError, self.obj.prepare)

    def test_check_install_exceptions(self):
        self.obj.settings.merge({"path": '*'})
        self.obj.execution.merge({
            "concurrency": 2,
            "hold-for": '2s',
            "scenario": {}})
        self.assertRaises(ToolError, self.obj.prepare)

    def test_repetition_exceptions(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "scenario": {
                "requests": [
                    "http://blazedemo.com",
                    "http://ya.ru"]}})
        self.obj.prepare()
        self.assertEqual(len(self.obj.resource_files()), 0)
        self.assertRaises(TaurusConfigError, self.obj.startup)

    def test_full_execution(self):
        self.obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "requests": [
                    "http://blazedemo.com",
                    "http://ya.ru"]}})
        self.obj.prepare()
        try:
            self.obj.startup()
            self.obj.engine.aggregator.check()
            while not self.obj.check():
                time.sleep(self.obj.engine.check_interval)
        finally:
            self.obj.shutdown()

        self.obj.post_process()
        self.assertNotEquals(self.obj.process, None)

    def test_diagnostics(self):
        self.obj.execution.merge({
            "iterations": 1,
            "scenario": {
                "requests": [
                    "http://blazedemo.com"]}})
        self.obj.prepare()
        try:
            self.obj.startup()
            while not self.obj.check():
                time.sleep(self.obj.engine.check_interval)
        finally:
            self.obj.shutdown()
        self.obj.post_process()
        self.assertIsNotNone(self.obj.get_error_diagnostics())