Repository: pinpoint-apm/pinpoint
Issue: elasticsearch bboss test failure
Labels: bug
module:plugin

Hello, @yin-bp 

I've noticed that bboss plugin integration tests are failing in our daily routine test.

Do you mind checking `ElasticsearchExecutorIT.java` out?





Issue comments:
Ok, let me look at this problem and solve it
attaching log, which may help you better
```
Error Message
java.lang.AssertionError: Cannot find apiId of [org.frameworkset.elasticsearch.client.ConfigRestClientUtil.createIndiceMapping(java.lang.String, java.lang.String)]
Stacktrace
com.navercorp.pinpoint.test.plugin.PinpointPluginTestException: java.lang.AssertionError: Cannot find apiId of [org.frameworkset.elasticsearch.client.ConfigRestClientUtil.createIndiceMapping(java.lang.String, java.lang.String)]
	at com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchExecutorIT.indiceCreate(ElasticsearchExecutorIT.java:116)
	at com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchExecutorIT.testClientInterface(ElasticsearchExecutorIT.java:101)
```
Hi,@RoySRose :
This problem is caused by not enabling ElasticsearchBboss plugin, can enable the plugin in pinpoint.config:
profiler.elasticsearchbboss.enabled=true

Pull request review comments:

Patch that resolved the issue:
diff --git a/agent/src/main/resources-local/pinpoint.config b/agent/src/main/resources-local/pinpoint.config
index cd2275f432d6..349b83c6b89d 100644
--- a/agent/src/main/resources-local/pinpoint.config
+++ b/agent/src/main/resources-local/pinpoint.config
@@ -1071,7 +1071,7 @@ profiler.elasticsearch.recordESVersion=false
 ###########################################################
 # ElasticsearchBBoss
 ###########################################################
-profiler.elasticsearchbboss.enabled=false
+profiler.elasticsearchbboss.enabled=true
 profiler.elasticsearchbboss.recordResult=false
 profiler.elasticsearchbboss.recordArgs=true
 profiler.elasticsearchbboss.recordDsl=true
diff --git a/agent/src/main/resources-release/pinpoint-real-env-lowoverhead-sample.config b/agent/src/main/resources-release/pinpoint-real-env-lowoverhead-sample.config
index 941f9cb99073..c842a062f0f4 100644
--- a/agent/src/main/resources-release/pinpoint-real-env-lowoverhead-sample.config
+++ b/agent/src/main/resources-release/pinpoint-real-env-lowoverhead-sample.config
@@ -793,7 +793,7 @@ profiler.elasticsearch.recordESVersion=false
 ###########################################################
 # ElasticsearchBBoss
 ###########################################################
-profiler.elasticsearchbboss.enabled=false
+profiler.elasticsearchbboss.enabled=true
 profiler.elasticsearchbboss.recordResult=false
 profiler.elasticsearchbboss.recordArgs=true
 profiler.elasticsearchbboss.recordDsl=true
diff --git a/agent/src/main/resources-release/pinpoint.config b/agent/src/main/resources-release/pinpoint.config
index d77e52b072a7..ab3ab1d53f72 100644
--- a/agent/src/main/resources-release/pinpoint.config
+++ b/agent/src/main/resources-release/pinpoint.config
@@ -985,7 +985,7 @@ profiler.elasticsearch.recordESVersion=false
 ###########################################################
 # ElasticsearchBBoss
 ###########################################################
-profiler.elasticsearchbboss.enabled=false
+profiler.elasticsearchbboss.enabled=true
 profiler.elasticsearchbboss.recordResult=false
 profiler.elasticsearchbboss.recordArgs=true
 profiler.elasticsearchbboss.recordDsl=true


Test patch:
diff --git a/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java b/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java
index f536a6027303..d164ba8a294d 100644
--- a/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java
+++ b/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java
@@ -17,19 +17,12 @@
 
 import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier;
 import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder;
-import com.navercorp.pinpoint.plugin.AgentPath;
-import com.navercorp.pinpoint.test.plugin.Dependency;
-import com.navercorp.pinpoint.test.plugin.JvmVersion;
-import com.navercorp.pinpoint.test.plugin.PinpointAgent;
-import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
 import org.frameworkset.elasticsearch.ElasticSearchHelper;
 import org.frameworkset.elasticsearch.client.ClientInterface;
 import org.frameworkset.elasticsearch.entity.ESDatas;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic;
 import pl.allegro.tech.embeddedelasticsearch.PopularProperties;
 
@@ -47,12 +40,8 @@
  * @author yinbp[yin-bp@163.com]
  */
 
