From 92286e18deda853a73574583fb0ebde5d691ce38 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Mon, 21 Sep 2026 00:09:59 +0800 Subject: [PATCH] disable blue-green deployment in test environment --- deploy/scripts/deploy-built-service.sh | 6 ++---- deploy/scripts/deploy-services.sh | 2 +- scripts/blue-green-deployment-contract.test.mjs | 9 ++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/deploy/scripts/deploy-built-service.sh b/deploy/scripts/deploy-built-service.sh index b4062334b..a658d1e77 100644 --- a/deploy/scripts/deploy-built-service.sh +++ b/deploy/scripts/deploy-built-service.sh @@ -348,8 +348,7 @@ deploy_local() { if [ "${TARGET_IS_LOCAL:-false}" = "true" ]; then echo "镜像已在目标服务器本机,直接部署: $IMAGE" - if [ "$DEPLOY_ENV" = "production" ] \ - || { [ "$DEPLOY_ENV" = "test" ] && [ "$SERVICE" != "gateway" ] && [ "$SERVICE" != "gateway-overseas" ]; }; then + if [ "$DEPLOY_ENV" = "production" ]; then printf '%s' "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY_HOST" trap local_registry_logout EXIT HUP INT TERM docker pull "$IMAGE" @@ -433,8 +432,7 @@ printf '%s' "$REGISTRY_PASSWORD" | run_ssh docker login -u "$REGISTRY_USER" --pa trap remote_registry_logout EXIT HUP INT TERM run_ssh docker pull "$IMAGE" -if [ "$DEPLOY_ENV" = "production" ] \ - || { [ "$DEPLOY_ENV" = "test" ] && [ "$SERVICE" != "gateway" ] && [ "$SERVICE" != "gateway-overseas" ]; }; then +if [ "$DEPLOY_ENV" = "production" ]; then echo "$DEPLOY_ENV 服务使用蓝绿执行器,旧实例在候选槽健康前保持运行" run_ssh sh "$REMOTE_DIR/$REMOTE_BLUE_GREEN_NAME" \ "$DEPLOY_ENV" "$IMAGE_REPOSITORY" "$IMAGE_TAG" "$SERVICE" \ diff --git a/deploy/scripts/deploy-services.sh b/deploy/scripts/deploy-services.sh index 5880075cf..8c720a1fe 100644 --- a/deploy/scripts/deploy-services.sh +++ b/deploy/scripts/deploy-services.sh @@ -195,7 +195,7 @@ if [ "$DEPLOY_ENV" = "test" ] || [ "$DEPLOY_ENV" = "production" ]; then -f "$COMPOSE_FILE" \ pull $SERVICES for service in $SERVICES; do - if [ "$DEPLOY_ENV" = test ] && { [ "$service" = gateway ] || [ "$service" = gateway-overseas ]; }; then + if [ "$DEPLOY_ENV" = test ]; then docker compose --project-name "$PROJECT_NAME" --env-file "$ENV_FILE" -f "$COMPOSE_FILE" \ up -d --no-deps --pull never "$service" continue diff --git a/scripts/blue-green-deployment-contract.test.mjs b/scripts/blue-green-deployment-contract.test.mjs index cfc60686d..4b23368d2 100644 --- a/scripts/blue-green-deployment-contract.test.mjs +++ b/scripts/blue-green-deployment-contract.test.mjs @@ -90,13 +90,12 @@ test('production single-service pipeline dispatches the blue-green executor', as assert.match(deploy, /if \[ "\$DEPLOY_ENV" = "production" \]/) assert.match(deploy, /run_ssh sh "\$REMOTE_DIR\/\$REMOTE_BLUE_GREEN_NAME"/) assert.match(deploy, /TARGET_IS_LOCAL[\s\S]*?deploy-blue-green-service\.sh/) - assert.match(batch, /if \[ "\$DEPLOY_ENV" = "test" \] \|\| \[ "\$DEPLOY_ENV" = "production" \][\s\S]*?deploy-blue-green-service\.sh/) + assert.match(batch, /sh deploy\/scripts\/deploy-blue-green-service\.sh/) }) -test('test business services use blue-green while test gateways retain their fixed entry ports', async () => { +test('test environment uses single-slot compose updates', async () => { const deploy = await read('deploy/scripts/deploy-built-service.sh') const batch = await read('deploy/scripts/deploy-services.sh') - assert.match(deploy, /\[ "\$DEPLOY_ENV" = "test" \][\s\S]*?\[ "\$SERVICE" != "gateway" \]/) - assert.match(batch, /\[ "\$DEPLOY_ENV" = "test" \] \|\| \[ "\$DEPLOY_ENV" = "production" \]/) - assert.match(batch, /\[ "\$service" = gateway \] \|\| \[ "\$service" = gateway-overseas \]/) + assert.doesNotMatch(deploy, /if \[ "\$DEPLOY_ENV" = "test" \] \\\n\s*\|\|[\s\S]*?deploy-blue-green-service\.sh/) + assert.match(batch, /if \[ "\$DEPLOY_ENV" = test \]; then[\s\S]*?up -d --no-deps --pull never "\$service"/) })