You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/10/30 09:01:48 UTC
[GitHub] [hive] pkumarsinha commented on a change in pull request #1623: HIVE-24327: During Atlas metadata replication, handle a case when Atl…
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org