feat(database-lab): add local database test environments

This commit is contained in:
二丫讲梵
2026-07-18 22:11:35 +08:00
committed by GitHub
parent 2a65b278e8
commit dda65c0ef0
53 changed files with 1705 additions and 2 deletions
@@ -0,0 +1,19 @@
services:
database:
image: docker.cnb.cool/znb/images/postgres:14.23
container_name: dbx-postgresql-14.23
ports:
- "${DB_BIND_ADDRESS:-127.0.0.1}:${DB_PORT:-5433}:5432"
environment:
POSTGRES_PASSWORD: "${DB_PASSWORD:-123456}"
POSTGRES_DB: dbx
volumes:
- data:/var/lib/postgresql/data
- ./init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d dbx"]
interval: 5s
timeout: 5s
retries: 30
volumes:
data:
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS dbx_smoke (
id BIGSERIAL PRIMARY KEY,
note TEXT NOT NULL,
nullable_value TEXT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_dbx_smoke_note ON dbx_smoke (note);
INSERT INTO dbx_smoke (note, nullable_value) VALUES ('DBX smoke 中文 🚀', NULL);
@@ -0,0 +1,13 @@
{
"database": "postgresql",
"name": "PostgreSQL",
"version": "14.23",
"displayVersion": "14.23",
"image": "docker.cnb.cool/znb/images/postgres:14.23",
"platforms": ["linux/amd64", "linux/arm64"],
"service": "database",
"defaultPort": 5432,
"connection": { "host": "127.0.0.1", "port": 5433, "username": "postgres", "password": "123456", "database": "dbx" },
"shell": ["env", "PGPASSWORD=${DB_PASSWORD}", "psql", "-h", "127.0.0.1", "-p", "5432", "-U", "postgres", "-d", "dbx"],
"smoke": { "steps": [{ "name": "query initialized row over TCP", "command": ["env", "PGPASSWORD=${DB_PASSWORD}", "psql", "-h", "127.0.0.1", "-p", "5432", "-U", "postgres", "-d", "dbx", "-Atc", "SELECT note FROM dbx_smoke WHERE id=1"], "expect": "DBX smoke" }] }
}
@@ -0,0 +1,19 @@
services:
database:
image: docker.cnb.cool/znb/images/postgres:17.4
container_name: dbx-postgresql-17.4
ports:
- "${DB_BIND_ADDRESS:-127.0.0.1}:${DB_PORT:-5433}:5432"
environment:
POSTGRES_PASSWORD: "${DB_PASSWORD:-123456}"
POSTGRES_DB: dbx
volumes:
- data:/var/lib/postgresql/data
- ./init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d dbx"]
interval: 5s
timeout: 5s
retries: 30
volumes:
data:
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS dbx_smoke (
id BIGSERIAL PRIMARY KEY,
note TEXT NOT NULL,
nullable_value TEXT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_dbx_smoke_note ON dbx_smoke (note);
INSERT INTO dbx_smoke (note, nullable_value) VALUES ('DBX smoke 中文 🚀', NULL);
@@ -0,0 +1,13 @@
{
"database": "postgresql",
"name": "PostgreSQL",
"version": "17.4",
"displayVersion": "17.4",
"image": "docker.cnb.cool/znb/images/postgres:17.4",
"platforms": ["linux/amd64", "linux/arm64"],
"service": "database",
"defaultPort": 5432,
"connection": { "host": "127.0.0.1", "port": 5433, "username": "postgres", "password": "123456", "database": "dbx" },
"shell": ["env", "PGPASSWORD=${DB_PASSWORD}", "psql", "-h", "127.0.0.1", "-p", "5432", "-U", "postgres", "-d", "dbx"],
"smoke": { "steps": [{ "name": "query initialized row over TCP", "command": ["env", "PGPASSWORD=${DB_PASSWORD}", "psql", "-h", "127.0.0.1", "-p", "5432", "-U", "postgres", "-d", "dbx", "-Atc", "SELECT note FROM dbx_smoke WHERE id=1"], "expect": "DBX smoke" }] }
}