mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Merge 'Use UV more in python related scripts and actions' from Pedro Muniz
Some checks are pending
Build and push limbo-sim image / deploy (push) Waiting to run
Go Tests / test (push) Waiting to run
Java Tests / test (push) Waiting to run
JavaScript / Publish (push) Blocked by required conditions
JavaScript / stable - aarch64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Waiting to run
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Python / macos-x86_64 (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / build-wasm (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
JavaScript / Build universal macOS binary (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / linux (x86_64) (push) Waiting to run
Some checks are pending
Build and push limbo-sim image / deploy (push) Waiting to run
Go Tests / test (push) Waiting to run
Java Tests / test (push) Waiting to run
JavaScript / Publish (push) Blocked by required conditions
JavaScript / stable - aarch64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Waiting to run
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Waiting to run
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Python / macos-x86_64 (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / build-wasm (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Blocked by required conditions
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
JavaScript / Build universal macOS binary (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / linux (x86_64) (push) Waiting to run
This PR initializes an UV project in `antithesis_tests` so that we can have an easier time to track dependencies and build pylimbo automatically for our environment. Consequently, making it easier to create new antithesis tests in the future with better IDE support. Also modified our Github actions to check python linting with Ruff, and removed unnecessary Python jobs. With that, I applied the Ruff fixes which is the cause of the many file changes. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #1782
This commit is contained in:
commit
edc6eb9a36
35 changed files with 676 additions and 521 deletions
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pathlib import Path
|
||||
import time
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
|
||||
|
||||
def test_basic_queries():
|
||||
|
@ -62,7 +63,7 @@ def test_joins():
|
|||
shell.run_test(
|
||||
"file-cross-join",
|
||||
"select * from users, products limit 1;",
|
||||
"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79.0",
|
||||
"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79.0", # noqa: E501
|
||||
)
|
||||
shell.quit()
|
||||
|
||||
|
@ -76,7 +77,7 @@ def test_left_join_self():
|
|||
|
||||
shell.run_test(
|
||||
"file-left-join-self",
|
||||
"select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 left join users as u2 on u1.id = u2.id + 1 limit 2;",
|
||||
"select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 left join users as u2 on u1.id = u2.id + 1 limit 2;", # noqa: E501
|
||||
"Jamie|\nCindy|Jamie",
|
||||
)
|
||||
shell.quit()
|
||||
|
@ -99,9 +100,7 @@ def test_switch_back_to_in_memory():
|
|||
shell.run_test("open-testing-db-file", ".open testing/testing.db", "")
|
||||
# Then switch back to :memory:
|
||||
shell.run_test("switch-back", ".open :memory:", "")
|
||||
shell.run_test(
|
||||
"schema-in-memory", ".schema users", "-- Error: Table 'users' not found."
|
||||
)
|
||||
shell.run_test("schema-in-memory", ".schema users", "-- Error: Table 'users' not found.")
|
||||
shell.quit()
|
||||
|
||||
|
||||
|
@ -172,9 +171,7 @@ SELECT 2;"""
|
|||
def test_comments():
|
||||
shell = TestLimboShell()
|
||||
shell.run_test("single-line-comment", "-- this is a comment\nSELECT 1;", "1")
|
||||
shell.run_test(
|
||||
"multi-line-comments", "-- First comment\n-- Second comment\nSELECT 2;", "2"
|
||||
)
|
||||
shell.run_test("multi-line-comments", "-- First comment\n-- Second comment\nSELECT 2;", "2")
|
||||
shell.run_test("block-comment", "/*\nMulti-line block comment\n*/\nSELECT 3;", "3")
|
||||
shell.run_test(
|
||||
"inline-comments",
|
||||
|
@ -187,9 +184,7 @@ def test_comments():
|
|||
def test_import_csv():
|
||||
shell = TestLimboShell()
|
||||
shell.run_test("memory-db", ".open :memory:", "")
|
||||
shell.run_test(
|
||||
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
|
||||
)
|
||||
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
|
||||
shell.run_test(
|
||||
"import-csv-no-options",
|
||||
".import --csv ./testing/test_files/test.csv csv_table",
|
||||
|
@ -206,9 +201,7 @@ def test_import_csv():
|
|||
def test_import_csv_verbose():
|
||||
shell = TestLimboShell()
|
||||
shell.run_test("open-memory", ".open :memory:", "")
|
||||
shell.run_test(
|
||||
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
|
||||
)
|
||||
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
|
||||
shell.run_test(
|
||||
"import-csv-verbose",
|
||||
".import --csv -v ./testing/test_files/test.csv csv_table",
|
||||
|
@ -225,9 +218,7 @@ def test_import_csv_verbose():
|
|||
def test_import_csv_skip():
|
||||
shell = TestLimboShell()
|
||||
shell.run_test("open-memory", ".open :memory:", "")
|
||||
shell.run_test(
|
||||
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
|
||||
)
|
||||
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
|
||||
shell.run_test(
|
||||
"import-csv-skip",
|
||||
".import --csv --skip 1 ./testing/test_files/test.csv csv_table",
|
||||
|
@ -250,51 +241,33 @@ def test_update_with_limit():
|
|||
limbo.run_test("update-limit", "UPDATE t SET a = 10 LIMIT 1;", "")
|
||||
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 10;", "1")
|
||||
limbo.run_test("update-limit-zero", "UPDATE t SET a = 100 LIMIT 0;", "")
|
||||
limbo.run_test(
|
||||
"update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0"
|
||||
)
|
||||
limbo.run_test("update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0")
|
||||
limbo.run_test("update-limit-all", "UPDATE t SET a = 100 LIMIT -1;", "")
|
||||
# negative limit is treated as no limit in sqlite due to check for --val = 0
|
||||
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 100;", "6")
|
||||
limbo.run_test(
|
||||
"udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1;", ""
|
||||
)
|
||||
limbo.run_test(
|
||||
"update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "1"
|
||||
)
|
||||
limbo.run_test("udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1;", "")
|
||||
limbo.run_test("update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "1")
|
||||
limbo.quit()
|
||||
|
||||
|
||||
|
||||
def test_update_with_limit_and_offset():
|
||||
limbo = TestLimboShell(
|
||||
"CREATE TABLE t (a,b,c); insert into t values (1,2,3), (4,5,6), (7,8,9), (1,2,3),(4,5,6), (7,8,9);"
|
||||
)
|
||||
limbo.run_test("update-limit-offset", "UPDATE t SET a = 10 LIMIT 1 OFFSET 3;", "")
|
||||
limbo.run_test(
|
||||
"update-limit-offset-result", "SELECT COUNT(*) from t WHERE a = 10;", "1"
|
||||
)
|
||||
limbo.run_test("update-limit-offset-result", "SELECT COUNT(*) from t WHERE a = 10;", "1")
|
||||
limbo.run_test("update-limit-result", "SELECT a from t LIMIT 4;", "1\n4\n7\n10")
|
||||
limbo.run_test(
|
||||
"update-limit-offset-zero", "UPDATE t SET a = 100 LIMIT 0 OFFSET 0;", ""
|
||||
)
|
||||
limbo.run_test(
|
||||
"update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0"
|
||||
)
|
||||
limbo.run_test("update-limit-offset-zero", "UPDATE t SET a = 100 LIMIT 0 OFFSET 0;", "")
|
||||
limbo.run_test("update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0")
|
||||
limbo.run_test("update-limit-all", "UPDATE t SET a = 100 LIMIT -1 OFFSET 1;", "")
|
||||
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 100;", "5")
|
||||
limbo.run_test(
|
||||
"udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1 OFFSET 2;", ""
|
||||
)
|
||||
limbo.run_test(
|
||||
"update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "0"
|
||||
)
|
||||
limbo.run_test("udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1 OFFSET 2;", "")
|
||||
limbo.run_test("update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "0")
|
||||
limbo.quit()
|
||||
|
||||
|
||||
|
||||
def test_insert_default_values():
|
||||
limbo = TestLimboShell(
|
||||
"CREATE TABLE t (a integer default(42),b integer default (43),c integer default(44));"
|
||||
)
|
||||
limbo = TestLimboShell("CREATE TABLE t (a integer default(42),b integer default (43),c integer default(44));")
|
||||
for _ in range(1, 10):
|
||||
limbo.execute_dot("INSERT INTO t DEFAULT VALUES;")
|
||||
limbo.run_test("insert-default-values", "SELECT * FROM t;", "42|43|44\n" * 9)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pydantic import BaseModel
|
||||
from cli_tests import console
|
||||
|
||||
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
||||
|
@ -81,13 +81,13 @@ class CollateTest(BaseModel):
|
|||
)
|
||||
|
||||
limbo.run_test(
|
||||
"Grouping is performed using the NOCASE collating sequence (Values 'abc', 'ABC', and 'Abc' are placed in the same group).",
|
||||
"Grouping is performed using the NOCASE collating sequence (Values 'abc', 'ABC', and 'Abc' are placed in the same group).", # noqa: E501
|
||||
"SELECT count(*) FROM t1 GROUP BY d ORDER BY 1;",
|
||||
"\n".join(map(lambda x: str(x), [4])),
|
||||
)
|
||||
|
||||
limbo.run_test(
|
||||
"Grouping is performed using the BINARY collating sequence. 'abc' and 'ABC' and 'Abc' form different groups",
|
||||
"Grouping is performed using the BINARY collating sequence. 'abc' and 'ABC' and 'Abc' form different groups", # noqa: E501
|
||||
"SELECT count(*) FROM t1 GROUP BY (d || '') ORDER BY 1;",
|
||||
"\n".join(map(lambda x: str(x), [1, 1, 2])),
|
||||
)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from typing import Any, Optional, Union
|
||||
from rich.console import Console, JustifyMethod
|
||||
from rich.theme import Theme
|
||||
from rich.style import Style
|
||||
|
||||
from rich.console import Console, JustifyMethod
|
||||
from rich.style import Style
|
||||
from rich.theme import Theme
|
||||
|
||||
custom_theme = Theme(
|
||||
{
|
||||
|
@ -95,6 +95,7 @@ def debug(
|
|||
_stack_offset=_stack_offset + 1,
|
||||
)
|
||||
|
||||
|
||||
def test(
|
||||
*objects: Any,
|
||||
sep: str = " ",
|
||||
|
@ -119,4 +120,4 @@ def test(
|
|||
highlight=highlight,
|
||||
log_locals=log_locals,
|
||||
_stack_offset=_stack_offset + 1,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
# Eventually extract these tests to be in the fuzzing integration tests
|
||||
import os
|
||||
import tempfile
|
||||
from faker import Faker
|
||||
from faker.providers.lorem.en_US import Provider as P
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pydantic import BaseModel
|
||||
from cli_tests import console
|
||||
from enum import Enum
|
||||
import random
|
||||
import sqlite3
|
||||
import tempfile
|
||||
from enum import Enum
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from faker import Faker
|
||||
from faker.providers.lorem.en_US import Provider as P
|
||||
from pydantic import BaseModel
|
||||
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
||||
|
@ -233,11 +234,7 @@ class Table(BaseModel):
|
|||
|
||||
# These statements should always cause a constraint error as there is no where clause here
|
||||
def generate_update(self) -> str:
|
||||
vals = [
|
||||
f"{col.name} = {col.col_type.generate(fake)}"
|
||||
for col in self.columns
|
||||
if col.primary_key
|
||||
]
|
||||
vals = [f"{col.name} = {col.col_type.generate(fake)}" for col in self.columns if col.primary_key]
|
||||
vals = ", ".join(vals)
|
||||
|
||||
return f"UPDATE {self.name} SET {vals};"
|
||||
|
@ -374,7 +371,7 @@ def main():
|
|||
tests = all_tests()
|
||||
for test in tests:
|
||||
console.info(test.table)
|
||||
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
|
||||
with tempfile.NamedTemporaryFile(suffix=".db") as tmp:
|
||||
try:
|
||||
# Use with syntax to automatically close shell on error
|
||||
with TestLimboShell("") as limbo:
|
||||
|
@ -387,7 +384,7 @@ def main():
|
|||
|
||||
tests = [custom_test_2, regression_test_update_single_key]
|
||||
for test in tests:
|
||||
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
|
||||
with tempfile.NamedTemporaryFile(suffix=".db") as tmp:
|
||||
try:
|
||||
with TestLimboShell("") as limbo:
|
||||
limbo.execute_dot(f".open {tmp.name}")
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
|
||||
sqlite_exec = "./scripts/limbo-sqlite3"
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
@ -40,14 +41,10 @@ def test_uuid():
|
|||
)
|
||||
limbo.run_test_fn("SELECT uuid4_str();", lambda res: len(res) == 36)
|
||||
limbo.run_test_fn("SELECT hex(uuid7());", lambda res: int(res, 16) is not None)
|
||||
limbo.run_test_fn(
|
||||
"SELECT uuid7_timestamp_ms(uuid7()) / 1000;", lambda res: res.isdigit()
|
||||
)
|
||||
limbo.run_test_fn("SELECT uuid7_timestamp_ms(uuid7()) / 1000;", lambda res: res.isdigit())
|
||||
limbo.run_test_fn("SELECT uuid7_str();", validate_string_uuid)
|
||||
limbo.run_test_fn("SELECT uuid_str(uuid7());", validate_string_uuid)
|
||||
limbo.run_test_fn(
|
||||
"SELECT hex(uuid_blob(uuid7_str()));", lambda res: int(res, 16) is not None
|
||||
)
|
||||
limbo.run_test_fn("SELECT hex(uuid_blob(uuid7_str()));", lambda res: int(res, 16) is not None)
|
||||
limbo.run_test_fn("SELECT uuid_str(uuid_blob(uuid7_str()));", validate_string_uuid)
|
||||
limbo.run_test_fn(
|
||||
f"SELECT uuid7_timestamp_ms('{specific_time}') / 1000;",
|
||||
|
@ -160,12 +157,8 @@ def test_aggregates():
|
|||
validate_percentile2,
|
||||
"test aggregate percentile function with 1 argument works",
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"SELECT percentile_cont(value, 0.25) from test;", validate_percentile1
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"SELECT percentile_disc(value, 0.55) from test;", validate_percentile_disc
|
||||
)
|
||||
limbo.run_test_fn("SELECT percentile_cont(value, 0.25) from test;", validate_percentile1)
|
||||
limbo.run_test_fn("SELECT percentile_disc(value, 0.55) from test;", validate_percentile_disc)
|
||||
limbo.quit()
|
||||
|
||||
|
||||
|
@ -223,8 +216,7 @@ def test_crypto():
|
|||
# Hashing and Decode
|
||||
limbo.run_test_fn(
|
||||
"SELECT crypto_encode(crypto_blake3('abc'), 'hex');",
|
||||
lambda res: res
|
||||
== "6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85",
|
||||
lambda res: res == "6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85",
|
||||
"blake3 should encrypt correctly",
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
|
@ -239,8 +231,7 @@ def test_crypto():
|
|||
)
|
||||
limbo.run_test_fn(
|
||||
"SELECT crypto_encode(crypto_sha256('abc'), 'hex');",
|
||||
lambda a: a
|
||||
== "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
|
||||
lambda a: a == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
|
||||
"sha256 should encrypt correctly",
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
|
@ -252,7 +243,7 @@ def test_crypto():
|
|||
limbo.run_test_fn(
|
||||
"SELECT crypto_encode(crypto_sha512('abc'), 'hex');",
|
||||
lambda a: a
|
||||
== "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",
|
||||
== "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", # noqa: E501
|
||||
"sha512 should encrypt correctly",
|
||||
)
|
||||
|
||||
|
@ -401,9 +392,7 @@ def test_kv():
|
|||
)
|
||||
for i in range(100):
|
||||
limbo.execute_dot(f"insert into t values ('key{i}', 'val{i}');")
|
||||
limbo.run_test_fn(
|
||||
"select count(*) from t;", lambda res: "100" == res, "can insert 100 rows"
|
||||
)
|
||||
limbo.run_test_fn("select count(*) from t;", lambda res: "100" == res, "can insert 100 rows")
|
||||
limbo.run_test_fn("update t set value = 'updated' where key = 'key33';", null)
|
||||
limbo.run_test_fn(
|
||||
"select * from t where key = 'key33';",
|
||||
|
@ -422,12 +411,8 @@ def test_kv():
|
|||
"can update all rows",
|
||||
)
|
||||
limbo.run_test_fn("delete from t limit 96;", null, "can delete 96 rows")
|
||||
limbo.run_test_fn(
|
||||
"select count(*) from t;", lambda res: "4" == res, "four rows remain"
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"update t set key = '100' where 1;", null, "where clause evaluates properly"
|
||||
)
|
||||
limbo.run_test_fn("select count(*) from t;", lambda res: "4" == res, "four rows remain")
|
||||
limbo.run_test_fn("update t set key = '100' where 1;", null, "where clause evaluates properly")
|
||||
limbo.run_test_fn(
|
||||
"select * from t where key = '100';",
|
||||
lambda res: res == "100|updated2",
|
||||
|
@ -509,9 +494,7 @@ def test_vfs():
|
|||
ext_path = "target/debug/liblimbo_ext_tests"
|
||||
limbo.run_test_fn(".vfslist", lambda x: "testvfs" not in x, "testvfs not loaded")
|
||||
limbo.execute_dot(f".load {ext_path}")
|
||||
limbo.run_test_fn(
|
||||
".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded"
|
||||
)
|
||||
limbo.run_test_fn(".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded")
|
||||
limbo.execute_dot(".open testing/vfs.db testvfs")
|
||||
limbo.execute_dot("create table test (id integer primary key, value float);")
|
||||
limbo.execute_dot("create table vfs (id integer primary key, value blob);")
|
||||
|
@ -742,8 +725,7 @@ def test_tablestats():
|
|||
|
||||
limbo.run_test_fn(
|
||||
"SELECT * FROM stats ORDER BY name;",
|
||||
lambda res: sorted(_split(res))
|
||||
== sorted(["logs|1", "people|3", "products|11", "users|10000"]),
|
||||
lambda res: sorted(_split(res)) == sorted(["logs|1", "people|3", "products|11", "users|10000"]),
|
||||
"stats shows correct initial counts (and skips itself)",
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import select
|
||||
from time import sleep
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
from typing import Callable, List, Optional
|
||||
from cli_tests import console
|
||||
|
||||
from cli_tests import console
|
||||
|
||||
PIPE_BUF = 4096
|
||||
|
||||
|
@ -107,7 +107,7 @@ class TestLimboShell:
|
|||
flags="",
|
||||
):
|
||||
if exec_name is None:
|
||||
exec_name = os.environ.get('SQLITE_EXEC')
|
||||
exec_name = os.environ.get("SQLITE_EXEC")
|
||||
if exec_name is None:
|
||||
exec_name = "./scripts/limbo-sqlite3"
|
||||
if flags == "":
|
||||
|
@ -142,10 +142,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3)
|
|||
console.test(f"Running test: {name}", _stack_offset=2)
|
||||
actual = self.shell.execute(sql)
|
||||
assert actual == expected, (
|
||||
f"Test failed: {name}\n"
|
||||
f"SQL: {sql}\n"
|
||||
f"Expected:\n{repr(expected)}\n"
|
||||
f"Actual:\n{repr(actual)}"
|
||||
f"Test failed: {name}\nSQL: {sql}\nExpected:\n{repr(expected)}\nActual:\n{repr(actual)}"
|
||||
)
|
||||
|
||||
def run_debug(self, sql: str):
|
||||
|
@ -153,9 +150,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3)
|
|||
actual = self.shell.execute(sql)
|
||||
console.debug(f"OUTPUT:\n{repr(actual)}", _stack_offset=2)
|
||||
|
||||
def run_test_fn(
|
||||
self, sql: str, validate: Callable[[str], bool], desc: str = ""
|
||||
) -> None:
|
||||
def run_test_fn(self, sql: str, validate: Callable[[str], bool], desc: str = "") -> None:
|
||||
# Print the test that is executing before executing the sql command
|
||||
# Printing later confuses the user of the code what test has actually failed
|
||||
if desc:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pydantic import BaseModel
|
||||
from cli_tests import console
|
||||
|
||||
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
||||
|
@ -39,10 +39,7 @@ class UpdateTest(BaseModel):
|
|||
f"{self.vals}",
|
||||
)
|
||||
|
||||
stmt = [
|
||||
f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};"
|
||||
for i in range(self.vals)
|
||||
]
|
||||
stmt = [f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};" for i in range(self.vals)]
|
||||
|
||||
expected = [f"{zero_blob}|{t2_val}|{t3_val}" for _ in range(self.vals)]
|
||||
sqlite.run_test(
|
||||
|
@ -84,15 +81,10 @@ class UpdateTest(BaseModel):
|
|||
f"{self.vals}",
|
||||
)
|
||||
|
||||
stmt = [
|
||||
f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};"
|
||||
for i in range(self.vals)
|
||||
]
|
||||
stmt = [f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};" for i in range(self.vals)]
|
||||
|
||||
expected = [
|
||||
f"{zero_blob}|{t2_val}|{t3_val}"
|
||||
if i != 0
|
||||
else f"{zero_blob}|{t2_update_val}|{t3_val}"
|
||||
f"{zero_blob}|{t2_val}|{t3_val}" if i != 0 else f"{zero_blob}|{t2_update_val}|{t3_val}"
|
||||
for i in range(self.vals)
|
||||
]
|
||||
sqlite.run_test(
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# vfs benchmarking/comparison
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import statistics
|
||||
import argparse
|
||||
import os
|
||||
import statistics
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from time import perf_counter, sleep
|
||||
from typing import Dict
|
||||
|
||||
from cli_tests.console import error, info, test
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from cli_tests.console import info, error, test
|
||||
|
||||
LIMBO_BIN = Path("./target/release/limbo")
|
||||
DB_FILE = Path("testing/temp.db")
|
||||
|
@ -37,9 +37,7 @@ def bench_one(vfs: str, sql: str, iterations: int) -> list[float]:
|
|||
|
||||
for i in range(1, iterations + 1):
|
||||
start = perf_counter()
|
||||
_ = shell.run_test_fn(
|
||||
sql, lambda x: x is not None and append_time(times, start, perf_counter)
|
||||
)
|
||||
_ = shell.run_test_fn(sql, lambda x: x is not None and append_time(times, start, perf_counter))
|
||||
test(f" {vfs} | run {i:>3}: {times[-1]:.6f}s")
|
||||
|
||||
shell.quit()
|
||||
|
@ -60,9 +58,7 @@ def cleanup_temp_db() -> None:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Benchmark a SQL statement against all Limbo VFS back‑ends."
|
||||
)
|
||||
parser = argparse.ArgumentParser(description="Benchmark a SQL statement against all Limbo VFS back‑ends.")
|
||||
parser.add_argument("sql", help="SQL statement to execute (quote it)")
|
||||
parser.add_argument("iterations", type=int, help="number of repetitions")
|
||||
args = parser.parse_args()
|
||||
|
@ -105,9 +101,7 @@ def main() -> None:
|
|||
else:
|
||||
pct = (avg - baseline_avg) / baseline_avg * 100.0
|
||||
faster_slower = "slower" if pct > 0 else "faster"
|
||||
info(
|
||||
f"{vfs:<{name_pad}} : {avg:.6f} ({abs(pct):.1f}% {faster_slower} than {baseline})"
|
||||
)
|
||||
info(f"{vfs:<{name_pad}} : {avg:.6f} ({abs(pct):.1f}% {faster_slower} than {baseline})")
|
||||
info("-" * 60)
|
||||
cleanup_temp_db()
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import tempfile
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pydantic import BaseModel
|
||||
from cli_tests import console
|
||||
from time import sleep
|
||||
|
||||
from cli_tests import console
|
||||
from cli_tests.test_limbo_cli import TestLimboShell
|
||||
from pydantic import BaseModel
|
||||
|
||||
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
|
||||
|
||||
|
@ -46,9 +46,7 @@ class InsertTest(BaseModel):
|
|||
big_stmt = "".join(big_stmt)
|
||||
expected = "\n".join(expected)
|
||||
|
||||
limbo.run_test_fn(
|
||||
big_stmt, lambda res: validate_with_expected(res, expected), self.name
|
||||
)
|
||||
limbo.run_test_fn(big_stmt, lambda res: validate_with_expected(res, expected), self.name)
|
||||
|
||||
def test_compat(self):
|
||||
console.info("Testing in SQLite\n")
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sqlite3
|
||||
|
||||
from faker import Faker
|
||||
|
||||
conn = sqlite3.connect('database.db')
|
||||
conn = sqlite3.connect("database.db")
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Create the user table
|
||||
cursor.execute('''
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY,
|
||||
first_name TEXT,
|
||||
|
@ -20,18 +21,29 @@ cursor.execute('''
|
|||
zipcode TEXT,
|
||||
age INTEGER
|
||||
)
|
||||
''')
|
||||
""")
|
||||
|
||||
cursor.execute('''
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS products (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT,
|
||||
price REAL
|
||||
)
|
||||
''')
|
||||
""")
|
||||
|
||||
product_list = ["hat", "cap", "shirt", "sweater", "sweatshirt",
|
||||
"shorts", "jeans", "sneakers", "boots", "coat", "accessories"]
|
||||
product_list = [
|
||||
"hat",
|
||||
"cap",
|
||||
"shirt",
|
||||
"sweater",
|
||||
"sweatshirt",
|
||||
"shorts",
|
||||
"jeans",
|
||||
"sneakers",
|
||||
"boots",
|
||||
"coat",
|
||||
"accessories",
|
||||
]
|
||||
|
||||
fake = Faker()
|
||||
for _ in range(10000):
|
||||
|
@ -45,18 +57,23 @@ for _ in range(10000):
|
|||
zipcode = fake.zipcode()
|
||||
age = fake.random_int(min=1, max=100)
|
||||
|
||||
cursor.execute('''
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO users (first_name, last_name, email, phone_number, address, city, state, zipcode, age)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''', (first_name, last_name, email, phone_number, address, city, state, zipcode, age))
|
||||
""",
|
||||
(first_name, last_name, email, phone_number, address, city, state, zipcode, age),
|
||||
)
|
||||
|
||||
for product in product_list:
|
||||
price = fake.random_int(min=1, max=100)
|
||||
cursor.execute('''
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO products (name, price)
|
||||
VALUES (?, ?)
|
||||
''', (product, price))
|
||||
|
||||
""",
|
||||
(product, price),
|
||||
)
|
||||
|
||||
|
||||
conn.commit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue