Giter VIP home page Giter VIP logo

elasticsearch-maven-plugin's Introduction

Elasticsearch Maven Plugin Java CI with Maven

A Maven plugin to run instances of Elasticsearch version 5+ during the integration test phase of a build. Instances are started in forked processes using the runforked goal. They are terminated using the stop goal and, for extra peace of mind, using a JVM shutdown hook.

Each instance is installed in ${project.build.directory}/elasticsearch${instanceIndex}.

This plugin is known to work with Elasticsearch versions 5 to 8. For versions 8+, the xpack security is disabled - there is no need for HTTPS or basic authentication to send requests to the Elasticsearch server. For Elasticsearch version 1.x.x and 2.x.x support, see version 1.x and 2.x of this plugin.

NB: There was a license conflict with one of the project files, which was fixed in version 6.26 of the plugin. See this discussion for details.

NB: Because the plugin uses the new Apache Maven Artifact Resolver, it only works with Maven 3.9.x and above.

Usage

The Elasticsearch behaviour and properties can be configured through the following plugin configuration parameters:

  • instanceCount [defaultValue=1]

    how many Elasticsearch instances to start (all within the same cluster)

  • skip [defaultValue=false]

    whether to skip the plugin execution or not

  • clusterName [defaultValue="test"]

    the name of the cluster to create

  • flavour [defaultValue="oss"]

    only applicable to Elasticsearch versions 6.3.0 to 7.10.x (inclusive); the flavour of Elasticsearch to install (oss, default); the default is not supported, due to x-pack issues; this property is ignored by all versions outside that range

  • version [defaultValue="5.0.0"]

    the version of Elasticsearch to install

  • downloadUrl [defaultValue=""]

    the Elasticsearch download URL (eg. https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-6.3.0.zip); if provided, it overrides the default download URL (https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${flavour}-${version}.zip); the flavour and version plugin properties are still required for building the coordinates of the maven artifact to install in the local repository.

    You can also end your url with "/%s", it will indicate to the plugin to replace the "%s" value by his own computed filename (ideal for proxy like nexus,Artifactory, ...)

    Ex: By providing the following configuration

    <downloadUrl>http://my_private_repository/elasticsearch-downloads/%s</downloadUrl>
    <flavour>oss</flavour>
    <version>7.4.2</version>
    

    The computed binary filename would be:

    • on linux: elasticsearch-oss-7.4.2.tar.gz
    • on windows: elasticsearch-oss-7.4.2.zip

    And the resulting download url would be:

    • on Linux: http://my_private_repository/elasticsearch-downloads/elasticsearch-oss-7.4.2.tar.gz
    • on Windows: http://my_private_repository/elasticsearch-downloads/elasticsearch-oss-7.4.2.zip
  • downloadUrlUsername [defaultValue=""]

    username supplied as part of basic authentication when downloading

  • downloadUrlPassword [defaultValue=""]

    password supplied as part of basic authentication when downloading

  • httpPort [defaultValue=9200]

    the port to configure Elasticsearch to listen to HTTP traffic to; when configuring multiple instances, they will be assigned subsequent HTTP ports starting with this value (mind the conflicts with the transport ports)

  • transportPort [defaultValue=9300]

    the port for the Elasticsearch node to node communication; when configuring multiple instances, they will be assigned subsequent transport ports starting with this value (mind the conflicts with the HTTP ports)

  • pathConf [defaultValue=""] (note: common to all instances !!!)

    the absolute path (or relative to the maven project) of the custom directory containing configuration files, to be copied to Elasticsearch instances

  • environmentVariables [defaultValue=""]

    the environment variables to set before starting each Elasticsearch instance (see the Environment variables section for details)

  • pathData [defaultValue=""] - work in progress (note: per instance !!!); while support for this is being implemented, use pathConf to configure this option

    the custom data directory to configure in Elasticsearch

  • pathLogs [defaultValue=""] - work in progress (note: per instance !!!); while support for this is being implemented, use pathConf to configure this option

    the custom logs directory to configure in Elasticsearch

  • plugins [defaultValue=""]

    the list of plugins to install in each Elasticsearch instance before starting it (see the Plugins section for details)

  • instanceSettings [defaultValue=""]

    the list of settings to apply to corresponding Elasticsearch instances (see the InstanceSettings section for details)

  • pathInitScript [defaultValue=""]

    the path of the initialization scripts (see the Initialization scripts section for details)

  • keepExistingData [defaultValue=true]

    whether to keep the data and log directories, if they already exist; since the behavior, before this flag was implemented, was to keep the existing data, the default is true

  • instanceStartupTimeout [defaultValue=120]

    how long to wait (in seconds) for each Elasticsearch instance to start up; since Elasticsearch 8 takes significantly longer than the previous versions to start up, the default was changed from 30 to 120 seconds

  • clusterStartupTimeout [defaultValue=30]

    how long to wait (in seconds) for all instances to form a cluster; this is in addition to the instance startup timeout

  • clientSocketTimeout [defaultValue=5000]

    the default socket timeout (in milliseconds) for requests sent to the Elasticsearch server

  • setAwait [defaultValue=false]

    whether to block the execution once all Elasticsearch instances have started, so that the maven build will not proceed to the next step; use CTRL+C to abort the process

  • autoCreateIndex [defaultValue=true]

    configuration of automatic index creation represented by action.auto_create_index setting

  • logLevel [defaultValue=INFO]

    the log level to be used by the console logger; the valid values are defined in AbstractElasticsearchBaseMojo.getMavenLogLevel() and they are: DEBUG, INFO, WARN, ERROR, FATAL, DISABLED.

To use the plugin, include the following in your pom.xml file and modify the configuration as needed:

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <!--
        THE PLUGIN VERSION; FOR THE LIST OF AVAILABLE VERSIONS, SEE
        https://github.com/alexcojocaru/elasticsearch-maven-plugin/releases
    -->
    <version>6.27</version>
    <configuration>
        <!-- THE ELASTICSEARCH VERSION; REPLACE WITH THE VERSION YOU NEED -->
        <version>7.2.0</version>
        <clusterName>test</clusterName>
        <transportPort>9300</transportPort>
        <httpPort>9200</httpPort>
    </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>

Environment variables

The environment variables to set before starting each Elasticsearch instance.

Environment variables may be referenced from the Elasticsearch configuration, but the main use case for defining environment variables is to set JAVA_HOME, so that Elasticsearch is run with a different JDK than the one used to run Maven.

The way to define environment variables is as follows:

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>6.27</version>
    <configuration>
        <clusterName>test</clusterName>
        <transportPort>9300</transportPort>
        <httpPort>9200</httpPort>
        ...
        <environmentVariables>
            <SOME_CUSTOM_VARIABLE>somevalue</SOME_CUSTOM_VARIABLE>
            <JAVA_HOME>${path-to-java-home-configured-through-maven-profiles}</JAVA_HOME>
        </environmentVariables>
        ...
    </configuration>
    <executions>
        ...
    </executions>
</plugin>

JDK Toolchain

An alternative method of running Elasticsearch with a different JDK than the one used to run Maven is to utilize Maven JDK toolchains.

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>6.27</version>
    <configuration>
        <clusterName>test</clusterName>
        <transportPort>9300</transportPort>
        <httpPort>9200</httpPort>
        ...
        <jdkToolchain>
            <version>11</version>
            <vendor>sun</vendor>
        </jdkToolchain>
        ...
    </configuration>
    <executions>
        ...
    </executions>
</plugin>

toolchains.xml

<toolchains>
    ...
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>11</version>
            <vendor>sun</vendor>
        </provides>
        <configuration>
            <jdkHome>/path/to/jdk11</jdkHome>
        </configuration>
    </toolchain>
    ...
</toolchains>

Plugins

A list of Elasticsearch plugins can be provided to the elasticsearch-maven-plugin. They will be installed into each Elasticsearch instance inside the plugins directory using the --batch option, before the instance gets started.

The way to enable plugins is as follows:

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>6.27</version>
    <configuration>
        <clusterName>test</clusterName>
        <transportPort>9300</transportPort>
        <httpPort>9200</httpPort>
        ...
        <plugins>
            <plugin>
                <uri>analysis-icu</uri>
            </plugin>
            <plugin>
                <uri>https://github.com/alexcojocaru/plugin.zip</uri>
                <esJavaOpts>-Djavax.net.ssl.trustStore=/home/alex/trustStore.jks</esJavaOpts>
            </plugin>
            <plugin>
                <uri>file:///home/alex/foo.zip</uri>
            </plugin>
        </plugins>
        ...
    </configuration>
    <executions>
        ...
    </executions>
