Remove unreliable storage test

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.
This commit is contained in:
Jonatan Kłosko 2023-08-08 18:58:04 +02:00
parent 3477767ed2
commit e9ab9dec91

View file

@ -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