Skip to content

Commit a3bba8d

Browse files
committed
Add framework for Carrara testing
1 parent a130d21 commit a3bba8d

4 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Carrara Tests
2+
3+
TileDB v3 aka Carrara introduces a new URL schema with supports relative paths and group membership lifecycle changes.
4+
5+
This directory contains unit tests for Carrara-specific behavior.
6+
7+
# Running the tests
8+
9+
Prerequisites
10+
11+
- You have a user account in a Carrara deployment
12+
- You have set up your TileDB profile so that you can log into the account with a profile name
13+
- You have created a teamspace for testing use
14+
15+
With that, set the environment variables and install package dependencies:
16+
17+
```bash
18+
pip install tiledb_client
19+
export CARRARA_TEST_PROFILE="..." # Profile name
20+
export CARRARA_TEST_WORKSPACE="..." # Workspace name (must match workspace in the profile)
21+
export CARRARA_TEST_TEAMSPACE="..." # Teamspace to use for tests
22+
```
23+
24+
Run the tests with pytest:
25+
```bash
26+
pytest api/python/remotes_tests/carrara/
27+
```
28+
29+
Objects will be created at the specified workspace/teamspace: `tiledb://${CARRARA_TEST_WORKSPACE}/${CARRARA_TEST_TEAMSPACE}/...`. The test should remove all created objects when completed; however, assets may remain in the case of a test failure.

apis/python/remote_tests/carrara/__init__.py

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (c) TileDB, Inc.
2+
# Licensed under the MIT License.
3+
4+
from __future__ import annotations
5+
6+
import os
7+
from collections.abc import Generator
8+
from uuid import uuid4
9+
10+
import tiledbvcf
11+
import tiledb
12+
import pytest
13+
14+
15+
# Base CARRARA URI used for all tests.
16+
# - The teamspace must be owned by the test user.
17+
# - The workspace must match the workspace defined in the profile.
18+
PROFILE_NAME = os.getenv("CARRARA_TEST_PROFILE") or "qa"
19+
WORKSPACE_NAME = os.getenv("CARRARA_TEST_WORKSPACE") or "TileDB-Inc."
20+
TEAMSPACE_NAME = os.getenv("CARRARA_TEST_TEAMSPACE") or "uat-tests"
21+
TEST_FOLDER = os.getenv("CARRARA_TEST_FOLDER") or "remote_test"
22+
BASE_URI = f"tiledb://{WORKSPACE_NAME}/{TEAMSPACE_NAME}/{TEST_FOLDER}"
23+
24+
25+
@pytest.fixture(scope="session")
26+
def carrara_login() -> None:
27+
import tiledb.client
28+
29+
tiledb.client.login(profile_name=PROFILE_NAME)
30+
assert tiledb.client.workspaces.get_workspace(tiledb.client.client.get_workspace_id()).name == WORKSPACE_NAME
31+
32+
33+
@pytest.fixture
34+
def carrara_array_path() -> Generator[str, None, None]:
35+
"""Fixture returns an Array path that will be recursively deleted after test finishes."""
36+
import tiledb.client
37+
38+
path = f"{BASE_URI}/{uuid4()}"
39+
yield path
40+
41+
tiledb.client.assets.delete_asset(path, delete_storage=True)
42+
43+
44+
@pytest.fixture
45+
def carrara_group_path() -> Generator[str, None, None]:
46+
"""Fixture returns a Group path that will be recursively deleted after test finishes."""
47+
path = f"{BASE_URI}/{uuid4()}"
48+
yield path
49+
50+
try:
51+
with tiledb.Group(path, mode="m") as G:
52+
G.delete(recursive=True)
53+
except tiledb.TileDBError:
54+
pass
55+
56+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) TileDB, Inc.
2+
# Licensed under the MIT License.
3+
"""
4+
Basic object creation with Carrara URIs.
5+
"""
6+
7+
8+
from __future__ import annotations
9+
10+
import tiledbvcf
11+
12+
def test_dataset_create(carrara_login: None, carrara_group_path: str):
13+
with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds:
14+
ds.create_dataset()
15+
16+
with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds:
17+
assert ds.count() == 0

0 commit comments

Comments
 (0)