24 lines
1.4 KiB
Python
24 lines
1.4 KiB
Python
"""Run OT dotnet tests against the explicitly owned loopback SQL fixture only.
|
|
|
|
The state file is private and never copied into source/evidence. Password values
|
|
are placed in the child environment, never printed or included in process args.
|
|
"""
|
|
import argparse,json,os,re,subprocess
|
|
from pathlib import Path
|
|
parser=argparse.ArgumentParser()
|
|
parser.add_argument('--state',required=True,type=Path)
|
|
parser.add_argument('command',nargs=argparse.REMAINDER)
|
|
args=parser.parse_args()
|
|
command=args.command[1:] if args.command[:1]==['--'] else args.command
|
|
if command[:2]!=['dotnet','test']:parser.error('This fixture runner permits dotnet test only')
|
|
state=json.loads(args.state.read_text())
|
|
match=re.fullmatch(r'127\.0\.0\.1,(\d+)',state['server'])
|
|
if not match or not state['name'].startswith('codex-ot-ui-sql-'):parser.error('An owned loopback SQL fixture is required')
|
|
label=subprocess.check_output(['docker','inspect',state['name'],'--format','{{index .Config.Labels "codex.task"}}'],text=True).strip()
|
|
binding=subprocess.check_output(['docker','port',state['name'],'1433/tcp'],text=True).strip()
|
|
if label!='scada-ui-consistency-ot14' or binding!='127.0.0.1:'+match[1]:parser.error('Fixture ownership/binding validation failed')
|
|
environment=os.environ.copy()
|
|
environment['OTOPCUA_CONFIG_TEST_SERVER']=state['server']
|
|
environment['OTOPCUA_CONFIG_TEST_SA_PASSWORD']=state['password']
|
|
raise SystemExit(subprocess.call(command,env=environment))
|