Acceptance tests: Remove ES bootstrap boilerplate
Instead of initializing the indices and mapping using Transport client, just use the production code for that: AbstractElasticIndex.deleteAll() does the job. Refactor the code to access the injector and call this method iterating over Collection<IndexDefinition<?, ?, ?>>. That way we also don't need clean up anymore, because deleteAll does two things delete all indices and create the mapping. With this change embedded ES mode is still used for acceptance tests, but only Node API to start a single node of cluster. Change-Id: I57e5d0718424b8ff1593f5152b5b1113bd0b6a8e
This commit is contained in:
		 David Ostrovsky
					David Ostrovsky
				
			
				
					committed by
					
						 David Pursehouse
						David Pursehouse
					
				
			
			
				
	
			
			
			 David Pursehouse
						David Pursehouse
					
				
			
						parent
						
							a29b921dc1
						
					
				
				
					commit
					764af7d0b5
				
			| @@ -22,7 +22,6 @@ import com.google.inject.Guice; | ||||
| import com.google.inject.Injector; | ||||
| import java.util.concurrent.ExecutionException; | ||||
| import org.eclipse.jgit.lib.Config; | ||||
| import org.junit.After; | ||||
| import org.junit.AfterClass; | ||||
| import org.junit.BeforeClass; | ||||
|  | ||||
| @@ -51,11 +50,10 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest { | ||||
|     return testName.getMethodName().toLowerCase() + "_"; | ||||
|   } | ||||
|  | ||||
|   @After | ||||
|   public void cleanupIndex() { | ||||
|     if (nodeInfo != null) { | ||||
|       ElasticTestUtils.deleteAllIndexes(nodeInfo, testName()); | ||||
|     } | ||||
|   @Override | ||||
|   protected void initAfterLifecycleStart() throws Exception { | ||||
|     super.initAfterLifecycleStart(); | ||||
|     ElasticTestUtils.createAllIndexes(injector); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -64,7 +62,6 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest { | ||||
|     InMemoryModule.setDefaults(elasticsearchConfig); | ||||
|     String indicesPrefix = testName(); | ||||
|     ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); | ||||
|     ElasticTestUtils.createAllIndexes(nodeInfo, indicesPrefix); | ||||
|     return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -24,7 +24,6 @@ import com.google.inject.Injector; | ||||
| import java.util.concurrent.ExecutionException; | ||||
| import org.eclipse.jgit.junit.TestRepository; | ||||
| import org.eclipse.jgit.lib.Config; | ||||
| import org.junit.After; | ||||
| import org.junit.AfterClass; | ||||
| import org.junit.BeforeClass; | ||||
| import org.junit.Rule; | ||||
| @@ -58,11 +57,10 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest { | ||||
|     return testName.getMethodName().toLowerCase() + "_"; | ||||
|   } | ||||
|  | ||||
|   @After | ||||
|   public void cleanupIndex() { | ||||
|     if (nodeInfo != null) { | ||||
|       ElasticTestUtils.deleteAllIndexes(nodeInfo, testName()); | ||||
|     } | ||||
|   @Override | ||||
|   protected void initAfterLifecycleStart() throws Exception { | ||||
|     super.initAfterLifecycleStart(); | ||||
|     ElasticTestUtils.createAllIndexes(injector); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -71,7 +69,6 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest { | ||||
|     InMemoryModule.setDefaults(elasticsearchConfig); | ||||
|     String indicesPrefix = testName(); | ||||
|     ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); | ||||
|     ElasticTestUtils.createAllIndexes(nodeInfo, indicesPrefix); | ||||
|     return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import com.google.inject.Guice; | ||||
| import com.google.inject.Injector; | ||||
| import java.util.concurrent.ExecutionException; | ||||
| import org.eclipse.jgit.lib.Config; | ||||
| import org.junit.After; | ||||
| import org.junit.AfterClass; | ||||
| import org.junit.BeforeClass; | ||||
|  | ||||
| @@ -51,11 +50,10 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest { | ||||
|     return testName.getMethodName().toLowerCase() + "_"; | ||||
|   } | ||||
|  | ||||
|   @After | ||||
|   public void cleanupIndex() { | ||||
|     if (nodeInfo != null) { | ||||
|       ElasticTestUtils.deleteAllIndexes(nodeInfo, testName()); | ||||
|     } | ||||
|   @Override | ||||
|   protected void initAfterLifecycleStart() throws Exception { | ||||
|     super.initAfterLifecycleStart(); | ||||
|     ElasticTestUtils.createAllIndexes(injector); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -64,7 +62,6 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest { | ||||
|     InMemoryModule.setDefaults(elasticsearchConfig); | ||||
|     String indicesPrefix = testName(); | ||||
|     ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port, indicesPrefix); | ||||
|     ElasticTestUtils.createAllIndexes(nodeInfo, indicesPrefix); | ||||
|     return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration)); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user