Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport #51934 to 23.4: Fix async connect to hosts with multiple ips
- Loading branch information
1 parent
2ca98e1
commit 78148fd
Showing
8 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
7 changes: 7 additions & 0 deletions
7
tests/integration/test_async_connect_to_multiple_ips/configs/enable_hedged.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<clickhouse> | ||
<profiles> | ||
<default> | ||
<use_hedged_requests>1</use_hedged_requests> | ||
</default> | ||
</profiles> | ||
</clickhouse> |
4 changes: 4 additions & 0 deletions
4
tests/integration/test_async_connect_to_multiple_ips/configs/listen_host.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<clickhouse> | ||
<listen_host>::</listen_host> | ||
</clickhouse> | ||
|
72 changes: 72 additions & 0 deletions
72
tests/integration/test_async_connect_to_multiple_ips/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import pytest | ||
from helpers.cluster import ClickHouseCluster | ||
|
||
|
||
cluster = ClickHouseCluster(__file__) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def cluster_without_dns_cache_update(): | ||
try: | ||
cluster.start() | ||
|
||
yield cluster | ||
|
||
except Exception as ex: | ||
print(ex) | ||
|
||
finally: | ||
cluster.shutdown() | ||
pass | ||
|
||
|
||
node1 = cluster.add_instance( | ||
"node1", | ||
main_configs=["configs/listen_host.xml"], | ||
user_configs=["configs/enable_hedged.xml"], | ||
with_zookeeper=True, | ||
ipv4_address="10.5.95.11", | ||
) | ||
|
||
node2 = cluster.add_instance( | ||
"node2", | ||
main_configs=["configs/listen_host.xml"], | ||
user_configs=["configs/enable_hedged.xml"], | ||
with_zookeeper=True, | ||
ipv4_address="10.5.95.12", | ||
) | ||
|
||
|
||
# node1 - source with table, have invalid ipv6 | ||
# node2 - destination, doing remote query | ||
def test(cluster_without_dns_cache_update): | ||
node1.query( | ||
"CREATE TABLE test(t Date, label UInt8) ENGINE = MergeTree PARTITION BY t ORDER BY label;" | ||
) | ||
node1.query("INSERT INTO test SELECT toDate('2022-12-28'), 1;") | ||
assert node1.query("SELECT count(*) FROM test") == "1\n" | ||
|
||
wrong_ip = "2001:3984:3989::1:1118" | ||
|
||
node2.exec_in_container( | ||
(["bash", "-c", "echo '{} {}' >> /etc/hosts".format(wrong_ip, node1.name)]) | ||
) | ||
node2.exec_in_container( | ||
( | ||
[ | ||
"bash", | ||
"-c", | ||
"echo '{} {}' >> /etc/hosts".format(node1.ipv4_address, node1.name), | ||
] | ||
) | ||
) | ||
|
||
assert node1.query("SELECT count(*) from test") == "1\n" | ||
node2.query("SYSTEM DROP DNS CACHE") | ||
node1.query("SYSTEM DROP DNS CACHE") | ||
assert ( | ||
node2.query( | ||
f"SELECT count(*) FROM remote('{node1.name}', default.test) limit 1;" | ||
) | ||
== "1\n" | ||
) |