From 98cdc9c2b2da13be2dd1eeb8a3a7493ff98f3157 Mon Sep 17 00:00:00 2001 From: panxiao81 Date: Thu, 10 Sep 2026 09:30:58 +0000 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20=E8=BF=90=E8=A1=8C=20PostgreSQL=20ada?= =?UTF-8?q?pter=20=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 7 +++++++ CONTRIBUTING.md | 4 ++-- docs/development.md | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f8b94b..ddce6ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,5 +30,12 @@ jobs: go mod tidy make test + - name: Running PostgreSQL Integration Tests + run: make test-integration + + - name: Clean up Integration Dependencies + if: always() + run: make dev-down + - name: Verify generated files and modules are current run: git diff --exit-code diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e77bff7..111840f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,8 +65,8 @@ homelab 日常集群。 Gitea Actions 直接使用 `.github/workflows` 中兼容 GitHub Actions 语法的工作流: -- `Tests`:运行生成、格式化、vet、envtest,并检查生成文件和 `go.mod`/`go.sum` - 没有未提交漂移。 +- `Tests`:运行生成、格式化、vet、envtest、一次性 Docker adapter integration tests, + 并检查生成文件和 `go.mod`/`go.sum` 没有未提交漂移。 - `Lint`:校验 golangci-lint 配置并运行静态检查。 - `E2E Tests`:在一次性 Kind 集群中安装 CRD 和 controller,执行端到端验证。 diff --git a/docs/development.md b/docs/development.md index 82d0b7b..2d609c3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -108,7 +108,16 @@ Kubernetes auth、最小 policy 和 ESO 必须在 Kind E2E fixture 中验证。 ### 3. 运行针对临时依赖的测试或 controller -adapter 集成测试加入后,统一通过独立 Make target 执行,不默认塞进快速单元测试。 +adapter 集成测试通过独立 Make target 执行,不默认塞进快速单元测试: + +```sh +make test-integration +``` + +该 target 会启动一次性 Compose 依赖,并通过 `POSTGRES_TEST_DSN` 把测试指向开发 +PostgreSQL。registry 测试会删除并重建固定的测试 schema,因此禁止将该变量指向真实 +homelab database。测试后运行 `make dev-down` 清理依赖。 + 本机运行 controller 时,先确认当前 kubeconfig 指向专用 Kind,而不是真实 homelab: ```sh @@ -157,8 +166,8 @@ E2E fixture 必须把测试 PostgreSQL、OpenBao 和 ESO 部署进 Kind,并等 -> 删除 Kind ``` -当前 controller 尚未实现 PostgreSQL/OpenBao adapter,脚手架 E2E 只能验证 CRD、 -manager Deployment 和 metrics endpoint。上述真实依赖 fixture 应与第一个完整 +当前 controller 只实现 PostgreSQL registry adapter,尚未实现完整 PostgreSQL/OpenBao +provisioning;现有 E2E 只能验证 CRD、manager Deployment 和 metrics endpoint。上述真实依赖 fixture 应与第一个完整 reconcile 纵向切片一起实现,不能在文档中声称已经通过。 ## 测试数据与泄漏检查 From 5ff3cf7282e5e3116544f9e07197f24b677900d5 Mon Sep 17 00:00:00 2001 From: panxiao81 Date: Thu, 10 Sep 2026 16:50:13 +0000 Subject: [PATCH 2/2] fix: connect integration tests to Compose network --- .github/workflows/test.yml | 9 +++++++-- docs/development.md | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddce6ba..99386f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,11 +31,16 @@ jobs: make test - name: Running PostgreSQL Integration Tests - run: make test-integration + run: | + make dev-up + docker network connect postgresql-tenant-operator-dev_default "${HOSTNAME}" + POSTGRES_TEST_DSN="postgres://postgres:postgres-dev-only@postgres:5432/postgres?sslmode=disable" make test-integration - name: Clean up Integration Dependencies if: always() - run: make dev-down + run: | + docker network disconnect postgresql-tenant-operator-dev_default "${HOSTNAME}" || true + make dev-down - name: Verify generated files and modules are current run: git diff --exit-code diff --git a/docs/development.md b/docs/development.md index 2d609c3..cd02f0b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -118,6 +118,11 @@ make test-integration PostgreSQL。registry 测试会删除并重建固定的测试 schema,因此禁止将该变量指向真实 homelab database。测试后运行 `make dev-down` 清理依赖。 +Gitea Actions 的 job 本身运行在 Docker container 中,不能通过 `127.0.0.1` 访问 +Docker host 上发布的 Compose 端口。CI 会暂时将 job container 加入 Compose 网络, +并通过 `postgres:5432` 运行集成测试;清理前先断开该网络,才能删除 Compose +network。本机执行仍使用默认的 `127.0.0.1:15432`。 + 本机运行 controller 时,先确认当前 kubeconfig 指向专用 Kind,而不是真实 homelab: ```sh