neils-dev commented on code in PR #3297:
URL: https://github.com/apache/ozone/pull/3297#discussion_r850029841


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestGrpcOzoneManagerServer.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ *
+ */
+
+package org.apache.hadoop.ozone.om;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.mockito.Mockito;
+import 
org.apache.hadoop.ozone.protocolPB.OzoneManagerProtocolServerSideTranslatorPB;
+
+/**
+ * Tests for GrpcOzoneManagerServer.
+ */
+public class TestGrpcOzoneManagerServer {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestGrpcOzoneManagerServer.class);
+  private OzoneManager ozoneManager;
+  private OzoneManagerProtocolServerSideTranslatorPB omServerProtocol;
+  private GrpcOzoneManagerServer server;
+
+  @Rule
+  public Timeout timeout = Timeout.seconds(30);
+
+  @Test
+  public void testStartStop() throws Exception {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    ozoneManager = Mockito.mock(OzoneManager.class);
+    omServerProtocol = ozoneManager.getOmServerProtocol();
+
+    server = new GrpcOzoneManagerServer(conf,
+        omServerProtocol,
+        ozoneManager.getDelegationTokenMgr(),
+        ozoneManager.getCertificateClient());
+
+    try {
+      server.start();
+    } catch (Exception e) {
+      e.printStackTrace();

Review Comment:
   Updated with `junit`` assertion`.  The test passes when the exception is 
thrown and printed out through the stack trace.  I think the intention was to 
trap and print `server.start() `exceptions, then throw exception on following 
statements to `server.stop()`, thus testing both start and stop.  However, the 
`stop()` is absolute, trapping all exceptions and logging the error.
   
   Deliberately asserting now in addition to printing the exception stack so 
the unit test fails on exception from `start()` method. 



##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/protocolPB/TestGrpcOmTransport.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ *
+ */
+
+package org.apache.hadoop.ozone.protocolPB;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.om.protocolPB.GrpcOmTransport;
+import org.apache.hadoop.ozone.om.protocolPB.OmTransport;
+import org.apache.hadoop.ozone.om.protocolPB.OmTransportFactory;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_TRANSPORT_CLASS;
+
+/**
+ * Tests for GrpcOmTransport.
+ */
+public class TestGrpcOmTransport {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestGrpcOmTransport.class);
+  @Rule
+  public Timeout timeout = Timeout.seconds(30);
+
+
+  @Test
+  public void testGrpcOmTransportFactory() throws Exception {
+    String omServiceId = "";
+    String transportCls = GrpcOmTransport.class.getName();
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.set(OZONE_OM_TRANSPORT_CLASS,
+        transportCls);
+
+    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+    OmTransport omTransport = OmTransportFactory.create(conf, ugi, 
omServiceId);
+    Assert.assertEquals(GrpcOmTransport.class.getSimpleName(),
+        omTransport.getClass().getSimpleName());
+
+  }
+
+  @Test
+  public void testHrpcOmTransportFactory() throws Exception {
+    String omServiceId = "";
+    OzoneConfiguration conf = new OzoneConfiguration();
+
+    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+    OmTransport omTransport = OmTransportFactory.create(conf, ugi, 
omServiceId);
+    // OmTransport should be Hadoop Rpc and
+    // fail equality GrpcOmTransport equality test
+    Assert.assertNotEquals(GrpcOmTransport.class.getSimpleName(),
+        omTransport.getClass().getSimpleName());
+  }
+
+  @Test
+  public void testStartStop() throws Exception {
+    String omServiceId = "";
+    OzoneConfiguration conf = new OzoneConfiguration();
+
+    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+    GrpcOmTransport client = new GrpcOmTransport(conf, ugi, omServiceId);
+
+    try {
+      client.start();
+    } catch (Exception e) {
+      e.printStackTrace();

Review Comment:
   Same as above, instead with client.start / client.stop.  Now both printing 
the exception stack and asserting the error.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to