Exemplo n.º 1
0
def get_ab():
    path = os.path.abspath(RESOURCES_DIR + "ab/ab" + EXE_SUFFIX)
    obj = ApacheBenchmarkExecutor()
    obj.engine = EngineEmul()
    obj.env = obj.engine.env
    obj.settings.merge({"path": path})
    return obj
Exemplo n.º 2
0
 def test_full_execution(self):
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "iterations": 3,
         "headers": {
             "Content-Type": "text/plain"
         },
         "scenario": {
             "keepalive": True,
             "requests": [
                 {
                     "url": "http://blazedemo.com",
                     "headers": [
                         {"X-Answer": "42"},
                     ],
                     "keepalive": False,
                     "method": "GET",
                 }
             ],
         }
     })
     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)
Exemplo n.º 3
0
 def test_full_execution(self):
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "concurrency": 2,
         "iterations": 3,
         "headers": {
             "Content-Type": "text/plain"
         },
         "scenario": {
             "keepalive": True,
             "requests": [
                 {
                     "url": "http://blazedemo.com",
                     "headers": [
                         {"X-Answer": "42"},
                     ],
                     "keepalive": False,
                     "method": "GET",
                 }
             ],
         }
     })
     obj.prepare()
     obj.get_widget()
     try:
         obj.startup()
         while not obj.check():
             time.sleep(obj.engine.check_interval)
     finally:
         obj.shutdown()
     obj.post_process()
     self.assertNotEquals(obj.process, None)
Exemplo n.º 4
0
def get_ab():
    path = os.path.abspath(RESOURCES_DIR + "ab/ab" + EXE_SUFFIX)
    obj = ApacheBenchmarkExecutor()
    obj.engine = EngineEmul()
    obj.env = obj.engine.env
    obj.settings.merge({"path": path})
    return obj
Exemplo n.º 5
0
 def test_no_request_exception(self):
     "Checks that executor.startup fails if there's no request specified."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({"scenario": {}})
     obj.prepare()
     self.assertRaises(TaurusConfigError, obj.startup)
Exemplo n.º 6
0
 def test_no_request_exception(self):
     "Checks that executor.startup fails if there's no request specified."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "scenario": {}})
     obj.prepare()
     self.assertRaises(ValueError, obj.startup)
Exemplo n.º 7
0
 def test_no_apache_benchmark(self):
     "Checks that prepare() fails if ApacheBenchmark is not installed."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": '*',})
     obj.execution.merge({
         "scenario": {
             "requests": ["http://blazedemo.com"]
         }})
     self.assertRaises(RuntimeError, obj.prepare)
Exemplo n.º 8
0
 def test_no_apache_benchmark(self):
     "Checks that prepare() fails if ApacheBenchmark is not installed."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": '*',})
     obj.execution.merge({
         "scenario": {
             "requests": ["http://blazedemo.com"]
         }})
     self.assertRaises(RuntimeError, obj.prepare)
Exemplo n.º 9
0
 def test_non_get_request_exception(self):
     """
     Checks that executor.startup fails if
     request with non-GET method is specified.
     """
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({
         "scenario": {
             "requests": [{
                 "url": "http://blazedemo.com",
                 "method": "POST",
             }]
         }
     })
     obj.prepare()
     self.assertRaises(TaurusConfigError, obj.startup)
Exemplo n.º 10
0
 def test_non_get_request_exception(self):
     """
     Checks that executor.startup fails if
     request with non-GET method is specified.
     """
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "scenario": {
             "requests": [
                 {
                     "url": "http://blazedemo.com",
                     "method": "POST",
                 }
             ]
         }})
     obj.prepare()
     self.assertRaises(ValueError, obj.startup)
Exemplo n.º 11
0
 def test_iter(self):
     "Ensures that executor doesn't fail with minimal configuration."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),})
     obj.execution.merge({
         "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.assertNotEquals(obj.process, None)
Exemplo n.º 12
0
 def test_diagnostics(self):
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge({
         "concurrency": 1,
         "iterations": 1,
         "scenario": {
             "requests": ["http://blazedemo.com"]
         }
     })
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(obj.engine.check_interval)
     obj.shutdown()
     obj.post_process()
     self.assertIsNotNone(obj.get_error_diagnostics())
Exemplo n.º 13
0
 def test_iter(self):
     "Ensures that executor doesn't fail with minimal configuration."
     obj = ApacheBenchmarkExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({
         "path": get_res_path(TOOL_NAME),
     })
     obj.execution.merge(
         {"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.assertNotEquals(obj.process, None)