Skip to content

Commit efa2065

Browse files
authored
Merge pull request #28 from tidesdb/fix-overflow-and-ci
fix memory corruption and ci
2 parents 0321cf6 + b55b0db commit efa2065

23 files changed

Lines changed: 585 additions & 80 deletions

.github/workflows/test.yml renamed to .github/workflows/tidesdb-python-build-test.yml

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test TidesDB Python Bindings
1+
name: TidesDB Python Workflow
22

33
on:
44
push:
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
18+
python-version: ['3.11']
1919

2020
steps:
2121
- name: Checkout Python bindings
@@ -25,8 +25,15 @@ jobs:
2525
uses: actions/checkout@v4
2626
with:
2727
repository: tidesdb/tidesdb
28+
ref: master
2829
path: tidesdb-core
2930

31+
- name: Show TidesDB version
32+
working-directory: tidesdb-core
33+
run: |
34+
echo "Building TidesDB from commit:"
35+
git log -1 --oneline
36+
3037
- name: Set up Python ${{ matrix.python-version }}
3138
uses: actions/setup-python@v5
3239
with:
@@ -120,10 +127,16 @@ jobs:
120127
run: |
121128
pip install -e .
122129
123-
# Run tests
130+
# Verify library can be loaded
131+
- name: Verify TidesDB library
132+
run: |
133+
python -c "from tidesdb import TidesDB; print('TidesDB library loaded successfully')"
134+
135+
# Run tests with verbose output
124136
- name: Run tests
125137
run: |
126-
pytest test_tidesdb.py -v --cov=tidesdb --cov-report=xml --cov-report=term
138+
pytest -v --tb=short -x
139+
timeout-minutes: 60
127140

128141
# Upload coverage
129142
- name: Upload coverage to Codecov
@@ -135,34 +148,6 @@ jobs:
135148
name: codecov-umbrella
136149
fail_ci_if_error: false
137150

138-
lint:
139-
name: Lint and Format Check
140-
runs-on: ubuntu-latest
141-
steps:
142-
- uses: actions/checkout@v4
143-
144-
- name: Set up Python
145-
uses: actions/setup-python@v5
146-
with:
147-
python-version: '3.11'
148-
149-
- name: Install linting tools
150-
run: |
151-
python -m pip install --upgrade pip
152-
pip install black flake8 mypy
153-
154-
- name: Check formatting with black
155-
run: |
156-
black --check --line-length 100 tidesdb.py test_tidesdb.py
157-
158-
- name: Lint with flake8
159-
run: |
160-
flake8 tidesdb.py test_tidesdb.py --max-line-length=100 --ignore=E203,W503
161-
162-
- name: Type check with mypy
163-
run: |
164-
mypy tidesdb.py --ignore-missing-imports
165-
continue-on-error: true
166151

167152
package:
168153
name: Build Package

