From e9ab9dec91a90b2f1973f20a2b25e387f9a45611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 8 Aug 2023 18:58:04 +0200 Subject: [PATCH] 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. --- test/livebook/storage_test.exs | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/test/livebook/storage_test.exs b/test/livebook/storage_test.exs index cf45a7f9044..df355758118 100644 --- a/test/livebook/storage_test.exs +++ b/test/livebook/storage_test.exs @@ -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