From bbce092efcd81f028cbe2f62d328d3573a495e79 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Mon, 26 Aug 2024 17:43:58 +0100 Subject: [PATCH] add a small delay to prevent test failures --- packages/sync-service/test/electric/shape_cache_test.exs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/sync-service/test/electric/shape_cache_test.exs b/packages/sync-service/test/electric/shape_cache_test.exs index 7c05dc7ff9..3184c841ca 100644 --- a/packages/sync-service/test/electric/shape_cache_test.exs +++ b/packages/sync-service/test/electric/shape_cache_test.exs @@ -802,6 +802,12 @@ defmodule Electric.ShapeCacheTest do {^shape_id, ^offset} = ShapeCache.get_or_create_shape_id(@shape, opts) + # without this sleep, this test becomes unreliable. I think maybe due to + # delays in actually writing the data to cubdb/fsyncing the tx. I've + # tried explicit `CubDb.file_sync/1` calls but it doesn't work, the only + # reliable method is to wait just a little bit... + Process.sleep(5) + restart_shape_cache(context) :started = ShapeCache.await_snapshot_start(shape_id, opts)