From 84bcf9bd0f9d919ba94e07b0fe36cf2cfb1e2459 Mon Sep 17 00:00:00 2001 From: rick Date: Wed, 29 Nov 2023 03:40:07 +0000 Subject: [PATCH] test: run e2e testing on all supported databases --- .github/workflows/halo.yaml | 2 +- e2e/Makefile | 6 +++++ e2e/compose-mysql.yaml | 46 +++++++++++++++++++++++++++++++++++ e2e/compose-postgres.yaml | 48 +++++++++++++++++++++++++++++++++++++ e2e/compose.yaml | 29 ---------------------- 5 files changed, 101 insertions(+), 30 deletions(-) create mode 100644 e2e/Makefile create mode 100644 e2e/compose-mysql.yaml create mode 100644 e2e/compose-postgres.yaml diff --git a/.github/workflows/halo.yaml b/.github/workflows/halo.yaml index 46418dafc..fa52b1756 100644 --- a/.github/workflows/halo.yaml +++ b/.github/workflows/halo.yaml @@ -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 diff --git a/e2e/Makefile b/e2e/Makefile new file mode 100644 index 000000000..3339af3fe --- /dev/null +++ b/e2e/Makefile @@ -0,0 +1,6 @@ +all: + ./start.sh + ./start.sh compose-postgres.yaml + ./start.sh compose-mysql.yaml +demo: + docker-compose up halo diff --git a/e2e/compose-mysql.yaml b/e2e/compose-mysql.yaml new file mode 100644 index 000000000..62a9914ab --- /dev/null +++ b/e2e/compose-mysql.yaml @@ -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 diff --git a/e2e/compose-postgres.yaml b/e2e/compose-postgres.yaml new file mode 100644 index 000000000..08f0ce66e --- /dev/null +++ b/e2e/compose-postgres.yaml @@ -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 diff --git a/e2e/compose.yaml b/e2e/compose.yaml index 7e8cb99f6..c7892e962 100644 --- a/e2e/compose.yaml +++ b/e2e/compose.yaml @@ -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