.gitignore

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Python
21
__pycache__/
32
*.py[cod]
43
*$py.class
@@ -19,23 +18,14 @@ wheels/
1918
*.egg-info/
2019
.installed.cfg
2120
*.egg
22-
23-
# Testing
2421
.pytest_cache/
2522
.coverage
2623
htmlcov/
2724
.tox/
28-
29-
# IDE
3025
.vscode/
3126
.idea/
3227
*.swp
3328
*.swo
34-
*~
35-
36-
# OS
3729
.DS_Store
3830
Thumbs.db
39-
40-
# Test database
4131
test_db/

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dev = [
5858

5959
[tool.black]
6060
line-length = 100
61-
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
61+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313']
6262
include = '\.pyi?$'
6363

6464
[tool.isort]

tests/test_tidesdb.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ def test_context_manager(self):
4545
"""Test database as context manager."""
4646
with TidesDB(self.test_db_path) as db:
4747
self.assertIsNotNone(db)
48+
# Create a CF with background compaction disabled
49+
config = ColumnFamilyConfig(enable_background_compaction=False)
50+
db.create_column_family("test_cf", config)
4851
# Database should be closed after context
4952

5053
def test_create_drop_column_family(self):
5154
"""Test creating and dropping column families."""
5255
with TidesDB(self.test_db_path) as db:
53-
# Create with default config
54-
db.create_column_family("test_cf")
56+
# Create with background compaction disabled
57+
config = ColumnFamilyConfig(enable_background_compaction=False)
58+
db.create_column_family("test_cf", config)
5559

5660
# Verify it exists
5761
cf_list = db.list_column_families()
@@ -92,10 +96,11 @@ def test_create_column_family_with_config(self):
9296
def test_list_column_families(self):
9397
"""Test listing column families."""
9498
with TidesDB(self.test_db_path) as db:
95-
# Create multiple column families
99+
# Create multiple column families with background compaction disabled
100+
config = ColumnFamilyConfig(enable_background_compaction=False)
96101
cf_names = ["cf1", "cf2", "cf3"]
97102
for name in cf_names:
98-
db.create_column_family(name)
103+
db.create_column_family(name, config)
99104

100105
# List them
101106
cf_list = db.list_column_families()
@@ -107,7 +112,8 @@ def test_list_column_families(self):
107112
def test_transaction_put_get_delete(self):
108113
"""Test basic CRUD operations with transactions."""
109114
with TidesDB(self.test_db_path) as db:
110-
db.create_column_family("test_cf")
115+
config = ColumnFamilyConfig(enable_background_compaction=False)
116+
db.create_column_family("test_cf", config)
111117

112118
# Put data
113119
with db.begin_txn() as txn:
@@ -136,7 +142,8 @@ def test_transaction_put_get_delete(self):
136142
def test_transaction_with_ttl(self):
137143
"""Test transactions with TTL."""
138144
with TidesDB(self.test_db_path) as db:
139-
db.create_column_family("test_cf")
145+
config = ColumnFamilyConfig(enable_background_compaction=False)
146+
db.create_column_family("test_cf", config)
140147

141148
# Put with TTL (2 seconds from now)
142149
ttl = int(time.time()) + 2
@@ -160,7 +167,8 @@ def test_transaction_with_ttl(self):
160167
def test_multi_operation_transaction(self):
161168
"""Test transaction with multiple operations."""
162169
with TidesDB(self.test_db_path) as db:
163-
db.create_column_family("test_cf")
170+
config = ColumnFamilyConfig(enable_background_compaction=False)
171+
db.create_column_family("test_cf", config)
164172

165173
# Multiple operations in one transaction
166174
with db.begin_txn() as txn:
@@ -181,7 +189,8 @@ def test_multi_operation_transaction(self):
181189
def test_transaction_rollback(self):
182190
"""Test transaction rollback."""
183191
with TidesDB(self.test_db_path) as db:
184-
db.create_column_family("test_cf")
192+
config = ColumnFamilyConfig(enable_background_compaction=False)
193+
db.create_column_family("test_cf", config)
185194

186195
# Put some data and rollback
187196
with db.begin_txn() as txn:
@@ -196,7 +205,8 @@ def test_transaction_rollback(self):
196205
def test_transaction_auto_rollback_on_exception(self):
197206
"""Test transaction automatically rolls back on exception."""
198207
with TidesDB(self.test_db_path) as db:
199-
db.create_column_family("test_cf")
208+
config = ColumnFamilyConfig(enable_background_compaction=False)
209+
db.create_column_family("test_cf", config)
200210

201211
# Exception in context manager should trigger rollback
202212
try:
@@ -214,7 +224,8 @@ def test_transaction_auto_rollback_on_exception(self):
214224
def test_iterator_forward(self):
215225
"""Test forward iteration."""
216226
with TidesDB(self.test_db_path) as db:
217-
db.create_column_family("test_cf")
227+
config = ColumnFamilyConfig(enable_background_compaction=False)
228+
db.create_column_family("test_cf", config)
218229

219230
# Insert test data
220231
test_data = {
@@ -251,7 +262,8 @@ def test_iterator_forward(self):
251262
def test_iterator_backward(self):
252263
"""Test backward iteration."""
253264
with TidesDB(self.test_db_path) as db:
254-
db.create_column_family("test_cf")
265+
config = ColumnFamilyConfig(enable_background_compaction=False)
266+
db.create_column_family("test_cf", config)
255267

256268
# Insert test data
257269
test_data = {
@@ -286,7 +298,8 @@ def test_iterator_backward(self):
286298
def test_iterator_as_python_iterator(self):
287299
"""Test iterator as Python iterator."""
288300
with TidesDB(self.test_db_path) as db:
289-
db.create_column_family("test_cf")
301+
config = ColumnFamilyConfig(enable_background_compaction=False)
302+
db.create_column_family("test_cf", config)
290303

291304
# Insert test data
292305
test_data = {
@@ -439,7 +452,8 @@ def test_compression_algorithms(self):
439452
def test_pickle_support(self):
440453
"""Test storing Python objects with pickle."""
441454
with TidesDB(self.test_db_path) as db:
442-
db.create_column_family("test_cf")
455+
config = ColumnFamilyConfig(enable_background_compaction=False)
456+
db.create_column_family("test_cf", config)
443457

444458
# Store complex Python object
445459
test_obj = {
@@ -476,15 +490,17 @@ def test_error_handling(self):
476490
db.drop_column_family("nonexistent_cf")
477491

478492
# Try to get from non-existent CF
479-
db.create_column_family("test_cf")
493+
config = ColumnFamilyConfig(enable_background_compaction=False)
494+
db.create_column_family("test_cf", config)
480495
with db.begin_read_txn() as txn:
481496
with self.assertRaises(TidesDBException):
482497
txn.get("nonexistent_cf", b"key")
483498

484499
def test_large_values(self):
485500
"""Test storing large values."""
486501
with TidesDB(self.test_db_path) as db:
487-
db.create_column_family("test_cf")
502+
config = ColumnFamilyConfig(enable_background_compaction=False)
503+
db.create_column_family("test_cf", config)
488504

489505
# Store 1MB value
490506
large_value = b"x" * (1024 * 1024)
@@ -502,7 +518,8 @@ def test_large_values(self):
502518
def test_many_keys(self):
503519
"""Test storing many keys."""
504520
with TidesDB(self.test_db_path) as db:
505-
db.create_column_family("test_cf")
521+
config = ColumnFamilyConfig(enable_background_compaction=False)
522+
db.create_column_family("test_cf", config)
506523

507524
num_keys = 1000
508525

0 commit comments

Comments
 (0)