Exemple #1
0
 def test_repetition_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "scenario": {
             "requests": ["http://blazedemo.com",
                          "http://ya.ru"]}})
     obj.prepare()
     self.assertEqual(len(obj.resource_files()), 0)
     self.assertRaises(ValueError, obj.startup)
Exemple #2
0
 def test_check_install_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": '*',})
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {}})
     try:
         obj.prepare()
     except RuntimeError:
         return
     self.fail()
Exemple #3
0
 def test_url_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {}})
     try:
         obj.prepare()
     except ValueError:
         return
     self.fail()
Exemple #4
0
 def test_check_install_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": '*',
     })
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {}
     })
     try:
         obj.prepare()
     except RuntimeError:
         return
     self.fail()
Exemple #5
0
 def test_url_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {}
     })
     try:
         obj.prepare()
     except ValueError:
         return
     self.fail()
Exemple #6
0
 def test_iter(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "iterations": 3,
         "scenario": {
             "think-time": "1s",
             "requests": ["http://blazedemo.com",
                          "http://ya.ru"]}
     })
     obj.prepare()
     obj.get_widget()
     obj.startup()
Exemple #7
0
 def test_repetition_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "scenario": {
             "requests": ["http://blazedemo.com",
                          "http://ya.ru"]}})
     obj.prepare()
     try:
         obj.startup()
     except ValueError:
         return
     self.fail()
Exemple #8
0
 def test_iter(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "iterations": 3,
         "scenario": {
             "think-time": "1s",
             "requests": ["http://blazedemo.com",
                          "http://ya.ru"]}
     })
     obj.prepare()
     obj.get_widget()
     obj.startup()
Exemple #9
0
 def test_repetition_exceptions(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({
         "concurrency": 2,
         "scenario": {
             "requests": ["http://blazedemo.com", "http://ya.ru"]
         }
     })
     obj.prepare()
     try:
         obj.startup()
     except ValueError:
         return
     self.fail()
Exemple #10
0
 def test_hold(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {
             "headers": {
                 'h1': 'value1',
                 'h2': 'value2'},
             "variables": {
                 'v1': 1,
                 'v2': 'TWO'},
             "script": get_res_path('url-file')}})
     obj.prepare()
     obj.get_widget()
     obj.startup()
Exemple #11
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())
Exemple #12
0
 def test_hold(self):
     obj = SiegeExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "hold-for": '2s',
         "scenario": {
             "headers": {
                 'h1': 'value1',
                 'h2': 'value2'},
             "variables": {
                 'v1': 1,
                 'v2': 'TWO'},
             "script": get_res_path('url-file')}})
     obj.prepare()
     obj.prepare()
     self.assertNotEqual(len(obj.resource_files()), 0)
     obj.get_widget()
     obj.startup()
Exemple #13
0
    def test_full_execution(self):
        obj = SiegeExecutor()
        obj.engine = EngineEmul()
        obj.settings.merge({
            "path": get_res_path(TOOL_NAME),})
        obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "requests": ["http://blazedemo.com",
                             "http://ya.ru"]}
        })
        obj.prepare()
        try:
            obj.startup()
            while not obj.check():
                time.sleep(obj.engine.check_interval)
        finally:
            obj.shutdown()

        obj.post_process()
        self.assertNotEquals(obj.process, None)
Exemple #14
0
    def test_full_execution(self):
        obj = SiegeExecutor()
        obj.engine = EngineEmul()
        obj.settings.merge({
            "path": get_res_path(TOOL_NAME),})
        obj.execution.merge({
            "concurrency": 2,
            "iterations": 3,
            "scenario": {
                "requests": ["http://blazedemo.com",
                             "http://ya.ru"]}
        })
        obj.prepare()
        obj.startup()
        try:
            while not obj.check():
                time.sleep(obj.engine.check_interval)
        finally:
            obj.shutdown()

        obj.post_process()
        self.assertNotEquals(obj.process, None)
Exemple #15
0
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())
Exemple #16
0
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())