Comments (9)
You have a couple of options to address this issue:
- do not run such jobs in parallel on the same build machine
- use a random ES port for each build (see below for details)
You can use this plugin config:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>es-ports</id>
<phase>generate-test-resources</phase>
<goals>
<!-- called during generate-test-resources and records unused port numbers in ${es.http.port} and ${es.tcp.port} -->
<goal>reserve-network-port</goal>
</goals>
<configuration>
<portNames>
<portName>es.http.port</portName>
<portName>es.tcp.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
to reserve two random port on the local machine to be used by the ES server.
You can than pass the ports (properties) to the ES plugin (to start the server) and to your application (to connect to the ES server using those 2 ports).
That's how I have configured one of my projects to start a local MySQL server on a random port in the pre-integration-test phase, and to start an application (in the same phase) which connects to the MySQL server on that port.
I hope that helps.
from elasticsearch-maven-plugin.
I think that the problem is that Jenkins is executing the integration test in few jobs at the same time (because we have few jobs per different environment and pipelines)
I am not going to remove the issue because maybe is useful for other people.
Regards.
from elasticsearch-maven-plugin.
Cool! Thanks @alexcojocaru
from elasticsearch-maven-plugin.
I am kind of experiencing a similar problem where I need ES to run in a different port if one of the ports is in use
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>es-ports</id>
<phase>generate-test-resources</phase>
<goals>
<!-- called during generate-test-resources and records unused port numbers in ${es.http.port} and ${es.tcp.port} -->
<goal>reserve-network-port</goal>
</goals>
<configuration>
<portNames>
<portName>es.http.port</portName>
<portName>es.tcp.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.alexcojocaru</groupId>
<artifactId>elasticsearch-maven-plugin</artifactId>
<version>5.7</version>
<configuration>
<clusterName>testCluster</clusterName>
<transportPort>${es.tcp.port}</transportPort>
<httpPort>${es.http.port}</httpPort>
<version>6.0.0</version>
<autoCreateIndex>true</autoCreateIndex>
<pathInitScript> src/test/resources/initialize/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>
I am using 2 plugins here - one for reserving network port and the other is for spinning up ES. I wasn't sure how the port numbers will be passed through properties. Can it be a comma separated list of ports? any examples?
from elasticsearch-maven-plugin.
No, it cannot be a list of ports. Your configuration above looks correct. Are you having issues with it?
from elasticsearch-maven-plugin.
Still finding it difficult to comprehend.
The properties tag in pom.xml
> <properties>
> <es.http.port>9400</es.http.port>
> <es.tcp.port>9500</es.tcp.port>
> </properties>
In this case I supply only 2 ports one for TCP and the other for HTTP.
If these are already in use, how does it know to choose a different one?
from elasticsearch-maven-plugin.
It does not choose a different one, if the provided ones are in use.
The snippet in your previous comment does use random port numbers, which are reserved, meaning the ES instance should not run into the "address already in use" problem.
from elasticsearch-maven-plugin.
Does that mean I need not set the port numbers in the properties tag? The below snippet should work all by itself?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>es-ports</id>
<phase>generate-test-resources</phase>
<goals>
<!-- called during generate-test-resources and records unused port numbers in ${es.http.port} and ${es.tcp.port} -->
<goal>reserve-network-port</goal>
</goals>
<configuration>
<portNames>
<portName>es.http.port</portName>
<portName>es.tcp.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.alexcojocaru</groupId>
<artifactId>elasticsearch-maven-plugin</artifactId>
<version>5.7</version>
<configuration>
<clusterName>testCluster</clusterName>
<transportPort>${es.tcp.port}</transportPort>
<httpPort>${es.http.port}</httpPort>
<version>6.0.0</version>
<autoCreateIndex>true</autoCreateIndex>
<pathInitScript> src/test/resources/initialize/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>
This snippet above - picks up random free ports and when another instance of ES is spun it shouldn't complain.
from elasticsearch-maven-plugin.
Yes, I believe the config above would work.
from elasticsearch-maven-plugin.
Related Issues (20)
- unable to download via proxy HOT 5
- No such file or directory error during parallel plugin executions in jenkins HOT 13
- How to fix elasticsearch node startup taking too long? HOT 4
- Add support for downloading from a url protected by basic authentication HOT 3
- Failed to execute goal com.github.alexcojocaru:elasticsearch-maven-plugin:6.13:runforked (start-elasticsearch) on project website: This Elasticsearch process destroyer does not support this operation HOT 2
- Failed to compile in java 11 HOT 2
- Import not found in the prebuild groovy script HOT 4
- Add elasticsearch oss for 6.8.10 HOT 4
- Cannot read the PID of the Elasticsearch process from the pid file in directory "target/elasticsearch0" HOT 2
- Cannot download and start 8.x HOT 8
- Cannot delete download directory for 8.x with plugin 6.20 HOT 1
- Unable to call POST _refresh HOT 6
- Could not resolve artifact with coordinates org.elasticsearch.distribution.zip:elasticsearch:zip:6.8.0 HOT 4
- "master not discovered yet" for 6.20+ HOT 5
- Problem running plugin on java 17 HOT 8
- Plugin seems to be there, but I get Connection refused HOT 4
- Error in opening zip file HOT 1
- Compatibility of licenses HOT 5
- Similiar Plugin for OpenSearch? HOT 2
- resolve ES for Mac M1? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-maven-plugin.