Skip to content

Commit 14cae1f

Browse files
authored
Fix randomly failing test DenseArrayTest::test_open_with_timestamp[False] (#2090)
1 parent c6ce3e5 commit 14cae1f

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

tiledb/tests/test_libtiledb.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,7 @@ def test_open_with_timestamp(self, use_timestamps):
836836
with tiledb.DenseArray(self.path("foo"), mode="w") as T:
837837
T[:] = A
838838

839-
read1_timestamp = -1
840839
with tiledb.DenseArray(self.path("foo"), mode="r") as T:
841-
read1_timestamp = T.timestamp_range
842840
self.assertEqual(T[0], 0)
843841
self.assertEqual(T[1], 0)
844842
self.assertEqual(T[2], 0)
@@ -849,41 +847,36 @@ def test_open_with_timestamp(self, use_timestamps):
849847
with tiledb.DenseArray(self.path("foo"), mode="w") as T:
850848
T[0:1] = 1
851849

852-
read2_timestamp = -1
853-
with tiledb.DenseArray(self.path("foo"), mode="r") as T:
854-
read2_timestamp = T.timestamp_range
855-
self.assertTrue(read2_timestamp > read1_timestamp)
856-
857850
if use_timestamps:
858851
# sleep 200ms and write
859852
time.sleep(0.2)
860853
with tiledb.DenseArray(self.path("foo"), mode="w") as T:
861854
T[1:2] = 2
862855

863-
read3_timestamp = -1
864-
with tiledb.DenseArray(self.path("foo"), mode="r") as T:
865-
read3_timestamp = T.timestamp_range
866-
self.assertTrue(read3_timestamp > read2_timestamp > read1_timestamp)
856+
frags = tiledb.array_fragments(self.path("foo"))
857+
# timestamps are in the form of (start, end) for each fragment, with start == end,
858+
# as we are not dealing with consolidated fragments. Let's simply read from 0 to the end timestamp.
859+
read_timestamps = [(0, frag.timestamp_range[1]) for frag in frags]
867860

868861
# read at first timestamp
869862
with tiledb.DenseArray(
870-
self.path("foo"), timestamp=read1_timestamp, mode="r"
863+
self.path("foo"), timestamp=read_timestamps[0], mode="r"
871864
) as T:
872865
self.assertEqual(T[0], 0)
873866
self.assertEqual(T[1], 0)
874867
self.assertEqual(T[2], 0)
875868

876869
# read at second timestamp
877870
with tiledb.DenseArray(
878-
self.path("foo"), timestamp=read2_timestamp, mode="r"
871+
self.path("foo"), timestamp=read_timestamps[1], mode="r"
879872
) as T:
880873
self.assertEqual(T[0], 1)
881874
self.assertEqual(T[1], 0)
882875
self.assertEqual(T[2], 0)
883876

884877
# read at third timestamp
885878
with tiledb.DenseArray(
886-
self.path("foo"), timestamp=read3_timestamp, mode="r"
879+
self.path("foo"), timestamp=read_timestamps[2], mode="r"
887880
) as T:
888881
self.assertEqual(T[0], 1)
889882
self.assertEqual(T[1], 2)

0 commit comments

Comments
 (0)