mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
add integration test
This commit is contained in:
parent
d9b3a2732b
commit
c8d8f7e59b
@ -0,0 +1,33 @@
|
||||
import http.server
|
||||
import sys
|
||||
|
||||
|
||||
class RequestHandler(http.server.BaseHTTPRequestHandler):
|
||||
def get_response(self):
|
||||
if self.path != "/":
|
||||
return "Wrong Path", 400
|
||||
|
||||
content_type = self.headers.get('Content-Type')
|
||||
if content_type is None:
|
||||
return "No Content-Type", 400
|
||||
|
||||
correct_content_type = self.headers.get('X-Test-Answer')
|
||||
if correct_content_type is None:
|
||||
return "No X-Test-Answer", 400
|
||||
|
||||
if content_type != correct_content_type:
|
||||
return "Wrong Content-Type", 400
|
||||
|
||||
return "OK", 200
|
||||
|
||||
def do_POST(self):
|
||||
response, code = self.get_response()
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
self.send_header("Content-Length", len(response.encode()))
|
||||
self.end_headers()
|
||||
return response, code
|
||||
|
||||
|
||||
httpd = http.server.HTTPServer(("0.0.0.0", int(sys.argv[1])), RequestHandler)
|
||||
httpd.serve_forever()
|
52
tests/integration/test_url_content_type_override/test.py
Normal file
52
tests/integration/test_url_content_type_override/test.py
Normal file
@ -0,0 +1,52 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.mock_servers import start_mock_servers
|
||||
|
||||
SERVER_HOSTNAME = "localhost"
|
||||
SERVER_PORT = 5001
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
|
||||
node = cluster.add_instance("instance")
|
||||
|
||||
|
||||
def start_server():
|
||||
script_dir = os.path.join(os.path.dirname(__file__), "mock_server")
|
||||
start_mock_servers(
|
||||
cluster,
|
||||
script_dir,
|
||||
[
|
||||
(
|
||||
"simple_server.py",
|
||||
SERVER_HOSTNAME,
|
||||
SERVER_PORT,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def start_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
start_server()
|
||||
yield
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
def test_url_content_type_override():
|
||||
assert (
|
||||
"200"
|
||||
== node.query(
|
||||
f"INSERT INTO FUNCTION url('http://{SERVER_HOSTNAME}:{SERVER_PORT}/', JSONEachRow, 'x UInt8', headers('X-Test-Answer' = 'application/x-ndjson; charset=UTF-8')) SELECT 1)"
|
||||
).strip()
|
||||
)
|
||||
|
||||
assert (
|
||||
"200"
|
||||
== node.query(
|
||||
f"INSERT INTO FUNCTION url('http://{SERVER_HOSTNAME}:{SERVER_PORT}/', JSONEachRow, 'x UInt8', headers('Content-Type' = 'upyachka', 'X-Test-Answer' = 'upyachka')) SELECT 1)"
|
||||
).strip()
|
||||
)
|
Loading…
Reference in New Issue
Block a user