This is an automated email from the ASF dual-hosted git repository. brahma pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push: new ff05695585 AMBARI-25719. (cont.) don't rethrow exception. just logging (#3361) ff05695585 is described below commit ff056955858b8035cab15152479a2858519014d2 Author: Yubi Lee <eubn...@naver.com> AuthorDate: Sat Sep 10 15:02:35 2022 +0900 AMBARI-25719. (cont.) don't rethrow exception. just logging (#3361) * AMBARI-25719. (cont.) don't rethrow exception. just logging and add unit test Signed-off-by: Brahma Reddy Battula <bra...@apache.org> --- .../events/publishers/AgentCommandsPublisher.java | 6 +-- .../orm/dao/KerberosKeytabPrincipalDAOTest.java | 60 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/AgentCommandsPublisher.java b/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/AgentCommandsPublisher.java index a42deaa07e..7249ad5646 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/AgentCommandsPublisher.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/AgentCommandsPublisher.java @@ -111,7 +111,9 @@ public class AgentCommandsPublisher { if (!clusterDesiredConfigs.containsKey(clusterId)) { clusterDesiredConfigs.put(clusterId, clusters.getCluster(clusterId).getDesiredConfigs()); } - } catch (NumberFormatException|AmbariException ignored) {} + } catch (NumberFormatException|AmbariException e) { + LOG.error("Exception on sendAgentCommand", e); + } } Map<String, DesiredConfig> desiredConfigs = (clusterId != null && clusterDesiredConfigs.containsKey(clusterId)) @@ -122,7 +124,6 @@ public class AgentCommandsPublisher { }).get(); } catch (InterruptedException|ExecutionException e) { LOG.error("Exception on sendAgentCommand", e); - throw new RuntimeException(e); } try { @@ -137,7 +138,6 @@ public class AgentCommandsPublisher { }).get(); } catch (InterruptedException|ExecutionException e) { LOG.error("Exception on sendAgentCommand", e); - throw new RuntimeException(e); } } } diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/KerberosKeytabPrincipalDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/KerberosKeytabPrincipalDAOTest.java new file mode 100644 index 0000000000..5c4a793bc8 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/KerberosKeytabPrincipalDAOTest.java @@ -0,0 +1,60 @@ +package org.apache.ambari.server.orm.dao; + +import com.google.inject.Provider; +import org.apache.ambari.server.orm.entities.HostEntity; +import org.apache.ambari.server.orm.entities.KerberosKeytabEntity; +import org.apache.ambari.server.orm.entities.KerberosKeytabPrincipalEntity; +import org.apache.ambari.server.orm.entities.KerberosPrincipalEntity; +import org.easymock.EasyMockRule; +import org.easymock.Mock; +import org.easymock.MockType; +import org.easymock.TestSubject; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import javax.persistence.EntityManager; +import java.util.ArrayList; +import java.util.List; + +import static org.easymock.EasyMock.*; + +public class KerberosKeytabPrincipalDAOTest { + + @Rule + public EasyMockRule mocks = new EasyMockRule(this); + + @Mock(type = MockType.STRICT) + private Provider<EntityManager> entityManagerProvider; + + @Mock(type = MockType.STRICT) + private EntityManager entityManager; + + @TestSubject + private KerberosKeytabPrincipalDAO kerberosKeytabPrincipalDAO = new KerberosKeytabPrincipalDAO(); + + @Before + public void before() { + reset(entityManagerProvider); + expect(entityManagerProvider.get()).andReturn(entityManager).atLeastOnce(); + replay(entityManagerProvider); + } + + @Test + public void testFindOrCreate() { + HostEntity hostEntity = new HostEntity(); + hostEntity.setHostName("h1"); + hostEntity.setHostId(1L); + + KerberosKeytabEntity kke = new KerberosKeytabEntity(); + kke.setKeytabPath("/some/path"); + + KerberosPrincipalEntity kpe = new KerberosPrincipalEntity(); + kpe.setPrincipalName("t...@example.com"); + + List<KerberosKeytabPrincipalEntity> keytabList = new ArrayList<>(); + keytabList.add(null); + + kerberosKeytabPrincipalDAO.findOrCreate(kke, hostEntity, kpe, keytabList); + } +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@ambari.apache.org For additional commands, e-mail: commits-h...@ambari.apache.org