test: run e2e testing on all supported databases

pull/4938/head
rick 2023-11-29 03:40:07 +00:00 committed by Rick
parent e054e9b8a4
commit 84bcf9bd0f
5 changed files with 101 additions and 30 deletions

View File

@ -92,4 +92,4 @@ jobs:
repo=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
docker tag ghcr.io/${repo}/halo-dev:pr-${{ github.event.number }} ghcr.io/halo-dev/halo-dev:main
cd e2e && ./start.sh
cd e2e && make all

6
e2e/Makefile Normal file
View File

@ -0,0 +1,6 @@
all:
./start.sh
./start.sh compose-postgres.yaml
./start.sh compose-mysql.yaml
demo:
docker-compose up halo

46
e2e/compose-mysql.yaml Normal file
View File

@ -0,0 +1,46 @@
version: '3.1'
services:
testing:
build:
context: .
dockerfile: Dockerfile
links:
- halo
depends_on:
halo:
condition: service_healthy
halo:
image: ghcr.io/halo-dev/halo-dev:${TAG:-main}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:mysql://mysql:3306/halo
- --spring.r2dbc.username=root
- --spring.r2dbc.password=halo
- --spring.sql.init.platform=mysql
links:
- mysql
depends_on:
mysql:
condition: service_healthy
mysql:
image: mysql:8.1.0
container_name: mysql
restart: on-failure:3
command:
- --default-authentication-plugin=caching_sha2_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --explicit_defaults_for_timestamp=true
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 10s
timeout: 5s
retries: 5
environment:
- MYSQL_ROOT_PASSWORD=halo
- MYSQL_DATABASE=halo

48
e2e/compose-postgres.yaml Normal file
View File

@ -0,0 +1,48 @@
version: '3.1'
services:
testing:
build:
context: .
dockerfile: Dockerfile
links:
- halo
depends_on:
halo:
condition: service_healthy
halo:
image: ghcr.io/halo-dev/halo-dev:${TAG:-main}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://postgres/halo
- --spring.r2dbc.username=halo
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=openpostgresql
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
# - --halo.external-url=http://localhost:8090/
ports:
- 8090:8090
links:
- postgres
depends_on:
postgres:
condition: service_healthy
postgres:
image: postgres:15.4
container_name: postgres
restart: on-failure:3
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
environment:
- POSTGRES_PASSWORD=openpostgresql
- POSTGRES_USER=halo
- POSTGRES_DB=halo
- PGUSER=halo

View File

@ -17,34 +17,5 @@ services:
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://halodb/halo
- --spring.r2dbc.username=halo
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=openpostgresql
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
# - --halo.external-url=http://localhost:8090/
ports:
- 8090:8090
links:
- postgresql
depends_on:
postgresql:
condition: service_healthy
postgresql:
image: postgres:15.4
container_name: halodb
restart: on-failure:3
ports:
- "5432:5432"
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
environment:
- POSTGRES_PASSWORD=openpostgresql
- POSTGRES_USER=halo
- POSTGRES_DB=halo
- PGUSER=halo