Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 59 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ jobs:
elixir-version: 1.20.x
- name: Retrieve dependencies cache
uses: actions/cache@v4
id: mix-cache # id to use in retrieve action
id: mix-deps-cache
with:
path: deps
key: >-
v1-${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{
hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: v2-28.x-1.20.x-deps-${{ hashFiles('mix.lock') }}
- name: Install Dependencies
run: mix deps.get 1>/dev/null
- name: Check format
Expand All @@ -51,12 +49,26 @@ jobs:
elixir-version: ${{matrix.elixir}}
- name: Retrieve dependencies cache
uses: actions/cache@v4
id: mix-cache # id to use in retrieve action
id: mix-deps-cache
with:
path: deps
path: |
grpc/deps
grpc_core/deps
grpc_server/deps
key: >-
v2-${{ matrix.otp }}-${{ matrix.elixir }}-deps-${{
hashFiles('grpc/mix.lock', 'grpc_core/mix.lock', 'grpc_server/mix.lock') }}
- name: Retrieve build cache
uses: actions/cache@v4
id: mix-build-cache
with:
path: |
grpc/_build
grpc_core/_build
grpc_server/_build
key: >-
v1-${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{
hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
v2-${{ matrix.otp }}-${{ matrix.elixir }}-build-${{
hashFiles('grpc/mix.lock', 'grpc_core/mix.lock', 'grpc_server/mix.lock') }}
- name: Install Dependencies
run: mix setup 1>/dev/null
- name: Compile with warnings as errors
Expand All @@ -65,11 +77,27 @@ jobs:
run: mix test --warnings-as-errors
- name: Run Warning Tests
run: mix test --only warning_test
- name: Retrieve mint install cache
uses: actions/cache@v4
id: mix-mint-cache
with:
path: ${{ runner.temp }}/mix-install-mint
key: >-
v2-${{ matrix.otp }}-${{ matrix.elixir }}-adapter-mint-${{
hashFiles('grpc/mix.lock', 'grpc_core/mix.lock', 'grpc_server/mix.lock') }}
- name: Run :mint optional dependency test
run: elixir script/adapter_test.exs mint
run: MIX_INSTALL_DIR="${{ runner.temp }}/mix-install-mint" elixir script/adapter_test.exs mint
working-directory: ./grpc
- name: Retrieve gun install cache
uses: actions/cache@v4
id: mix-gun-cache
with:
path: ${{ runner.temp }}/mix-install-gun
key: >-
v2-${{ matrix.otp }}-${{ matrix.elixir }}-adapter-gun-${{
hashFiles('grpc/mix.lock', 'grpc_core/mix.lock', 'grpc_server/mix.lock') }}
- name: Run :gun optional dependency test
run: elixir script/adapter_test.exs gun
run: MIX_INSTALL_DIR="${{ runner.temp }}/mix-install-gun" elixir script/adapter_test.exs gun
working-directory: ./grpc
interop-tests:
runs-on: ubuntu-latest
Expand All @@ -84,12 +112,16 @@ jobs:
elixir-version: 1.20.x
- name: Retrieve dependencies cache
uses: actions/cache@v4
id: mix-cache # id to use in retrieve action
id: mix-deps-cache
with:
path: deps
key: >-
v1-${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{
hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
path: interop/deps
key: v2-28.x-1.20.x-interop-deps-${{ hashFiles('interop/mix.lock') }}
- name: Retrieve build cache
uses: actions/cache@v4
id: mix-build-cache
with:
path: interop/_build
key: v2-28.x-1.20.x-interop-build-${{ hashFiles('interop/mix.lock') }}
- name: Install Dependencies
run: mix deps.get 1>/dev/null
working-directory: ./interop
Expand Down Expand Up @@ -118,12 +150,20 @@ jobs:
elixir-version: ${{ matrix.elixir }}
- name: Retrieve dependencies cache
uses: actions/cache@v4
id: mix-cache # id to use in retrieve action
id: mix-deps-cache
with:
path: deps
path: interop/deps
key: >-
v2-${{ matrix.otp }}-${{ matrix.elixir }}-interop-deps-${{
hashFiles('interop/mix.lock') }}
- name: Retrieve build cache
uses: actions/cache@v4
id: mix-build-cache
with:
path: interop/_build
key: >-
v1-${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{
hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
v2-${{ matrix.otp }}-${{ matrix.elixir }}-interop-build-${{
hashFiles('interop/mix.lock') }}
- name: Install Dependencies
run: mix deps.get 1>/dev/null
working-directory: ./interop
Expand Down
4 changes: 2 additions & 2 deletions grpc/test/grpc/adapters/mint/connection_process_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ defmodule GRPC.Client.Adapters.Mint.ConnectionProcessTest do
assert {:noreply, _new_state} =
ConnectionProcess.handle_continue(:process_request_stream_queue, state)

refute_receive {:tag, :ok}, 500
refute_received {:tag, :ok}
end

test "(window_size >= body_size) stream body, send end_stream message and check request_queue when queue is not empty",
Expand Down Expand Up @@ -435,7 +435,7 @@ defmodule GRPC.Client.Adapters.Mint.ConnectionProcessTest do
assert {:noreply, new_state} = ConnectionProcess.handle_info(tcp_message, state)
assert new_state.conn.state != :closed
assert new_state.retry_attempt == 0
refute_receive {:elixir_grpc, :connection_down, _pid}, 200
refute_received {:elixir_grpc, :connection_down, _pid}
end
end

Expand Down
19 changes: 13 additions & 6 deletions grpc/test/grpc/adapters/mint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ defmodule GRPC.Client.Adapters.MintTest do
channel = build(:channel, adapter: Mint, port: port, host: "localhost")

assert {:ok, result} = Mint.connect(channel, [])
# wait for settings to be pushed
Process.sleep(50)
state = :sys.get_state(result.adapter_payload.conn_pid)

# Mint mirrors advertised client_settings onto conn at connect time.
assert state.connect_opts[:client_settings] == [
initial_window_size: 8_000_000,
max_frame_size: 8_000_000
]

assert %{initial_window_size: 8_000_000, max_frame_size: 8_000_000} =
Map.get(state.conn, :client_settings)
Map.take(state.conn.client_settings, [:initial_window_size, :max_frame_size])
end

test "allow client settings to be passed", %{port: port} do
Expand All @@ -71,12 +75,15 @@ defmodule GRPC.Client.Adapters.MintTest do
]
)

# wait for settings to be pushed
Process.sleep(50)
state = :sys.get_state(result.adapter_payload.conn_pid)

assert state.connect_opts[:client_settings] == [
initial_window_size: 50_000,
max_frame_size: 50_000
]

assert %{initial_window_size: 50_000, max_frame_size: 50_000} =
Map.get(state.conn, :client_settings)
Map.take(state.conn.client_settings, [:initial_window_size, :max_frame_size])
end
end

Expand Down
5 changes: 3 additions & 2 deletions grpc/test/grpc/client/connection_supervised_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ defmodule GRPC.Client.ConnectionSupervisedTest do
caller = self()

for _ <- 1..5 do
assert {:error, :timeout} = Connection.await_ready(name, 50)
assert {:error, :timeout} = Connection.await_ready(name, 10)
end

# Five starts prove the connection registered every call; each re-entry
Expand Down Expand Up @@ -286,7 +286,8 @@ defmodule GRPC.Client.ConnectionSupervisedTest do

other = spawn(fn -> :ok end)
send(conn, {:EXIT, other, :some_crash})
refute_receive {:resolver_init, _}, 200
:sys.get_state(conn)
refute_received {:resolver_init, _}

Process.exit(worker, :kill)
assert_receive {:resolver_init, _new_worker}, 1_000
Expand Down
9 changes: 5 additions & 4 deletions grpc/test/grpc/client/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,19 @@ defmodule GRPC.Client.ConnectionTest do
assert %{active: ^supervisor_children} =
DynamicSupervisor.count_children(GRPC.Client.Supervisor)

assert after_memory <= before_memory + 100_000,
# Residual heap after one GC is typically tens of KB; real header leaks are MBs.
assert after_memory <= before_memory + 250_000,
"supervisor memory grew: before=#{before_memory} after=#{after_memory}"
end

test "500 cycles leave persistent_term clean and no per-LB tables leak", %{
test "100 cycles leave persistent_term clean and no per-LB tables leak", %{
target: target,
adapter: adapter
} do
before_table_count = length(:ets.all())
before_pt_count = connection_pt_count()

for _ <- 1..500 do
for _ <- 1..100 do
ref = make_ref()
{:ok, channel} = Connection.connect(target, adapter: adapter, name: ref)
{:ok, _} = Connection.disconnect(channel)
Expand Down Expand Up @@ -347,7 +348,7 @@ defmodule GRPC.Client.ConnectionTest do
)

assert_receive :interceptor_init
refute_receive :interceptor_init, 100
refute_received :interceptor_init

Connection.disconnect(channel)
end
Expand Down
Loading
Loading