Repository: dadoonet/elasticsearch-beyonder
Pull request #44 (2018-11-16 10:49:21)

Update to Elasticsearch 6.5.0
This is also a preparation for 7.0.0 which uses new API/Classes.


Patch:
diff --git a/.travis.yml b/.travis.yml
index e9fb311..645074e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,10 +11,6 @@ script:
 # We fetch as much as dependencies we can but we don't print the output so it's more digest
 # Sadly this is the only way to make maven download everything and not pollute the logs...
   - mvn --batch-mode clean dependency:resolve dependency:resolve-plugins install -DskipTests -Dsilent=true > /dev/null
-  # TODO We should add -Pes-xpack
-  # Test against 5.x version
-  - mvn --batch-mode clean verify -Pes-5x
-  # Test against 6.x version (default)
   - mvn --batch-mode clean verify
 after_success:
   - "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && mvn deploy -DskipTests --settings deploy-settings.xml"
diff --git a/README.md b/README.md
index 82421ca..f031b2b 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Versions
 
 | elasticsearch-beyonder  | elasticsearch | Release date |
 |:-----------------------:|:-------------:|:------------:|
-| 6.3-SNAPSHOT            | 5.x, 6.x      |              |
+| 6.5-SNAPSHOT            | 6.x           |              |
 | 5.1                     | 5.x, 6.x      |  2017-07-12  |
 | 5.0                     | 5.x, 6.x      |  2017-07-11  |
 | 2.1.0                   | 2.0, 2.1      |  2015-11-25  |
