v0.11.0 harden persistence and prepare game replays

This commit is contained in:
2026-09-07 14:39:00 -04:00
parent 21dea47694
commit 5d2be4abb2
42 changed files with 3591 additions and 693 deletions
+16 -11
View File
@@ -8,7 +8,7 @@ This directory contains comprehensive test suites for the Chess API server, cove
- `curl` - HTTP client
- `sqlite3` - SQLite CLI (for database tests)
- `base64` - Base64 encoder (for JWT tests)
- Compiled `chessd` binary in accessible path
- Compiled `bin/chess-server` binary (or pass another path to the scripts)
## Running the test server
From repo root
@@ -16,17 +16,21 @@ From repo root
test/run-test-server.sh
```
Pass binary path as first argument of the script if it's not placed in current directory `./chessd`.
Server will run with '-dev' option, enabling db WAL mode and relaxing rate limiting.
Pass the binary path as the first argument when it is not at `bin/chess-server`.
The server runs with `-dev`, debug logging, HTTP request logging, and relaxed rate limiting. WAL is enabled for every persistent server mode.
Will clean up test database and temporary files, so it's preferred for clean testing.
Can be used for all the tests.
Logging can be adjusted without editing the script:
```bash
LOG_LEVEL=info LOG_HTTP=false test/run-test-server.sh bin/chess-server
```
### Pre-configured Users
| Username | Password | Email |
|----------|----------|-------|
| alice | AlicePass123 | alice@example.com |
| bob | BobPass456 | bob@example.com |
| charlie | CharliePass789 | - |
### Features
- Automatically initializes database schema
@@ -34,6 +38,7 @@ Can be used for all the tests.
- Runs on port 8080 (API) and 9090 (Web UI)
- Development mode with relaxed rate limits
- Fixed JWT secret for consistent tokens
- Debug persistence and engine-queue logs by default
- Graceful shutdown on Ctrl+C
### Manual Testing Examples
@@ -67,8 +72,8 @@ Tests core game mechanics and API endpoints.
### Running the test
```bash
# Terminal 1: Start server in development mode
test/run-test-server.sh ./chessd
# Direct (no cleanup required): ./chessd -dev
test/run-test-server.sh bin/chess-server
# Direct (no cleanup required): bin/chess-server -dev
# Terminal 2: Run API tests
test/test-api.sh
@@ -92,11 +97,11 @@ Tests user management, authentication, and persistence via API integration.
### Running the test
```bash
# Terminal 1: Start test server with database
# Server is running with -dev option (WAL mode db)
test/test-db-server.sh ./chessd
# Server is running with -dev and persistent WAL storage
test/test-db-server.sh bin/chess-server
# Terminal 2: Run API integration tests
test/test-db.sh ./chessd
test/test-db.sh bin/chess-server
```
### Coverage
@@ -123,8 +128,8 @@ Tests real-time game updates via HTTP long-polling.
### Running the test
```bash
# Terminal 1: Start server with storage
test/run-test-server.sh ./chessd
# Direct (test.db cleanup required): ./chessd -dev -storage-path test.db
test/run-test-server.sh bin/chess-server
# Direct (test.db cleanup required): bin/chess-server -dev -storage-path test.db
# Terminal 2: Run long-polling tests
test/test-longpoll.sh
+10 -5
View File
@@ -7,6 +7,8 @@ CHESS_SERVER_EXEC=${1:-"bin/chess-server"}
TEST_DB="test.db"
PID_FILE="/tmp/chess-server_test.pid"
API_PORT=${API_PORT:-8080}
LOG_LEVEL=${LOG_LEVEL:-debug}
LOG_HTTP=${LOG_HTTP:-true}
# Colors for output
GREEN='\033[0;32m'
@@ -18,7 +20,7 @@ NC='\033[0m'
# Check executable
if [ ! -x "$CHESS_SERVER_EXEC" ]; then
echo -e "${RED}Error: chess-server executable not found or not executable: $CHESS_SERVER_EXEC${NC}"
echo "Provide the path to chess-server binary as first argument or place it in the current directory."
echo "Provide the path to chess-server as the first argument or build bin/chess-server."
echo "Build the binary if not available: go build ./cmd/chess-server"
exit 1
fi
@@ -90,7 +92,8 @@ echo "Configuration:"
echo " Executable: $CHESS_SERVER_EXEC"
echo " Database: $TEST_DB"
echo " Port: $API_PORT"
echo " Mode: Development (WAL enabled, relaxed rate limits)"
echo " Mode: Development (relaxed rate limits; persistent WAL storage)"
echo " Log level: $LOG_LEVEL (HTTP requests: $LOG_HTTP)"
echo " Purpose: Backend for chess-server tests"
echo " PID File: $PID_FILE"
echo ""
@@ -105,8 +108,10 @@ echo ""
# Start chess-server in foreground with dev mode and storage
"$CHESS_SERVER_EXEC" \
-dev \
-storage-path "$TEST_DB" \
-dev \
-log-level "$LOG_LEVEL" \
-log-http="$LOG_HTTP" \
-storage-path "$TEST_DB" \
-api-port "$API_PORT" \
-pid "$PID_FILE" \
-pid-lock
-pid-lock