From 33d2962593c34b5c51f49e7b326e1ec3a5122334 Mon Sep 17 00:00:00 2001
From: aderm <394102339@qq.com>
Date: Sun, 17 Nov 2019 11:23:11 +0800
Subject: [PATCH] [test/plugin] add elasticsearch 7.x plugin test scenario.
(#3868)
* [test/plugin] add elasticsearch 7.x plugin test scenario.
* refresh index, make can search.
* remove unused package.
* update supported framework document.
* fix service name repeat.
---
Jenkinsfile-Agent-Test-4 | 8 +-
docs/en/guides/Plugin-test.md | 3 +-
.../java-agent/Supported-list.md | 1 +
.../configuration.yml | 6 +-
.../configuration.yml | 8 +-
.../controller/CaseController.java | 4 +-
.../elasticsearch-7.x-scenario/bin/startup.sh | 21 ++
.../config/expectedData.yaml | 149 ++++++++++++
.../configuration.yml | 35 +++
.../elasticsearch-7.x-scenario/pom.xml | 147 ++++++++++++
.../src/main/assembly/assembly.xml | 41 ++++
.../testcase/elasticsearch/Application.java | 37 +++
.../config/ElasticsearchConfig.java | 58 +++++
.../controller/CaseController.java | 223 ++++++++++++++++++
.../src/main/resources/application.yaml | 23 ++
.../src/main/resources/log4j2.xml | 30 +++
.../support-version.list | 27 +++
17 files changed, 810 insertions(+), 11 deletions(-)
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/bin/startup.sh
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/configuration.yml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/pom.xml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/assembly/assembly.xml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/Application.java
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/config/ElasticsearchConfig.java
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/application.yaml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/log4j2.xml
create mode 100644 test/plugin/scenarios/elasticsearch-7.x-scenario/support-version.list
diff --git a/Jenkinsfile-Agent-Test-4 b/Jenkinsfile-Agent-Test-4
index 0ba437d5c..d3b74e5b0 100755
--- a/Jenkinsfile-Agent-Test-4
+++ b/Jenkinsfile-Agent-Test-4
@@ -68,7 +68,7 @@ pipeline {
}
}
- stage('Test Cases Report (154)') {
+ stage('Test Cases Report (165)') {
steps {
echo "Test Cases Report"
}
@@ -118,6 +118,12 @@ pipeline {
stage('Group2') {
stages {
+ stage('elasticsearch-7.x-scenario 7.0.0-7.4.2 (11)') {
+ steps {
+ sh 'bash test/plugin/run.sh elasticsearch-7.x-scenario'
+ }
+ }
+
stage('spring-webflux 2.x (18)') {
steps {
sh 'bash test/plugin/run.sh webflux-scenario'
diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md
index 996f17d04..26d9204dd 100644
--- a/docs/en/guides/Plugin-test.md
+++ b/docs/en/guides/Plugin-test.md
@@ -670,9 +670,10 @@ ehcache 2.8.x-2.10.x | 19 | 442.00
undertow 1.3.0-2.0.27 | 23 | 596.00
jedis 2.4.0-2.9.0 | 18 | 524.00
-#### Group 2 (2148.155s)
+#### Group 2 (2398.155s)
scenario name | versions | elapsed time (sec)
---|---|---
+elasticsearch-7.x-scenario | 11 | 250.00
spring-webflux 2.x | 18 | 705.60
spring 4.1.x-4.2.x | 20 | 574.75
solrj 7.x | 12 | 367.05
diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md
index 7ac9fc2e4..7f2be18db 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -58,6 +58,7 @@
* [Elasticsearch](https://github.com/elastic/elasticsearch)
* [transport-client](https://github.com/elastic/elasticsearch/tree/master/client/transport) 5.2.x-5.6.x
* [rest-high-level-client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.7/index.html) 6.7.1-6.8.4
+ * [rest-high-level-client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.0/java-rest-high.html) 7.0.0-7.4.2
* [Solr](https://github.com/apache/lucene-solr/)
* [SolrJ](https://github.com/apache/lucene-solr/tree/master/solr/solrj) 7.x
* [Cassandra](https://github.com/apache/cassandra) 3.x
diff --git a/test/plugin/scenarios/elasticsearch-5.x-scenario/configuration.yml b/test/plugin/scenarios/elasticsearch-5.x-scenario/configuration.yml
index ce958778f..df2394332 100644
--- a/test/plugin/scenarios/elasticsearch-5.x-scenario/configuration.yml
+++ b/test/plugin/scenarios/elasticsearch-5.x-scenario/configuration.yml
@@ -18,11 +18,11 @@ healthCheck: http://localhost:8080/elasticsearch-case/case/healthcheck
startScript: ./bin/startup.sh
framework: elasticsearch
environment:
- - elasticsearch.server=elasticsearch-server
+ - elasticsearch.server=elasticsearch-server-5.x
dependencies:
- elasticsearch-server:
+ elasticsearch-server-5.x:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0
- hostname: elasticsearch-server
+ hostname: elasticsearch-server-5.x
expose:
- 9300
- 9200
diff --git a/test/plugin/scenarios/elasticsearch-6.x-scenario/configuration.yml b/test/plugin/scenarios/elasticsearch-6.x-scenario/configuration.yml
index ddad2d58a..edb99a886 100644
--- a/test/plugin/scenarios/elasticsearch-6.x-scenario/configuration.yml
+++ b/test/plugin/scenarios/elasticsearch-6.x-scenario/configuration.yml
@@ -18,11 +18,11 @@ healthCheck: http://localhost:8080/elasticsearch-case/case/healthcheck
startScript: ./bin/startup.sh
framework: elasticsearch
environment:
- - elasticsearch.server=elasticsearch-server:9200
+ - elasticsearch.server=elasticsearch-server-6.x:9200
dependencies:
- elasticsearch-server:
- image: elasticsearch:6.7.1
- hostname: elasticsearch-server
+ elasticsearch-server-6.x:
+ image: elasticsearch:${CASE_SERVER_IMAGE_VERSION}
+ hostname: elasticsearch-server-6.x
expose:
- 9200
environment:
diff --git a/test/plugin/scenarios/elasticsearch-6.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java b/test/plugin/scenarios/elasticsearch-6.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
index e872d1bae..3cd0d7d87 100644
--- a/test/plugin/scenarios/elasticsearch-6.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
+++ b/test/plugin/scenarios/elasticsearch-6.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
@@ -27,7 +27,7 @@ import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.admin.indices.flush.FlushRequest;
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
@@ -88,7 +88,7 @@ public class CaseController {
// index
index(client, indexName);
- client.indices().flush(new FlushRequest(indexName), RequestOptions.DEFAULT);
+ client.indices().refresh(new RefreshRequest(indexName), RequestOptions.DEFAULT);
//get
get(client, indexName);
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/bin/startup.sh b/test/plugin/scenarios/elasticsearch-7.x-scenario/bin/startup.sh
new file mode 100644
index 000000000..34c8fd1ab
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/bin/startup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# 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.
+
+home="$(cd "$(dirname $0)"; pwd)"
+
+java -jar ${agent_opts} -Dskywalking.plugin.elasticsearch.trace_dsl=true ${home}/../libs/elasticsearch-7.x-scenario.jar &
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml
new file mode 100644
index 000000000..e2e3b51a7
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml
@@ -0,0 +1,149 @@
+# 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.
+registryItems:
+ applications:
+ - {elasticsearch-7.x-scenario: nq 0}
+ instances:
+ - {elasticsearch-7.x-scenario: 1}
+ operationNames:
+ - elasticsearch-7.x-scenario: [Elasticsearch/CreateRequest, Elasticsearch/IndexRequest,
+ Elasticsearch/GetRequest, Elasticsearch/SearchRequest,
+ Elasticsearch/UpdateRequest, Elasticsearch/DeleteRequest,
+ /elasticsearch-case/case/elasticsearch]
+ heartbeat: []
+segmentItems:
+- applicationCode: elasticsearch-7.x-scenario
+ segmentSize: ge 1
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: Elasticsearch/CreateRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - {key: db.statement, value: not null}
+ - operationName: Elasticsearch/IndexRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 2
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - {key: db.statement, value: not null}
+ - operationName: Elasticsearch/GetRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 3
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - {key: db.statement, value: not null}
+ - operationName: Elasticsearch/SearchRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 4
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - {key: db.statement, value: not null}
+ - operationName: Elasticsearch/UpdateRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 5
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - {key: db.statement, value: not null}
+ - operationName: Elasticsearch/DeleteRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 6
+ spanLayer: Database
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 77
+ componentName: ''
+ isError: false
+ spanType: Exit
+ peer: not null
+ peerId: 0
+ tags:
+ - {key: db.type, value: Elasticsearch}
+ - {key: db.instance, value: not null}
+ - operationName: /elasticsearch-case/case/elasticsearch
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 1
+ componentName: ''
+ isError: false
+ spanType: Entry
+ peer: ''
+ peerId: 0
+ tags:
+ - {key: url, value: 'http://localhost:8080/elasticsearch-case/case/elasticsearch'}
+ - {key: http.method, value: GET}
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/configuration.yml b/test/plugin/scenarios/elasticsearch-7.x-scenario/configuration.yml
new file mode 100644
index 000000000..1abc433d1
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/configuration.yml
@@ -0,0 +1,35 @@
+# 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.
+
+type: jvm
+entryService: http://localhost:8080/elasticsearch-case/case/elasticsearch
+healthCheck: http://localhost:8080/elasticsearch-case/case/healthCheck
+startScript: ./bin/startup.sh
+framework: elasticsearch-7.x-scenario
+environment:
+- elasticsearch.server=elasticsearch-server-7.x:9200
+dependencies:
+ elasticsearch-server-7.x:
+ image: elasticsearch:${CASE_SERVER_IMAGE_VERSION}
+ hostname: elasticsearch-server-7.x
+ expose:
+ - 9200
+ environment:
+ - cluster.name=docker-node
+ - xpack.security.enabled=false
+ - bootstrap.memory_lock=true
+ - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
+ - discovery.type=single-node
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/pom.xml b/test/plugin/scenarios/elasticsearch-7.x-scenario/pom.xml
new file mode 100644
index 000000000..a1e7919e5
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/pom.xml
@@ -0,0 +1,147 @@
+
+
+
+
+ org.apache.skywalking.apm.testcase
+ elasticsearch-7.x-scenario
+ 1.0.0
+ jar
+
+ 4.0.0
+
+
+ UTF-8
+ 1.8
+
+ 7.3.0
+
+ 7.3.0
+ 2.1.6.RELEASE
+
+
+ skywalking-elasticsearch-7.x-scenario
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot-version}
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+
+
+ jul-to-slf4j
+ org.slf4j
+
+
+
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-high-level-client
+ ${test.framework.version}
+
+
+ elasticsearch
+ org.elasticsearch
+
+
+ elasticsearch-rest-client
+ org.elasticsearch.client
+
+
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-client
+ ${test.framework.version}
+
+
+ org.elasticsearch
+ elasticsearch
+ ${test.framework.version}
+
+
+
+
+ elasticsearch-7.x-scenario
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot-version}
+
+
+
+ repackage
+
+
+
+
+
+ maven-compiler-plugin
+
+ ${compiler.version}
+ ${compiler.version}
+ ${project.build.sourceEncoding}
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ assemble
+ package
+
+ single
+
+
+
+ src/main/assembly/assembly.xml
+
+ ./target/
+
+
+
+
+
+
+
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 000000000..52790912f
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+
+
+
+
+ zip
+
+
+
+
+ ./bin
+ 0775
+
+
+
+
+
+ ${project.build.directory}/elasticsearch-7.x-scenario.jar
+ ./libs
+ 0775
+
+
+
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/Application.java b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/Application.java
new file mode 100644
index 000000000..57e75377c
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/Application.java
@@ -0,0 +1,37 @@
+/*
+ * 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.skywalking.apm.testcase.elasticsearch;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author aderm
+ */
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ try {
+ SpringApplication.run(Application.class, args);
+ } catch (Exception e) {
+ // Never do this
+ }
+ }
+}
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/config/ElasticsearchConfig.java b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/config/ElasticsearchConfig.java
new file mode 100644
index 000000000..46edcefdb
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/config/ElasticsearchConfig.java
@@ -0,0 +1,58 @@
+/*
+ * 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.skywalking.apm.testcase.elasticsearch.config;
+
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author aderm
+ */
+@Configuration
+public class ElasticsearchConfig {
+
+ @Value("${elasticsearch.server}")
+ private String elasticsearchHost;
+
+ @Bean(destroyMethod = "close")
+ public RestHighLevelClient client() {
+ HttpHost[] httpHostArry = parseEsHost();
+ RestHighLevelClient client = new RestHighLevelClient((RestClient.builder(httpHostArry)));
+ return client;
+ }
+
+ private HttpHost[] parseEsHost() {
+ HttpHost[] httpHostArray = null;
+ if (!elasticsearchHost.isEmpty()) {
+ String[] hostIp = elasticsearchHost.split(",");
+ httpHostArray = new HttpHost[hostIp.length];
+
+ for (int i = 0; i < hostIp.length; ++i) {
+ String[] hostIpItem = hostIp[i].split(":");
+ String ip = hostIpItem[0].trim();
+ String port = hostIpItem[1].trim();
+ httpHostArray[i] = new HttpHost(ip, Integer.parseInt(port), "http");
+ }
+ }
+ return httpHostArray;
+ }
+}
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
new file mode 100644
index 000000000..dce7ee27b
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticsearch/controller/CaseController.java
@@ -0,0 +1,223 @@
+/*
+ * 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.skywalking.apm.testcase.elasticsearch.controller;
+
+import static java.util.Collections.singletonMap;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
+import org.elasticsearch.action.get.GetRequest;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.action.update.UpdateResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.cluster.health.ClusterHealthStatus;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.script.Script;
+import org.elasticsearch.script.ScriptType;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author aderm
+ */
+@RestController
+@RequestMapping("/case")
+public class CaseController {
+
+ private static Logger logger = LogManager.getLogger(CaseController.class);
+
+ @Autowired
+ private RestHighLevelClient client;
+
+ @GetMapping("/healthCheck")
+ public String healthcheck() throws Exception {
+ ClusterHealthRequest request = new ClusterHealthRequest();
+ request.timeout(TimeValue.timeValueSeconds(10));
+ request.waitForStatus(ClusterHealthStatus.GREEN);
+
+ ClusterHealthResponse response = client.cluster().health(request, RequestOptions.DEFAULT);
+ if (response.isTimedOut()) {
+ String message = "elastic search node start fail!";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ return "Success";
+ }
+
+ @GetMapping("/elasticsearch")
+ public String elasticsearch() throws Exception {
+ String indexName = UUID.randomUUID().toString();
+ try {
+ //create
+ createIndex(client, indexName);
+ // index
+ index(client, indexName);
+
+ client.indices().refresh(new RefreshRequest(indexName), RequestOptions.DEFAULT);
+
+ //get
+ get(client, indexName);
+ // search
+ search(client, indexName);
+ // update
+ update(client, indexName);
+ // delete
+ delete(client, indexName);
+ } finally {
+ if (null != client) {
+ client.close();
+ }
+ }
+ return "Success";
+ }
+
+ private void createIndex(RestHighLevelClient client, String indexName) throws IOException {
+ CreateIndexRequest request = new CreateIndexRequest(indexName);
+
+ XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
+ {
+ builder.startObject("properties");
+ {
+ builder.startObject("author");
+ {
+ builder.field("type", "keyword");
+ }
+ builder.endObject();
+ builder.startObject("title");
+ {
+ builder.field("type", "keyword");
+ }
+ builder.endObject();
+ }
+ builder.endObject();
+ }
+ builder.endObject();
+ request.mapping(builder);
+
+ request.settings(Settings.builder()
+ .put("index.number_of_shards", 1)
+ .put("index.number_of_replicas", 0)
+ );
+
+ CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT);
+ if (createIndexResponse.isAcknowledged() == false) {
+ String message = "elasticsearch create index fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+
+ private void index(RestHighLevelClient client, String indexName) throws IOException {
+ XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
+ {
+ builder.field("author", "Marker");
+ builder.field("title", "Java programing.");
+ }
+ builder.endObject();
+ IndexRequest indexRequest = new IndexRequest(indexName).id("1").source(builder);
+
+ IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
+ if (indexResponse.status().getStatus() >= 400) {
+ String message = "elasticsearch index data fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+
+ private void get(RestHighLevelClient client, String indexName) throws IOException {
+ GetRequest getRequest = new GetRequest(indexName, "1");
+ GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);
+
+ if (!getResponse.isExists()) {
+ String message = "elasticsearch get data fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+
+ private void update(RestHighLevelClient client, String indexName) throws IOException {
+ UpdateRequest request = new UpdateRequest(indexName, "1");
+ Map parameters = singletonMap("title", "c++ programing.");
+ Script inline = new Script(ScriptType.INLINE, "painless", "ctx._source.title = params.title", parameters);
+ request.script(inline);
+
+ UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
+ if (updateResponse.getVersion() != 2) {
+ String message = "elasticsearch update data fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+
+ private void delete(RestHighLevelClient client, String indexName) throws IOException {
+ DeleteIndexRequest request = new DeleteIndexRequest(indexName);
+ AcknowledgedResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT);
+ if (!deleteIndexResponse.isAcknowledged()) {
+ String message = "elasticsearch delete index fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+
+ private void search(RestHighLevelClient client, String indexName) throws IOException {
+ SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
+ sourceBuilder.query(QueryBuilders.termQuery("author", "Marker"));
+ sourceBuilder.from(0);
+ sourceBuilder.size(10);
+
+ SearchRequest searchRequest = new SearchRequest();
+ searchRequest.indices(indexName);
+ searchRequest.source(sourceBuilder);
+ SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
+
+ int length = searchResponse.getHits().getHits().length;
+ if (!(length > 0)) {
+ String message = "elasticsearch search data fail.";
+ logger.error(message);
+ throw new RuntimeException(message);
+ }
+ }
+}
+
+
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/application.yaml
new file mode 100644
index 000000000..7cc560285
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/application.yaml
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+#
+server:
+ port: 8080
+ servlet:
+ context-path: /elasticsearch-case
+logging:
+ config: classpath:log4j2.xml
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 000000000..9849ed5a8
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/support-version.list b/test/plugin/scenarios/elasticsearch-7.x-scenario/support-version.list
new file mode 100644
index 000000000..6f580b790
--- /dev/null
+++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/support-version.list
@@ -0,0 +1,27 @@
+# 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
+# "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.
+
+7.0.0
+7.1.0
+7.1.1
+7.2.0
+7.2.1
+7.3.0
+7.3.1
+7.3.2
+7.4.0
+7.4.1
+7.4.2