</plugin>

The plugin tag takes 2 parameters:

Instance settings

Instance settings are applied to each corresponding elasticsearch instance (via -E on the commandline) during startup. If the list is smaller then instanceCount no extra settings are applied to the remaining instances. If it's larger, the extra items are ignored.

Example:

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>6.27</version>
    <configuration>
        ...
        <instanceCount>2</instanceCount>
        <instanceSettings>
            <properties>
                <node.name>First</node.name>
                <node.attr.data_type>ingest</node.attr.data_type>
            </properties>
            <properties>
                <node.name>Second</node.name>
                <node.attr.data_type>search</node.attr.data_type>
            </properties>
        </instanceSettings>
        ...
    </configuration>
    <executions>
        ...
    </executions>
</plugin>

Initialization scripts

A comma-separated list of initialization script files can be provided using the pathInitScript parameter of the plugin, in which case they will be executed against the local Elasticsearch cluster. The file extension defines the file format: json for JSON format, anything else for custom format, both formats can be used at the same time.

The script paths will be trimmed and executed in the order they are provided. For example:

<pathInitScript>script1.json,script2.script</pathInitScript>

is equivalent to

<pathInitScript>
    script1.json,
    script2.script
</pathInitScript>

And the plugin will always execute script1.json before script2.script

JSON format

The provided JSON files should contain a list of requests to be sent, one by one, to the Elasticsearch cluster. Each request definition has three properties:

  • the request method: one of PUT, POST, DELETE

    the name (in uppercase) of the request method to be used for the current request

  • the path part of the URL (should not start with slash)

    will be appended to the protocol, hostname and port parts when the full URL is constructed

  • the payload

    it should not be defined for DELETE requests; some Elasticsearch requests do not require a payload (eg. POST index/_refresh in Elasticsearch version 7 or less), in which case define the payload as {}; some Elasticsearch requests do not allow a payload (eg. POST index/_refresh in Elasticsearch version 8), in which case do not define the payload property

Example (see the src/main/test/resources/init.json file for a more complete example):

To send a POST request to http://localhost:9200/test_index/test_type/_mapping, followed by a DELETE request to http://localhost:9200/test_index/test_type/1:

[
    {
        "method": "POST",
        "path": "test_index/test_type/_mapping",
        "payload": {
            "test_type": {
                "properties": {
                    "name": {
                        "type": "keyword"
                    },
                    "lastModified": {
                        "type": "date"
                    }
                }
            }
        }
    },
    {
        "method": "DELETE",
        "path": "test_index/test_type/1"
    }
]

Custom format

Each line defines a request to be sent to the Elasticsearch cluster, and it has three parts separated by colon:

  • the request method: one of PUT, POST, DELETE

    the name (in uppercase) of the request method to be used for the current request

  • the path part of the URL (should not start with slash)

    will be appended to the protocol, hostname and port parts when the full URL is constructed

  • the JSON to send to Elasticsearch as payload

    it should be empty for DELETE requests

Note: Empty lines are ignored, as well as lines starting with the '#' sign.

Examples (see the src/it/runforked-with-init-script/init.script file for a more complete example):

FAQ

Error: Could not find or load main class (on OSX 10.13.6)

There seems to be an issue when starting certain versions of Elasticsearch (eg. 5.6.8) on OSX 10.13.6, directly or via the plugin. The issue is caused by the incorrect quoting of the -cp argument on the Java command built by the bin/elasticsearch script inside the Elasticsearch package. A workaround is described here. In summary, set the ES_JVM_OPTIONS environment variable to -cp "./target/elasticsearch0/lib/*" in the IDE's run configuration or on the shell environment where maven/Elasticsearch is executed.

Error: Could not reserve enough space for x object heap (on Win 10)

This has the same root cause as the OSX specific error described above, and can be fixed using the same workaround.

Node is killed when running in TravisCI (not applicable; travis-ci.com is not free)

When running your build job in TravisCI, it can happen that your node is being killed without any notice. To fix that you may have to modify the .travis.yml file as follows:

sudo: true
before_script:
  - sudo sysctl -w vm.max_map_count=262144

Error: java.lang.RuntimeException: can not run elasticsearch as root (in Docker)

When running the build in Docker, depending on the Docker image, the current user in the container maybe be the root user and, because of this, Elasticsearch will fail to start. The fix is to use a Docker image which does not use the root user. See this discussion for details.

Avoid downloading a plugin from the Internet repeatedly

When you want to run integration tests with a given plugin (eg. reindex-client), elasticsearch-maven-plugin will run behind the scene a command like bin/elasticsearch-plugin install reindex-client which will download the plugin from the Internet at every execution.

You can use some Maven magic to avoid the download by first using maven-dependency-plugin to download the plugin as an artifact which will be stored in your local .m2 directory, then copy from there to your project target directory, eg.

mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
    -DrepoUrl=https://repo1.maven.org/maven2 \
    -Dartifact=org.elasticsearch.plugin:reindex-client:5.4.2

Then just tell the elasticsearch-maven-plugin to use the local URI.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>integ-setup-dependencies-plugins</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.elasticsearch.plugin</groupId>
                        <artifactId>reindex-client</artifactId>
                        <version>5.4.2</version>
                        <type>zip</type>
                    </artifactItem>
                </artifactItems>
                <useBaseVersion>true</useBaseVersion>
                <outputDirectory>${project.build.directory}/integration-tests/plugins</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>6.27</version>
    <configuration>
        <version>5.4.2</version>
        <plugins>
            <plugin>
                <uri>file://${project.build.directory}/integration-tests/plugins/reindex-client-5.4.2.zip</uri>
            </plugin>
        </plugins>
    </configuration>
</plugin>

Why does the plugin uses a lock file and why does it need to open a server socket?

The plugin, at runtime, looks for the Elasticsearch artifact in the local maven repository and, if not found, it downloads it into the system temp directory and installs it from there into the local maven repo. When several Elasticsearch maven plugins are executed at the same time on a single machine (eg. during parallel builds), and the ES artifact hasn't already been installed in the local repo, it is not desirable that each plugin downloads and installs the same artifact; that is because the ES artifact is a large file (~ 250 Mb), and downloading the same file multiple times would be a waste of bandwidth.

Because of this, the plugin is capable to synchronize with other plugins running at the same time on the same machine, so that a single one downloads and installs, while the rest wait for the master plugin to complete in order to move forward with using the artifact. The synchronization mechanism is described by this diagram.

This is related to this plugin issue.

Integration Tests

The integration tests exist as maven plugins in the src/it directory and are executed via the maven invoker plugin (see the pom.xml for details on its configuration).

Each test has a maven like structure, with a pom.xml and a src/test/java directory containing the test sources.

The properties common between all tests are defined in the invoker plugin config under the "testProperties" tag.

During the integration test phase, the invoker plugin copies the tests to target/it and executes the "clean" and "verify" goals on each them. They are executed in a separate process with a brand new maven config, defined using the following two invoker plugin properties: localRepositoryPath (set to target/local-repo) and settingsFile (set to src/it/settings.xml). The invoker configuration also defines a pre-build hook script and a post-build hook script to run before and after executing the test. These are groovy scripts which each test directory must contain.

The structure of an integration test

Because the integration tests are executed as maven projects, they have a maven-like file structure.

pom.xml

The pom.xml is generic and does not contain anything specific to any test - it defines the test project dependencies and which goals to execute on the elasticsearch maven plugin.

setup.groovy

The pre-build hook script (setup.groovy) does the plugin and context configuration, by using the ItSetup util to create a map of plugin properties and to save them to the test.properties file in the test directory (to be picked up by the Java tests via the methods in ItBase). The properties are also set on the context, for some are needed by the post-build hook script. Defining the number of ES instances is required in the groovy script. The ES cluster name and the HTTP and transport protocol ports are randomly generated by ItSetup.generateProperties to avoid clashes between integration tests. Any other properties to be passed over to the plugin can be added to the props map (see src/it/runforked-auto-create-index-false/setup.groovy for an example).

verify.groovy

The standard verification done here is that the ES base directory(ies) were created and that the ES instance(s) are not running (via the ItVerification util). This file uses some of the plugin properties set on the context by the pre-build hook script.

Java test file(s)

