[ https://issues.apache.org/jira/browse/HIVE-27129?focusedWorklogId=850213&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-850213 ]
ASF GitHub Bot logged work on HIVE-27129: ----------------------------------------- Author: ASF GitHub Bot Created on: 10/Mar/23 01:57 Start Date: 10/Mar/23 01:57 Worklog Time Spent: 10m Work Description: junlinzeng-db commented on code in PR #4104: URL: https://github.com/apache/hive/pull/4104#discussion_r1131853638 ########## standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetastoreHttpHeaders.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.hive.metastore; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; +import org.apache.hadoop.hive.metastore.api.Database; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge; +import org.apache.http.Header; +import org.apache.http.HttpException; +import org.apache.http.HttpRequest; +import org.apache.http.HttpRequestInterceptor; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.protocol.HttpContext; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.IOException; + +import static org.junit.Assert.*; + +@Category(MetastoreCheckinTest.class) public class TestHiveMetastoreHttpHeaders { + private static Configuration conf; + private static HiveMetaStoreClient msc; + private static int port; + private static final String testHeaderKey1 = "X-XXXX"; + private static final String testHeaderVal1 = "yyyy"; + private static final String testHeaderKey2 = "X-ZZZZ"; + private static final String testHeaderVal2 = "aaaa"; + + static class TestHiveMetaStoreClient extends HiveMetaStoreClient { + public TestHiveMetaStoreClient(Configuration conf) throws MetaException { + super(conf); + } + + @Override protected HttpClientBuilder createHttpClientBuilder() throws MetaException { + HttpClientBuilder builder = super.createHttpClientBuilder(); + builder.addInterceptorLast(new HttpRequestInterceptor() { + @Override public void process(HttpRequest httpRequest, HttpContext httpContext) + throws HttpException, IOException { + Header header1 = httpRequest.getFirstHeader(testHeaderKey1); + assertEquals(testHeaderVal1, header1.getValue()); + Header header2 = httpRequest.getFirstHeader(testHeaderKey2); + assertEquals(testHeaderVal2, header2.getValue()); + } + }); + return builder; + } + } + + @Before public void setUp() throws Exception { + conf = MetastoreConf.newMetastoreConf(); + + MetaStoreTestUtils.setConfForStandloneMode(conf); + MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.EXECUTE_SET_UGI, false); + MetastoreConf.setVar(conf, MetastoreConf.ConfVars.THRIFT_TRANSPORT_MODE, "http"); + MetastoreConf.setVar(conf, MetastoreConf.ConfVars.METASTORE_CLIENT_THRIFT_TRANSPORT_MODE, "http"); + port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf); Review Comment: I think most of the Hive test do not do tear down. I was mostly copying them. I would prefer to not change it if you are ok https://github.com/apache/hive/blob/cd53e0a4d9b99f825beb7a7f5c9acc1b3e822edd/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java#L42 https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java#L52 Issue Time Tracking ------------------- Worklog Id: (was: 850213) Time Spent: 1h 10m (was: 1h) > Enhanced support to Hive Client http support > -------------------------------------------- > > Key: HIVE-27129 > URL: https://issues.apache.org/jira/browse/HIVE-27129 > Project: Hive > Issue Type: Improvement > Reporter: Junlin Zeng > Assignee: Junlin Zeng > Priority: Major > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > Currently we support using http in the hive metastore connection. However, we > do not support custom headers and also default trust store. This ticket > tracks the work to improve the http journey. -- This message was sent by Atlassian Jira (v8.20.10#820010)