From d595d4a8c430f83935f5fa17c5ee23cffdf379bd Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 25 Mar 2022 12:16:43 +0800 Subject: [PATCH] add success and failure count in assertions (#318) --- packages/api/elastic_migrate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/api/elastic_migrate.py b/packages/api/elastic_migrate.py index b18a1d58d..d0be65ede 100644 --- a/packages/api/elastic_migrate.py +++ b/packages/api/elastic_migrate.py @@ -78,6 +78,8 @@ UPDATE_HIGHLIGHT_SQL = f''' def assertData(conn, client): # get all users from postgres try: + success = 0 + failure = 0 cursor = conn.cursor(cursor_factory=RealDictCursor) cursor.execute('''SELECT id FROM omnivore.user''') result = cursor.fetchall() @@ -90,11 +92,14 @@ def assertData(conn, client): index='pages', body={'query': {'term': {'userId': userId}}})['count'] if countInPostgres == countInElastic: + success += 1 print(f'User {userId} OK') else: + failure += 1 print( f'User {userId} ERROR: postgres: {countInPostgres}, elastic: {countInElastic}') cursor.close() + print(f'Asserted data, success: {success}, failure: {failure}') except Exception as err: print('Assert data ERROR:', err) exit(1)