The actual tests are defined in java files in the src/test/java directory under each integration test directory (eg. src/it/runforked-auto-create-index-false/src/test/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AutoCreateIndexTest.java). They will be compiled and executed during the maven invoker plugin execution of the integration test maven project. All java tests should extend com.github.alexcojocaru.mojo.elasticsearch.v2.ItBase to get the clusterName and httpPort read from the context (ie. the "test.properties" file created by the pre-build hook script) and the ES client set up.

NOTE: It is not possible to execute such a test case in an IDE, due to the lack of context (the test properties must be set in the props file by executing the groovy script, the elasticsearch maven plugin must be running, etc).

How to write new tests

Copy one of the existing integration tests and modify as needed. It will be picked up by the invoker plugin due to the wildcard definition in the plugin config in pom.xml.

How to run single integration test

Set the integrationTest env variable to the integration test name when running maven, eg:

$ mvn clean verify -DintegrationTest=runforked-defaults-es6

How to debug an integration test

There are two ways to obtain more information during the execution of an integration test:

Debugging the maven execution

To have the invoker plugin output detailed information about the integration test execution, change the debug attribute of the invoker plugin configuration (in the pom.xml) to true.

Debugging the elasticsearch maven plugin execution during the integration test

Set the es.logLevel property of the plugin to DEBUG, by adding

props.put("es.logLevel", "DEBUG");

to the setup.groovy file for the integration test you want to debug.

elasticsearch-maven-plugin's People

Contributors

alexcojocaru avatar brackxm avatar dadoonet avatar dependabot[bot] avatar gsfernandes avatar hippegger avatar imod avatar jonfreedman avatar joschi avatar kizombadev avatar lukas-vlcek avatar meshuga avatar nahguam avatar nirajpatel avatar reardencode avatar rustyx avatar snuyanzin avatar statut avatar steghio avatar stringaling avatar yrodiere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticsearch-maven-plugin's Issues

Log directory always empty

I am not sure whether it's a bug or usage error on my side, but for some reason the log directory is always empty ("elasticsearch-logs"). Is there anything I need to configure to see exception logs there?

I could make it work by adding an slf4j binding as a plug-in dependency and building elasticsearch-maven-plugin from sources, so it contains a log4j.properties file (I'm using log4j); Then I could see at least all exceptions on the Maven console. But clearly that cannot be the right way :)

Any help is highly appreciated!

Do not fail when a plugin has already been installed

When I add a plugin with its file URL like file://path/to/target/myplugin.zip and start again the same mvn install command, it fails because the plugin already exists.

Tested with 5.4.2:

[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch-plugin, install, --batch, file:///Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/integration-tests/plugins/x-pack-5.4.2.zip]' in directory '/Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/elasticsearch0'
-> Downloading file:///Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/integration-tests/plugins/x-pack-5.4.2.zip
[=================================================] 100%   
ERROR: plugin directory [/Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/elasticsearch0/plugins/x-pack] already exists; if you need to update the plugin, uninstall it first using command 'remove x-pack'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.137 s
[INFO] Finished at: 2017-06-21T14:18:09+02:00
[INFO] Final Memory: 30M/325M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.7:runforked (start-elasticsearch) on project elasticsearch-beyonder: Elasticsearch [0]: Cannot execute command '[bin/elasticsearch-plugin, install, --batch, file:///Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/integration-tests/plugins/x-pack-5.4.2.zip]' in directory '/Users/dpilato/Documents/Elasticsearch/dev/elasticsearch-beyonder/target/elasticsearch0': Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

IMHO this should not fail the build or at least we need an option to ignore that failure.

WDYT?

Skip an execution

Is there any way that this plugin can support skipping the execution? I'm thinking along the lines of something like in the snippet below.

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <clusterName>test</clusterName>
        <tcpPort>9300</tcpPort>
        <httpPort>9200</httpPort>
        <skip>${skip.elasticSearch}</skip>
    </configuration>
    <execution>
        ...
    </execution>
</plugin>

There doesn't seem to be anything that will allow this to skip. It can be a part of the configuration for any execution as well. Thank you.

java.io.IOException: An existing connection was forcibly closed by the remote host

I got the following, when run mvn verify

[2018-05-30T14:28:24,065][WARN ][o.e.h.n.Netty4HttpServerTransport] [h3Pu-H5] caught exception while handling client http traffic, closing connection [id: 0x172478f4, L:/0:0:0:0:0:0:0:1:9400 - R:/0:0:0:0:0:0:0:1:52160]
java.io.IOException: An existing connection was forcibly closed by the remote host

Than it proceed and execute all required operations, but would like to avoid this exception.

Plugin in pom

        <plugin>
            <groupId>com.github.alexcojocaru</groupId>
            <artifactId>elasticsearch-maven-plugin</artifactId>
            <version>6.5</version>
            <configuration>
                <clusterName>testCluster</clusterName>
                <transportPort>9500</transportPort>
                <timeout>5000</timeout>
                <httpPort>9400</httpPort>
                <version>5.4.0</version>
                <pathInitScript>src/test/resources/elasticsearch/Init.script</pathInitScript>
            </configuration>
            <executions>
                <execution>
                    <id>start-elasticsearch</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>runforked</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop-elasticsearch</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 

How to set Elasticsearch version.

According to the README <version> is used to set Elasticsearch version. Default "5.0.0". However, setting version to 5.0.0 causes a maven error.
[ERROR] Plugin com.github.alexcojocaru:elasticsearch-maven-plugin:5.0.0 or one of its dependencies could not be resolved: Failure to find com.github.alexcojocaru:elasticsearch-maven-plugin:jar:5.0.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

That message makes it sound like sets the elasticsearch-maven-plugin version, not the Elasticsearch version. Indeed, values of 5.5 or 5.9 work just fine even though there currently is no version 5.9 of Elasticsearch.

On the other hand, no matter what I set in <version> I always see Elasticsearch 5.0.0 launched. I want to launch ES 5.5.0. How do I do that?

Allow dots in field names (ES 2.4.x)

Hi,
I have a project that currently uses ES 1.7.5 and is targeting ES 2.4.x for an upgrade, and has dots in the names of some fields. These names must retain dots, as they come from/are used by other parts of a distributed system.

ES <2.4 does not support dots in field names, but ES 2.4.x supports dots via a commandline option -Dmapper.allow_dots_in_name=true (See the ES docs). This issue is to request support for mapper.allow_dots_in_name via the config for this plugin, so that we can set the option in our integration tests automatically.

I have tried setting the option via maven-failsafe-plugin, both as a system property and as part of the argLine options, to no avail, but the option flag can be added to a mvn verify command: mvn verify -Dmapper.allow_dots_in_name=true.

Allow to add plug-ins as Maven dependency

I would like to add plug-ins obtainable via Maven to the bootstrapped ES instance. Unless there is already a convinient way for doing this, I am proposing to add support for it like so:

<plugin>
    <groupId>com.github.alexcojocaru</groupId>
    <artifactId>elasticsearch-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <clusterName>hsearch-es-test-cluster</clusterName>
        <tcpPort>9300</tcpPort>
        <httpPort>9200</httpPort>
        <pluginsPath>${project.build.directory}/_ES_PLUGINS_</pluginsPath>

        <!-- Obtains plug-in ZIPs given via Maven group + artifact id -->
        <pluginArtifacts>
            <pluginArtifact>org.elasticsearch.plugin:delete-by-query:2.0.0</pluginArtifact>
            <pluginArtifact>org.elasticsearch.plugin:analyzer-icu:2.0.0</pluginArtifact>
            ...
        </pluginArtifacts>
    </configuration>
    <executions>
        ...
    </executions>
</plugin>

If you like the idea in general, I could try and help out with implementing it. WDYT?

Memory Issue when starting

Hi!

Environment: Windows 7

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Exception in thread "Thread-1" java.lang.IllegalStateException: This Elasticsearch process destroyer does not support this operation
    at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.remove(ForkedElasticsearchProcessDestroyer.java:68)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:411)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:109)
    at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedInstance.run(ForkedInstance.java:39)
    at java.lang.Thread.run(Thread.java:748)
[DEBUG] Waiting  up to 30s for Elasticsearch to start ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:38 min
[INFO] Finished at: 2017-10-20T11:19:45+03:00
[INFO] Final Memory: 28M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.10:runforked (start-elasticsearch) on project mrc-credit-limit: Condition returned by method "waitToStart" in class com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor was not fulfilled within 30 seconds. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] The Elasticsearch process has already stopped. Nothing to clean up

Process finished with exit code 1

pom.xml

