Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up mnesia tests #723

Merged
merged 2 commits into from
Feb 8, 2024
Merged
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
11 changes: 6 additions & 5 deletions test/pow/store/backend/mnesia_cache_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do

# Set short TTL on node a
flush_process_mailbox()
config = Config.put(@default_config, :ttl, 100)
config = Config.put(@default_config, :ttl, @assertion_timeout)
assert :rpc.call(node_a, MnesiaCache, :put, [config, {"short_ttl_key_set_on_a", "value"}])
assert_receive {{:mnesia, ^node_b}, {:mnesia_system_event, {:mnesia_user, {:refresh_invalidators, {_, _}}}}}
assert_receive {{:mnesia, ^node_b}, {:mnesia_system_event, {:mnesia_user, {:refresh_invalidators, {_, _}}}}}, @assertion_timeout

# Stop node a
flush_process_mailbox()
Expand All @@ -241,7 +241,7 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do

# Ensure that node b invalidates with TTL set on node a
assert :rpc.call(node_b, MnesiaCache, :get, [config, "short_ttl_key_set_on_a"]) == "value"
assert_receive {{:mnesia, ^node_b}, {:mnesia_table_event, {:delete, {MnesiaCache, [_, "short_ttl_key_set_on_a"]}, _}}}, @assertion_timeout
assert_receive {{:mnesia, ^node_b}, {:mnesia_table_event, {:delete, {MnesiaCache, [_, "short_ttl_key_set_on_a"]}, _}}}, @assertion_timeout + 100
assert :rpc.call(node_b, MnesiaCache, :get, [config, "short_ttl_key_set_on_a"]) == :not_found

# Start node a but not mnesia yet before we test cross node TTL
Expand Down Expand Up @@ -560,8 +560,9 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do
rpc(node, Application, :ensure_all_started, [app_name])
end

# Remove logger to prevent logs
rpc(node, Logger, :remove_backend, [:console])
# Silence console logging on node
rpc(node, :logger, :remove_handler, [:default])
rpc(node, Logger, :remove_backend, [:console]) # TODO: Remove when Elixir 1.15 is required

add_listener_module(node)

Expand Down
Loading