Skip to content

Commit 897eddd

Browse files
authored
fix ci (#226)
1 parent 30a6d1f commit 897eddd

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
clickhouse:
3+
image: clickhouse/clickhouse-server:latest-alpine
4+
ports:
5+
- 8123:8123
6+
environment:
7+
- CLICKHOUSE_SKIP_USER_SETUP=1
8+
ulimits:
9+
nofile:
10+
soft: 262144
11+
hard: 262144

mix.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ defmodule EctoCh.MixProject do
2222

2323
# Run "mix help compile.app" to learn about applications.
2424
def application do
25-
[
26-
extra_applications: [:logger]
27-
]
25+
[extra_applications: extra_applications(Mix.env())]
2826
end
2927

3028
# Specifies which paths to compile per environment.
@@ -35,6 +33,9 @@ defmodule EctoCh.MixProject do
3533
defp test_paths(nil), do: ["test"]
3634
defp test_paths(_any), do: ["integration_test"]
3735

36+
defp extra_applications(:test), do: [:logger, :inets]
37+
defp extra_applications(_), do: [:logger]
38+
3839
# Run "mix help deps" to learn about dependencies.
3940
defp deps do
4041
[

test/ecto/integration/clickhouse_joins_test.exs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ defmodule Ecto.Integration.ClickHouseJoinsTest do
237237
]
238238
end
239239

240-
# https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00976_asof_join_on.sql
240+
# https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00976_asof_join_on.sql.j2
241241
# https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00976_asof_join_on.reference
242242
test "00976_asof_join_on" do
243243
TestRepo.query!("CREATE TABLE 00976_A(a UInt32, t UInt32) ENGINE = Memory")
@@ -411,8 +411,17 @@ defmodule Ecto.Integration.ClickHouseJoinsTest do
411411
)
412412
end
413413

414+
[[ch_version]] = TestRepo.query!("select version()").rows
415+
416+
expected_error =
417+
if ch_version >= "25.2" do
418+
~r/INVALID_JOIN_ON_EXPRESSION/
419+
else
420+
~r/NOT_IMPLEMENTED/
421+
end
422+
414423
# SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND A.t < B.t OR A.a == B.b + 1 ORDER BY (A.a, A.t); -- { serverError 48 }
415-
assert_raise Ch.Error, ~r/NOT_IMPLEMENTED/, fn ->
424+
assert_raise Ch.Error, expected_error, fn ->
416425
TestRepo.all(
417426
from a in "00976_A",
418427
join: b in "00976_B",

test/test_helper.exs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ Application.put_env(:ecto_ch, TestRepo,
1212
show_sensitive_data_on_connection_error: true
1313
)
1414

15+
clickhouse_available? =
16+
case :httpc.request(:get, {~c"http://localhost:8123/ping", []}, [], []) do
17+
{:ok, {{_version, _status = 200, _reason}, _headers, ~c"Ok.\n"}} ->
18+
true
19+
20+
{:error, {:failed_connect, [{:to_address, _to_address}, {:inet, [:inet], :econnrefused}]}} ->
21+
false
22+
end
23+
24+
unless clickhouse_available? do
25+
Mix.shell().error("""
26+
ClickHouse is not detected! Please start the local container with the following command:
27+
28+
docker compose up -d clickhouse
29+
""")
30+
end
31+
1532
{:ok, _} = Ecto.Adapters.ClickHouse.ensure_all_started(TestRepo.config(), :temporary)
1633

1734
_ = Ecto.Adapters.ClickHouse.storage_down(TestRepo.config())

0 commit comments

Comments
 (0)