<plugin>
	<groupId>com.github.alexcojocaru</groupId>
	<artifactId>elasticsearch-maven-plugin</artifactId>
	<version>5.10</version>
	<configuration>
		<clusterName>creditlimit</clusterName>
		<transportPort>9300</transportPort>
		<httpPort>9200</httpPort>
		<version>5.5.2</version>
	</configuration>
	<executions>
		<execution>
			<id>start-elasticsearch</id>
			<phase>compile</phase>
			<goals>
				<goal>runforked</goal>
			</goals>
		</execution>
		<execution>
			<id>stop-elasticsearch</id>
			<phase>prepare-package</phase>
			<goals>
				<goal>stop</goal>
			</goals>
		</execution>
	</executions>
</plugin>

Document how to contribute and run tests

Hey

I'm on my way to submit a PR for #42 but I have hard time to understand how to run the test I added to test the new feature I added.
So I'm running for now a mvn clean install every time but it's far from being optimal as I'm spending most of the time running the other integration tests.

Could you document how to create tests (well, I copy and paste for now so I should be good) but give some tricks on how to actually run a single test?

Also, everything you put in src/it is preprocessed by Groovy if I understand correctly. Is there a best practice to write a pom.xml example (and a java test) which you can easily run from the IDE?

Best!

The JVM Shutdownhook seems not to be working on Windows

When the stop goal is not executed, (due to a failing test), the ES instance is still running. Consecutive executions of maven will fail.

The log output shows:

[INFO] Stopping the Elasticsearch process at application shutdown ...
[INFO] ... the Elasticsearch process has stopped. Exit code: 1

On Linux it works:

[INFO] Stopping the Elasticsearch process at application shutdown ...
[INFO] ... the Elasticsearch process has stopped. Exit code: 143

Environment:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: c:\Apps\apache-maven-3.3.9
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: c:\Apps\Java\jdk8_112_64\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

Plugin Version 6.0
ES Version 5.6.3

Windows 10: This Elasticsearch process destroyer does not support this operation at startup

This seems to be related to #69 but the error displayed in Windows environments is a bit different, so I thought it was worth a separate issue for reference and documentation in case other stumble on it.

This is the error I got on Windows 10

[INFO] Using Elasticsearch [0] configuration: com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration@1351f28[id=0,baseDir=D:\myproject\target\elasticsearc
h0,httpPort=9200,transportPort=9300,pathData=<null>,pathLogs=<null>,settings=<null>]
[INFO] Elasticsearch[0]: Executing command '[cmd, /c, bin\elasticsearch-plugin, list]' in directory 'D:\myproject\target\elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[cmd, /c, bin\elasticsearch, -p, pid, -Ecluster.name=esDevCluster, -Ehttp.port=9200, -Etransport.tcp.port=9300, -Ehttp.cors.enabled=true]' in dir
ectory 'D:\myproject\target\elasticsearch0'
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Exception in thread "Thread-5" java.lang.IllegalStateException: This Elasticsearch process destroyer does not support this operation
        at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.remove(ForkedElasticsearchProcessDestroyer.java:50)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:411)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
        at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:222)
        at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:167)
        at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedInstance.run(ForkedInstance.java:42)
        at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:04 min
