提交 07ed4ba4 编写于 作者: Z zhang2014

ISSUES-5436 add integration test for custom http

上级 6b716e51
<yandex>
<http_port>8123</http_port>
<CustomHTTP>
<HTTPMatch>
<URL>/${database}/a/${id}/${table}</URL>
<QUERY>INSERT INTO ${database:ASTIdentifier}.${table:ASTIdentifier}(id) VALUES</QUERY>
<QUERY>SELECT * FROM ${database:ASTIdenfier}.t</QUERY>
<QUERY>SELECT * FROM a.${table:ASTIdenfier} WHERE id={id:UInt8}</QUERY>
</HTTPMatch>
</CustomHTTP>
</yandex>
<yandex>
<http_port>8123</http_port>
<custom_http>
<test_for_single_insert>
<URL>/test_for_single_insert</URL>
<query>INSERT INTO test.test VALUES</query>
</test_for_single_insert>
<test_for_single_select>
<URL>/test_for_single_select</URL>
<query>SELECT * FROM test.test ORDER BY id</query>
</test_for_single_select>
<test_for_multiple_select>
<URL>/test_for_multiple_select</URL>
<query>SELECT * FROM test.test ORDER BY id</query>
<query>SELECT * FROM test.test ORDER BY id</query>
</test_for_multiple_select>
<test_for_hybrid_insert_and_select_with_one_insert>
<URL>/test_for_multiple_select</URL>
<query>INSERT INTO test.test VALUES</query>
<query>SELECT 'test_for_hybrid_insert_and_select_with_one_insert first'</query>
<query>SELECT 'test_for_hybrid_insert_and_select_with_one_insert second'</query>
</test_for_hybrid_insert_and_select_with_one_insert>
<!-- ErrorCode test
<test_for_hybrid_insert_and_select_with_multiple_insert>
</test_for_hybrid_insert_and_select_with_multiple_insert>
<test_for_multiple_insert>
<URL>/test_for_multiple_insert</URL>
<query>SELECT * FROM test.test ORDER BY id</query>
</test_for_multiple_insert>
-->
<test_for_url_match>
<URL>/test_for_url_match</URL>
<query>SELECT 'Matched test_for_url_match'</query>
</test_for_url_match>
<test_for_method_match>
<URL>PUT</URL>
<query>SELECT 'Matched test_for_method_match'</query>
</test_for_method_match>
<test_for_multiple_match>
<URL>/test_for_multiple_match</URL>
<method>GET</method>
<query>SELECT 'Matched test_for_multiple_match'</query>
</test_for_multiple_match>
</custom_http>
</yandex>
import pytest
import requests
from helpers.cluster import ClickHouseCluster
from helpers.test_tools import assert_eq_with_retry
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance('node', main_configs=['configs/custom_http.xml'])
test_instance = cluster.add_instance('node', main_configs=['configs/custom_http_config.xml'])
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
node.query('''
CREATE DATABASE `test`;
CREATE TABLE `test`.`test_custom_http` (`id` UInt8) Engine=Memory;
''')
test_instance.query('CREATE DATABASE `test`')
test_instance.query('CREATE TABLE `test`.`test` (`id` UInt8) Engine = Memory')
yield cluster
finally:
cluster.shutdown()
def test(started_cluster):
node_ip = cluster.get_instance_ip(node)
url = 'http://%s:8123/test/a/1/test_custom_http' % node_ip
data="(1)"
params = {'id':1}
response = requests.post(url, params = params, data = data)
assert response.text == '\n1\n1\n'
def test_for_single_insert(started_cluster):
assert test_instance.http_query('/test_for_single_insert', data='(1)(2)(3)') == '\n'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册