@@ -172,7 +172,7 @@ For example, create the following file `src/main/resources/elasticsearch/twitter
 
 ```javascript
 {
-  "index" : {
+  "settings" : {
     "number_of_shards" : 3,
     "number_of_replicas" : 2
   }
@@ -265,15 +265,7 @@ mvn clean install -DskipUnitTests
 
 ## Integration Tests
 
-Integration tests are launching an elasticsearch server thank to [elasticsearch-maven-plugin](https://github.com/alexcojocaru/elasticsearch-maven-plugin/)
-which makes that super easy to have!
-
-Tests are ran by default on the 5.x series but you can choose to run them against another version by using the following
-maven profiles:
-
-* `es-6x`: runs against an elasticsearch 6.x cluster
-* `es-5x` (default): runs against an elasticsearch 5.x cluster
-
+Integration tests are launching a Docker instance. So you need to have Docker installed.
 
 If you want to disable running integration tests, use `skipIntegTests` option:
 
@@ -281,13 +273,6 @@ If you want to disable running integration tests, use `skipIntegTests` option:
 mvn clean install -DskipIntegTests
 ```
 
-Integration tests can be ran against a cluster secured by [x-pack](https://www.elastic.co/downloads/x-pack).
-You have to activate as well the `es-xpack` profile (not supported yet):
-
-```sh
-mvn clean install -Pes-xpack
-```
-
 If you wish to run integration tests against a cluster which is already running externally, you can configure the
 following settings to locate your cluster:
 
@@ -297,8 +282,6 @@ following settings to locate your cluster:
 | `tests.cluster.scheme`        | `http`        |
 | `tests.cluster.rest.port`     | `9400`        |
 | `tests.cluster.transport.port`| `9500`        |
-| `tests.cluster.user`          | `elastic`     |
-| `tests.cluster.pass`          | `changeme`    |
 
 For example:
 
@@ -318,6 +301,8 @@ mvn clean install \
     -Dtests.cluster.pass=GENERATEDPASSWORD
 ```
 
+Only Rest Tests will pass in that case.
+
 License
 =======
 
diff --git a/pom.xml b/pom.xml
index c864d03..4644a9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
     <groupId>fr.pilato.elasticsearch</groupId>
     <artifactId>elasticsearch-beyonder</artifactId>
     <packaging>jar</packaging>
-    <version>6.4-SNAPSHOT</version>
+    <version>6.5-SNAPSHOT</version>
     <name>Elasticsearch Beyonder</name>
     <url>https://github.com/dadoonet/elasticsearch-beyonder</url>
     <description>
@@ -22,24 +22,22 @@ when an elasticsearch client starts.
     </licenses>
 
     <properties>
-        <elasticsearch.version>6.3.1</elasticsearch.version>
+        <elasticsearch.version>6.5.0</elasticsearch.version>
         <test.elasticsearch.version>${elasticsearch.version}</test.elasticsearch.version>
         <slf4j.version>1.7.25</slf4j.version>
         <log4j.version>2.11.0</log4j.version>
         <commons.io.version>2.6</commons.io.version>
-        <jackson.version>2.9.6</jackson.version>
+        <jackson.version>2.9.7</jackson.version>
+
+        <!-- For integration tests using Docker or external cluster -->
+        <integ.elasticsearch.image>docker.elastic.co/elasticsearch/elasticsearch</integ.elasticsearch.image>
+        <integ.elasticsearch.version>${elasticsearch.version}</integ.elasticsearch.version>
+        <tests.cluster.rest.port>9400</tests.cluster.rest.port>
+        <tests.cluster.transport.port>9500</tests.cluster.transport.port>
 
-        <!-- For integration tests -->
-        <elasticsearch.groupid>org.elasticsearch.distribution.zip</elasticsearch.groupid>
         <skipTests>false</skipTests>
         <skipUnitTests>${skipTests}</skipUnitTests>
         <skipIntegTests>${skipTests}</skipIntegTests>
-        <tests.cluster.rest.port>9400</tests.cluster.rest.port>
-        <tests.cluster.transport.port>9500</tests.cluster.transport.port>
-        <elasticsearch.security.artifact>x-pack</elasticsearch.security.artifact>
-        <elasticsearch.security.version>${test.elasticsearch.version}</elasticsearch.security.version>
-        <integ.security.username>elastic</integ.security.username>
-        <integ.security.password>changeme</integ.security.password>
 
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -94,6 +92,14 @@ when an elasticsearch client starts.
             <releases><enabled>false</enabled></releases>
             <snapshots><enabled>true</enabled></snapshots>
         </repository>
+
+        <repository>
+            <id>elastic-lucene-snapshots</id>
+            <name>Elastic Lucene Snapshots</name>
+            <url>http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/6d9c714052</url>
+            <releases><enabled>true</enabled></releases>
+            <snapshots><enabled>false</enabled></snapshots>
+        </repository>
     </repositories>
 
     <dependencies>
@@ -111,13 +117,6 @@ when an elasticsearch client starts.
             <version>${elasticsearch.version}</version>
             <optional>true</optional>
         </dependency>
-        <!-- add the x-pack jar as a dependency -->
-        <dependency>
-            <groupId>org.elasticsearch.client</groupId>
-            <artifactId>x-pack-transport</artifactId>
-            <version>${elasticsearch.version}</version>
-            <optional>true</optional>
-        </dependency>
 
         <dependency>
             <groupId>commons-io</groupId>
@@ -288,44 +287,55 @@ when an elasticsearch client starts.
                     </execution>
                 </executions>
             </plugin>
+            <!-- For IT using Docker -->
+            <plugin>
+                <groupId>io.fabric8</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>0.26.1</version>
+                <configuration>
+                    <images>
+                        <image>
+                            <alias>elasticsearch-it</alias>
+                            <name>dadoonet/docker-elasticsearch:${project.version}</name>
+                            <build>
+                                <from>${integ.elasticsearch.image}:${integ.elasticsearch.version}</from>
+                            </build>
+                            <run>
+                                <ports>
+                                    <port>tests.cluster.rest.port:9200</port>
+                                    <port>tests.cluster.transport.port:9300</port>
+                                </ports>
+                                <wait>
+                                    <http>
+                                        <url>http://localhost:${tests.cluster.rest.port}/</url>
+                                        <status>200..499</status>
+                                    </http>
+                                    <time>60000</time>
+                                </wait>
+                            </run>
+                        </image>
+                    </images>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>start-elasticsearch</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>build</goal>
+                            <goal>stop</goal>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop-elasticsearch</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>com.github.alexcojocaru</groupId>
-                    <artifactId>elasticsearch-maven-plugin</artifactId>
-                    <version>6.6</version>
-                    <configuration>
-                        <flavor>oss</flavor>
-                        <version>${test.elasticsearch.version}</version>
-                        <httpPort>${tests.cluster.rest.port}</httpPort>
-                        <transportPort>${tests.cluster.transport.port}</transportPort>
-                        <autoCreateIndex>true</autoCreateIndex>
-                        <skip>${skipIntegTests}</skip>
-                    </configuration>
-                    <executions>
-                        <!--
-                            The elasticsearch maven plugin goals are by default bound to the
-                            pre-integration-test and post-integration-test phases
-                        -->
-                        <execution>
-                            <id>start-elasticsearch</id>
-                            <phase>pre-integration-test</phase>
-                            <goals>
-                                <goal>runforked</goal>
-                            </goals>
-                        </execution>
-                        <execution>
-                            <id>stop-elasticsearch</id>
-                            <phase>post-integration-test</phase>
-                            <goals>
-                                <goal>stop</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-                </plugin>
-            </plugins>
-        </pluginManagement>
     </build>
 
     <developers>
@@ -339,52 +349,6 @@ when an elasticsearch client starts.
     </developers>
 
     <profiles>
-        <profile>
-            <id>es-5x</id>
-            <properties>
-                <test.elasticsearch.version>5.6.10</test.elasticsearch.version>
-            </properties>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>com.github.alexcojocaru</groupId>
-                        <artifactId>elasticsearch-maven-plugin</artifactId>
-                        <version>5.11</version>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-        <profile>
-            <id>es-xpack</id>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>com.github.alexcojocaru</groupId>
-                        <artifactId>elasticsearch-maven-plugin</artifactId>
-                        <configuration>
-                            <flavour>default</flavour>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-        <profile>
-            <id>es-6x</id>
-            <activation>
-                <activeByDefault>true</activeByDefault>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>com.github.alexcojocaru</groupId>
-                        <artifactId>elasticsearch-maven-plugin</artifactId>
-                        <configuration>
-                            <flavour>oss</flavour>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
         <profile>
             <id>release</id>
             <build>
diff --git a/release.sh b/release.sh
index de53361..27745da 100755
--- a/release.sh
+++ b/release.sh
@@ -57,14 +57,9 @@ promptyn () {
     done
 }
 
-test_against_version () {
-    if [ -z "$1" ]; then
-        echo "Building the release..."
-        mvn clean install -DskipTests -Prelease ${MAVEN_OPTION} >> /tmp/beyonder-${RELEASE_VERSION}.log
-    else
-        echo "Building and testing against elasticsearch $1.x..."
-        mvn clean verify -Pes-$1x ${MAVEN_OPTION} >> /tmp/beyonder-${RELEASE_VERSION}.log
-    fi
+run_integration_tests () {
+    echo "Building the release..."
+    mvn clean install -DskipTests -Prelease ${MAVEN_OPTION} >> /tmp/beyonder-${RELEASE_VERSION}.log
 
     if [ $? -ne 0 ]
     then
@@ -129,12 +124,8 @@ mvn versions:set -DnewVersion=${RELEASE_VERSION} >> /tmp/beyonder-${RELEASE_VERS
 # Git commit release
 git commit -q -a -m "prepare release beyonder-$RELEASE_VERSION"
 
-# Testing against different elasticsearch versions
-test_against_version 5
-test_against_version 6
-
 # Testing that release will work at the end
-test_against_version
+run_integration_tests
 
 # Just display the end of the build
 tail -7 /tmp/beyonder-${RELEASE_VERSION}.log
diff --git a/src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java b/src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java
index b378bdc..000091f 100644
--- a/src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java
+++ b/src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java
@@ -82,25 +82,19 @@ public class ResourceList {
             /* A JAR path */
             logger.trace("found a jar file resource: {}", dirURL);
             String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file
-            String prefix = dirURL.getPath().substring(5 + jarPath.length())
-                        // remove any ! that a class loader (e.g. from spring boot) could have added
-                        .replaceAll("!", "")
-                        // remove leading slash that is not part of the JarEntry::getName
-                        .substring(1);
+            JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
+            Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
             Set<String> result = new HashSet<>(); //avoid duplicates in case it is a subdirectory
-            try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))) {
-                Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
-                while(entries.hasMoreElements()) {
-                    String name = entries.nextElement().getName();
-                    if (name.startsWith(prefix)) { //filter according to the path
-                        String entry = name.substring(prefix.length());
-                        int checkSubdir = entry.indexOf("/");
-                        if (checkSubdir >= 0) {
-                            // if it is a subdirectory, we just return the directory name
-                            entry = entry.substring(0, checkSubdir);
-                        }
-                        result.add(entry);
+            while(entries.hasMoreElements()) {
+                String name = entries.nextElement().getName();
+                if (name.startsWith(root)) { //filter according to the path
+                    String entry = name.substring(root.length());
+                    int checkSubdir = entry.indexOf("/");
+                    if (checkSubdir >= 0) {
+                        // if it is a subdirectory, we just return the directory name
+                        entry = entry.substring(0, checkSubdir);
                     }
+                    result.add(entry);
                 }
             }
             String[] resources = result.toArray(new String[result.size()]);
diff --git a/src/main/java/fr/pilato/elasticsearch/tools/alias/AliasElasticsearchUpdater.java b/src/main/java/fr/pilato/elasticsearch/tools/alias/AliasElasticsearchUpdater.java
index 2314327..7929a79 100644
--- a/src/main/java/fr/pilato/elasticsearch/tools/alias/AliasElasticsearchUpdater.java
+++ b/src/main/java/fr/pilato/elasticsearch/tools/alias/AliasElasticsearchUpdater.java
@@ -19,17 +19,14 @@
 
 package fr.pilato.elasticsearch.tools.alias;
 
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
-
 public class AliasElasticsearchUpdater {
 
     private static final Logger logger = LoggerFactory.getLogger(AliasElasticsearchUpdater.class);
@@ -44,7 +41,7 @@ public class AliasElasticsearchUpdater {
     @Deprecated
     public static void createAlias(Client client, String alias, String index) throws Exception {
         logger.trace("createAlias({},{})", alias, index);
-        IndicesAliasesResponse response = client.admin().indices().prepareAliases().addAlias(index, alias).get();
+        AcknowledgedResponse response = client.admin().indices().prepareAliases().addAlias(index, alias).get();
         if (!response.isAcknowledged()) throw new Exception("Could not define alias [" + alias + "] for index [" + index + "].");
         logger.trace("/createAlias({},{})", alias, index);
     }
@@ -63,11 +60,9 @@ public class AliasElasticsearchUpdater {
         assert alias != null;
         assert index != null;
 
-        String json = "{\"actions\":[{\"add\":{\"index\":\"" + index +"\",\"alias\":\"" + alias +"\"}}]}";
-
-        Response response = client.performRequest("POST", "/_aliases/", Collections.<String, String>emptyMap(),
-                new StringEntity(json, ContentType.APPLICATION_JSON));
-
+        Request request = new Request("POST", "/_aliases/");
+        request.setJsonEntity("{\"actions\":[{\"add\":{\"index\":\"" + index +"\",\"alias\":\"" + alias +"\"}}]}");
+        Response response = client.performRequest(request);
 
         if (response.getStatusLine().getStatusCode() != 200) {
             logger.warn("Could not create alias [{}] on index [{}]", alias, index);
diff --git a/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java b/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java
index 6a11445..4e0e66e 100644
--- a/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java
+++ b/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java
@@ -19,20 +19,17 @@
 
 package fr.pilato.elasticsearch.tools.index;
 
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
 import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
-
 /**
  * Manage elasticsearch index settings
  * @author David Pilato
@@ -103,8 +100,8 @@ public class IndexElasticsearchUpdater {
 		assert client != null;
 		assert index != null;
 
-		DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(index).get();
-		if (!deleteIndexResponse.isAcknowledged()) {
+        AcknowledgedResponse response = client.admin().indices().prepareDelete(index).get();
+		if (!response.isAcknowledged()) {
 			logger.warn("Could not delete index [{}]", index);
 			throw new Exception("Could not delete index ["+index+"].");
 		}
@@ -131,7 +128,7 @@ public class IndexElasticsearchUpdater {
 		// If there are settings for this index, we use it. If not, using Elasticsearch defaults.
 		if (settings != null) {
 			logger.trace("Found settings for index [{}]: [{}]", index, settings);
-			cirb.setSettings(settings, XContentType.JSON);
+			cirb.setSource(settings, XContentType.JSON);
 		}
 
 		CreateIndexResponse createIndexResponse = cirb.execute().actionGet();
@@ -260,7 +257,7 @@ public class IndexElasticsearchUpdater {
 		assert client != null;
 		assert index != null;
 
-		Response response = client.performRequest("DELETE", "/" + index);
+		Response response = client.performRequest(new Request("DELETE", "/" + index));
 		if (response.getStatusLine().getStatusCode() != 200) {
 			logger.warn("Could not delete index [{}]", index);
 			throw new Exception("Could not delete index ["+index+"].");
@@ -282,15 +279,15 @@ public class IndexElasticsearchUpdater {
 		assert client != null;
 		assert index != null;
 
-		StringEntity entity = null;
+        Request request = new Request("PUT", "/" + index);
 
 		// If there are settings for this index, we use it. If not, using Elasticsearch defaults.
 		if (settings != null) {
 			logger.trace("Found settings for index [{}]: [{}]", index, settings);
-			entity = new StringEntity(settings, ContentType.APPLICATION_JSON);
+			request.setJsonEntity(settings);
 		}
 
-		Response response = client.performRequest("PUT", "/" + index, Collections.<String, String>emptyMap(), entity);
+        Response response = client.performRequest(request);
 		if (response.getStatusLine().getStatusCode() != 200) {
 			logger.warn("Could not create index [{}]", index);
 			throw new Exception("Could not create index ["+index+"].");
@@ -312,11 +309,13 @@ public class IndexElasticsearchUpdater {
 		assert client != null;
 		assert index != null;
 
+
 		if (settings != null) {
 			logger.trace("Found update settings for index [{}]: [{}]", index, settings);
 			logger.debug("updating settings for index [{}]", index);
-			StringEntity entity = new StringEntity(settings, ContentType.APPLICATION_JSON);
-			client.performRequest("PUT", "/" + index + "/_settings", Collections.<String, String>emptyMap(), entity);
+            Request request = new Request("PUT", "/" + index + "/_settings");
+            request.setJsonEntity(settings);
+			client.performRequest(request);
 		}
 
 		logger.trace("/updateIndex([{}])", index);
@@ -330,7 +329,7 @@ public class IndexElasticsearchUpdater {
 	 * @throws Exception if the elasticsearch API call is failing
 	 */
 	public static boolean isIndexExist(RestClient client, String index) throws Exception {
-		Response response = client.performRequest("HEAD", "/" + index);
+		Response response = client.performRequest(new Request("HEAD", "/" + index));
 		return response.getStatusLine().getStatusCode() == 200;
 	}
 
diff --git a/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java b/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java
index c56b387..65f1180 100644
--- a/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java
+++ b/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java
@@ -19,10 +19,9 @@
 
 package fr.pilato.elasticsearch.tools.template;
 
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.common.xcontent.XContentType;
@@ -30,7 +29,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.Collections;
 
 /**
  * Manage elasticsearch templates
@@ -110,7 +108,7 @@ public class TemplateElasticsearchUpdater {
 		assert client != null;
 		assert template != null;
 
-		PutIndexTemplateResponse response = client.admin().indices()
+        AcknowledgedResponse response = client.admin().indices()
 				.preparePutTemplate(template)
 				.setSource(json.getBytes(), XContentType.JSON)
 				.get();
@@ -210,9 +208,9 @@ public class TemplateElasticsearchUpdater {
 		assert client != null;
 		assert template != null;
 
-		Response response = client.performRequest("PUT", "/_template/" + template, Collections.<String, String>emptyMap(),
-				new StringEntity(json, ContentType.APPLICATION_JSON));
-
+		Request request = new Request("PUT", "/_template/" + template);
+		request.setJsonEntity(json);
+		Response response = client.performRequest(request);
 
 		if (response.getStatusLine().getStatusCode() != 200) {
 			logger.warn("Could not create template [{}]", template);
@@ -230,7 +228,7 @@ public class TemplateElasticsearchUpdater {
      * @throws IOException if something goes wrong
 	 */
 	public static boolean isTemplateExist(RestClient client, String template) throws IOException {
-		Response response = client.performRequest("HEAD", "/_template/" + template);
+		Response response = client.performRequest(new Request("HEAD", "/_template/" + template));
 		return response.getStatusLine().getStatusCode() == 200;
 	}
 
@@ -242,7 +240,7 @@ public class TemplateElasticsearchUpdater {
 	 */
 	public static void removeTemplate(RestClient client, String template) throws Exception {
 		logger.trace("removeTemplate({})", template);
-		client.performRequest("DELETE", "/_template/" + template);
+		client.performRequest(new Request("DELETE", "/_template/" + template));
 		logger.trace("/removeTemplate({})", template);
 	}
 
diff --git a/src/main/java/fr/pilato/elasticsearch/tools/type/TypeElasticsearchUpdater.java b/src/main/java/fr/pilato/elasticsearch/tools/type/TypeElasticsearchUpdater.java
index 70c7b16..24304d3 100644
--- a/src/main/java/fr/pilato/elasticsearch/tools/type/TypeElasticsearchUpdater.java
+++ b/src/main/java/fr/pilato/elasticsearch/tools/type/TypeElasticsearchUpdater.java
@@ -19,18 +19,15 @@
 
 package fr.pilato.elasticsearch.tools.type;
 
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
-
 /**
  * Manage elasticsearch types (mappings)
  * @author David Pilato
@@ -133,10 +130,10 @@ public class TypeElasticsearchUpdater {
 
         if (mapping != null) {
             // Create type and mapping
-            PutMappingResponse mappingResponse = client.admin().indices().preparePutMapping(index)
+            AcknowledgedResponse response = client.admin().indices().preparePutMapping(index)
                     .setType(type)
                     .setSource(mapping, XContentType.JSON).get();
-            if (!mappingResponse.isAcknowledged()) {
+            if (!response.isAcknowledged()) {
                 logger.warn("Could not create type [{}/{}]", index, type);
                 throw new Exception("Could not create type ["+index+"/"+type+"].");
             }
@@ -214,7 +211,7 @@ public class TypeElasticsearchUpdater {
      * @throws Exception if the elasticsearch call is failing
      */
     public static boolean isTypeExist(RestClient client, String index, String type) throws Exception {
-        Response response = client.performRequest("HEAD", "/" + index + "/_mapping/" + type);
+        Response response = client.performRequest(new Request("HEAD", "/" + index + "/_mapping/" + type));
         return response.getStatusLine().getStatusCode() == 200;
     }
 
@@ -236,8 +233,9 @@ public class TypeElasticsearchUpdater {
 
         if (mapping != null) {
             // Create type and mapping
-            StringEntity entity = new StringEntity(mapping, ContentType.APPLICATION_JSON);
-            Response response = client.performRequest("PUT", "/" + index + "/_mapping/" + type, Collections.<String, String>emptyMap(), entity);
+            Request request = new Request("PUT", "/" + index + "/_mapping/" + type);
+            request.setJsonEntity(mapping);
+            Response response = client.performRequest(request);
             if (response.getStatusLine().getStatusCode() != 200) {
                 logger.warn("Could not create type [{}/{}]", index, type);
                 throw new Exception("Could not create type ["+index+"/"+type+"].");


Test patch:
diff --git a/src/test/java/fr/pilato/elasticsearch/tools/AbstractBeyonderTest.java b/src/test/java/fr/pilato/elasticsearch/tools/AbstractBeyonderTest.java
index 6666135..250b444 100644
--- a/src/test/java/fr/pilato/elasticsearch/tools/AbstractBeyonderTest.java
+++ b/src/test/java/fr/pilato/elasticsearch/tools/AbstractBeyonderTest.java
@@ -20,25 +20,22 @@
 package fr.pilato.elasticsearch.tools;
 
 import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
-import org.elasticsearch.client.RestClientBuilder;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.net.ConnectException;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.not;
 import static org.junit.Assume.assumeThat;
@@ -50,8 +47,6 @@ public abstract class AbstractBeyonderTest {
 
     private final static String DEFAULT_TEST_CLUSTER_HOST = "127.0.0.1";
     private final static String DEFAULT_TEST_CLUSTER_SCHEME = "http";
-    private final static String DEFAULT_USERNAME = "elastic";
-    private final static String DEFAULT_PASSWORD = "changeme";
     private final static Integer DEFAULT_TEST_CLUSTER_REST_PORT = 9400;
     private final static Integer DEFAULT_TEST_CLUSTER_TRANSPORT_PORT = 9500;
 
@@ -59,16 +54,12 @@ public abstract class AbstractBeyonderTest {
     private final static String testClusterScheme = System.getProperty("tests.cluster.scheme", DEFAULT_TEST_CLUSTER_SCHEME);
     private final static int testClusterRestPort = Integer.parseInt(System.getProperty("tests.cluster.rest.port", DEFAULT_TEST_CLUSTER_REST_PORT.toString()));
     final static int testClusterTransportPort = Integer.parseInt(System.getProperty("tests.cluster.transport.port", DEFAULT_TEST_CLUSTER_TRANSPORT_PORT.toString()));
-    final static String testClusterUser = System.getProperty("tests.cluster.user", DEFAULT_USERNAME);
-    final static String testClusterPass = System.getProperty("tests.cluster.pass", DEFAULT_PASSWORD);
 
     abstract protected void testBeyonder(String root,
                                 List<String> indices,
                                 List<List<String>> types,
                                 List<String> templates) throws Exception;
 
-    static boolean securityInstalled;
-
     private static RestClient client;
 
     static RestClient restClient() throws IOException {
@@ -81,53 +72,21 @@ public abstract class AbstractBeyonderTest {
     private static void startRestClient() throws IOException {
         if (client == null) {
             client = RestClient.builder(new HttpHost(testClusterHost, testClusterRestPort, testClusterScheme)).build();
-
-            securityInstalled = testClusterRunning(false);
-            if (securityInstalled) {
-                // We have a secured cluster. So we need to create a secured client
-                // But first we need to close the previous client we built
-                if (client != null) {
-                    client.close();
-                }
-
-                final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-                credentialsProvider.setCredentials(AuthScope.ANY,
-                        new UsernamePasswordCredentials(testClusterUser, testClusterPass));
-
-                client = RestClient.builder(new HttpHost(testClusterHost, testClusterRestPort, testClusterScheme))
-                        .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
-                            @Override
-                            public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
-                                return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
-                            }
-                        })
-                        .build();
-                securityInstalled = testClusterRunning(true);
-            }
+            testClusterRunning();
         }
     }
 
-    private static boolean testClusterRunning(boolean withSecurity) throws IOException {
+    private static boolean testClusterRunning() throws IOException {
         try {
-            Response response = client.performRequest("GET", "/");
+            Response response = client.performRequest(new Request("GET", "/"));
             Map<String, Object> asMap = (Map<String, Object>) JsonUtil.asMap(response).get("version");
-
-            logger.info("Starting integration tests against an external cluster running elasticsearch [{}] with {}",
-                    asMap.get("number"), withSecurity ? "security" : "no security" );
-            return withSecurity;
+            logger.info("Starting integration tests against an external cluster running elasticsearch [{}]", asMap.get("number"));
+            return false;
         } catch (ConnectException e) {
             // If we have an exception here, let's ignore the test
             logger.warn("Integration tests are skipped: [{}]", e.getMessage());
             assumeThat("Integration tests are skipped", e.getMessage(), not(containsString("Connection refused")));
-            return withSecurity;
-        } catch (ResponseException e) {
-            if (e.getResponse().getStatusLine().getStatusCode() == 401) {
-                logger.debug("The cluster is secured. So we need to build a client with security", e);
-                return true;
-            } else {
-                logger.error("Full error is", e);
-                throw e;
-            }
+            return false;
         } catch (IOException e) {
             logger.error("Full error is", e);
             throw e;
@@ -140,8 +99,8 @@ public abstract class AbstractBeyonderTest {
     public void testDefaultDir() throws Exception {
         // Default dir es
         testBeyonder(null,
-                asList("twitter"),
-                asList(asList("tweet")),
+                singletonList("twitter"),
+                singletonList(singletonList("tweet")),
                 null);
     }
 
@@ -149,18 +108,8 @@ public abstract class AbstractBeyonderTest {
     public void testOneIndexOneType() throws Exception {
         // Single index/single type
         testBeyonder("models/oneindexonetype",
-                asList("twitter"),
-                asList(asList("tweet")),
-                null);
-    }
-
-    @Test
-    public void testTwoIndicesTwoTypesOneType() throws Exception {
-        assumeTrue("Skipping test as current version does not support multiple types.", supportsMultipleTypes);
-        // 2 indices: 2 types and 1 type
-        testBeyonder("models/twoindicestwotypesonetype",
-                asList("rss", "twitter"),
-                asList(asList("doc1", "doc2"), asList("tweet")),
+                singletonList("twitter"),
+                singletonList(singletonList("tweet")),
                 null);
     }
 
@@ -168,8 +117,8 @@ public abstract class AbstractBeyonderTest {
     public void testSettingsAnalyzer() throws Exception {
         // Custom settings (analyzer)
         testBeyonder("models/settingsanalyzer",
-                asList("twitter"),
-                asList(asList("tweet")),
+                singletonList("twitter"),
+                singletonList(singletonList("tweet")),
                 null);
     }
 
@@ -177,8 +126,8 @@ public abstract class AbstractBeyonderTest {
     public void testOneIndexNoType() throws Exception {
         // 1 index and no type
         testBeyonder("models/oneindexnotype",
-                asList("twitter"),
-                asList((List<String>) null),
+                singletonList("twitter"),
+                singletonList(null),
                 null);
     }
 
@@ -188,19 +137,19 @@ public abstract class AbstractBeyonderTest {
         testBeyonder("models/template",
                 null,
                 null,
-                asList("twitter_template"));
+                singletonList("twitter_template"));
     }
 
     @Test
     public void testUpdateSettings() throws Exception {
         // 1 _update_settings
         testBeyonder("models/update-settings/step1",
-                asList("twitter"),
-                asList(asList("tweet")),
+                singletonList("twitter"),
+                singletonList(singletonList("tweet")),
                 null);
         testBeyonder("models/update-settings/step2",
-                asList("twitter"),
-                asList((List<String>) null),
+                singletonList("twitter"),
+                singletonList(null),
                 null);
     }
 
diff --git a/src/test/java/fr/pilato/elasticsearch/tools/BeyonderRestIT.java b/src/test/java/fr/pilato/elasticsearch/tools/BeyonderRestIT.java
index a95af03..e7826b2 100644
--- a/src/test/java/fr/pilato/elasticsearch/tools/BeyonderRestIT.java
+++ b/src/test/java/fr/pilato/elasticsearch/tools/BeyonderRestIT.java
@@ -23,6 +23,7 @@ import fr.pilato.elasticsearch.tools.alias.AliasElasticsearchUpdater;
 import fr.pilato.elasticsearch.tools.index.IndexElasticsearchUpdater;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpEntity;
+import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.RestClient;
 import org.junit.AfterClass;
@@ -67,7 +68,7 @@ public class BeyonderRestIT extends AbstractBeyonderTest {
     @Before
     public void cleanCluster() {
         try {
-            client.performRequest("DELETE", "/_all");
+            client.performRequest(new Request("DELETE", "/_all"));
         } catch (IOException e) {
             assumeNoException(e);
         }
@@ -92,7 +93,7 @@ public class BeyonderRestIT extends AbstractBeyonderTest {
     @BeforeClass
     public static void setTestBehavior() {
         try {
-            Response response = client.performRequest("GET", "/");
+            Response response = client.performRequest(new Request("GET", "/"));
             Map<String, Object> responseAsMap = asMap(response);
             logger.trace("get server response: {}", responseAsMap);
             Object oVersion = extractFromPath(responseAsMap, "version").get("number");
@@ -153,7 +154,7 @@ public class BeyonderRestIT extends AbstractBeyonderTest {
     public void testAliases() throws Exception {
         IndexElasticsearchUpdater.createIndex(client, "test_aliases", true);
         AliasElasticsearchUpdater.createAlias(client, "foo", "test_aliases");
-        Map<String, Object> response = asMap(client.performRequest("GET", "/_alias/foo"));
+        Map<String, Object> response = asMap(client.performRequest(new Request("GET", "/_alias/foo")));
         assertThat(response, hasKey("test_aliases"));
     }
 
@@ -176,7 +177,7 @@ public class BeyonderRestIT extends AbstractBeyonderTest {
     }
 
     private String getMapping(String indexName) throws IOException {
-        HttpEntity response = client.performRequest("GET", indexName + "/_mapping").getEntity();
+        HttpEntity response = client.performRequest(new Request("GET", indexName + "/_mapping")).getEntity();
         ByteArrayOutputStream out = new ByteArrayOutputStream(Math.toIntExact(response.getContentLength()));
         IOUtils.copy(response.getContent(), out);
         return new String(out.toByteArray());
diff --git a/src/test/java/fr/pilato/elasticsearch/tools/BeyonderTransportIT.java b/src/test/java/fr/pilato/elasticsearch/tools/BeyonderTransportIT.java
index 698386a..4137433 100644
--- a/src/test/java/fr/pilato/elasticsearch/tools/BeyonderTransportIT.java
+++ b/src/test/java/fr/pilato/elasticsearch/tools/BeyonderTransportIT.java
@@ -27,7 +27,6 @@ import org.elasticsearch.client.transport.NoNodeAvailableException;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.TransportAddress;
 import org.elasticsearch.transport.client.PreBuiltTransportClient;
-import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -52,20 +51,10 @@ public class BeyonderTransportIT extends AbstractBeyonderTest {
 
     @BeforeClass
     public static void startElasticsearch() throws IOException {
-        // This is going to initialize our Rest Client if not initialized yet and will check
-        // if security is activated on this cluster
+        // This is going to initialize our Rest Client if not initialized yet
         restClient();
-        if (securityInstalled) {
-            client = new PreBuiltXPackTransportClient(
-                    Settings.builder()
-                            .put("client.transport.ignore_cluster_name", true)
-                            .put("xpack.security.user", testClusterUser + ":" + testClusterPass)
-                            .build()
-            ).addTransportAddress(new TransportAddress(new InetSocketAddress(testClusterHost, testClusterTransportPort)));
-        } else {
-            client = new PreBuiltTransportClient(Settings.builder().put("client.transport.ignore_cluster_name", true).build())
-                    .addTransportAddress(new TransportAddress(new InetSocketAddress(testClusterHost, testClusterTransportPort)));
-        }
+        client = new PreBuiltTransportClient(Settings.builder().put("client.transport.ignore_cluster_name", true).build())
+                .addTransportAddress(new TransportAddress(new InetSocketAddress(testClusterHost, testClusterTransportPort)));
     }
 
     @AfterClass
diff --git a/src/test/resources/models/settingsanalyzer/twitter/_settings.json b/src/test/resources/models/settingsanalyzer/twitter/_settings.json
index d54f1b1..e65807e 100644
--- a/src/test/resources/models/settingsanalyzer/twitter/_settings.json
+++ b/src/test/resources/models/settingsanalyzer/twitter/_settings.json
@@ -1,5 +1,5 @@
 {
-	"index" : {
+	"settings" : {
 		"analysis":{
 			"analyzer":{
                 "custom_uax_url_email":{
@@ -25,4 +25,4 @@
 			}
 		}
 	}
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/models/twoindicestwotypesonetype/rss/_settings.json b/src/test/resources/models/twoindicestwotypesonetype/rss/_settings.json
deleted file mode 100644
index a4a5b89..0000000
--- a/src/test/resources/models/twoindicestwotypesonetype/rss/_settings.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-	"index" : {
-		"analysis":{
-			"analyzer":{
-				"francais":{
-					"type":"custom",
-					"tokenizer":"standard",
-					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
-				}
-			},
-			"filter":{
-				"stop_francais":{
-					"type":"stop",
-					"stopwords":["_french_"]
-				},
-				"fr_stemmer" : {
-					"type" : "stemmer",
-					"name" : "french"
-				}
-			}
-		}
-	}
-}
\ No newline at end of file
diff --git a/src/test/resources/models/twoindicestwotypesonetype/rss/doc1.json b/src/test/resources/models/twoindicestwotypesonetype/rss/doc1.json
deleted file mode 100644
index 6dd519f..0000000
--- a/src/test/resources/models/twoindicestwotypesonetype/rss/doc1.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "doc1" : {
-        "properties" : {
-            "message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
-            "author" : {"type" : "text", "store" : false}
-        }
-    }
-}
diff --git a/src/test/resources/models/twoindicestwotypesonetype/rss/doc2.json b/src/test/resources/models/twoindicestwotypesonetype/rss/doc2.json
deleted file mode 100644
index 9d48a5d..0000000
--- a/src/test/resources/models/twoindicestwotypesonetype/rss/doc2.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "doc2" : {
-        "properties" : {
-            "message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
-            "author" : {"type" : "text", "store" : false}
-        }
-    }
-}
diff --git a/src/test/resources/models/twoindicestwotypesonetype/twitter/_settings.json b/src/test/resources/models/twoindicestwotypesonetype/twitter/_settings.json
deleted file mode 100644
index a4a5b89..0000000
--- a/src/test/resources/models/twoindicestwotypesonetype/twitter/_settings.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-	"index" : {
-		"analysis":{
-			"analyzer":{
-				"francais":{
-					"type":"custom",
-					"tokenizer":"standard",
-					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
-				}
-			},
-			"filter":{
-				"stop_francais":{
-					"type":"stop",
-					"stopwords":["_french_"]
-				},
-				"fr_stemmer" : {
-					"type" : "stemmer",
-					"name" : "french"
-				}
-			}
-		}
-	}
-}
\ No newline at end of file
diff --git a/src/test/resources/models/twoindicestwotypesonetype/twitter/tweet.json b/src/test/resources/models/twoindicestwotypesonetype/twitter/tweet.json
deleted file mode 100644
index 3866657..0000000
--- a/src/test/resources/models/twoindicestwotypesonetype/twitter/tweet.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "tweet" : {
-        "properties" : {
-            "message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
-            "author" : {"type" : "text", "store" : false}
-        }
-    }
-}
diff --git a/src/test/resources/models/update-settings/step1/twitter/_settings.json b/src/test/resources/models/update-settings/step1/twitter/_settings.json
index 710f501..77c4e06 100644
--- a/src/test/resources/models/update-settings/step1/twitter/_settings.json
+++ b/src/test/resources/models/update-settings/step1/twitter/_settings.json
@@ -1,5 +1,5 @@
 {
-	"index" : {
+	"settings" : {
         "number_of_shards" : 1,
         "number_of_replicas" : 0
 	}
diff --git a/src/test/resources/models/update-settings/step2/twitter/_update_settings.json b/src/test/resources/models/update-settings/step2/twitter/_update_settings.json
index 3da2209..041827b 100644
--- a/src/test/resources/models/update-settings/step2/twitter/_update_settings.json
+++ b/src/test/resources/models/update-settings/step2/twitter/_update_settings.json
@@ -1,5 +1,3 @@
 {
-    "index" : {
-        "number_of_replicas" : 1
-    }
+    "number_of_replicas" : 1
 }