[INFO] Finished at: 2019-02-26T10:56:59-06:00
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:6.4:runforked (start-elasticsearch) on project marketplacecms: Condition returned by method "waitToStartIns
tance" in class com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor was not fulfilled within 60 seconds. -> [Help 1]
[ERROR]```

Frequent process Termination

Hi,
I've configure plugin as

            <plugin>
                <groupId>com.github.alexcojocaru</groupId>
                <artifactId>elasticsearch-maven-plugin</artifactId>
                <version>5.9</version>
                <configuration>
                    <clusterName>${elasticsearch.clustername}</clusterName>
                    <transportPort>${elasticsearch.tcp.port}</transportPort>
                    <httpPort>${elasticsearch.http.port}</httpPort>
                    <pathConf>${qa.config.dir}/elasticsearch-config</pathConf>
                    <version>5.5.1</version>
                    <timeout>120</timeout>
                    <autoCreateIndex>false</autoCreateIndex>
                    <plugins>
                        <plugin>
                            <uri>analysis-icu</uri>
                        </plugin>
                        <plugin>
                            <uri>file:///${qa.config.dir}/elasticsearch-plugins/analyzed-queries/analyzed-queries-${elasticsearch.version}.0.zip</uri>
                        </plugin>
                    </plugins>
                </configuration>
                <executions>
                    <execution>
                        <id>start-elasticsearch</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>runforked</goal>
                        </goals>
                        <configuration>
                            <pathInitScript>${elasticsearch.loadscript}</pathInitScript>
                            <skip>${skip.elasticsearch}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-elasticsearch</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.elasticsearch}</skip>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.elasticsearch</groupId>
                        <artifactId>elasticsearch</artifactId>
                        <version>${elasticsearch.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

But while execution, I keep getting failures while executing load scripts

[ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.9:runforked (start-elasticsearch) on project ls-search-qa-features: Execution start-elasticsearch of goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.9:runforked failed: Cannot execute command PUT:company:{"settings":{"analysis":{"char_filter":{"extract_id":{"type":"pattern_replace","pattern":"^.*?\\s?([\\S]+)\\s*$","replacement":"$1"},"add_start_stop_tokens":
....
....
.....
 java.net.SocketTimeoutException: Read timed out -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ls-search-qa-features
[INFO] Apache ActiveMQ 5.10.0 (localhost, ID:UX000954-TPL-A-61745-1502096948112-0:1) is shutting down
[INFO] Stopping the Elasticsearch process at application shutdown ...
[INFO] Connector tcp://127.0.0.1:61616 stopped
[INFO] ... the Elasticsearch process has stopped. Exit code: 1

Although, this is happening intermittently, one common thing is, this always fails during load script (<pathInitScript>${elasticsearch.loadscript}</pathInitScript>) execution.

Could you please take a look?

No implementation for org.eclipse.aether.RepositorySystem was bound

I am getting this error:

WARNUNG: Error injecting: com.github.alexcojocaru.mojo.elasticsearch.v2.RunForkedMojo
com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.eclipse.aether.RepositorySystem was bound.
  while locating com.github.alexcojocaru.mojo.elasticsearch.v2.RunForkedMojo

1 error
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:999)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1025)
    at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:990)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1036)
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:986)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

With the maven version shipped with Ubuntu 14.04 LTS

mvn --version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"

Is there any change to make this plugin compatible to the 3.0 branch of maven?

I can start plugin blocking execution

Use-Case

when I develop integration tests and want to debug them, I want to run plugin in blocking manner in order not to have to restart ES all the time, or run full maven clean verify cycle.

AT

  • given
    • plugin has a run mojo
  • when
    • I execute run goal
  • then
    • ES instance is started with configuration values specified for the plugin
    • ES instance is blocking and waits for requests

Add support for x-pack (security)

When you add x-pack as a plugin, elasticsearch maven plugin refuses to start because it can't access to GET / due to default security.

It gives:

[DEBUG] Sending GET request to http://localhost:9400/
[DEBUG] Response with status code 401 and content: {"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

We need to add support for username and password (default to elastic and changeme).

I'll hopefully will come with a PR for it.

ElasticSearch stopping after Init script execution

Hello,
I am new at using this plugin, so my apologies if this is a stupid question.

What I am trying to do is, run the elasticsearch instance and then run my application that will connect to this instance. But, when I run - "mvn elasticsearch:runforked". It starts, runs the Init script and then stops.

Instead I want to keep it running after the Init script.

[INFO] The Elasticsearch instance has started
[INFO] The Elasticsearch cluster has started
[INFO] Sending PUT request to http://localhost:9200/test/ with entity '{ "mappings":{"default":{ "properties":{ "myField":{"type":"keyword"}}}}}'
[2018-02-26T16:21:58,423][INFO ][o.e.c.m.MetaDataCreateIndexService] [aswHGsc] [test] creating index, cause [api], templates [], shards [5]/[1], mappings [default]
[INFO] Sending PUT request to http://localhost:9200/test/default/1 with entity '{ "myField ":"hello world"}'
[2018-02-26T16:21:58,692][INFO ][o.e.c.m.MetaDataMappingService] [aswHGsc] [test/tKNrCWV3RLu8ypMUPqL5XQ] update_mapping [default]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.795 s
[INFO] Finished at: 2018-02-26T16:21:58-08:00
[INFO] Final Memory: 18M/310M
[INFO] ------------------------------------------------------------------------
[INFO] Stopping the Elasticsearch process at application shutdown ...
[INFO] ... the Elasticsearch process has stopped. Exit code: 143

Thank you

Sincerely,
Manjiri

Elasticsearch version 2 unable to start instance

Hello,

Unfortunately, our prod env is running elastic search version 2.4.1. So, I am trying to use version 2 of this plugin.

But, when I try - mvn elasticsearch:start it doesnt seem to load the Init script and also, doesnt seem to start the elasticsearch instance.

IRV-MNAMJOSH-7D:mtd mnamjoshi$ mvn elasticsearch:start
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building java-metadata 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- elasticsearch-maven-plugin:2.0:start (default-cli) @ java-metadata ---
log4j:WARN No appenders could be found for logger (org.elasticsearch.node).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.882 s
[INFO] Finished at: 2018-05-24T22:26:05-07:00
[INFO] Final Memory: 22M/309M
[INFO] ------------------------------------------------------------------------
IRV-MNAMJOSH-7D:mtd mnamjoshi

Following is the snippet from my pom.xml -

com.github.alexcojocaru elasticsearch-maven-plugin 2.0
					<configuration>
    					<!-- REPLACE THE FOLLOWING WITH THE ELASTICSEARCH VERSION YOU NEED -->
    					<version>2.0.0</version>
    					<clusterName>mtd</clusterName>
    					<transportPort>9300</transportPort>
    					<httpPort>9200</httpPort>
    					<tcpPort>9300</tcpPort>
    					<setAwait>true</setAwait>
    					<pathInitScript>src/test/resources/elasticsearch/Init.script</pathInitScript>
					</configuration>
					<dependencies>
						<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
						<dependency>
							<groupId>org.slf4j</groupId>
							<artifactId>slf4j-log4j12</artifactId>
							<version>1.7.25</version>
						</dependency>
					</dependencies>
					<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>

Thank you

Sincerely,
Manjiri

Cannot run program /pid

When integration tests stop, plugin throws the following exception:

[INFO] [INFO] --- jetty-maven-plugin:8.1.3.v20120416:stop (stop-jetty) @ --- [INFO] Stopping server 0 [INFO] --- elasticsearch-maven-plugin:5.0:stop (stop-elasticsearch) @ --- [INFO] Stopping Elasticsearch [com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration@34d6bca6[id=0,baseDir=D:\work\...\target\elasticsearch0,httpPort=0,transportPort=0,pathData=<null>,pathLogs=<null>]] [ERROR] Exception while stopping Elasticsearch java.io.IOException: Cannot run program "/pid" (in directory "D:\work\...\target\elasticsearch0"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at com.github.alexcojocaru.mojo.elasticsearch.v2.StopMojo.execute(StopMojo.java:50) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 16:35Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 23 more

Windows 7x64.

What is the cause of that? Thanks.

ES v6.3.0 fails to start with "Permission denied" for the x-pack-ml module

With the new version of ES there are now 2 different distribution flavors:

  • "elasticsearch" (default, with x-pack) and
  • "elasticsearch-oss" (OSS only, no x-pack).

Some people might need to run tests against either of the two flavors, so I suggest you expose the artifactId configuration property for specifying which flavor to download. Alternatively, you could have a config flag isOSSflavor or something similar.

Also when the default flavor of 6.3.0 is downloaded and started, I get a "Permission denied" exception because the executables inside elasticsearch0/modules/x-pack do not have +x permissions on them. So we'd have to run an additional command chmod 755 on the "modules" folder to get the default flavor running.

Make the plugin thread safe - and annotate it as such

15:35:03 [WARNING] *****************************************************************
15:35:03 [WARNING] * Your build is requesting parallel execution, but project      *
15:35:03 [WARNING] * contains the following plugin(s) that have goals not marked   *
15:35:03 [WARNING] * as @threadSafe to support parallel building.                  *
15:35:03 [WARNING] * While this /may/ work fine, please look for plugin updates    *
15:35:03 [WARNING] * and/or request plugins be made thread-safe.                   *
15:35:03 [WARNING] * If reporting an issue, report it against the plugin in        *
15:35:03 [WARNING] * question, not against maven-core                              *
15:35:03 [WARNING] *****************************************************************
15:35:03 [WARNING] The following plugins are not marked @threadSafe in [...]:
15:35:03 [WARNING] com.github.alexcojocaru:elasticsearch-maven-plugin:6.6
15:35:03 [WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.
15:35:03 [WARNING] *****************************************************************

Permission denied on Travis with ES 6.4

I am trying to switch from Elasticsearch version 6.2 to 6.4.
However, I now get the following error when launching Elasticsearch 6.4 on Travis:

[INFO] Installing /tmp/elasticsearch-oss-6.4.0.zip to /home/travis/.m2/repository/com/github/alexcojocaru/elasticsearch-oss/6.4.0/elasticsearch-oss-6.4.0.zip
[INFO] Elasticsearch[0]: Executing command '[chmod, 755, bin/elasticsearch-plugin]' in directory '/home/travis/build/kizombaDev/EventStudio/event-common/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[sed, -i, -e, 1s:.*:#!/usr/bin/env bash:, bin/elasticsearch-plugin]' in directory '/home/travis/build/kizombaDev/EventStudio/event-common/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch-plugin, list]' in directory '/home/travis/build/kizombaDev/EventStudio/event-common/target/elasticsearch0' bin/elasticsearch-plugin: line 3: bin/elasticsearch-cli: Permission denied

Everything worked fine with ES 6.2 ...
Am I doing something wrong or is this possibly a bug?

Let me know if you need further information

Using ${build.directory} in the configPath

I am using the plugin inside of a submodule project, so I need to specify the config folder using one of the maven properties.
Something like this:

                <configuration>
                    <clusterName>idx-integrationtest-cluster</clusterName>
                    <tcpPort>9399</tcpPort>
                    <httpPort>9299</httpPort>
                    <configPath>${build.directory}/src/test/resources/es_config</configPath>
                </configuration>

But looks like ${build.directory} is not supported inside of the configPath.
How to do it?

Regards.

Cannot run inside of docker due to user permissions

Semi related to #68

When attempting to run inside of a docker container, the following is returned from a maven verify:

[2018-09-19T23:52:52,197][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

While elasticsearch surely shouldn't run as root in a typical environment, is it not possible to override the user attribute for this to account for things like containers where the typical POSIX model is not necessarily at play, at the very least for unit/integration tests?

Build fails on Windows

It is impossible to build the plugin on a Windows system:

  1. BootstrapClusterStepTest fails due to path separator differences ('\' vs '/').

  2. taskkill /F forcibly kills the ES instance and leaves the pid file around. Subsequent isAlive checks fail.

Not working for Elastic Search Java High Level Rest Client

Hi, We were using this dependency for testing Integration test cases. Recently we upgraded from Transport Client to High Level Client. After this migration, this is not working, getting Connection Refused.

So could you support for High Rest Client ?

JUnit integration

thanks for this plugin!

How do I run integration tests with JUnit against a this test ES instance?

Run with local version of elastic

I have a local version of elastic search zip in my build directory. is there a possibility to skip the download and use the local version

Node seems to be killed when running in TravisCI

I just switched my project to elasticsearch-maven-plugin (which is great BTW) and I found that my elasticsearch node is getting killed apparently.

The build is working super fine locally. But fails in TravisCI.

For example this build: https://travis-ci.org/dadoonet/spring-elasticsearch/builds/210279724

I suspect this is caused by travis-ci/travis-ci#6534 but I would expect elasticsearch barfing more before dying actually.

May be there is a workaround or may be we should just document that it can happen an link to the Travis issue in the doc?

Some logs:

[2017-03-12T15:59:20,974][INFO ][o.e.n.Node               ] [Q3beqyO] starting ...
[2017-03-12T15:59:21,133][WARN ][i.n.u.i.MacAddressUtil   ] Failed to find a usable hardware address from the network interfaces; using random bytes: 26:93:fc:18:6b:6a:2c:ed
[2017-03-12T15:59:21,203][INFO ][o.e.t.TransportService   ] [Q3beqyO] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2017-03-12T15:59:21,211][WARN ][o.e.b.BootstrapChecks    ] [Q3beqyO] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[DEBUG] Sending GET request to http://localhost:9200/
[DEBUG] Sending GET request to http://localhost:9200/
[DEBUG] Sending GET request to http://localhost:9200/
[2017-03-12T15:59:24,271][INFO ][o.e.c.s.ClusterService   ] [Q3beqyO] new_master {Q3beqyO}{Q3beqyOTRNmkkow3pXMK0g}{biMDuBQdQD2bxga9m2Cm6Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-03-12T15:59:24,334][INFO ][o.e.h.HttpServer         ] [Q3beqyO] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2017-03-12T15:59:24,335][INFO ][o.e.n.Node               ] [Q3beqyO] started
[2017-03-12T15:59:24,349][INFO ][o.e.g.GatewayService     ] [Q3beqyO] recovered [0] indices into cluster_state
[DEBUG] Sending GET request to http://localhost:9200/
[DEBUG] Response with status code 200 and content: {  "name" : "Q3beqyO",  "cluster_name" : "elasticsearch",  "cluster_uuid" : "zYXkHQ0nRmSeZiXf9o04OQ",  "version" : {    "number" : "5.2.2",    "build_hash" : "f9d9b74",    "build_date" : "2017-02-24T17:26:45.835Z",    "build_snapshot" : false,    "lucene_version" : "6.4.1"  },  "tagline" : "You Know, for Search"}
[DEBUG] Elasticsearch has started

Then some tests are running well:

15:59:30,846 DEBUG [f.p.e.t.i.IndexElasticsearchUpdater] Index [twitter] doesn't exist. Creating it.
15:59:30,847 TRACE [f.p.e.t.i.IndexElasticsearchUpdater] createIndex([twitter])
15:59:30,848 TRACE [f.p.e.t.i.IndexElasticsearchUpdater] Found settings for index [twitter]: [{
}]
[2017-03-12T15:59:31,063][INFO ][o.e.c.m.MetaDataCreateIndexService] [Q3beqyO] [twitter] creating index, cause [api], templates [], shards [5]/[1], mappings []
15:59:31,459 TRACE [f.p.e.t.i.IndexElasticsearchUpdater] /createIndex([twitter])
15:59:31,462 TRACE [f.p.e.t.SettingsReader] Reading file [es/twitter/tweet.json]...
15:59:31,537 DEBUG [f.p.e.t.t.TypeElasticsearchUpdater] Type [twitter]/[tweet] doesn't exist. Creating it.
15:59:31,537 TRACE [f.p.e.t.t.TypeElasticsearchUpdater] createType([twitter/tweet])
[2017-03-12T15:59:32,333][INFO ][o.e.c.m.MetaDataMappingService] [Q3beqyO] [twitter/LT0TS5uFSpa4Is78h-8naA] create_mapping [tweet]
15:59:32,818 TRACE [f.p.e.t.t.TypeElasticsearchUpdater] /createType([twitter/tweet])
15:59:32,818 DEBUG [f.p.e.t.t.TypeElasticsearchUpdater] Type definition for [twitter]/[tweet] succesfully created.
15:59:32,818 TRACE [f.p.e.t.i.IndexSettingsReader] Reading [_settings.json] for [rss] in [es]...
15:59:32,818 TRACE [f.p.e.t.SettingsReader] Reading file [es/rss/_settings.json]...
15:59:32,819 TRACE [f.p.e.t.SettingsReader] Can not find [es/rss/_settings.json] in class loader.
15:59:36,115 DEBUG [f.p.e.t.i.IndexElasticsearchUpdater] Index [rss] doesn't exist. Creating it.
15:59:36,115 TRACE [f.p.e.t.i.IndexElasticsearchUpdater] createIndex([rss])

And suddenly 💥

15:59:36,171 WARN  [o.s.c.s.ClassPathXmlApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esClient': Invocation of init method failed; nested exception is NoNodeAvailableException[None of the configured nodes were available: [{Q3beqyO}{Q3beqyOTRNmkkow3pXMK0g}{biMDuBQdQD2bxga9m2Cm6Q}{127.0.0.1}{127.0.0.1:9300}]]; nested: NodeDisconnectedException[[Q3beqyO][127.0.0.1:9300][indices:admin/create] disconnected];
15:59:36,173 INFO  [o.e.c.t.TransportClientNodesService] failed to get node info for {#transport#-1}{oBLQPybTT2akQRbmQF7o8g}{127.0.0.1}{127.0.0.1:9300}, disconnecting...
org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

If we look at elasticsearch logs:

[2017-03-12T15:59:24,349][INFO ][o.e.g.GatewayService     ] [Q3beqyO] recovered [0] indices into cluster_state
[2017-03-12T15:59:31,063][INFO ][o.e.c.m.MetaDataCreateIndexService] [Q3beqyO] [twitter] creating index, cause [api], templates [], shards [5]/[1], mappings []
[2017-03-12T15:59:32,333][INFO ][o.e.c.m.MetaDataMappingService] [Q3beqyO] [twitter/LT0TS5uFSpa4Is78h-8naA] create_mapping [tweet]

The process has been killed without any notice as we can see when elasticsearch-maven-plugin tries to stop it:

[INFO] --- elasticsearch-maven-plugin:5.7:stop (stop-elasticsearch) @ spring-elasticsearch ---
[INFO] Stopping Elasticsearch [com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration@6f2864c3[id=0,baseDir=/home/travis/build/dadoonet/spring-elasticsearch/target/elasticsearch0,httpPort=0,transportPort=0,pathData=<null>,pathLogs=<null>]]
[DEBUG] Using environment: null
[INFO] Elasticsearch[0]: Executing command '[kill, 1595]' in directory '/home/travis/build/dadoonet/spring-elasticsearch/target/elasticsearch0'
kill: No such process
[ERROR] Exception while stopping Elasticsearch
com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException: Elasticsearch [0]: Cannot execute command '[kill, 1595]' in directory '/home/travis/build/dadoonet/spring-elasticsearch/target/elasticsearch0'
	at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:108)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:56)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.StopMojo.execute(StopMojo.java:44)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:91)
	... 23 more

Let me know if you have any idea/workaround for this. Feel free to close if you don't think we can document anything regarding this problem.

Provide some example project

I try to execute the given example projects in the src/it directory using the version 6.5 of the maven module (maven version is 3.3.9), but the tests are halting on the same error (Caused by: java.io.FileNotFoundException: test.properties (The file or the directory not exists). For example:

`[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/src/test/resources
[INFO]
[INFO] --- elasticsearch-maven-plugin:6.5:runforked (run) @ test ---
[INFO] Using Elasticsearch [0] configuration: com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration@61942c1[id=0,baseDir=/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0,httpPort=9200,transportPort=9300,pathData=,pathLogs=,settings=]
Downloading: https://oss.sonatype.org/content/groups/public/org/elasticsearch/distribution/zip/elasticsearch/6.0.0/elasticsearch-6.0.0.zip
Downloaded: https://oss.sonatype.org/content/groups/public/org/elasticsearch/distribution/zip/elasticsearch/6.0.0/elasticsearch-6.0.0.zip (27401 KB at 2006.0 KB/sec)
[INFO] Elasticsearch[0]: Executing command '[chmod, 755, bin/elasticsearch-plugin]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[sed, -i, -e, 1s:.:#!/usr/bin/env bash:, bin/elasticsearch-plugin]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch-plugin, list]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[chmod, 755, bin/elasticsearch]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[sed, -i, -e, 1s:.
:#!/usr/bin/env bash:, bin/elasticsearch]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch, -p, pid, -Ecluster.name=test, -Ehttp.port=9200, -Etransport.tcp.port=9300, -Ehttp.cors.enabled=true]' in directory '/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0'
[2018-06-14T11:16:08,049][INFO ][o.e.n.Node ] [] initializing ...
[2018-06-14T11:16:08,852][INFO ][o.e.e.NodeEnvironment ] [GqvgITe] using [1] data paths, mounts [[/home (/dev/nvme0n1p4)]], net usable_space [16.7gb], net total_space [176gb], types [ext4]
[2018-06-14T11:16:08,857][INFO ][o.e.e.NodeEnvironment ] [GqvgITe] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-06-14T11:16:08,871][INFO ][o.e.n.Node ] node name [GqvgITe] derived from node ID [GqvgITeLQVW62jbZ6tfX-A]; set [node.name] to override
[2018-06-14T11:16:08,879][INFO ][o.e.n.Node ] version[6.0.0], pid[20731], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Linux/4.13.0-45-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_171/25.171-b11]
[2018-06-14T11:16:08,909][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0, -Des.path.conf=/home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/elasticsearch0/config]
[2018-06-14T11:16:12,697][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [aggs-matrix-stats]
[2018-06-14T11:16:12,698][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [analysis-common]
[2018-06-14T11:16:12,699][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [ingest-common]
[2018-06-14T11:16:12,701][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [lang-expression]
[2018-06-14T11:16:12,709][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [lang-mustache]
[2018-06-14T11:16:12,710][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [lang-painless]
[2018-06-14T11:16:12,711][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [parent-join]
[2018-06-14T11:16:12,711][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [percolator]
[2018-06-14T11:16:12,711][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [reindex]
[2018-06-14T11:16:12,712][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [repository-url]
[2018-06-14T11:16:12,712][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [transport-netty4]
[2018-06-14T11:16:12,713][INFO ][o.e.p.PluginsService ] [GqvgITe] loaded module [tribe]
[2018-06-14T11:16:12,713][INFO ][o.e.p.PluginsService ] [GqvgITe] no plugins loaded
[2018-06-14T11:16:14,399][INFO ][o.e.d.DiscoveryModule ] [GqvgITe] using discovery type [zen]
[2018-06-14T11:16:15,230][INFO ][o.e.n.Node ] initialized
[2018-06-14T11:16:15,231][INFO ][o.e.n.Node ] [GqvgITe] starting ...
[2018-06-14T11:16:15,475][INFO ][o.e.t.TransportService ] [GqvgITe] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-06-14T11:16:15,489][WARN ][o.e.b.BootstrapChecks ] [GqvgITe] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-06-14T11:16:18,585][INFO ][o.e.c.s.MasterService ] [GqvgITe] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {GqvgITe}{GqvgITeLQVW62jbZ6tfX-A}{Ac3eFxW0QRq1LSD6FFDlWw}{127.0.0.1}{127.0.0.1:9300}
[2018-06-14T11:16:18,590][INFO ][o.e.c.s.ClusterApplierService] [GqvgITe] new_master {GqvgITe}{GqvgITeLQVW62jbZ6tfX-A}{Ac3eFxW0QRq1LSD6FFDlWw}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {GqvgITe}{GqvgITeLQVW62jbZ6tfX-A}{Ac3eFxW0QRq1LSD6FFDlWw}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-06-14T11:16:18,609][INFO ][o.e.h.n.Netty4HttpServerTransport] [GqvgITe] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-06-14T11:16:18,610][INFO ][o.e.n.Node ] [GqvgITe] started
[2018-06-14T11:16:18,627][INFO ][o.e.g.GatewayService ] [GqvgITe] recovered [0] indices into cluster_state
[INFO] The Elasticsearch instance has started
[2018-06-14T11:16:19,305][WARN ][o.e.h.n.Netty4HttpServerTransport] [GqvgITe] caught exception while handling client http traffic, closing connection [id: 0x94b4441a, L:/127.0.0.1:9200 - R:/127.0.0.1:55440]
java.io.IOException: A kapcsolatot bontotta a távoli fél
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:1.8.0_171]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[?:1.8.0_171]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_171]
at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[?:1.8.0_171]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[?:1.8.0_171]
at io.netty.buffer.PooledHeapByteBuf.setBytes(PooledHeapByteBuf.java:261) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) ~[netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:544) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.13.Final.jar:4.1.13.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
[INFO] The Elasticsearch cluster has started
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ test ---
[2018-06-14T11:16:20,374][WARN ][o.e.h.n.Netty4HttpServerTransport] [GqvgITe] caught exception while handling client http traffic, closing connection [id: 0xc9767643, L:/127.0.0.1:9200 - R:/127.0.0.1:55442]
java.io.IOException: A kapcsolatot bontotta a távoli fél
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:1.8.0_171]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[?:1.8.0_171]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_171]
at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[?:1.8.0_171]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[?:1.8.0_171]
at io.netty.buffer.PooledHeapByteBuf.setBytes(PooledHeapByteBuf.java:261) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) ~[netty-buffer-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) ~[netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:544) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.13.Final.jar:4.1.13.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ test ---
[INFO] Surefire report directory: /home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/surefire-reports


T E S T S

Running com.github.alexcojocaru.mojo.elasticsearch.v2.DefaultsTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.076 sec <<< FAILURE!
com.github.alexcojocaru.mojo.elasticsearch.v2.DefaultsTest Time elapsed: 0.075 sec <<< ERROR!
java.lang.RuntimeException: Cannot load httpPort from test.properties
at com.github.alexcojocaru.mojo.elasticsearch.v2.ItBase.beforeClass(ItBase.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.mockito.internal.runners.SilentJUnitRunner.run(SilentJUnitRunner.java:39)
at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:104)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.FileNotFoundException: test.properties (Nincs ilyen fájl vagy könyvtár)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at com.github.alexcojocaru.mojo.elasticsearch.v2.ItBase.beforeClass(ItBase.java:36)
... 24 more

Results :

Tests in error:
com.github.alexcojocaru.mojo.elasticsearch.v2.DefaultsTest: Cannot load httpPort from test.properties

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.121 s
[INFO] Finished at: 2018-06-14T11:16:21+02:00
[INFO] Final Memory: 24M/262M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project test: There are test failures.
[ERROR]
[ERROR] Please refer to /home/totha/work/elastic-hunspell/elasticsearch-maven-plugin/src/it/runforked-defaults-es6/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[INFO] Cleaning up at application shutdown...
[INFO] The Elasticsearch process is still running; stopping it ...
[INFO] ... the Elasticsearch process [0] has stopped. Exit code: 143
`
Can you help me in, what the problem is?

Thanks in advance!
Adrian

No implementation for org.eclipse.aether.RepositorySystem was bound. while locating org.apache.maven.artifact.resolver.DefaultArtifactResolver

I am using object of ArtifactResolver in my junit test class in following way
final ArtifactResolver resolver = (ArtifactResolver)this .getContainer().lookup(ArtifactResolver.ROLE);

It works find when I am use maven-compat dependency with version 3.0-alpha-2.But, I had to update this dependency version to 3.3.9 to use certain upgraded methods and code. The moment, I upgrade its version, I started getting following error in my eclipse and jenkins central both

No implementation for org.eclipse.aether.RepositorySystem was bound. while locating org.apache.maven.artifact.resolver.DefaultArtifactResolver at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.MergedModule -> org.eclipse.sisu.plexus.PlexusBindingModule) at ClassRealm[plexus.core, parent: null] (via modules: org.eclipse.sisu.wire.MergedModule -> org.eclipse.sisu.plexus.PlexusBindingModule) while locating org.apache.maven.artifact.resolver.ArtifactResolver1 error role: org.apache.maven.artifact.resolver.ArtifactResolver roleHint: at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:243) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:237) at com.cwsoft.plugins.build.artifact.DownloadMojoTest.init(DownloadMojoTest.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:168) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37) at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:

Maven version that I am using is maven 3.3.9.

Make plugin independent from environment variables

When ES_HOME or ES_PATH_CONF are set, the ES instance started by the plugin uses those values instead of the provided ones, which often results in a failure.

Remove ES_HOME, ES_JAVA_OPTS and ES_PATH_CONF from the environment when spawning the ES process.

SocketTimeoutException when ES is initialized.

I get the following error when the plugin initializes ES via init script:

[ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.1:runforked (start-elasticsearch) on project es: Execution start-elasticsearch of goal com.github.alexcojocaru:elasticsearch-maven-plugin:5.1:runforked failed: Cannot execute command PUT:test_index:{}: java.net.SocketTimeoutException: Read timed out -> [Help 1]

Init script has not very convinient format.

Init script has not very convinient format. I mean, that for now, it is parsed right if a command is in one line, which is not very convinient when you have big mapping or record. Do you plan to make it more convinient?

Thanks.

Wrong URL when downloading elasticsearch?

I'm seeing this in logs when downloading a new elasticsearch version (6.3+):

Downloading from elastic-download-service: https://artifacts.elastic.co/maven/com/github/alexcojocaru/elasticsearch/6.3.1/elasticsearch-6.3.1.zip
Downloading from central: https://repo.maven.apache.org/maven2/com/github/alexcojocaru/elasticsearch/6.3.1/elasticsearch-6.3.1.zip

The elastic-download-service URL sounds wrong to me. Is that an issue or something you did on purpose?

unable to create multi-node ES cluster

I am trying to create some tests which require multiple nodes to belong to the same cluster using the elasticsearch-maven-plugin.

I tried setting the instanceCount to 2 in the pom.xml file and running mvn verify I am seeing two instances of ES created on port 9400 and 9401. However, when I query them for stats only a single node is reported:

curl -XGET http://localhost:9400/_nodes?pretty
...
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  }
...

and same thing when I do curl -XGET http://localhost:9401/_nodes?pretty.

What I am trying to achieve is to see was "total" : 2 for the node count in this cluster.

I realize that the instanceCount option generates two separate elasticsearch instances, but is there a way to connect them so that they're part of the same cluster?

Whatever files get created by the plugin are transient. Even changing the elasticsearch.yml files in an attempt to create a cluster gets overwritten next time mvn verify is run.

Add non-daemon/fork mode goal to stay running until manually stopped

This plugin is fantastic for starting and stopping ES during the build; thank you for it!

Due to the fast lather-rinse-repeat cycle of test creation/modification and app code creation/modification, keeping the server running for developing and manually testing (e.g. running a specific test) would reduce the cycle time.

I would like to use this plugin for that too, keeping the config with one setup for development and automated tests. Adding an option to manually start the server and stay running until manually stopped (with the stop goal or Ctrl-c the console) would accomplish this; perhaps a "run" goal in addition to "runforked" would work?

Failed to bind to: /127.0.0.1:9399: Address already in use

We are using your plugin for integration test.
The problem is that sometimes, We have an error when try to start ES, because the port is already in use.
Maybe because the previous execution of the job was stopped before finish and elasticsearch did not stopped.
At the same time, we start up a jetty instance, but we never have problems when with stop the job before to finish.

[INFO] [ERROR] Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:1.9:start (start-elasticsearch) on project search-ws: Execution start-elasticsearch of goal com.github.alexcojocaru:elasticsearch-maven-plugin:1.9:start failed: Failed to bind to [9399]: Failed to bind to: /127.0.0.1:9399: Address already in use

Note: We are using port 9399 as the http port.

I am going to try to reproduce the error in my local environment.

OSX 10.13.6: Error: Could not find or load main class

After adding and configuring the plugin, when trying to run the project containing it, we get the next error:

[INFO] Using Elasticsearch [0] configuration: com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration@2bef09c0[id=0,baseDir=/myproject/target/elasticsearch0,httpPort=9200,transportPort=9300,pathData=<null>,pathLogs=<null>,settings=<null>]
[INFO] Elasticsearch[0]: Executing command '[chmod, 755, bin/elasticsearch-plugin]' in directory '/myproject/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[sed, -i, -e, 1s:.*:#!/usr/bin/env bash:, bin/elasticsearch-plugin]' in directory '/myproject/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch-plugin, list]' in directory '/myproject/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[chmod, 755, bin/elasticsearch]' in directory '/myproject/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[sed, -i, -e, 1s:.*:#!/usr/bin/env bash:, bin/elasticsearch]' in directory '/myproject/target/elasticsearch0'
[INFO] Elasticsearch[0]: The process finished with exit code 0
[INFO] Elasticsearch[0]: Executing command '[bin/elasticsearch, -p, pid, -Ecluster.name=esDevCluster, -Ehttp.port=9200, -Etransport.tcp.port=9300, -Ehttp.cors.enabled=true]' in directory '/myproject/target/elasticsearch0'
Error: Could not find or load main class -Xms500m
Exception in thread "Thread-5" java.lang.IllegalStateException: This Elasticsearch process destroyer does not support this operation
	at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.remove(ForkedElasticsearchProcessDestroyer.java:50)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:411)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:222)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:167)
	at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedInstance.run(ForkedInstance.java:42)
	at java.lang.Thread.run(Thread.java:748)

After adding a few debugging messages to the elasticsearch run script and running it directly, we noticed that the final java command is like the next one

/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java -Xms2G -Xmx2G -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/myproject/target/elasticsearch0 -cp /myproject/target/elasticsearch0/lib/* org.elasticsearch.bootstrap.Elasticsearch

Running the previous command directly yields to the exact same error.

However, quoting the -cp parameter value makes it work just fine, like this

/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java -Xms2G -Xmx2G -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/myproject/target/elasticsearch0 -cp '/myproject/target/elasticsearch0/lib/*' org.elasticsearch.bootstrap.Elasticsearch

Kind Regards
Juan

The process with PID could not be terminated. The operation attempted is not supported.

Sometimes the ES instance on Windows can't be killed, and the build fails :-(

May be related to an unkillable state.

[INFO] com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException: Elasticsearch [0]: Cannot execute command '[taskkill, /F, /pid, 12340]' in directory 'C:\Projects\elasticsearch-maven-plugin\target\it\runforked-with-path-conf\target\elasticsearch0'
[INFO] Output:
[INFO]
[INFO] Error:
[INFO] ERROR: The process with PID 12340 could not be terminated.
[INFO] Reason: The operation attempted is not supported.
[INFO]
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:267)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:149)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.terminateWindowsProcess(ForkedElasticsearchProcessDestroyer.java:118)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.terminateProcess(ForkedElasticsearchProcessDestroyer.java:65)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer.access$000(ForkedElasticsearchProcessDestroyer.java:15)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.ForkedElasticsearchProcessDestroyer$1.run(ForkedElasticsearchProcessDestroyer.java:28)
[INFO] Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
[INFO]  at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
[INFO]  at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
[INFO]  at com.github.alexcojocaru.mojo.elasticsearch.v2.util.ProcessUtil.executeScript(ProcessUtil.java:222)
[INFO]  ... 5 more

Override Xms, Xmx

Is it possible to override the default xms and xmx arguments of Elasticsearch?

[INFO ][o.e.n.Node ] JVM arguments [-Xms2g, -Xmx2g,...]

wait Indefinitely

Hi Alex,

Thank you for the plugin!

I am trying to pass the -DwaitIndefinitely but it is not working. What am i missing.

mvn clean verify -DwaitIndefinitely

Allow to redirect log to file

  • given
    • I run forked plugin execution
  • when
    • I specify log path parameter
  • then
    • com.github.alexcojocaru.mojo.elasticsearch.v2.AbstractElasticsearchBaseMojo#getLog is returning file based logger

Right now plugin is always writing to the console log, would be nice to configure it somehow.

Groovy support ?

Hello,

how can i enable the groovy support in the elasticsearch ?

<dependencies>
                    <dependency>
                        <groupId>org.elasticsearch</groupId>
                        <artifactId>elasticsearch</artifactId>
                        <!-- REPLACE THE FOLLOWING WITH THE VERSION OF YOUR DESIRE -->
                        <version>${elasticsearch.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.elasticsearch.module</groupId>
                        <artifactId>lang-groovy</artifactId>
                        <version>${elasticsearch.version}</version>
                    </dependency>
                </dependencies>

i add this as a dependency but this is not working.

Thanks for your help

can not run elasticsearch as root

Hi,

I wrote some tests using the plugin, all works as expected.
when running our project on our jenkins we get "can not run elasticsearch as root".

I know that ES cannot run as root user, is there any option in the plugin settings to run it as different user? or any other solution?

Thanks

Failed to obtain node locks when running in TravisCI

Hi.

The build process is working without any problems in my locally but fails in TravisCI.

The Build

[2017-12-04T13:24:40,213][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/travis/build/hakdogan/ElasticSearch/target/elasticsearch0/data/test]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.4.jar:5.6.4]
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/travis/build/hakdogan/ElasticSearch/target/elasticsearch0/data/test]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
	at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:261) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.4.jar:5.6.4]
	... 6 more

travis.yml

language: java
jdk:
- oraclejdk8
sudo: true
script: mvn clean install

before_script:
  - sudo sysctl -w vm.max_map_count=262144

after_success:
- mvn clean cobertura:cobertura coveralls:report

deploy:
  provider: releases
  skip_cleanup: true

  on:
    tags: true
    all_branches: true
    repo: hakdogan/ElasticSearch

pom.xml

<plugin>
                <groupId>com.github.alexcojocaru</groupId>
                <artifactId>elasticsearch-maven-plugin</artifactId>
                <version>6.0</version>
                <configuration>
                    <version>5.6.4</version>
                    <clusterName>test</clusterName>
                    <transportPort>9300</transportPort>
                    <httpPort>9200</httpPort>
                    <timeout>120</timeout>
                </configuration>
                <executions>
                    <execution>
                        <id>run</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>runforked</goal>
                        </goals>
                    </execution>
                    <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>

I haven't found anything like this between the issues. The problem seems to be write permission, any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.