fix(deploy): enforce TEST service memory budgets
This commit is contained in:
@@ -69,7 +69,8 @@ case "$command" in
|
||||
esac
|
||||
`
|
||||
|
||||
async function runDeployment({ imageTag, failingTag, failingStartTag, restartingTag, allowRollback = true, environment = 'test', service = 'audit-service', missingHealth = false, topicPrefix = `${environment}-`, remote = false }) {
|
||||
// 通过临时 Docker/SSH 替身验证环境选择、健康门禁及失败后的镜像恢复。
|
||||
async function runDeployment({ imageTag, failingTag, failingStartTag, restartingTag, allowRollback = true, environment = 'test', service = 'audit-service', missingHealth = false, missingTestLimits = false, topicPrefix = `${environment}-`, remote = false }) {
|
||||
const temporaryDirectory = await mkdtemp(join(tmpdir(), 'firstleg-rollback-'))
|
||||
const mockBin = join(temporaryDirectory, 'bin')
|
||||
const dockerPath = join(mockBin, 'docker')
|
||||
@@ -115,7 +116,7 @@ cp "$1" "\${2#*:}"
|
||||
service,
|
||||
envFile.replaceAll('\\', '/')
|
||||
], {
|
||||
cwd: repositoryRoot,
|
||||
cwd: missingTestLimits ? temporaryDirectory : repositoryRoot,
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
...process.env,
|
||||
@@ -158,6 +159,16 @@ test('successful deployment keeps the new healthy image', async (context) => {
|
||||
assert.match(result.stdout, /部署前运行镜像: registry\.local\/group\/firstleg\/audit-service:oldgood/)
|
||||
assert.match(result.stdout, /新镜像健康检查通过: registry\.local\/group\/firstleg\/audit-service:newgood/)
|
||||
assert.equal(result.currentImage, 'registry.local/group/firstleg/audit-service:newgood')
|
||||
for (const command of result.dockerLog.split(/\r?\n/).filter(line => line.startsWith('compose '))) {
|
||||
assert.match(command, /-f deploy\/docker-compose\.yml -f deploy\/docker-compose\.test-limits\.yml /)
|
||||
}
|
||||
})
|
||||
|
||||
test('TEST rejects a missing memory limits file before Docker', async () => {
|
||||
const result = await runDeployment({ imageTag: 'newgood', missingTestLimits: true })
|
||||
assert.equal(result.status, 2)
|
||||
assert.equal(result.dockerLog, '')
|
||||
assert.match(result.stderr, /TEST memory limits file missing/)
|
||||
})
|
||||
|
||||
test('unhealthy deployment restores the previous healthy image and still fails the job', async (context) => {
|
||||
@@ -232,6 +243,7 @@ test('gray deploy preserves health checks and uses an isolated Compose project',
|
||||
assert.equal(result.status, 0, result.stderr)
|
||||
assert.match(result.dockerLog, /--project-name firstleg-production/)
|
||||
assert.doesNotMatch(result.dockerLog, /--project-name firstleg-test/)
|
||||
assert.doesNotMatch(result.dockerLog, /docker-compose\.test-limits\.yml/)
|
||||
})
|
||||
|
||||
test('gray deployment rejects TEST message scope before any Docker operation', async () => {
|
||||
|
||||
Reference in New Issue
Block a user