Skip to content

Commit

Permalink
Make timestamp overrides optional in tests and add faketime test (#1953)
Browse files Browse the repository at this point in the history
* Add pytest input parameter to only set the ordering timestamp for one variation

* change libtiledb version to 'dev'

* Add test

* Add more assetions and handle assertion exits

* Add group metadata test

* Fix test for linux

* Set core to 2.22.0

* Add faketime CI requirement for tests

* Skip tests if libfaketime is not installed

* Fixes
  • Loading branch information
kounelisagis authored Apr 19, 2024
1 parent 410a88a commit 8a98a42
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 202 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ jobs:
- name: "Check build directory"
run: ls -Rl

- name: "Install libfaketime (linux and macOS)"
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-12'
run: |
git clone https://github.com/wolfcw/libfaketime/
cd libfaketime
sudo make install
cd ..
- name: "Run tests"
run: pytest -vv --showlocals

Expand Down
27 changes: 16 additions & 11 deletions tiledb/tests/test_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class SOMA919Test(DiskTestCase):
We've distilled @atolopko-czi's gist example using the TileDB-Py API directly.
"""

def run_test(self):
def run_test(self, use_timestamps):
import tempfile

import numpy as np
Expand All @@ -267,13 +267,17 @@ def run_test(self):

root_uri = tempfile.mkdtemp()

# this tiledb.Ctx is how we set the write timestamps for tiledb.Group
group_ctx100 = tiledb.Ctx(
{
"sm.group.timestamp_start": 100,
"sm.group.timestamp_end": 100,
}
)
if use_timestamps:
group_ctx100 = tiledb.Ctx(
{
"sm.group.timestamp_start": 100,
"sm.group.timestamp_end": 100,
}
)
timestamp = 100
else:
group_ctx100 = tiledb.Ctx()
timestamp = None

# create the group and add a dummy subgroup "causes_bug"
tiledb.Group.create(root_uri, ctx=group_ctx100)
Expand All @@ -284,7 +288,7 @@ def run_test(self):
# add an array to the group (in a separate write operation)
with tiledb.Group(root_uri, mode="w", ctx=group_ctx100) as expt:
df_path = os.path.join(root_uri, "df")
tiledb.from_numpy(df_path, np.ones((100, 100)), timestamp=100)
tiledb.from_numpy(df_path, np.ones((100, 100)), timestamp=timestamp)
expt.add(name="df", uri=df_path)

# check our view of the group at current time;
Expand All @@ -301,12 +305,13 @@ def run_test(self):
tiledb.libtiledb.version() < (2, 15, 0),
reason="SOMA919 fix implemented in libtiledb 2.15",
)
def test_soma919(self):
@pytest.mark.parametrize("use_timestamps", [True, False])
def test_soma919(self, use_timestamps):
N = 100
fails = 0
for i in range(N):
try:
self.run_test()
self.run_test(use_timestamps)
except AssertionError:
fails += 1
if fails > 0:
Expand Down
Loading

0 comments on commit 8a98a42

Please sign in to comment.