Added 'await using sql = new SQL(options)' to all tests that were missing SQL instance creation:
- Escapes, null for int, Helpers in Transaction, Undefined values throws, Null sets to null
- Result is array, Create table, Drop table, null, Unsigned Integer, Signed Integer
- Double, String, MediumInt/Int24, Boolean/TinyInt/BIT, Date, Timestamp, JSON
- bulk insert nested sql()
This fixes ReferenceError: sql is not defined errors that occurred after removing the global SQL instance.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace direct Docker spawning with docker-compose services
- Use mysql_tls and mysql_plain services from docker-compose
- Fix options object to use lazy evaluation for container info
- Remove docker build step as mysql_tls is now built by docker-compose
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove custom Docker container management (startContainer, waitForPostgres, findRandomPort)
- Use docker-compose helper module for container lifecycle
- Switch from postgres_auth to postgres_plain for broader compatibility
- Add host parameter to all connection configurations
- Remove unused imports (exec, promisify, dockerCLI)
This eliminates ~60 lines of Docker management code and makes the tests
more reliable by using the centralized health-checked infrastructure.
This PR consolidates all Docker-based test services into a centralized docker-compose
setup, eliminating per-test container spawning that was causing CI flakiness and
increased costs.
## Problem
- Tests were spawning individual Docker containers for each test suite
- Container startup race conditions caused intermittent test failures
- Docker resource exhaustion ("all predefined address pools have been fully subnetted")
- Redundant container creation increased CI runtime and costs
- No proper health checking led to "Connection refused" errors
## Solution
Implemented a unified docker-compose infrastructure with:
- Centralized service definitions for all test databases and services
- Proper health checks that block until services are ready
- Dynamic port allocation (except Autobahn which requires fixed port 9002)
- Reusable containers across test runs
- Smart health check configuration (only runs during startup, not continuously)
## Changes
### New Docker Infrastructure (`test/docker/`)
- `docker-compose.yml`: Defines all test services with health checks
- `index.ts`: TypeScript helper for programmatic service management
- `config/`: Service configuration files (PostgreSQL auth, Autobahn config)
- `init-scripts/`: Database initialization scripts
- CI script for pre-pulling images to warm Docker cache
### Service Configurations
- **PostgreSQL** (3 variants): plain, TLS, auth
- Health check: `pg_isready -U postgres`
- Dynamic port mapping
- Initialization scripts for test databases and users
- **MySQL** (3 variants): plain, native_password, TLS
- Health check: `mysqladmin ping`
- MySQL 8.0 for native_password (8.4 removed --default-authentication-plugin)
- Fixed user creation issue in auth tests
- **Redis/Valkey** (2 variants): plain, unified (TLS + Unix socket)
- Dynamic port mapping
- Unix socket support for local connections
- **MinIO** (S3-compatible storage)
- Automatic bucket creation
- Dynamic port mapping for both API and console
- **Autobahn** (WebSocket compliance test suite)
- Fixed port 9002 (required due to Host header validation)
- FIXME added for future WebSocket Host header customization
### Test Harness Updates
- `describeWithContainer()` signature changed from `(port: number)` to `(container: { port: number; host: string })`
- Uses `beforeAll()` to ensure container readiness
- Integrates with docker-compose helper module
- Default project name: `bun-test-services`
### Health Check Strategy
- Health checks configured with `interval: 1h` to effectively disable after startup
- `docker compose up --wait` blocks until services are healthy
- `start_period` gives services time to initialize before health checks begin
- Eliminates unreliable `sleep()` calls
## Test Results
All tests passing with new infrastructure:
- PostgreSQL: 792 tests ✅
- MySQL: 184 tests ✅
- Redis/Valkey: 304 tests ✅
- MinIO/S3: 276 tests ✅
- **Total: 1,556 tests passing**
## Performance Improvements
- Container startup: ~5-7s (once per test run) vs ~3-5s per test suite
- Eliminated redundant container creation
- Reduced Docker network allocation pressure
- Tests run faster due to container reuse
## Migration Details
### PostgreSQL Tests
- All variants working (plain, TLS, auth)
- Proper user creation with different auth methods
- TLS certificates mounted correctly
### MySQL Tests
- Fixed "Operation CREATE USER failed" by adding DROP USER IF EXISTS
- Fixed permission issues (GRANT on correct database)
- Downgraded from MySQL 8.4 to 8.0 for native_password plugin support
### S3/MinIO Tests
- Replaced direct Docker spawning with docker-compose
- Automatic bucket creation via `mc` command in container
- 276 S3 tests passing without modifications
### Known Issues
- Autobahn WebSocket tests cause Bun crash (pre-existing bug: `ASSERTION FAILED: m_pendingActivityCount > 0`)
- This is a Bun runtime issue, not related to Docker infrastructure
## Benefits
✅ Eliminates CI flakiness from container startup races
✅ Reduces CI costs through container reuse
✅ Consistent test environment across all runs
✅ Proper service readiness detection
✅ Easier local development (services persist between runs)
✅ No more Docker subnet exhaustion
## Testing
```bash
# Run individual test suites
bun bd test test/js/sql/sql-mysql.test.ts
bun bd test test/js/sql/sql-postgres.test.ts
bun bd test test/js/bun/s3/s3.test.ts
# All services use the same project
docker compose -p bun-test-services ps
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This PR makes connection string parsing more sensible in Bun.SQL,
without breaking the default fallback of postgres
Added some tests checking for connection string precedence
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
### What does this PR do?
Actually run the Timer/TimerZ tests in CI and disable
describeWithContainer in macos
### How did you verify your code works?
CI
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
### How did you verify your code works?
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
### What does this PR do?
handle Int24 to be numbers
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
add `lastInsertRowid` (matching SQLite)
add `affectedRows`
fix `mysql_native_password` deprecated authentication
fix AuthSwitch
Fixes:
https://github.com/oven-sh/bun/issues/22178#issuecomment-3228716080
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Fix handling BIT(1) and BIT(N) on binary protocol and text protocol, now
behavior is consistent
### How did you verify your code works?
Tests
### What does this PR do?
Change tinyint/bool type from mysql to number instead of bool to match
mariadb and mysql2 behavior since tinyint/bool can be bigger than 1 in
mysql
Fixes https://github.com/oven-sh/bun/issues/22158
### How did you verify your code works?
Test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Support the following:
```javascript
const nom = await sql`SELECT name FROM food WHERE category IN ${sql(['bun', 'baozi', 'xiaolongbao'])}`;
```
Previously, only e.g., `sql([1, 2, 3])` was supported.
To be honest I'm not sure what the semantics of SQLHelper *ought* to be.
I'm pretty sure objects ought to be auto-inferred. I'm not sure about
arrays, but given the rest of the code in `SQLHelper` trying to read the
tea leaves on stringified numeric keys I figured someone cared about
this use case. I don't know about other types, but I'm pretty sure that
`Object.keys("bun") === [0, 1, 2]` is an oversight and unintended.
(Incidentally, the reason numbers previously worked is because
`Object.keys(4) === []`). I decided that all non-objects and non-arrays
should be treated as not having auto-inferred columns.
Fixes#18637
### How did you verify your code works?
I wrote a test, but was unable to run it (or any other tests in this
file) locally due to Docker struggles. I sure hope it works!
### What does this PR do?
Fixes#20729
### How did you verify your code works?
There is a test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Add MySQL support, Refactor will be in a followup PR
### How did you verify your code works?
A lot of tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
### What does this PR do?
Support sqlite in the Bun.sql API
Fixes#18951Fixes#19701
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
### What does this PR do?
We should not call .deinit() after .toJS otherwise hasPendingActivity
will access invalid memory
### How did you verify your code works?
Test run it with debug build on macos or asan on and will catch it
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Fix: https://github.com/oven-sh/bun/issues/21351
Relevant changes:
Fix advance to properly cleanup success and failed queries that could be
still be in the queue
Always ref before executing
Use stronger atomics for ref/deref and hasPendingActivity
Fallback when thisValue is freed/null/zero and check if vm is being
shutdown
The bug in --hot in `resolveRopeIfNeeded` Issue is not meant to be fixed
in this PR this is a fix for the postgres regression
Added assertions so this bug is easier to catch on CI
### How did you verify your code works?
Test added
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>