mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 10:39:30 +00:00 
			
		
		
		
	Add log statements to debug test failures
This commit is contained in:
		
							parent
							
								
									f532164d0a
								
							
						
					
					
						commit
						0298190ed7
					
				| @ -90,6 +90,7 @@ public class ChangeEventHandler implements  EventHandler { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (changeEvent != null) { |         if (changeEvent != null) { | ||||||
|  |           LOG.info("Recording change event {} {}", changeEvent.getDateTime().getTime(), changeEvent); | ||||||
|           dao.changeEventDAO().insert(JsonUtils.pojoToJson(changeEvent)); |           dao.changeEventDAO().insert(JsonUtils.pojoToJson(changeEvent)); | ||||||
|         } |         } | ||||||
|       } catch(Exception e) { |       } catch(Exception e) { | ||||||
|  | |||||||
| @ -735,19 +735,46 @@ public abstract class EntityResourceTest<T> extends CatalogApplicationTest { | |||||||
|   protected final void validateChangeEvents(EntityInterface<T> entityInterface, EventType expectedEventType, |   protected final void validateChangeEvents(EntityInterface<T> entityInterface, EventType expectedEventType, | ||||||
|                                             ChangeDescription expectedChangeDescription, |                                             ChangeDescription expectedChangeDescription, | ||||||
|                                             Map<String, String> authHeaders) throws IOException { |                                             Map<String, String> authHeaders) throws IOException { | ||||||
|     ResultList<ChangeEvent> changeEvents = getChangeEvents(entityName, entityName, null, |     ResultList<ChangeEvent> changeEvents; | ||||||
|  |     ChangeEvent changeEvent = null; | ||||||
|  | 
 | ||||||
|  |     int iteration = 1; | ||||||
|  |     while (iteration < 10) { | ||||||
|  |       // Some times change event is not returned on quickly querying with a millisecond | ||||||
|  |       // Try multiple times before giving up | ||||||
|  |       changeEvents = getChangeEvents(entityName, entityName, null, | ||||||
|               entityInterface.getUpdatedAt(), authHeaders); |               entityInterface.getUpdatedAt(), authHeaders); | ||||||
| 
 | 
 | ||||||
|       assertTrue(changeEvents.getData().size() > 0); |       assertTrue(changeEvents.getData().size() > 0); | ||||||
|  |       for (ChangeEvent event : changeEvents.getData()) { | ||||||
|  |         if (event.getDateTime().getTime() == entityInterface.getUpdatedAt().getTime()) { | ||||||
|  |           changeEvent = event; | ||||||
|  |           break; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |       if (changeEvent != null) { | ||||||
|  |         break; | ||||||
|  |       } | ||||||
|  |       try { | ||||||
|  |         Thread.sleep(iteration * 10L); // Sleep with backoff | ||||||
|  |       } catch (InterruptedException e) { | ||||||
|  |         e.printStackTrace(); | ||||||
|  |       } | ||||||
|  |       iteration++; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     LOG.info("Did not find change event {} {} {}", entityInterface.getUpdatedAt().getTime(), entityInterface.getId(), | ||||||
|  |             expectedEventType); | ||||||
|  | 
 | ||||||
|  |     assertNotNull(changeEvent, "Expected change event " + expectedEventType + " at " | ||||||
|  |             + entityInterface.getUpdatedAt().getTime() + " was not found for entity " + entityInterface.getId()); | ||||||
| 
 | 
 | ||||||
|     // Top most changeEvent corresponds to the update |     // Top most changeEvent corresponds to the update | ||||||
|     ChangeEvent changeEvent = changeEvents.getData().get(0); |  | ||||||
|     assertEquals(expectedEventType, changeEvent.getEventType()); |     assertEquals(expectedEventType, changeEvent.getEventType()); | ||||||
|     assertEquals(entityName, changeEvent.getEntityType()); |     assertEquals(entityName, changeEvent.getEntityType()); | ||||||
|     assertEquals(entityInterface.getId(), changeEvent.getEntityId()); |     assertEquals(entityInterface.getId(), changeEvent.getEntityId()); | ||||||
|     assertEquals(entityInterface.getVersion(), changeEvent.getCurrentVersion()); |     assertEquals(entityInterface.getVersion(), changeEvent.getCurrentVersion()); | ||||||
|     assertEquals(entityInterface.getUpdatedBy(), changeEvent.getUserName()); |     assertEquals(entityInterface.getUpdatedBy(), changeEvent.getUserName()); | ||||||
|     assertEquals(entityInterface.getUpdatedAt().getTime(), changeEvent.getDateTime().getTime()); |  | ||||||
| 
 | 
 | ||||||
|     // previous, entity, changeDescription |     // previous, entity, changeDescription | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 sureshms
						sureshms