pan3793 commented on code in PR #5488:
URL: https://github.com/apache/kyuubi/pull/5488#discussion_r1710937465


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/events/handler/ServerElasticSearchLoggingEventHandlerSuite.scala:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.UUID
+
+import com.dimafeng.testcontainers.ElasticsearchContainer
+import com.dimafeng.testcontainers.ElasticsearchContainer.defaultImage
+import com.dimafeng.testcontainers.scalatest.TestContainerForAll
+import com.sksamuel.elastic4s.ElasticDsl._
+
+import org.apache.kyuubi._
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiConf._
+import 
org.apache.kyuubi.events.handler.ElasticSearchLoggingEventHandler.getElasticClient
+import org.apache.kyuubi.operation.HiveJDBCTestHelper
+
+abstract class ServerElasticSearchLoggingEventHandlerSuite extends 
WithKyuubiServer
+  with HiveJDBCTestHelper
+  with BatchTestHelper with TestContainerForAll {
+
+  protected val imageTag: String
+  override lazy val containerDef = 
ElasticsearchContainer.Def(s"$defaultImage:$imageTag")
+
+  override def startContainers(): containerDef.Container = {
+    val esContainer = containerDef.createContainer()
+    val jContainer = esContainer.container
+    jContainer.withPassword(esPassword)
+    jContainer.withEnv("xpack.security.enabled", "true")
+    esContainer.start()
+    esContainer
+  }
+
+  private val destIndex = "server-event-index"
+  override protected def jdbcUrl: String = getJdbcUrl
+
+  private var esServerUrl: String = _
+  private val esUser = "elastic"
+  private val esPassword = UUID.randomUUID().toString
+
+  override protected val conf: KyuubiConf = {
+    KyuubiConf()
+      .set(KyuubiConf.SERVER_EVENT_LOGGERS, Seq("ELASTICSEARCH"))
+      .set(KyuubiConf.SERVER_EVENT_ELASTICSEARCH_INDEX, destIndex)
+      .set(KyuubiConf.SERVER_EVENT_ELASTICSEARCH_INDEX_AUTOCREATE_ENABLED, 
true)
+      .set(KyuubiConf.SERVER_EVENT_ELASTICSEARCH_USER, esUser)
+      .set(KyuubiConf.SERVER_EVENT_ELASTICSEARCH_PASSWORD, esPassword)
+  }
+
+  override def beforeAll(): Unit = withContainers { esContainer =>
+    esServerUrl = s"http://${esContainer.httpHostAddress}";
+    conf.set(SERVER_EVENT_ELASTICSEARCH_SERVER_URL, esServerUrl)
+    super.beforeAll()
+  }
+
+  test("check server events sent to ElasticSearch index") {
+    withContainers { _ =>
+      val esClient = getElasticClient(esServerUrl, Some(esUser), 
Some(esPassword))
+      try {
+        Thread.sleep(1000)
+        val hits = esClient.execute {
+          search(destIndex).matchAllQuery()
+        }.await.result.hits.hits
+        assert(hits.length > 0)
+      } finally {
+        esClient.close()
+      }
+    }
+  }
+
+}
+
+class ServerElasticSearchLoggingEventHandlerSuiteForEs7
+  extends ServerElasticSearchLoggingEventHandlerSuite {
+  override val imageTag = "7.17.14"

Review Comment:
   does it support ES 6?
   
   a survey from another team in my company shows that we have bunches of 
customers  still using ES 6



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