mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
change integration to functional test
This commit is contained in:
parent
54af5c7ba7
commit
c8d3de8d9f
@ -1,50 +0,0 @@
|
|||||||
import http.server
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
class RequestHandler(http.server.BaseHTTPRequestHandler):
|
|
||||||
def get_response(self):
|
|
||||||
if self.path == "/":
|
|
||||||
return "OK", 200
|
|
||||||
|
|
||||||
# Resource not found.
|
|
||||||
return 404
|
|
||||||
|
|
||||||
def check_request(self):
|
|
||||||
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 self.get_response()
|
|
||||||
|
|
||||||
def do_POST(self):
|
|
||||||
response, code = self.check_request()
|
|
||||||
|
|
||||||
self.send_response(code)
|
|
||||||
self.send_header("Content-Type", "text/plain")
|
|
||||||
self.send_header("Content-Length", len(response.encode()))
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(response.encode())
|
|
||||||
|
|
||||||
def do_HEAD(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
|
|
||||||
|
|
||||||
def do_GET(self):
|
|
||||||
response, _ = self.do_HEAD()
|
|
||||||
self.wfile.write(response.encode())
|
|
||||||
|
|
||||||
|
|
||||||
httpd = http.server.HTTPServer(("0.0.0.0", int(sys.argv[1])), RequestHandler)
|
|
||||||
httpd.serve_forever()
|
|
@ -1,54 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from helpers.cluster import ClickHouseCluster
|
|
||||||
from helpers.mock_servers import start_mock_servers
|
|
||||||
|
|
||||||
SERVER_HOSTNAME = "resolver"
|
|
||||||
SERVER_PORT = 8080
|
|
||||||
|
|
||||||
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()
|
|
||||||
)
|
|
@ -0,0 +1,2 @@
|
|||||||
|
Content-Type: application/x-ndjson; charset=UTF-8
|
||||||
|
Content-Type: upyachka
|
25
tests/queries/0_stateless/03254_url_override_content_type.sh
Executable file
25
tests/queries/0_stateless/03254_url_override_content_type.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Tags: no-parallel
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
nc -l -p 61845 -q 0 > response.txt &
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT --query "INSERT INTO FUNCTION url('http://localhost:61845/', JSONEachRow, 'x UInt8') SELECT 1" > /dev/null 2>&1
|
||||||
|
|
||||||
|
( echo -e "Finish him\n" | nc localhost 61845 ) 2>/dev/null || true
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
grep "Content-Type" response.txt
|
||||||
|
|
||||||
|
nc -l -p 61846 -q 0 > response.txt &
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT --query "INSERT INTO FUNCTION url('http://localhost:61846/', JSONEachRow, 'x UInt8', headers('Content-Type' = 'upyachka')) SELECT 1" > /dev/null 2>&1
|
||||||
|
|
||||||
|
( echo -e "Finish him\n" | nc localhost 61846 ) 2>/dev/null || true
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
grep "Content-Type" response.txt
|
Loading…
Reference in New Issue
Block a user