test(e2e): smoke test через Testcontainers + fix audit_log.ip_address INET bug

Phase 1 e2e — proof framework работает:
- E2ESupport: Postgres 18 (postgis/postgis:18-3.6) + Kafka (cp-kafka 7.6.0)
  через Testcontainers, reuse=true. db-init.sql создаёт postgis+btree_gist
  расширения которые ожидает Liquibase 0001.
- application-test.yml: тушит cloud-config/vault/otel/outbox publishing,
  включает Liquibase autoconfig. Auth disabled для упрощения.
- SmokeE2ETest: full e2e — POST dictionary → POST record → GET record →
  проверка audit_log row. UUID-suffix в dictName для идемпотентности.
- master.xml: relativeToChangelogFile=true для всех include — иначе
  Liquibase из ordinis-app classpath не находит changes/X.xml в JAR.
- pom.xml: testcontainers 1.21.3, surefire env DOCKER_HOST + DOCKER_API_VERSION
  для macOS Docker Desktop.

Найден реальный prod-баг: audit_log.ip_address был INET, Hibernate JPA не
делает автоматический cast String→INET → INSERT падал. AuditLogger.write
обёрнут в try/catch, поэтому тихо съедал ошибку — на staging audit_log
оставался пустым после CRUD.
- 0012-audit-log-ipaddress-varchar.xml: ALTER COLUMN INET → VARCHAR(64)
- AuditLog entity: убрал columnDefinition="inet", length=64.
This commit is contained in:
Zimin A.N.
2026-05-05 19:16:53 +03:00
parent b58f6f400d
commit f535f7544d
9 changed files with 364 additions and 12 deletions
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.27.xsd">
<!--
Hibernate JPA не делает автоматический cast String→INET при INSERT.
Audit_log.ip_address был INET (см. 0004) — все INSERT'ы падают с
"column is of type inet but expression is of type character varying".
AuditLogger обёрнут в try/catch, поэтому не валит сервис, но audit
тихо не пишется — обнаружено e2e smoke тестом.
INET semantics (range queries, validation) для нас не критичны.
Меняем на VARCHAR(64) — IPv6 максимум 45 символов, запас на всякий.
-->
<changeSet id="0012-1-audit-log-ipaddress-varchar" author="ordinis">
<preConditions onFail="MARK_RAN">
<columnExists tableName="audit_log" columnName="ip_address"/>
</preConditions>
<sql>
ALTER TABLE audit_log
ALTER COLUMN ip_address TYPE VARCHAR(64) USING ip_address::TEXT;
</sql>
<rollback>
<sql>
ALTER TABLE audit_log
ALTER COLUMN ip_address TYPE INET USING ip_address::INET;
</sql>
</rollback>
</changeSet>
</databaseChangeLog>
@@ -5,16 +5,22 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.27.xsd">
<include file="changes/0001-extensions.xml"/>
<include file="changes/0002-dictionary-definitions.xml"/>
<include file="changes/0003-dictionary-records.xml"/>
<include file="changes/0004-audit-log.xml"/>
<include file="changes/0005-outbox-events.xml"/>
<include file="changes/0006-idempotency-keys.xml"/>
<include file="changes/0007-add-version-columns.xml"/>
<include file="changes/0008-fix-scope-check-uppercase.xml"/>
<include file="changes/0009-fix-records-scope-check.xml"/>
<include file="changes/0010-envers-tables.xml"/>
<include file="changes/0011-outbox-dlq.xml"/>
<!--
relativeToChangelogFile=true чтобы пути ресолвились относительно master.xml,
а не от Liquibase searchPath. Иначе при подключении из ordinis-app
(тесты) Liquibase не находит changes/ внутри JAR.
-->
<include file="changes/0001-extensions.xml" relativeToChangelogFile="true"/>
<include file="changes/0002-dictionary-definitions.xml" relativeToChangelogFile="true"/>
<include file="changes/0003-dictionary-records.xml" relativeToChangelogFile="true"/>
<include file="changes/0004-audit-log.xml" relativeToChangelogFile="true"/>
<include file="changes/0005-outbox-events.xml" relativeToChangelogFile="true"/>
<include file="changes/0006-idempotency-keys.xml" relativeToChangelogFile="true"/>
<include file="changes/0007-add-version-columns.xml" relativeToChangelogFile="true"/>
<include file="changes/0008-fix-scope-check-uppercase.xml" relativeToChangelogFile="true"/>
<include file="changes/0009-fix-records-scope-check.xml" relativeToChangelogFile="true"/>
<include file="changes/0010-envers-tables.xml" relativeToChangelogFile="true"/>
<include file="changes/0011-outbox-dlq.xml" relativeToChangelogFile="true"/>
<include file="changes/0012-audit-log-ipaddress-varchar.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>