2026-09-02 15:14:24 +08:00
|
|
|
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',
|
|
|
|
|
'file/src/main/resources/application.yml',
|
|
|
|
|
'finance/src/main/resources/application.yml',
|
|
|
|
|
'firstleg/src/main/resources/application.yml',
|
|
|
|
|
'gateway/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',
|
2026-09-29 18:47:37 +08:00
|
|
|
'config/nacos/test/baiyue-common.yml',
|
2026-09-02 15:14:24 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const composeFiles = [
|
|
|
|
|
'deploy/docker-compose.yml',
|
|
|
|
|
];
|
|
|
|
|
|
2026-09-02 15:30:29 +08:00
|
|
|
const infrastructureComposeFiles = [
|
|
|
|
|
['deploy/docker-compose.rocketmq.yml', 3],
|
|
|
|
|
['docker-compose-infra.yml', 3],
|
|
|
|
|
];
|
|
|
|
|
|
2026-09-02 15:14:24 +08:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-02 15:39:58 +08:00
|
|
|
test('Compose uses one bounded BaoTa-compatible log stream without application log mounts', () => {
|
2026-09-02 15:14:24 +08:00
|
|
|
for (const path of composeFiles) {
|
|
|
|
|
const source = readFileSync(path, 'utf8');
|
2026-09-02 15:39:58 +08:00
|
|
|
assert.match(source, /driver:\s+\$\{DOCKER_LOG_DRIVER:-json-file\}/, path);
|
2026-09-02 15:14:24 +08:00
|
|
|
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/);
|
|
|
|
|
});
|
2026-09-02 15:30:29 +08:00
|
|
|
|
2026-09-02 15:39:58 +08:00
|
|
|
test('infrastructure containers also use bounded BaoTa-compatible logs', () => {
|
2026-09-02 15:30:29 +08:00
|
|
|
for (const [path, expectedServiceCount] of infrastructureComposeFiles) {
|
|
|
|
|
const source = readFileSync(path, 'utf8');
|
|
|
|
|
assert.match(source, /x-bounded-logging:\s+&bounded-logging/, path);
|
2026-09-02 15:39:58 +08:00
|
|
|
assert.match(source, /driver:\s+\$\{DOCKER_LOG_DRIVER:-json-file\}/, path);
|
2026-09-02 15:30:29 +08:00
|
|
|
assert.match(source, /DOCKER_LOG_MAX_SIZE/, path);
|
|
|
|
|
assert.match(source, /DOCKER_LOG_MAX_FILE/, path);
|
|
|
|
|
assert.equal(
|
|
|
|
|
source.match(/logging:\s+\*bounded-logging/g)?.length,
|
|
|
|
|
expectedServiceCount,
|
|
|
|
|
path,
|
|
|
|
|
);
|
2026-09-02 15:39:58 +08:00
|
|
|
assert.doesNotMatch(source, /driver:\s+local/, path);
|
2026-09-02 15:30:29 +08:00
|
|
|
}
|
|
|
|
|
});
|