From 03f9aa7ee8babba08e3a3bea0a5c383ad5f67384 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 23:36:06 +0800 Subject: [PATCH] chore: write SMS smoke launch artifact directly --- .../production-launch-evidence.template.json | 2 +- .../web-launch-acceptance-checklist.md | 2 +- scripts/deploy/README.md | 4 ++-- scripts/remote-sms-login-smoke-test.js | 17 +++++++++++-- scripts/remote-sms-login-smoke.js | 24 +++++++++++++++++-- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/docs/refactor/production-launch-evidence.template.json b/docs/refactor/production-launch-evidence.template.json index a0f763e5..43d31bc4 100644 --- a/docs/refactor/production-launch-evidence.template.json +++ b/docs/refactor/production-launch-evidence.template.json @@ -57,7 +57,7 @@ { "id": "auth.sms-pnvs-remote-smoke", "status": "pass", - "command": "SMS_SMOKE_API_BASE_URL=https://api.example.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-real-phone SMS_SMOKE_ORIGIN=https://admin.example.com npm run smoke:sms-login:remote -- --json > docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json", + "command": "SMS_SMOKE_API_BASE_URL=https://api.example.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-real-phone SMS_SMOKE_ORIGIN=https://admin.example.com npm run smoke:sms-login:remote -- --write docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json", "completedAt": "2026-06-30T10:12:00+08:00", "artifact": "launch-artifacts/sms-pnvs-remote-smoke.json", "summary": { diff --git a/docs/refactor/web-launch-acceptance-checklist.md b/docs/refactor/web-launch-acceptance-checklist.md index 35297c59..354c3808 100644 --- a/docs/refactor/web-launch-acceptance-checklist.md +++ b/docs/refactor/web-launch-acceptance-checklist.md @@ -110,7 +110,7 @@ SMS_SMOKE_API_BASE_URL=https://api.tjszsb.com \ SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 \ SMS_SMOKE_PHONE=13800138000 \ SMS_SMOKE_ORIGIN=https://admin.tjszsb.com \ -npm run smoke:sms-login:remote -- --json > docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json +npm run smoke:sms-login:remote -- --write docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json ``` PNVS 只验收手机号登录/换绑验证码链路。催缴、营销、CRM 等非验证码短信不应接 PNVS;平台催缴通知仍按 webhook 类通知渠道验收。 diff --git a/scripts/deploy/README.md b/scripts/deploy/README.md index efa081e1..6a7c5ac6 100644 --- a/scripts/deploy/README.md +++ b/scripts/deploy/README.md @@ -335,14 +335,14 @@ npm run readiness:production ```bash npm run readiness:production:db npm run smoke:auth:remote -SMS_SMOKE_API_BASE_URL=https://api.tjszsb.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-real-phone SMS_SMOKE_ORIGIN=https://admin.tjszsb.com npm run smoke:sms-login:remote -- --json > docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json +SMS_SMOKE_API_BASE_URL=https://api.tjszsb.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-real-phone SMS_SMOKE_ORIGIN=https://admin.tjszsb.com npm run smoke:sms-login:remote -- --write docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json npm run perf:api:local ``` 如果要同时验证手机号绑定也走 PNVS provider verification,准备一个未绑定测试手机号后执行: ```bash -SMS_SMOKE_API_BASE_URL=https://api.tjszsb.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-login-phone SMS_SMOKE_BIND_PHONE=replace-with-bind-phone SMS_SMOKE_ORIGIN=https://admin.tjszsb.com npm run smoke:sms-login:remote -- --json > docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json +SMS_SMOKE_API_BASE_URL=https://api.tjszsb.com SMS_SMOKE_TENANT_ID=00000000-0000-0000-0000-000000000001 SMS_SMOKE_PHONE=replace-with-login-phone SMS_SMOKE_BIND_PHONE=replace-with-bind-phone SMS_SMOKE_ORIGIN=https://admin.tjszsb.com npm run smoke:sms-login:remote -- --write docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json ``` 压测必须在目标云服务器、目标数据库参数、目标对象存储和目标 Nginx 配置下重新计算,本地 Windows 压测数据只能作为开发参考。 diff --git a/scripts/remote-sms-login-smoke-test.js b/scripts/remote-sms-login-smoke-test.js index 3a372e10..339f79b0 100644 --- a/scripts/remote-sms-login-smoke-test.js +++ b/scripts/remote-sms-login-smoke-test.js @@ -1,5 +1,8 @@ import assert from 'node:assert/strict'; +import fs from 'node:fs'; import http from 'node:http'; +import os from 'node:os'; +import path from 'node:path'; import { spawn } from 'node:child_process'; import { runRemoteSmsLoginSmoke } from './remote-sms-login-smoke.js'; @@ -78,7 +81,9 @@ await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); function runCliSmoke(address) { return new Promise(resolve => { - const child = spawn(process.execPath, ['scripts/remote-sms-login-smoke.js', '--json'], { + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tiku-sms-smoke-')); + const writePath = path.join(tempDir, 'nested', 'sms-pnvs-remote-smoke.json'); + const child = spawn(process.execPath, ['scripts/remote-sms-login-smoke.js', '--json', '--write', writePath], { cwd: process.cwd(), env: { ...process.env, @@ -95,7 +100,12 @@ function runCliSmoke(address) { let stderr = ''; child.stdout.on('data', chunk => { stdout += chunk.toString('utf8'); }); child.stderr.on('data', chunk => { stderr += chunk.toString('utf8'); }); - child.on('close', status => resolve({ status, stdout, stderr })); + child.on('close', status => { + let artifact = ''; + if (fs.existsSync(writePath)) artifact = fs.readFileSync(writePath, 'utf8'); + fs.rmSync(tempDir, { recursive: true, force: true }); + resolve({ status, stdout, stderr, artifact }); + }); }); } @@ -133,9 +143,12 @@ try { const cliResult = await runCliSmoke(address); assert.equal(cliResult.status, 0, `CLI --json smoke should pass: ${cliResult.stdout} ${cliResult.stderr}`); const cliSummary = JSON.parse(cliResult.stdout); + const artifactSummary = JSON.parse(cliResult.artifact); assert.equal(cliSummary.provider, 'aliyun-pnvs'); assert.equal(cliSummary.bindProvider, 'aliyun-pnvs'); + assert.deepEqual(artifactSummary, cliSummary); assert.doesNotMatch(cliResult.stdout, /Enter received/, 'CLI --json stdout must stay machine-readable JSON'); + assert.doesNotMatch(cliResult.artifact, /Enter received/, 'CLI --write artifact must stay machine-readable JSON'); console.log('[PASS] remote SMS login smoke script'); } finally { await new Promise(resolve => server.close(resolve)); diff --git a/scripts/remote-sms-login-smoke.js b/scripts/remote-sms-login-smoke.js index 0872dcb6..d68079ce 100644 --- a/scripts/remote-sms-login-smoke.js +++ b/scripts/remote-sms-login-smoke.js @@ -1,4 +1,6 @@ import { createInterface } from 'node:readline/promises'; +import fs from 'node:fs'; +import path from 'node:path'; import { stdin as input, stdout as output, stderr } from 'node:process'; import { fileURLToPath, pathToFileURL } from 'node:url'; @@ -14,10 +16,21 @@ function envNumber(env, key, fallback) { } function parseArgs(argv) { - return { + const options = { json: argv.includes('--json'), quiet: argv.includes('--quiet'), + writePath: '', }; + for (let index = 0; index < argv.length; index += 1) { + const arg = argv[index]; + if (arg === '--write') { + options.writePath = argv[index + 1] || ''; + index += 1; + } else if (arg.startsWith('--write=')) { + options.writePath = arg.slice('--write='.length); + } + } + return options; } function normalizeBaseUrl(value) { @@ -216,7 +229,13 @@ async function runRemoteSmsLoginSmoke(inputConfig, options = {}) { async function main() { const options = parseArgs(process.argv.slice(2)); try { - const result = await runRemoteSmsLoginSmoke({ ...buildConfig(), jsonOutput: options.json }, { quiet: options.quiet || options.json }); + const machineOutput = options.json || Boolean(options.writePath); + const result = await runRemoteSmsLoginSmoke({ ...buildConfig(), jsonOutput: machineOutput }, { quiet: options.quiet || machineOutput }); + if (options.writePath) { + const resolvedPath = path.resolve(process.cwd(), options.writePath); + fs.mkdirSync(path.dirname(resolvedPath), { recursive: true }); + fs.writeFileSync(resolvedPath, `${JSON.stringify(result.summary, null, 2)}\n`, 'utf8'); + } if (options.json) console.log(JSON.stringify(result.summary, null, 2)); } catch (error) { if (options.json) { @@ -240,6 +259,7 @@ Optional: SMS_SMOKE_BIND_CODE= SMS_SMOKE_SKIP_SEND=true --json + --write docs/refactor/launch-artifacts/sms-pnvs-remote-smoke.json `); } process.exitCode = 1;