This is an automated email from the ASF dual-hosted git repository. apucher pushed a commit to branch tls-integration-test in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
commit 03b134805dc7f83194ffe2c97edf2e1631ea9597 Author: Alexander Pucher <[email protected]> AuthorDate: Wed Jun 2 14:38:07 2021 -0700 plumbing prep for TLS-enabled tests --- .../pinot/controller/helix/ControllerTest.java | 14 ++++++-- .../java/org/apache/pinot/core/util/TlsUtils.java | 1 - .../pinot/integration/tests/ClusterTest.java | 41 +++++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java index 4e2a4e1..f206f6b 100644 --- a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java +++ b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java @@ -42,6 +42,7 @@ import org.apache.commons.httpclient.methods.multipart.Part; import org.apache.commons.httpclient.methods.multipart.StringPart; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.apache.helix.ConfigAccessor; import org.apache.helix.HelixAdmin; import org.apache.helix.HelixDataAccessor; @@ -158,8 +159,17 @@ public abstract class ControllerTest { 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())) { + _controllerPort = Integer.parseInt(config.getControllerPort()); + } + + _controllerBaseApiUrl = controllerScheme + "://localhost:" + _controllerPort; _controllerRequestURLBuilder = ControllerRequestURLBuilder.baseUrl(_controllerBaseApiUrl); _controllerDataDir = config.getDataDir(); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/util/TlsUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/util/TlsUtils.java index 661c159..0d12b98 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/util/TlsUtils.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/util/TlsUtils.java @@ -49,7 +49,6 @@ import org.apache.pinot.spi.utils.CommonConstants; * Utility class for shared TLS configuration logic */ public final class TlsUtils { - private static final String ENABLED = "enabled"; private static final String CLIENT_AUTH_ENABLED = "client.auth.enabled"; private static final String KEYSTORE_PATH = "keystore.path"; private static final String KEYSTORE_PASSWORD = "keystore.password"; diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java index 726422e..25137b3 100644 --- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java +++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java @@ -82,7 +82,7 @@ import static org.testng.Assert.assertTrue; */ 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; protected static final Random RANDOM = new Random(System.currentTimeMillis()); protected String _brokerBaseApiUrl; @@ -133,6 +133,27 @@ public abstract class ClusterTest extends ControllerTest { _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); + _brokerBaseApiUrl = "https://localhost:" + _brokerPorts.get(0); + } + protected int getRandomBrokerPort() { return _brokerPorts.get(RANDOM.nextInt(_brokerPorts.size())); } @@ -197,6 +218,24 @@ public abstract class ClusterTest extends ControllerTest { } } + 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); + + try { + HelixServerStarter helixServerStarter = new HelixServerStarter(getHelixClusterName(), getZkUrl(), configuration); + _serverStarters.add(helixServerStarter); + helixServerStarter.start(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + protected PinotConfiguration getDefaultMinionConfiguration() { return new PinotConfiguration(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
