fix(deploy): eliminate duplicate container log writes
This commit is contained in:
@@ -131,6 +131,7 @@ node scripts/create-pending-review-orders.mjs
|
||||
| Mapper 注册静态合同 | `node scripts/mapper-scan-contract.mjs`、`node --test scripts/mapper-scan-contract.test.mjs`;自动核对全部持久化模块的 `@Mapper`、服务根包注解过滤扫描和唯一扫描入口,不启动 Spring、不连接数据库;`backend-full-regression.ps1` 在 Maven 前强制执行 |
|
||||
| Java 质量聚合摘要 | `node --test scripts/java-quality-summary.test.mjs`、`node scripts/java-quality-summary.mjs --output target/java-quality-summary.json`;聚合 Maven/服务拓扑、OpenAPI 覆盖、JaCoCo 和 SpotBugs 报告,默认只报告存量缺口,CI 用显式 `--require-jacoco --require-spotbugs` 检查报告完整性且当前允许失败 |
|
||||
| 单服务部署失败回滚合同 | `scripts/deploy-built-service-rollback.test.mjs`;模拟成功、健康失败和启动失败,确认仅恢复同服务先前健康镜像且部署任务仍失败 |
|
||||
| 容器日志单写合同 | `scripts/container-logging-contract.test.mjs`;离线确认应用只写标准输出、Compose 使用有界 `local` 驱动且不挂载应用日志目录 |
|
||||
|
||||
Admin/Client HTTP 脚本的离线合同只验证脚本结构、参数和模块边界,不访问测试环境:
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { test } from 'node:test';
|
||||
|
||||
const applicationConfigs = [
|
||||
'auth/src/main/resources/application.yml',
|
||||
'audit-service/src/main/resources/application.yml',
|
||||
'event-bridge-service/src/main/resources/application.yml',
|
||||
'file/src/main/resources/application.yml',
|
||||
'finance/src/main/resources/application.yml',
|
||||
'firstleg/src/main/resources/application.yml',
|
||||
'gateway/src/main/resources/application.yml',
|
||||
'gateway-overseas/src/main/resources/application.yml',
|
||||
'iam/src/main/resources/application.yml',
|
||||
'integration-service/src/main/resources/application.yml',
|
||||
'lastleg-service/src/main/resources/application.yml',
|
||||
'order/src/main/resources/application.yml',
|
||||
'print/src/main/resources/application.yml',
|
||||
'warehouse/src/main/resources/application.yml',
|
||||
'warehouse-overseas-service/src/main/resources/application.yml',
|
||||
'config/nacos/cn/baiyue-common.yml',
|
||||
'config/nacos/local/baiyue-common.yml',
|
||||
'config/nacos/overseas/baiyue-common.yml',
|
||||
];
|
||||
|
||||
const composeFiles = [
|
||||
'deploy/docker-compose.yml',
|
||||
'deploy/docker-compose.overseas.yml',
|
||||
];
|
||||
|
||||
test('deployable applications log only to stdout and stderr', () => {
|
||||
for (const path of applicationConfigs) {
|
||||
const source = readFileSync(path, 'utf8');
|
||||
assert.doesNotMatch(source, /LOG_PATH|LOGGING_FILE_NAME|LOGGING_ROLLING/, path);
|
||||
}
|
||||
});
|
||||
|
||||
test('Compose uses one bounded local log stream without application log mounts', () => {
|
||||
for (const path of composeFiles) {
|
||||
const source = readFileSync(path, 'utf8');
|
||||
assert.match(source, /driver:\s+local/, path);
|
||||
assert.match(source, /DOCKER_LOG_MAX_SIZE/, path);
|
||||
assert.match(source, /DOCKER_LOG_MAX_FILE/, path);
|
||||
assert.doesNotMatch(source, /LOG_PATH|LOG_ROOT|\/app\/logs/, path);
|
||||
}
|
||||
|
||||
const domesticCompose = readFileSync(composeFiles[0], 'utf8');
|
||||
assert.match(domesticCompose, /FILE_UPLOADS_HOST_DIR[^\n]+:\/data\/files/);
|
||||
});
|
||||
|
||||
test('runtime image does not prepare an application log directory', () => {
|
||||
const dockerfile = readFileSync('deploy/docker/Dockerfile', 'utf8');
|
||||
assert.doesNotMatch(dockerfile, /\/app\/logs/);
|
||||
});
|
||||
Reference in New Issue
Block a user