-@RunWith(PinpointPluginTestSuite.class)
-@PinpointAgent(AgentPath.PATH)
-@Dependency({"com.bbossgroups.plugins:bboss-elasticsearch-rest-jdbc:[5.6.9,]",
-		"pl.allegro.tech:embedded-elasticsearch:2.8.0"})
-@JvmVersion(8)
-public class ElasticsearchExecutorIT {
+
+public abstract class ElasticsearchExecutorIT {
 	private static EmbeddedElastic embeddedElastic;
 	private static ClientInterface clientInterface;
 	private static ClientInterface configRestClientInterface ;
@@ -64,13 +53,13 @@ public static void setUpBeforeClass() throws Exception {
 
 		// BBoss connect elasticsearch use localhost and http port 9200 default.
 
-//		Here is a bboss web demo base spring boot and elasticsearch 5.x,6.x:
+//		Here is a bboss web demo base spring boot and elasticsearch 5.x,6.x,7.x,8.x:
 //		https://github.com/bbossgroups/es_bboss_web
 //
 //		Here is a quickstart tutorial:
 //		https://esdoc.bbossgroups.com/#/quickstart
 		embeddedElastic = EmbeddedElastic.builder()
-				.withElasticVersion( "5.0.0")
+				.withElasticVersion( "6.8.0")
 				 .withSetting(PopularProperties.HTTP_PORT, 9200)
 				 .withEsJavaOpts("-Xms128m -Xmx512m")
 				 .withStartTimeout(2, MINUTES)
@@ -95,54 +84,65 @@ public static void tearDownAfterClass() {
 		if(embeddedElastic != null)
 			embeddedElastic.stop();
 	}
+
+
 	@Test
-	public void testClientInterface() throws Exception {
+	public void indiceCreate( ) throws Exception {
 		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
-		indiceCreate(verifier);
-		indiceExist(  verifier);
-		add2ndGetDocument(verifier);
-		bulkDocuments(verifier);
-		searchDocuments(verifier);
-		updateAndDeleteDocument(verifier);
-	}
-	public void indiceCreate(PluginTestVerifier verifier) throws Exception {
-		boolean existIndice = configRestClientInterface.existIndice("cars");
-		Method createIndiceMappingMethod = configRestClientInterface.getClass().getDeclaredMethod("createIndiceMapping",String.class,String.class);
-
-		if(!existIndice){
-			// Create cars indice with car indexType by bboss
-			// Get indice mappings and settings with dsl name "createCarIndice" from configfile elasticsearchbboss/car-mapping.xml
-			configRestClientInterface.createIndiceMapping("cars","createCarIndice");
-			verifier.verifyTrace(event(serviceType, createIndiceMappingMethod));
+		Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil");
+		Method createIndiceMappingMethod = configClass.getMethod("createIndiceMapping",String.class,String.class);
+		try {
+			configRestClientInterface.createIndiceMapping("cars", "createCarIndice");
+
 		}
-		else{
-			//drop and create indice
+		catch (Exception e){
+
+		};
+		verifier.verifyTrace(event(serviceType, createIndiceMappingMethod));
+
+
+
+	}
+
+	@Test
+	public void indiceDrop( ) throws Exception {
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
+		Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil");
+		Method dropIndiceMethod = configClass.getMethod("dropIndice",String.class);
+		try {
 			configRestClientInterface.dropIndice("cars");
-			configRestClientInterface.createIndiceMapping("cars","createCarIndice");
-			Method dropIndiceMethod = configRestClientInterface.getClass().getDeclaredMethod("dropIndice",String.class);
-			verifier.verifyTrace(event(serviceType, dropIndiceMethod));
-			verifier.verifyTrace(event(serviceType, createIndiceMappingMethod));
+		}
+		catch (Exception e){
+
 		}
 
+		verifier.verifyTrace(event(serviceType, dropIndiceMethod));
+
+
+
 	}
-	public void indiceExist(PluginTestVerifier verifier) throws Exception{
+	@Test
+	public void indiceExist( ) throws Exception{
 
 		//Validate the indice twitter exist or not
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
 
-		boolean existIndice = clientInterface.existIndice("twitter");
-
-		//TODO just a sample
-		Assert.assertEquals(existIndice,false);
 		//Validate the indice cars exist or not
-		existIndice = clientInterface.existIndice("cars");
-		Assert.assertEquals(existIndice,true);
-		Method existIndiceMethod = clientInterface.getClass().getDeclaredMethod("existIndice",String.class);
+		boolean existIndice = clientInterface.existIndice("cars");
+
+//		Assert.assertEquals(existIndice,true);
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method existIndiceMethod = restClientUtilClass.getMethod("existIndice",String.class);
 		verifier.verifyTrace(event(serviceType, existIndiceMethod));
 
 	}
 
-
-	public void add2ndGetDocument(PluginTestVerifier verifier) throws Exception{
+	@Test
+	public void addDocument( ) throws Exception{
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method addDocumentMethod = restClientUtilClass.getDeclaredMethod("addDocument",String.class,String.class,
+				Object.class,String.class);
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
 		Car car = new Car();
 		//set carid as the index documentid
 		car.setCarId("1");
@@ -152,21 +152,38 @@ public void add2ndGetDocument(PluginTestVerifier verifier) throws Exception{
 
 		//add data to cars/car indice. Use force refresh when test case,but product mode does not use forcerefresh
 		// and should use：
-		// clientInterface.addDocument("cars","car",car).
-		clientInterface.addDocument("cars","car",car,"refresh=true");
-		//get car by document id "1"
-		car = clientInterface.getDocument("cars","car","1",Car.class);
-		Assert.assertNotNull(car);
-		Assert.assertEquals("1",car.getCarId());
-		Method addDocumentMethod = clientInterface.getClass().getDeclaredMethod("addDocument",String.class,
-				String.class,Object.class,String.class);
+		// clientInterface.addDocument("cars",car).
+		try {
+			clientInterface.addDocument("cars", "car",car, "refresh=true");
+		}
+		catch (Exception e){
+
+		}
+
 		verifier.verifyTrace(event(serviceType, addDocumentMethod));
-		Method getDocumentMethod = clientInterface.getClass().getDeclaredMethod("getDocument",String.class,
-				String.class,String.class,Class.class);
+
+	}
+	@Test
+	public void getDocument( ) throws Exception{
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
+		//get car by document id "1"
+		try {
+			Car car = clientInterface.getDocument("cars","1",Car.class);
+		}
+		catch (Exception e){
+
+		}
+
+
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method getDocumentMethod = restClientUtilClass.getDeclaredMethod("getDocument",String.class,
+				String.class,Class.class);
 		verifier.verifyTrace(event(serviceType, getDocumentMethod));
 	}
 
-	public void bulkDocuments(PluginTestVerifier verifier)throws Exception{
+	@Test
+	public  void bulkDocuments( )throws Exception{
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
 		List<Car> cars = new ArrayList<Car>();
 		Car car = new Car();
 		//set carid as the index documentid
@@ -184,40 +201,51 @@ public void bulkDocuments(PluginTestVerifier verifier)throws Exception{
 		cars.add(car);
 		//add datas to cars/car indice.Use force refresh when test case,but product mode does not use forcerefresh
 		// and should use：
-		// clientInterface.addDocuments("cars","car",cars);
-		clientInterface.addDocuments("cars","car",cars,"refresh=true");
-		//get car by document id "2"
-		car = clientInterface.getDocument("cars","car","2",Car.class);
-		Assert.assertNotNull(car);
-		Assert.assertEquals("2",car.getCarId());
-		Method addDocumentsMethod = clientInterface.getClass().getDeclaredMethod("addDocuments",String.class,
-				String.class,List.class,String.class);
+		// clientInterface.addDocuments("cars",cars);
+
+		try {
+			clientInterface.addDocuments("cars","car",cars,"refresh=true");
+		}
+		catch (Exception e){
+
+		}
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method addDocumentsMethod = restClientUtilClass.getDeclaredMethod("addDocuments",String.class,String.class,
+				List.class,String.class);
 		verifier.verifyTrace(event(serviceType, addDocumentsMethod));
-		Method getDocumentMethod = clientInterface.getClass().getDeclaredMethod("getDocument",String.class,
-				String.class,String.class,Class.class);
-		verifier.verifyTrace(event(serviceType, getDocumentMethod));
+
 	}
 
 
 
-	public void searchDocuments(PluginTestVerifier verifier)throws Exception{
-		Map<String,Object> condition = new HashMap<>();
-		//set description as search condition
-		condition.put("description","passat");
+	@Test
+	public  void searchDocuments()throws Exception{
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
+		try {
+			Map<String,Object> condition = new HashMap<>();
+			//set description as search condition
+			condition.put("description","passat");
 
-		//search data to cars/car indice that match condition with a simple query dsl named testSearch defined in elasticsearchbboss/car-mapping.xml.
-		ESDatas<Car> carESDatas = configRestClientInterface.searchList("cars/_search","testSearch",condition,Car.class);
-		//datas that match condition
-		List<Car> cars = carESDatas.getDatas();
-		//totalsize that match condition
-		long totalSize = carESDatas.getTotalSize();
-		Assert.assertTrue(totalSize > 0);
-		Method searchListMethod = configRestClientInterface.getClass().getDeclaredMethod("searchList",String.class,
+			//search data to cars/car indice that match condition with a simple query dsl named testSearch defined in elasticsearchbboss/car-mapping.xml.
+			ESDatas<Car> carESDatas = configRestClientInterface.searchList("cars/_search","testSearch",condition,Car.class);
+			//datas that match condition
+			List<Car> cars = carESDatas.getDatas();
+			//totalsize that match condition
+			long totalSize = carESDatas.getTotalSize();
+		}
+		catch (Exception e){
+
+		}
+
+		Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil");
+		Method searchListMethod = configClass.getDeclaredMethod("searchList",String.class,
 				String.class,Map.class,Class.class);
 		verifier.verifyTrace(event(serviceType, searchListMethod));
 	}
 
-	public void updateAndDeleteDocument(PluginTestVerifier verifier)throws Exception{
+	@Test
+	public  void updateDocument( )throws Exception{
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
 		Car car = new Car();
 		//set carid as the index documentid
 		car.setCarId("1");
@@ -228,28 +256,40 @@ public void updateAndDeleteDocument(PluginTestVerifier verifier)throws Exception
 		// Update data on cars/car indice that document id is 1.
 		// Use force refresh when test case,but product mode does not use forcerefresh
 		// and should use：
-		// clientInterface.updateDocument("cars","car","1",car);
-		clientInterface.updateDocument("cars","car","1",car,"refresh=true");
-		// Get modified car
-		car = clientInterface.getDocument("cars","car","1",Car.class);
-		Assert.assertEquals("1.0T",car.getModel());
+		// clientInterface.updateDocument("cars","1",car);
+
+		try {
+			clientInterface.updateDocument("cars","car","1",car,"refresh=true");
+		}
+		catch (Exception e){
+
+		}
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method updateDocumentMethod = restClientUtilClass.getDeclaredMethod("updateDocument",String.class,String.class,
+				Object.class,Object.class,String.class);
+		verifier.verifyTrace(event(serviceType, updateDocumentMethod));
+
+	}
+
+	@Test
+	public  void deleteDocument( )throws Exception{
+		PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
 		// Delete data on cars/car indice that document id is 1.
 		// Use force refresh when test case,but product mode does not use forcerefresh
 		// and should use：
-		// clientInterface.deleteDocument("cars","car","1");
-		clientInterface.deleteDocument("cars","car","1","refresh=true");
-		// Get delete car. will get a null object.
-		car = clientInterface.getDocument("cars","car","1",Car.class);
-		Assert.assertNull(car);
-		Method updateDocumentMethod = clientInterface.getClass().getDeclaredMethod("updateDocument",String.class,
-				String.class,Object.class,Object.class,String.class);
-		verifier.verifyTrace(event(serviceType, updateDocumentMethod));
-		Method getDocumentMethod = clientInterface.getClass().getDeclaredMethod("getDocument",String.class,
-				String.class,String.class,Class.class);
-		verifier.verifyTrace(event(serviceType, getDocumentMethod));
-		Method deleteDocumentMethod = clientInterface.getClass().getDeclaredMethod("deleteDocument",String.class,
-				String.class,String.class,String.class);
-		verifier.verifyTrace(event(serviceType, deleteDocumentMethod));
+		// clientInterface.deleteDocument("cars","1");
+
+		try {
+			clientInterface.deleteDocument("cars","car","1","refresh=true");
+		}
+		catch (Exception e){
+
+		}
+		Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil");
+		Method deleteDocument = restClientUtilClass.getDeclaredMethod("deleteDocument",String.class,String.class,
+				String.class,String.class);
+		verifier.verifyTrace(event(serviceType, deleteDocument));
+
 	}
 
 }
diff --git a/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT569.java b/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT569.java
new file mode 100644
index 000000000000..b20dc97e374e
--- /dev/null
+++ b/agent-it8/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT569.java
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2018 NAVER Corp.
+ *  Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss;
+
+
+import com.navercorp.pinpoint.plugin.AgentPath;
+import com.navercorp.pinpoint.test.plugin.Dependency;
+import com.navercorp.pinpoint.test.plugin.JvmVersion;
+import com.navercorp.pinpoint.test.plugin.PinpointAgent;
+import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
+import org.junit.runner.RunWith;
+
+
+/**
+ * @author yinbp[yin-bp@163.com]
+ */
+
+@RunWith(PinpointPluginTestSuite.class)
+@PinpointAgent(AgentPath.PATH)
+@Dependency({"com.bbossgroups.plugins:bboss-elasticsearch-rest-jdbc:[5.6.9,5.8.3)",
+		"pl.allegro.tech:embedded-elasticsearch:2.8.0"})
+@JvmVersion(8)
+public class ElasticsearchExecutorIT569 extends ElasticsearchExecutorIT{
+
+
+}