"""Verify no change in output for QA vs. Local.""" import asyncio import json import httpx async def main() -> None: """Entrypoint.""" hosts = [ 'http://localhost:80', 'https://qa-ows-carveouts.theorchard.io' ] uris = [ '/carveout/vendor/15359/dms', '/carveout/vendor/15359/territory/1245', '/carveout/vendor/15359/territory', '/carveout/subaccount/18/dms', '/carveout/subaccount/18/territory/463', '/carveout/subaccount/18/territory', '/carveout/887845672650/dms', '/carveout/release/887845672650/territory/1', '/carveout/release/887845672650/territory', '/carveout/5032698634712', '/carveout/886788307476', '/carveout/887845672650', '/carveout/projection/5054526973572/dms/286', '/carveout/projection/887845672650/dms/1', '/carveout/projection/886788121157/dms/1245' ] # prepare coroutines calls = [] for uri in uris: for host in hosts: calls.append(call_url(host, uri)) # execute coroutines responses = await asyncio.gather(*calls) # group response data by uri results: dict = dict() for response in responses: uri = response['uri'] host = response['host'] results.setdefault(uri, dict()) results[uri][host] = response # evaulate responses across hosts for uniformity for k, v in results.items(): try: if not all([x['code'] == 200 for _, x in v.items()]): raise Exception('non-200 response') datas = [x['body'] for _, x in v.items()] for data in datas[1:]: if not data or data != datas[0]: raise Exception('data mis-match') except Exception as e: print(f'Error {k} {e}') print(json.dumps(v)) else: print(f'No errors {k}') async def call_url(host: str, uri: str) -> dict: """Make request to url.""" async with httpx.AsyncClient() as client: response = await client.get( f'{host}{uri}', timeout=60 ) return { 'uri': uri, 'host': host, 'code': response.status_code, 'body': response.json() } if __name__ == '__main__': asyncio.run(main())