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
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)
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)
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)
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)
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)
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)
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)
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)
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())
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)