You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/06/03 20:02:47 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7010: Cross-integration test of Realtime & Basic Auth & TLS

Jackie-Jiang commented on a change in pull request #7010:
URL: https://github.com/apache/incubator-pinot/pull/7010#discussion_r645062551



##########
File path: pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ConnectionFactory.java
##########
@@ -40,20 +37,20 @@ private ConnectionFactory() {
    * @return A connection that connects to the brokers in the given Helix cluster
    */
   public static Connection fromZookeeper(String zkUrl) {
-    return fromZookeeper(zkUrl, null);
+    return fromZookeeper(zkUrl, new JsonAsyncHttpPinotClientTransportFactory().buildTransport());

Review comment:
       Consider keeping a static default `PinotClientTransport` to be reused?

##########
File path: pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
   private static final Logger LOGGER = LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;
 
   public JsonAsyncHttpPinotClientTransport() {
+    _httpClient = new AsyncHttpClient();
   }
 
-  public JsonAsyncHttpPinotClientTransport(Map<String, String> headers) {
+  public JsonAsyncHttpPinotClientTransport(SSLContext sslContext, Map<String, String> headers, String scheme) {

Review comment:
       Annotate all arguments with nullable

##########
File path: pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
   private static final Logger LOGGER = LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;

Review comment:
       `_httpClient`, `_headers` and `_scheme` can be private final, `_sslContext` can be local variable 

##########
File path: pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransportFactory.java
##########
@@ -18,19 +18,46 @@
  */
 package org.apache.pinot.client;
 
+import java.util.HashMap;
 import java.util.Map;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
+
 
 /**
  * Pinot client transport factory for JSON encoded BrokerResults through HTTP.
  */
-class JsonAsyncHttpPinotClientTransportFactory implements PinotClientTransportFactory {
+public class JsonAsyncHttpPinotClientTransportFactory implements PinotClientTransportFactory {
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;

Review comment:
       private

##########
File path: pinot-core/src/main/java/org/apache/pinot/server/realtime/ServerSegmentCompletionProtocolHandler.java
##########
@@ -64,6 +65,7 @@ public static void init(PinotConfiguration uploaderConfig) {
       _sslContext = new ClientSSLContextGenerator(httpsConfig.subset(CommonConstants.PREFIX_OF_SSL_SUBSET)).generate();
       _controllerHttpsPort = httpsConfig.getProperty(CONFIG_OF_CONTROLLER_HTTPS_PORT, Integer.class);
     }
+    _protocol = uploaderConfig.getProperty(CONFIG_OF_PROTOCOL, HTTP_PROTOCOL);

Review comment:
       Do we need this extra config? If https is enabled, can we directly set https as the scheme?

##########
File path: pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java
##########
@@ -158,8 +159,17 @@ protected void startController(Map<String, Object> properties) {
 
     ControllerConf config = new ControllerConf(properties);
 
-    _controllerPort = Integer.valueOf(config.getControllerPort());
-    _controllerBaseApiUrl = "http://localhost:" + _controllerPort;
+    String controllerScheme = "http";
+    if (StringUtils.isNotBlank(config.getControllerVipProtocol())) {
+      controllerScheme = config.getControllerVipProtocol();
+    }
+
+    _controllerPort = DEFAULT_CONTROLLER_PORT;
+    if (StringUtils.isNotBlank(config.getControllerPort())) {

Review comment:
       I think controller port is mandatory

##########
File path: pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -131,6 +131,27 @@ protected void startBrokers(int numBrokers, int basePort, String zkStr)
     _brokerBaseApiUrl = "http://localhost:" + _brokerPorts.get(0);
   }
 
+  protected void startBrokerHttps()
+      throws Exception {
+    _brokerStarters = new ArrayList<>();
+    _brokerPorts = new ArrayList<>();
+
+    Map<String, Object> properties = getDefaultBrokerConfiguration().toMap();
+    properties.put(Broker.CONFIG_OF_BROKER_TIMEOUT_MS, 60 * 1000L);
+    properties.put(Broker.CONFIG_OF_DELAY_SHUTDOWN_TIME_MS, 0);
+
+    PinotConfiguration configuration = new PinotConfiguration(properties);
+    overrideBrokerConf(configuration);
+
+    HelixBrokerStarter brokerStarter =
+        new HelixBrokerStarter(configuration, getHelixClusterName(), getZkUrl(), LOCAL_HOST);
+    brokerStarter.start();
+    _brokerStarters.add(brokerStarter);
+
+    _brokerPorts.add(DEFAULT_BROKER_PORT);

Review comment:
       Don't hard-code the broker port. It might be occupied in certain environment. You may check the open port similar to the `startBrokers()`

##########
File path: pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
##########
@@ -0,0 +1,260 @@
+/**
+ * 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.pinot.integration.tests;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Preconditions;
+import groovy.lang.IntRange;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.pinot.client.Connection;
+import org.apache.pinot.client.ConnectionFactory;
+import org.apache.pinot.client.JsonAsyncHttpPinotClientTransportFactory;
+import org.apache.pinot.client.Request;
+import org.apache.pinot.client.ResultSetGroup;
+import org.apache.pinot.common.utils.FileUploadDownloadClient;
+import org.apache.pinot.core.common.MinionConstants;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableTaskConfig;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.apache.pinot.util.TestUtils;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.apache.pinot.integration.tests.BasicAuthTestUtils.AUTH_HEADER;
+
+
+public class BasicAuthTlsRealtimeIntegrationTest extends BaseClusterIntegrationTest {

Review comment:
       Should we replace the `BasicAuthRealtimeIntegrationTest` with this one? I think this one covers all the test cases in the other one?
   Currently the integration test suite already takes more than 1 hour to finish

##########
File path: pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -196,6 +217,24 @@ protected void startServers(int numServers, PinotConfiguration configuration, in
     }
   }
 
+  protected void startServerHttps() {
+    FileUtils.deleteQuietly(new File(Server.DEFAULT_INSTANCE_BASE_DIR));
+    _serverStarters = new ArrayList<>();
+
+    Map<String, Object> properties = getDefaultServerConfiguration().toMap();
+
+    PinotConfiguration configuration = new PinotConfiguration(properties);
+    overrideServerConf(configuration);

Review comment:
       Do we need to set extra properties like `startServers()`?

##########
File path: pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
   private static final Logger LOGGER = LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;
 
   public JsonAsyncHttpPinotClientTransport() {
+    _httpClient = new AsyncHttpClient();
   }
 
-  public JsonAsyncHttpPinotClientTransport(Map<String, String> headers) {
+  public JsonAsyncHttpPinotClientTransport(SSLContext sslContext, Map<String, String> headers, String scheme) {
     _headers = headers;
+    _scheme = scheme;

Review comment:
       Use default scheme (HTTP) if the given scheme is null

##########
File path: pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -79,7 +79,7 @@
  */
 public abstract class ClusterTest extends ControllerTest {
   private static final Logger LOGGER = LoggerFactory.getLogger(ClusterTest.class);
-  private static final int DEFAULT_BROKER_PORT = 18099;
+  protected static final int DEFAULT_BROKER_PORT = 18099;

Review comment:
       Don't expose this, we should check the actual broker port instead of using this default port because the default port might not be the actual port




-- 
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: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org