49 lines
3.2 KiB
Python
49 lines
3.2 KiB
Python
|
|
"""Read-only final audit of this detailed QA run's recorded fixture batches."""
|
||
|
|
import json
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from cleanup_verification import cleanup
|
||
|
|
from verify_cmvr_native import Client, TargetReadOnlyDb, require
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parents[1]
|
||
|
|
|
||
|
|
|
||
|
|
def run():
|
||
|
|
initial = json.loads((ROOT / '.local/deep-qa-batches-first.json').read_text(encoding='utf-8'))
|
||
|
|
prefixes = set(initial['prefixes'])
|
||
|
|
for name in ('all-features-blackbox.json', 'deep-qa-native.json',
|
||
|
|
'resource-scheduling-verification.json', 'deep-qa-scan-only.json',
|
||
|
|
'scanner-workflow-verification.json', 'import-deletion-verification.json'):
|
||
|
|
report = json.loads((ROOT / '.local' / name).read_text(encoding='utf-8'))
|
||
|
|
require(report.get('passed'), 'A prerequisite verification report is not successful: ' + name)
|
||
|
|
prefixes.add(report['prefix'])
|
||
|
|
batches = [dict(prefix=prefix, remaining=cleanup([prefix])['counts']) for prefix in sorted(prefixes)]
|
||
|
|
db = TargetReadOnlyDb(Client())
|
||
|
|
try:
|
||
|
|
def count(sql, parameters=()):
|
||
|
|
return db.select(sql, parameters)[0]['n']
|
||
|
|
remaining = dict(
|
||
|
|
resourceOccupations=count('SELECT COUNT(*) n FROM lab_resource_occupation WHERE deleted=0'),
|
||
|
|
robotOccupations=count('SELECT COUNT(*) n FROM lab_scan_robot_occupation WHERE deleted=0'),
|
||
|
|
activeScannerCommands=count('SELECT COUNT(*) n FROM lab_scanner_command WHERE active_endpoint IS NOT NULL'),
|
||
|
|
isolatedRobots=count('SELECT COUNT(*) n FROM iot_robot WHERE create_by LIKE %s OR create_by LIKE %s', ('E2E-AGV-%','E2E-SCANNER-%')),
|
||
|
|
isolatedDevices=count('SELECT COUNT(*) n FROM iot_device WHERE create_by LIKE %s OR create_by LIKE %s', ('E2E-AGV-%','E2E-SCANNER-%')),
|
||
|
|
taggedQaTasks=count('SELECT COUNT(*) n FROM lab_test_task WHERE deleted=0 AND (external_task_no LIKE %s OR external_task_no LIKE %s OR external_task_no LIKE %s)', ('SCANQA-%','E2E-ALL-%','E2E-SCANNER-%')))
|
||
|
|
demo = db.select('SELECT id,task_no,status FROM lab_test_task WHERE deleted=0 AND external_task_no LIKE %s ORDER BY task_no', ('DEMO-20261022-091650%',))
|
||
|
|
permanent = dict(robot=count('SELECT COUNT(*) n FROM iot_robot WHERE robot_id=%s', ('am-freescan-sim-robot',)),
|
||
|
|
device=count('SELECT COUNT(*) n FROM iot_device WHERE robot_id=%s AND device_id=%s', ('am-freescan-sim-robot','am-freescan-sim-agv')))
|
||
|
|
finally:
|
||
|
|
db.close()
|
||
|
|
report = dict(passed=all(not row['remaining'] for row in batches) and not any(remaining.values()) and
|
||
|
|
len(demo)==2 and all(row['status']=='COMPLETED' for row in demo) and
|
||
|
|
permanent==dict(robot=1,device=1), batches=batches, remaining=remaining,
|
||
|
|
protectedDemoTasks=demo, protectedSimulator=permanent, mutation=False)
|
||
|
|
(ROOT / '.local/deep-qa-cleanup.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf-8')
|
||
|
|
print(json.dumps(dict(passed=report['passed'], auditedBatches=len(batches), remaining=remaining,
|
||
|
|
protectedDemoTasks=len(demo), protectedSimulator=permanent)), flush=True)
|
||
|
|
require(report['passed'], 'Final QA cleanup/preservation audit did not pass')
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
run()
|