完善扫描流式预览、成果归档与PLY/STL查看、补扫历史、执行步骤及日志展示,支持局域网访问和改名节点的原始组件识别。修复试运行终止后的占用释放及未采集时重复暂停SDK的问题,增加终止中交互与回归验证。 验证:后端1114项通过、18项既有跳过;前端109项通过,类型检查及构建通过;Python脚本54项通过;模拟扫描设备7组试运行/终止接口回归通过。
83 lines
5.1 KiB
Python
83 lines
5.1 KiB
Python
"""Exercise execution progress with a tagged, software-only flow; never bind hardware.
|
|
|
|
The optional review handshakes allow browser checks during RUNNING/PAUSED/CANCELLED.
|
|
All generated business rows are cleaned by the exact run prefix in finally.
|
|
"""
|
|
import argparse
|
|
import datetime as dt
|
|
import json
|
|
import time
|
|
import uuid
|
|
from pathlib import Path
|
|
from cleanup_verification import cleanup
|
|
from verify_scan_only import ScanOnlyVerifier
|
|
from verify_cmvr_native import require
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
REVIEW=ROOT/'.local/execution-steps-browser-review.json'
|
|
DONE=REVIEW.with_suffix('.done')
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--review-seconds',type=int,default=0,choices=range(0,121))
|
|
options=parser.parse_args()
|
|
verifier=ScanOnlyVerifier()
|
|
verifier.prefix='E2E-STEPS-'+dt.datetime.now().strftime('%m%d%H%M%S')+'-'+uuid.uuid4().hex[:4]
|
|
verifier.sample_code=verifier.prefix+'-SAMPLE'
|
|
checks=[];passed=False;task=None;execution=None;cleaned={}
|
|
def check(name):
|
|
checks.append(dict(name=name,passed=True));print('PASS '+name,flush=True)
|
|
def review(phase):
|
|
if not options.review_seconds:return
|
|
payload=dict(prefix=verifier.prefix,taskId=str(task),executionId=str(execution),phase=phase)
|
|
REVIEW.write_text(json.dumps(payload),encoding='utf-8')
|
|
print('BROWSER REVIEW '+json.dumps(payload),flush=True)
|
|
deadline=time.monotonic()+options.review_seconds
|
|
while time.monotonic()<deadline:
|
|
if DONE.exists() and DONE.read_text(encoding='utf-8').strip()==verifier.prefix+':'+phase:break
|
|
time.sleep(.3)
|
|
try:
|
|
case=verifier.create_case('execution-progress')
|
|
graph=case['graph']
|
|
graph['nodes']=[n for n in graph['nodes'] if n.get('properties',{}).get('nodeType')!='EDGE']
|
|
graph['nodes'][0]['properties']['resourceRoles']=[]
|
|
warmup=dict(id='prepare-ui',type='sleep',x=350,y=180,properties=dict(name='准备软件验证参数',action='SLEEP',inputParams=[],nodeParams=[dict(name='delayMs',type='input',input='500')]))
|
|
waiting=dict(id='wait-ui',type='sleep',x=600,y=180,properties=dict(name='软件等待(界面验证,不连接设备)',action='SLEEP',inputParams=[],nodeParams=[dict(name='delayMs',type='input',input='300000')]))
|
|
graph['nodes'][1:1]=[warmup,waiting]
|
|
for n in graph['nodes']:
|
|
if n['id']=='code':n['properties']['name']='整理软件验证结果'
|
|
graph['edges']=[dict(id='steps-'+str(i),sourceNodeId=graph['nodes'][i]['id'],targetNodeId=graph['nodes'][i+1]['id']) for i in range(len(graph['nodes'])-1)]
|
|
require(all(n['properties'].get('action') in ('START','END','SLEEP','CODE') for n in graph['nodes']),'Unexpected hardware-capable action')
|
|
verifier.native.publish(case['itemId'],graph,'Software-only progress UI verification')
|
|
task=verifier.import_task('progress-ui',case['caseId'],1)
|
|
detail=verifier.task(task)
|
|
verifier.api('PUT','/lab/scan-task/prepare',dict(taskId=task,expectedRevision=detail['config']['revision'],testCaseId=case['caseId'],sampleReceived=True,requireFixture=False,fixtureConfirmed=False,robotId='',runtimeAssignments=[],runParams={}))
|
|
require(verifier.api('POST','/lab/scan-task/precheck',dict(taskId=task))['passed'],'Software-only precheck failed')
|
|
execution,_=verifier.start(task,verifier.task(task)['units'][0])
|
|
verifier.wait_execution(execution,'RUNNING')
|
|
time.sleep(1.5)
|
|
check('无设备绑定的软件流程启动,后续步骤可由冻结流程读取')
|
|
review('RUNNING')
|
|
verifier.api('POST','/lab/scan-task/pause',dict(taskId=task))
|
|
verifier.wait_execution(execution,'PAUSED');check('执行暂停后状态正确')
|
|
review('PAUSED')
|
|
verifier.api('POST','/lab/scan-task/resume',dict(taskId=task))
|
|
verifier.wait_execution(execution,'RUNNING');check('执行恢复后继续同一执行')
|
|
verifier.api('POST','/lab/scan-task/cancel',dict(taskId=task,reason=verifier.prefix+' UI verification complete'))
|
|
verifier.wait_execution(execution,'CANCELLED');check('执行取消后保留已完成步骤及未执行步骤')
|
|
review('CANCELLED')
|
|
passed=True
|
|
finally:
|
|
if task and verifier.task(task)['task']['status'] not in ('COMPLETED','CANCELLED'):
|
|
verifier.api('POST','/lab/scan-task/cancel',dict(taskId=task,reason=verifier.prefix+' cleanup'))
|
|
cleaned=cleanup([verifier.prefix],apply=True)
|
|
require(not cleanup([verifier.prefix])['counts'],'Tagged progress verification data remains')
|
|
for file in [REVIEW,DONE]:
|
|
if file.exists():file.unlink()
|
|
report=dict(prefix=verifier.prefix,passed=passed,checks=checks,cleanup=cleaned,physicalScannerControlRequests=0)
|
|
(ROOT/'.local/execution-steps-regression-20261026.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
|
verifier.native.db.close()
|
|
print(json.dumps(dict(passed=passed,checks=len(checks),physicalScannerControlRequests=0)),flush=True)
|
|
|
|
if __name__=='__main__':main()
|