def test_anonymous_proxy_no_connection(cfg, http_proxy, fresh_log_file): env = dict(os.environ) env["http_proxy"] = http_proxy.anonymous_url assert process.run_subprocess_with_logging(it.esrally_command_line_for(cfg, "list tracks"), env=env) == 0 assert_log_line_present(fresh_log_file, f"Connecting via proxy URL [{http_proxy.anonymous_url}] to the Internet") # unauthenticated proxy access is prevented assert_log_line_present(fresh_log_file, "No Internet connection detected")
def test_authenticated_proxy_user_can_connect(cfg, http_proxy, fresh_log_file): env = dict(os.environ) env["http_proxy"] = http_proxy.authenticated_url assert process.run_subprocess_with_logging(it.esrally_command_line_for(cfg, "list tracks"), env=env) == 0 assert_log_line_present(fresh_log_file, f"Connecting via proxy URL [{http_proxy.authenticated_url}] to the Internet") # authenticated proxy access is allowed assert_log_line_present(fresh_log_file, "Detected a working Internet connection")
def test_interrupt(cfg): port = 19200 dist = it.DISTRIBUTIONS[-1] # simulate a user cancelling a benchmark cmd = it.esrally_command_line_for( cfg, f'race --distribution-version="{dist}" --track="geonames" ' f"--kill-running-processes --target-hosts=127.0.0.1:{port} --test-mode " f"--car=4gheap,basic-license", ) assert run_subprocess_and_interrupt(cmd, 2, 15) == 130
def test_track_info_fails_with_wrong_track_params(cfg): # simulate a typo in track parameter cmd = it.esrally_command_line_for( cfg, "info --track=geonames --track-params='conflict_probability:5,number-of-replicas:1'" ) output = process.run_subprocess_with_output(cmd) expected = "Some of your track parameter(s) \"number-of-replicas\" are not used by this track; " \ "perhaps you intend to use \"number_of_replicas\" instead.\n\nAll track parameters you " \ "provided are:\n- conflict_probability\n- number-of-replicas\n\nAll parameters exposed by this track" assert expected in "\n".join(output)
def test_run_without_http_connection(cfg): cmd = it.esrally_command_line_for(cfg, "list races") output = process.run_subprocess_with_output(cmd, {"http_proxy": "http://invalid"}) expected = "No Internet connection detected. Specify --offline" assert expected in "\n".join(output)
def test_run_with_help(cfg): cmd = it.esrally_command_line_for(cfg, "--help") output = process.run_subprocess_with_output(cmd) expected = "usage: esrally [-h] [--version]" assert expected in "\n".join(output)