mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Add 's3_max_redirects' test
This commit is contained in:
parent
15b5d3a55a
commit
a7d4f4be65
@ -162,9 +162,10 @@ void PocoHTTPClient::makeRequestInternal(
|
|||||||
ProfileEvents::increment(select_metric(S3MetricType::Count));
|
ProfileEvents::increment(select_metric(S3MetricType::Count));
|
||||||
|
|
||||||
unsigned int max_redirect_attempts = global_context.getSettingsRef().s3_max_redirects;
|
unsigned int max_redirect_attempts = global_context.getSettingsRef().s3_max_redirects;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (unsigned int attempt = 0; attempt < max_redirect_attempts; ++attempt)
|
for (unsigned int attempt = 0; attempt <= max_redirect_attempts; ++attempt)
|
||||||
{
|
{
|
||||||
Poco::URI poco_uri(uri);
|
Poco::URI poco_uri(uri);
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
<yandex>
|
||||||
|
<profiles>
|
||||||
|
<default>
|
||||||
|
<s3_max_redirects>0</s3_max_redirects>
|
||||||
|
</default>
|
||||||
|
</profiles>
|
||||||
|
</yandex>
|
@ -85,6 +85,7 @@ def cluster():
|
|||||||
cluster.add_instance("restricted_dummy", main_configs=["configs/config_for_test_remote_host_filter.xml"],
|
cluster.add_instance("restricted_dummy", main_configs=["configs/config_for_test_remote_host_filter.xml"],
|
||||||
with_minio=True)
|
with_minio=True)
|
||||||
cluster.add_instance("dummy", with_minio=True, main_configs=["configs/defaultS3.xml"])
|
cluster.add_instance("dummy", with_minio=True, main_configs=["configs/defaultS3.xml"])
|
||||||
|
cluster.add_instance("s3_max_redirects", with_minio=True, main_configs=["configs/defaultS3.xml"], user_configs=["configs/s3_max_redirects.xml"])
|
||||||
logging.info("Starting cluster...")
|
logging.info("Starting cluster...")
|
||||||
cluster.start()
|
cluster.start()
|
||||||
logging.info("Cluster started")
|
logging.info("Cluster started")
|
||||||
@ -224,6 +225,34 @@ def test_put_get_with_redirect(cluster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Test put and get with S3 server redirect.
|
||||||
|
def test_put_with_zero_redirect(cluster):
|
||||||
|
# type: (ClickHouseCluster) -> None
|
||||||
|
|
||||||
|
bucket = cluster.minio_bucket
|
||||||
|
instance = cluster.instances["s3_max_redirects"] # type: ClickHouseInstance
|
||||||
|
table_format = "column1 UInt32, column2 UInt32, column3 UInt32"
|
||||||
|
values = "(1, 1, 1), (1, 1, 1), (11, 11, 11)"
|
||||||
|
filename = "test.csv"
|
||||||
|
|
||||||
|
# Should work without redirect
|
||||||
|
query = "insert into table function s3('http://{}:{}/{}/{}', 'CSV', '{}') values {}".format(
|
||||||
|
cluster.minio_host, cluster.minio_port, bucket, filename, table_format, values)
|
||||||
|
run_query(instance, query)
|
||||||
|
|
||||||
|
# Should not work with redirect
|
||||||
|
query = "insert into table function s3('http://{}:{}/{}/{}', 'CSV', '{}') values {}".format(
|
||||||
|
cluster.minio_redirect_host, cluster.minio_redirect_port, bucket, filename, table_format, values)
|
||||||
|
exception_raised = False
|
||||||
|
try:
|
||||||
|
run_query(instance, query)
|
||||||
|
except Exception as e:
|
||||||
|
assert str(e).find("Too many redirects while trying to access") != -1
|
||||||
|
exception_raised = True
|
||||||
|
finally:
|
||||||
|
assert exception_raised
|
||||||
|
|
||||||
|
|
||||||
def test_put_get_with_globs(cluster):
|
def test_put_get_with_globs(cluster):
|
||||||
# type: (ClickHouseCluster) -> None
|
# type: (ClickHouseCluster) -> None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user