dobesv commented on a change in pull request #1997: DRILL-7604: Allow session options to be set in HTTP queries URL: https://github.com/apache/drill/pull/1997#discussion_r384708067
########## File path: exec/java-exec/src/test/java/org/apache/drill/exec/server/rest/TestQueryWrapper.java ########## @@ -0,0 +1,224 @@ +/* + * 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.drill.exec.server.rest; + +import io.netty.channel.DefaultChannelPromise; +import io.netty.channel.local.LocalAddress; +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.user.UserSession; +import org.apache.drill.exec.server.Drillbit; +import org.apache.drill.exec.server.options.SystemOptionManager; +import org.apache.drill.exec.server.rest.auth.DrillUserPrincipal; +import org.apache.drill.exec.work.WorkManager; +import org.apache.drill.test.ClusterFixture; +import org.apache.drill.test.ClusterTest; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.junit.Test; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.drill.exec.ExecConstants.ENABLE_VERBOSE_ERRORS_KEY; +import static org.apache.drill.exec.ExecConstants.OUTPUT_FORMAT_OPTION; +import static org.apache.drill.exec.ExecConstants.PARQUET_FLAT_BATCH_MEMORY_SIZE_VALIDATOR; +import static org.apache.drill.exec.ExecConstants.QUERY_MAX_ROWS; +import static org.apache.drill.exec.ExecConstants.TEXT_ESTIMATED_ROW_SIZE; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +public class TestQueryWrapper extends ClusterTest { + + private static DrillRestServer server; + private static WorkManager workManager; + private static WebServer webServer; + + private void setupServer() throws IOException { + boolean impersonationEnabled = false; + setupServer(impersonationEnabled); + } + + private void setupServer(boolean impersonationEnabled) { + cluster = ClusterFixture.bareBuilder(dirTestWatcher) + .clusterSize(1) + .configProperty(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING, true) + .configProperty(ExecConstants.IMPERSONATION_ENABLED, impersonationEnabled) + .build(); + Drillbit drillbit = cluster.drillbit(); + workManager = drillbit.getManager(); + webServer = drillbit.getWebServer(); + final ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); + servletContextHandler.setContextPath("/"); + server = new DrillRestServer(workManager, servletContextHandler.getServletContext(), drillbit); + } + + private QueryWrapper.QueryResult run(String sql) throws Exception { + return runWithOptions(sql, null); + } + + private QueryWrapper.QueryResult runWithOptions(String sql, Map<String, Object> options) throws Exception { + if (cluster == null) { Review comment: In the other PR I setup the cluster with different options in different tests (e.g. with or without impersonation). I might as well keep that structure here in case all the PRs are merged that capability will be preserved. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
