pkumarsinha commented on a change in pull request #1623:
URL: https://github.com/apache/hive/pull/1623#discussion_r514954497
##########
File path:
ql/src/test/org/apache/hadoop/hive/ql/exec/repl/TestAtlasDumpTask.java
##########
@@ -175,4 +174,58 @@ public void testRetryingClientTimeBasedExhausted() throws
AtlasServiceException
}
Assert.assertTrue(inputStream == null);
}
+
+ @Test
+ public void testAtlasServerEntity() throws AtlasServiceException,
SemanticException {
+ AtlasClientV2 atlasClientV2 = mock(AtlasClientV2.class);
+ AtlasServer atlasServer = mock(AtlasServer.class);
+ when(atlasClientV2.getServer(anyString())).thenReturn(atlasServer);
+ AtlasRestClient atlasClient = new AtlasRestClientImpl(atlasClientV2, conf);
+ AtlasServer atlasServerRet = atlasClient.getServer("src", conf);
+ Assert.assertTrue(atlasServer == atlasServerRet);
+ }
+
+ @Test
+ public void testAtlasServerEntityNotFound() throws AtlasServiceException,
SemanticException {
+ setupConfForRetry();
+ AtlasServiceException atlasServiceException =
mock(AtlasServiceException.class);
+ ClientResponse.Status status = mock(ClientResponse.Status.class);
+ when(atlasServiceException.getStatus()).thenReturn(status);
+ when(status.getStatusCode()).thenReturn(404);
+ AtlasClientV2 atlasClientV2 = mock(AtlasClientV2.class);
+
when(atlasClientV2.getServer(anyString())).thenThrow(atlasServiceException);
+ AtlasRestClient atlasClient = new AtlasRestClientImpl(atlasClientV2, conf);
+ AtlasServer atlasServerRet = atlasClient.getServer("src", conf);
+ Assert.assertNull(atlasServerRet);
+ ArgumentCaptor<String> getServerReqCaptor =
ArgumentCaptor.forClass(String.class);
+ Mockito.verify(atlasClientV2,
Mockito.times(1)).getServer(getServerReqCaptor.capture());
+ }
+
+ @Test
+ public void testAtlasServerEntityRetryExhausted() throws
AtlasServiceException {
+ setupConfForRetry();
+ AtlasServiceException atlasServiceException =
mock(AtlasServiceException.class);
+ ClientResponse.Status status = mock(ClientResponse.Status.class);
+ when(atlasServiceException.getStatus()).thenReturn(status);
+ when(status.getStatusCode()).thenReturn(400);
+ AtlasClientV2 atlasClientV2 = mock(AtlasClientV2.class);
+
when(atlasClientV2.getServer(anyString())).thenThrow(atlasServiceException);
+ AtlasRestClient atlasClient = new AtlasRestClientImpl(atlasClientV2, conf);
+ try {
+ atlasClient.getServer("src", conf);
+ Assert.fail("Should have thrown SemanticException.");
+ } catch (SemanticException ex) {
+ Assert.assertTrue(ex.getMessage().contains("Retry exhausted for
retryable error code"));
Review comment:
Assert.assertTrue(atlasServiceException == ex.getCause()); is there
which I think is stronger check for atlas exception.
Do wee still need additional check?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]