"""Trigger one catalog refresh and verify its durable terminal state.""" import argparse,json,time,urllib.request,uuid BASE='http://127.0.0.1:8088' def get(path): with urllib.request.urlopen(BASE+path,timeout=20) as response:return json.load(response) def main(): parser=argparse.ArgumentParser();parser.add_argument('name');parser.add_argument('--timeout',type=int,default=600);args=parser.parse_args();source=next(item for item in get('/api/v1/source-catalog/sources')['data'] if item['name']==args.name);before=source['observed_at'];request=urllib.request.Request(BASE+f"/api/v1/source-catalog/sources/{source['connection_id']}/refresh",method='POST',headers={'Accept':'application/json','Idempotency-Key':'accept-'+uuid.uuid4().hex}) with urllib.request.urlopen(request,timeout=20) as response:job=json.load(response)['data'] print('job',job['id'],'source',args.name,'before',before,flush=True);seen=None;deadline=time.monotonic()+args.timeout while time.monotonic()