Server Pattern Tests¶
There are 6 tests covering three access patterns: standalone embedded, server-managed embedded, and HTTP API (remote access). All tests validate expected usage flows and performance characteristics.
The 3 Access Patterns¶
- Standalone:
db = arcadedb.create_database("./mydb")— simplest, no server overhead - Server-managed:
server.start()→db = server.create_database()— HTTP API available simultaneously - HTTP API:
requests.post(url, json=...)— remote/cross-process access
Test Cases¶
1) recommended server pattern¶
Starts server first, creates database through server, and validates both embedded access and HTTP availability. Asserts connection to studio URL and data retrieval via Java API.
2) thread safety¶
Creates server-managed database with 20 items, then spawns 5 threads concurrently querying ranges. Asserts all threads access successfully without errors.
3) context manager¶
Uses with arcadedb.create_server(...) as server: for automatic start/stop, creates database, inserts note, verifies count.
4) pattern 1: embedded first requires close¶
Creates a database in standalone embedded mode and populates it, then closes it to release the file lock, moves it into the server's databases/ directory, starts the server, and accesses it via server.get_database(...). Demonstrates that the embedded database MUST be closed before the server can access it.
5) embedded performance comparison¶
Creates both standalone and server-managed databases with 500 complex multi-field records and runs 100 varied queries (filters, aggregations, date ranges, LIKE patterns). Measures time and ops/sec. Asserts server-managed performance is similar (within 1.5x, typically 0.99x) to standalone. Validates that embedded access through server is direct JVM call, not HTTP.
6) HTTP API access pattern¶
Starts server, creates database via Java API (HTTP API lacks create), inserts 5 products via HTTP, queries via HTTP (returns JSON), performs 100 mixed CRUD ops (inserts, filtered queries, updates, aggregations, LIKE searches) via both HTTP and Java API. Records time and ops/sec. Calculates ratio (HTTP typically 5–7x slower) and per-op overhead (~0.7–1ms). Uses requests.Session() with auth for realistic connection pooling.
Quick Patterns¶
Just need a database:
Need HTTP API available:
server = arcadedb.create_server(root_path="./databases")
server.start()
db = server.create_database("mydb")
# Java API is direct JVM call (0.99x perf of standalone)
# HTTP also available at http://localhost:2480
Pre-populating before server:
db = arcadedb.create_database("./temp_db")
# ... populate ...
db.close() # ⚠️ Release file lock!
# Move to server directory, then start server
Remote/HTTP access: