Stabilize test harness and node sync e2e
This commit is contained in:
@@ -146,7 +146,7 @@ start_node() {
|
|||||||
PARRHESIA_IDENTITY_PATH="$identity_path" \
|
PARRHESIA_IDENTITY_PATH="$identity_path" \
|
||||||
PARRHESIA_SYNC_PATH="$sync_path" \
|
PARRHESIA_SYNC_PATH="$sync_path" \
|
||||||
MIX_ENV=prod \
|
MIX_ENV=prod \
|
||||||
mix run --no-halt >"$log_path" 2>&1 &
|
mix run --no-compile --no-halt >"$log_path" 2>&1 &
|
||||||
|
|
||||||
if [[ "$node_name" == "a" ]]; then
|
if [[ "$node_name" == "a" ]]; then
|
||||||
NODE_A_PID=$!
|
NODE_A_PID=$!
|
||||||
|
|||||||
@@ -60,12 +60,15 @@ defmodule Parrhesia.Web.TLSE2ETest do
|
|||||||
}}
|
}}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_eventually(fn ->
|
assert_eventually(
|
||||||
case nip11_request(port, ca.certfile) do
|
fn ->
|
||||||
{:ok, 200} -> true
|
case nip11_request(port, ca.certfile) do
|
||||||
_other -> false
|
{:ok, 200} -> true
|
||||||
end
|
_other -> false
|
||||||
end)
|
end
|
||||||
|
end,
|
||||||
|
5_000
|
||||||
|
)
|
||||||
|
|
||||||
first_fingerprint = server_cert_fingerprint(port)
|
first_fingerprint = server_cert_fingerprint(port)
|
||||||
assert first_fingerprint == TLSCerts.cert_sha256!(server_a.certfile)
|
assert first_fingerprint == TLSCerts.cert_sha256!(server_a.certfile)
|
||||||
@@ -75,9 +78,12 @@ defmodule Parrhesia.Web.TLSE2ETest do
|
|||||||
|
|
||||||
assert :ok = Endpoint.reload_listener(endpoint_name, listener_id)
|
assert :ok = Endpoint.reload_listener(endpoint_name, listener_id)
|
||||||
|
|
||||||
assert_eventually(fn ->
|
assert_eventually(
|
||||||
server_cert_fingerprint(port) == TLSCerts.cert_sha256!(server_b.certfile)
|
fn ->
|
||||||
end)
|
server_cert_fingerprint(port) == TLSCerts.cert_sha256!(server_b.certfile)
|
||||||
|
end,
|
||||||
|
10_000
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "mutual TLS requires a client certificate and enforces optional client pins", %{
|
test "mutual TLS requires a client certificate and enforces optional client pins", %{
|
||||||
@@ -327,17 +333,24 @@ defmodule Parrhesia.Web.TLSE2ETest do
|
|||||||
:"#{prefix}_#{System.unique_integer([:positive, :monotonic])}"
|
:"#{prefix}_#{System.unique_integer([:positive, :monotonic])}"
|
||||||
end
|
end
|
||||||
|
|
||||||
defp assert_eventually(fun, attempts \\ 40)
|
defp assert_eventually(fun, timeout_ms) do
|
||||||
defp assert_eventually(_fun, 0), do: flunk("condition was not met in time")
|
deadline = System.monotonic_time(:millisecond) + timeout_ms
|
||||||
|
do_assert_eventually(fun, deadline, timeout_ms, 50)
|
||||||
|
end
|
||||||
|
|
||||||
defp assert_eventually(fun, attempts) do
|
defp do_assert_eventually(fun, deadline, timeout_ms, interval_ms) do
|
||||||
if fun.() do
|
cond do
|
||||||
:ok
|
fun.() ->
|
||||||
else
|
:ok
|
||||||
receive do
|
|
||||||
after
|
System.monotonic_time(:millisecond) >= deadline ->
|
||||||
50 -> assert_eventually(fun, attempts - 1)
|
flunk("condition was not met in time (#{timeout_ms} ms)")
|
||||||
end
|
|
||||||
|
true ->
|
||||||
|
receive do
|
||||||
|
after
|
||||||
|
interval_ms -> do_assert_eventually(fun, deadline, timeout_ms, interval_ms)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,4 +5,6 @@ exclude_tags =
|
|||||||
[:nak_e2e]
|
[:nak_e2e]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
{:ok, _apps} = Application.ensure_all_started(:parrhesia)
|
||||||
|
|
||||||
ExUnit.start(exclude: exclude_tags)
|
ExUnit.start(exclude: exclude_tags)
|
||||||
|
|||||||
Reference in New Issue
Block a user