Focused matrix and cleanup checks pass. Native Superset error/recovery acceptance and final semantic freeze remain open; this is not release GO.
71 lines
3.7 KiB
Python
71 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
# #region Tooling.ChartHealth.NativeCanary [C:4] [TYPE Module] [SEMANTICS local,isolated,recovery,privileged]
|
|
# @PRE Parent authorizes access to the existing isolated laboratory; no build/deploy/data mutation is performed.
|
|
# @POST Error and recovered phases run real production observer checks; recovery is attempted in finally even if error check fails.
|
|
import argparse
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
# #region Tooling.ChartHealth.NativeCanary.Seed [C:3] [TYPE Function]
|
|
# @POST Only native namespaced metric metadata changes; captured Superset startup logs/credentials are never emitted.
|
|
def seed(env_file, phase):
|
|
command = ['docker','compose','-p','ss-tools-full-flow','--env-file',str(env_file),
|
|
'-f','docker-compose.full-flow.yml','-f','docker-compose.full-flow.finance.yml',
|
|
'exec','-T','superset-preprod','/app/.venv/bin/python','/fixture/chart_health_canary_seed.py','--phase',phase]
|
|
result = subprocess.run(command,cwd=ROOT,capture_output=True,text=True,timeout=120)
|
|
if result.returncode:
|
|
raise RuntimeError(f'CHART_HEALTH_NATIVE_SEED_FAILED_{result.returncode}')
|
|
records = [json.loads(line) for line in result.stdout.splitlines() if line.startswith('{"phase":')]
|
|
if len(records) != 1:
|
|
raise RuntimeError('CHART_HEALTH_NATIVE_SEED_IDENTITY_UNAVAILABLE')
|
|
return records[0]
|
|
# #endregion Tooling.ChartHealth.NativeCanary.Seed
|
|
|
|
|
|
# #region Tooling.ChartHealth.NativeCanary.Verify [C:3] [TYPE Function]
|
|
# @POST Test output and phase result are retained separately; a failure is not relabeled PASS.
|
|
def verify(args, record):
|
|
environment = {**os.environ,'CHART_HEALTH_NATIVE_ENV_FILE':str(args.env_file),
|
|
'CHART_HEALTH_NATIVE_URL':'http://127.0.0.1:18112','CHART_HEALTH_NATIVE_DASHBOARD_ID':str(record['dashboard_id']),
|
|
'CHART_HEALTH_NATIVE_PHASE':record['phase'],'CHART_HEALTH_NATIVE_OUTPUT':str(args.output/record['phase'])}
|
|
leaf = 'test_chart_health_native_dom_worker.py' if args.diagnose else 'test_chart_health_native_canary.py'
|
|
command = [str(ROOT/'backend/.venv/bin/python'),'-m','pytest','-q','--run-integration',
|
|
f'tests/services/dashboard_testing/registry/{leaf}']
|
|
result = subprocess.run(command,cwd=ROOT/'backend',env=environment,capture_output=True,text=True,timeout=700)
|
|
(args.output/f'{record["phase"]}-pytest.log').write_text(result.stdout+result.stderr)
|
|
return result.returncode
|
|
# #endregion Tooling.ChartHealth.NativeCanary.Verify
|
|
|
|
|
|
# #region Tooling.ChartHealth.NativeCanary.Main [C:4] [TYPE Function]
|
|
# @POST A fresh evidence directory preserves both phases; only both actual checks yield exit0.
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--env-file',type=Path,required=True)
|
|
parser.add_argument('--output',type=Path,required=True)
|
|
parser.add_argument('--diagnose',action='store_true')
|
|
args = parser.parse_args()
|
|
args.output = args.output.resolve()
|
|
args.output.mkdir(parents=True,exist_ok=False)
|
|
results = {'error':None,'recovered':None}
|
|
try:
|
|
record = seed(args.env_file,'error')
|
|
results['error'] = verify(args,record)
|
|
finally:
|
|
record = seed(args.env_file,'recovered')
|
|
results['recovered'] = verify(args,record)
|
|
(args.output/'phase-results.json').write_text(json.dumps(results,indent=2))
|
|
print(json.dumps({'scope':'native DOM diagnostic only' if args.diagnose else 'isolated native canary','phase_exit_codes':results}))
|
|
return 0 if results == {'error':0,'recovered':0} else 1
|
|
# #endregion Tooling.ChartHealth.NativeCanary.Main
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|
|
# #endregion Tooling.ChartHealth.NativeCanary
|