Skip to content

Commit

Permalink
Remove unreliable storage test
Browse files Browse the repository at this point in the history
We wait for the storage process to finish writing the table to file
and then read the file manually, however the storage may be writing
to the file again (and the writing is async), so we may try to read
a partially written file.
  • Loading branch information
jonatanklosko committed Aug 8, 2023
1 parent 3477767 commit e9ab9de
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions test/livebook/storage_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,41 +102,4 @@ defmodule Livebook.StorageTest do
assert [] = Storage.all(:unknown_namespace)
end
end

describe "persistence" do
defp read_table_and_lookup(entity) do
Process.sleep(1)

# :ets.tab2file is asynchronous and may occasionally take
# longer, so we retry
{:ok, tab} =
with {:error, _} <- read_table(),
:ok <- Process.sleep(100),
{:error, _} <- read_table(),
:ok <- Process.sleep(1000) do
read_table()
end

:ets.lookup(tab, {:persistence, entity})
end

defp read_table() do
Storage.config_file_path()
|> String.to_charlist()
|> :ets.file2tab()
end

test "insert triggers saving to file" do
:ok = Storage.insert(:persistence, "insert", key: "val")

assert [_test] = read_table_and_lookup("insert")
end

test "delete triggers saving to file" do
:ok = Storage.insert(:persistence, "delete", key: "val")
:ok = Storage.delete(:persistence, "delete")

assert [] = read_table_and_lookup("delete")
end
end
end

0 comments on commit e9ab9de

Please sign in to comment.