├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── deploy-settings.xml ├── pom.xml └── src ├── main ├── java │ └── fr │ │ └── pilato │ │ └── elasticsearch │ │ └── containers │ │ ├── ElasticsearchContainer.java │ │ └── ElasticsearchResource.java └── resources │ ├── fr │ └── pilato │ │ └── elasticsearch │ │ └── containers │ │ └── elasticsearch-default.properties │ └── org │ └── apache │ └── maven │ └── plugin │ └── announcement │ └── announcement.vm └── test ├── java └── fr │ └── pilato │ └── elasticsearch │ └── containers │ ├── ElasticsearchContainerTest.java │ ├── ElasticsearchResourceBaseTest.java │ ├── ElasticsearchResourceContructorTest.java │ ├── ElasticsearchResourceDefaultsTest.java │ ├── ElasticsearchResourceWithOssImageTest.java │ ├── ElasticsearchResourceWithPluginsAndPluginsDirTest.java │ ├── ElasticsearchResourceWithPluginsDirAndVersionTest.java │ ├── ElasticsearchResourceWithPluginsTest.java │ └── ElasticsearchResourceWithVersionTest.java └── resources ├── fr └── pilato │ └── elasticsearch │ └── containers │ ├── elasticsearch-oss-image.properties │ ├── elasticsearch-plugins-and-plugins-dir.properties │ ├── elasticsearch-plugins-dir-version.properties │ ├── elasticsearch-plugins-dir.properties │ ├── elasticsearch-plugins.properties │ └── elasticsearch-version.properties └── logback-test.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 5 | 6 | # User-specific stuff: 7 | .idea 8 | *.iml 9 | ### Maven template 10 | target/ 11 | pom.xml.tag 12 | pom.xml.releaseBackup 13 | pom.xml.versionsBackup 14 | pom.xml.next 15 | release.properties 16 | dependency-reduced-pom.xml 17 | buildNumber.properties 18 | .mvn/timing.properties 19 | 20 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) 21 | !/.mvn/wrapper/maven-wrapper.jar 22 | 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | 5 | sudo: required 6 | services: 7 | - docker 8 | 9 | install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 10 | 11 | script: 12 | - mvn -B test 13 | 14 | after_success: 15 | - "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && mvn deploy -DskipTests --settings deploy-settings.xml" 16 | 17 | cache: 18 | directories: 19 | - '$HOME/.m2/repository' 20 | 21 | branches: 22 | only: 23 | - "master" 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **IMPORTANT**: This project has moved under testcontainers project as an [elasticsearch module](https://github.com/testcontainers/testcontainers-java/tree/master/modules/elasticsearch). 2 | 3 | No more released will be done in this repository. 4 | 5 | # TestContainers elasticsearch testing module 6 | 7 | [![Build Status](https://travis-ci.org/dadoonet/testcontainers-java-module-elasticsearch.svg?branch=master)](https://travis-ci.org/dadoonet/testcontainers-java-module-elasticsearch) 8 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/fr.pilato.elasticsearch.testcontainers/testcontainers-elasticsearch/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/fr.pilato.elasticsearch.testcontainers/testcontainers-elasticsearch/) 9 | 10 | Testcontainers module for [elasticsearch](https://www.elastic.co/products/elasticsearch). 11 | 12 | Note that it's based on the [official Docker image](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/docker.html) provided by elastic. 13 | 14 | See [testcontainers.org](https://www.testcontainers.org) for more information about Testcontainers. 15 | 16 | ## Usage example 17 | 18 | You can start an elasticsearch container instance from any Java application by using: 19 | 20 | ```java 21 | // Create the elasticsearch container. 22 | ElasticsearchContainer container = new ElasticsearchContainer(); 23 | 24 | // Optional but highly recommended: Specify the version you need. 25 | container.withVersion("6.3.0"); 26 | 27 | // Optional: you can also set what is the Docker registry you want to use with. 28 | container.withBaseUrl("docker.elastic.co/elasticsearch/elasticsearch"); 29 | 30 | // Optional: define which plugin you would like to install. 31 | // It will download it from internet when building the image 32 | container.withPlugin("discovery-gce"); 33 | 34 | // Optional: define the plugins directory which should contain plugins ZIP files you want to install. 35 | // Note that if you want to just download an official plugin, use withPlugin(String) instead. 36 | container.withPluginDir(Paths.get("/path/to/zipped-plugins-dir")); 37 | 38 | // Optional: you can also change the password for X-Pack (for versions >= 6.1). 39 | container.withEnv("ELASTIC_PASSWORD", "changeme"); 40 | 41 | // Optional: you can add secured settings in case you are using a plugin which requires it. 42 | container.withSecureSetting("foo", "bar"); 43 | 44 | // Start the container. This step might take some time... 45 | container.start(); 46 | 47 | // Do whatever you want here. 48 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 49 | credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme")); 50 | RestClient client = RestClient.builder(container.getHost()) 51 | .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)) 52 | .build(); 53 | Response response = client.performRequest("GET", "/"); 54 | 55 | // Stop the container. 56 | container.stop(); 57 | ``` 58 | 59 | ## JUnit 4 Usage example 60 | 61 | Running elasticsearch as a resource during a test: 62 | 63 | ```java 64 | public class SomeTest { 65 | @Rule 66 | public ElasticsearchResource elasticsearch = new ElasticsearchResource(); 67 | 68 | @Test 69 | public void someTestMethod() { 70 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 71 | credentialsProvider.setCredentials(AuthScope.ANY, 72 | new UsernamePasswordCredentials("elastic", "changeme")); 73 | 74 | RestClient client = RestClient.builder(elasticsearch.getHost()) 75 | .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)) 76 | .build(); 77 | Response response = client.performRequest("GET", "/"); 78 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 79 | ``` 80 | 81 | The default version is read from a property file named `elasticsearch.properties` in `fr.pilato.elasticsearch.containers` package. 82 | If you provide an `elasticsearch.properties` in `fr.pilato.elasticsearch.containers` package, 83 | the settings will be read from it: 84 | 85 | ```properties 86 | baseUrl=docker.elastic.co/elasticsearch/elasticsearch 87 | version=6.3.0 88 | ``` 89 | 90 | You can also define this programmatically with: 91 | 92 | ```java 93 | @Rule 94 | public ElasticsearchResource elasticsearch = new ElasticsearchResource( 95 | "docker.elastic.co/elasticsearch/elasticsearch", // baseUrl (can be null) 96 | "6.3.0", // version (can be null) 97 | Paths.get("/path/to/zipped-plugins-dir"), // pluginsDir (can be null) 98 | Collections.singletonList("ingest-attachment"), // standard plugins (can be empty) 99 | Collections.singletonMap("foo", "bar"), // Map of secured settings (can be empty) 100 | "changeme"); // X-Pack security password to set (can be null) 101 | ``` 102 | 103 | Note that if you are still using the [TransportClient](https://www.elastic.co/guide/en/elasticsearch/client/java-api/6.3/transport-client.html) 104 | (not recommended as deprecated), the default cluster name is set to `docker-cluster` so you need to change `cluster.name` setting 105 | or set `client.transport.ignore_cluster_name` to `true`. 106 | 107 | ## Running without x-pack 108 | 109 | If you prefer to start a Docker image without x-pack plugin, which means with no security or 110 | other advanced features, you can use this baseUrl instead: `docker.elastic.co/elasticsearch/elasticsearch-oss`. 111 | 112 | ## Dependency information 113 | 114 | ### Maven 115 | 116 | ``` 117 | 118 | fr.pilato.elasticsearch.testcontainers 119 | testcontainers-elasticsearch 120 | 0.1 121 | 122 | ``` 123 | 124 | ### Gradle 125 | 126 | ``` 127 | compile group: 'fr.pilato.elasticsearch.testcontainers', name: 'testcontainers-elasticsearch', version: '0.1' 128 | ``` 129 | 130 | 131 | # Release guide 132 | 133 | To release the project you need to run the release plugin with the `release` profile as you need to sign the artifacts: 134 | 135 | ```sh 136 | mvn release:prepare 137 | git push --tags 138 | mvn release:perform -Prelease 139 | ``` 140 | 141 | If you need to skip the tests, run: 142 | 143 | ```sh 144 | mvn release:perform -Prelease -Darguments="-DskipTests" 145 | ``` 146 | 147 | To announce the release, run: 148 | 149 | ```sh 150 | cd target/checkout 151 | # Run the following command if you want to check the announcement email 152 | mvn changes:announcement-generate 153 | cat target/announcement/announcement.vm 154 | 155 | # Announce the release (change your smtp username and password) 156 | mvn changes:announcement-mail -Dchanges.username='YourSmtpUserName' -Dchanges.password='YourSmtpUserPassword' 157 | ``` 158 | 159 | # License 160 | 161 | See [LICENSE](LICENSE). 162 | 163 | # Copyright 164 | 165 | Copyright (c) 2017, 2018 David Pilato. 166 | 167 | -------------------------------------------------------------------------------- /deploy-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sonatype-nexus-snapshots 5 | ${env.OSSRH_USER} 6 | ${env.OSSRH_PASS} 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | fr.pilato.elasticsearch.testcontainers 6 | testcontainers-elasticsearch 7 | 0.2-SNAPSHOT 8 | 9 | TestContainers :: elasticsearch 10 | Dockerized Elasticsearch container for testing under Testcontainers. 11 | https://github.com/dadoonet/testcontainers-java-module-elasticsearch 12 | 13 | 14 | The Apache Software License, Version 2.0 15 | http://www.apache.org/licenses/LICENSE-2.0.txt 16 | repo 17 | 18 | 19 | 20 | 21 | 1.8.2 22 | 23 | 6.3.0 24 | 25 | 5.6.10 26 | ${elasticsearch.version} 27 | 9400 28 | ${project.build.directory}/plugins 29 | changeme 30 | false 31 | 32 | UTF-8 33 | UTF-8 34 | 35 | 36 | 37 | GitHub 38 | https://github.com/dadoonet/testcontainers-java-module-elasticsearch/issues/ 39 | 40 | 41 | 42 | 43 | dadoonet 44 | David Pilato 45 | david@pilato.fr 46 | http://david.pilato.fr/ 47 | +1 48 | 49 | 50 | 51 | 52 | 53 | org.testcontainers 54 | testcontainers 55 | ${testcontainer.version} 56 | 57 | 58 | org.elasticsearch.client 59 | elasticsearch-rest-client 60 | ${elasticsearch.client.version} 61 | 62 | 63 | 64 | ch.qos.logback 65 | logback-classic 66 | 1.2.3 67 | test 68 | 69 | 70 | 71 | 72 | 73 | 74 | src/main/resources 75 | true 76 | 77 | 78 | 79 | 80 | src/test/resources 81 | true 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-compiler-plugin 88 | 3.7.0 89 | 90 | 1.8 91 | 1.8 92 | 93 | 94 | 95 | org.apache.maven.plugins 96 | maven-dependency-plugin 97 | 2.10 98 | 99 | 100 | 101 | integ-setup-dependencies-plugins 102 | generate-test-resources 103 | 104 | copy 105 | 106 | 107 | ${skipTests} 108 | 109 | 110 | org.elasticsearch.plugin 111 | ingest-attachment 112 | ${elasticsearch.version} 113 | zip 114 | 115 | 116 | true 117 | ${plugin.dir}/${elasticsearch.version} 118 | 119 | 120 | 121 | 122 | integ-setup-dependencies-plugins-old 123 | generate-test-resources 124 | 125 | copy 126 | 127 | 128 | ${skipTests} 129 | 130 | 131 | org.elasticsearch.plugin 132 | ingest-attachment 133 | ${elasticsearch.version.old} 134 | zip 135 | 136 | 137 | true 138 | ${plugin.dir}/${elasticsearch.version.old} 139 | 140 | 141 | 142 | 143 | 144 | org.sonatype.plugins 145 | nexus-staging-maven-plugin 146 | 1.6.8 147 | true 148 | 149 | sonatype-nexus-staging 150 | https://oss.sonatype.org/ 151 | false 152 | 153 | 154 | 155 | org.apache.maven.plugins 156 | maven-changes-plugin 157 | 2.12.1 158 | 159 | auth.smtp.1and1.fr 160 | 465 161 | true 162 | dadoonet 163 | 164 | discuss+community-plugins@elastic.co 165 | 166 | 167 | GitHub 168 | 169 | 170 | new,doc 171 | bug 172 | update 173 | remove 174 | 175 | 176 | ${elasticsearch.version} 177 | 178 | 179 | 180 | 181 | org.apache.maven.plugins 182 | maven-release-plugin 183 | 2.5.3 184 | 185 | false 186 | 187 | 188 | 189 | 190 | 191 | 192 | scm:git:https://github.com/dadoonet/testcontainers-java-module-elasticsearch.git 193 | scm:git:git@github.com:dadoonet/testcontainers-java-module-elasticsearch.git 194 | https://github.com/dadoonet/testcontainers-java-module-elasticsearch 195 | HEAD 196 | 197 | 198 | 199 | 200 | sonatype-nexus-snapshots 201 | https://oss.sonatype.org/content/repositories/snapshots 202 | 203 | 204 | sonatype-nexus-staging 205 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 206 | 207 | 208 | 209 | 210 | 211 | 212 | elastic-download-service 213 | Elastic Download Service 214 | https://artifacts.elastic.co/maven/ 215 | true 216 | false 217 | 218 | 219 | 220 | oss-snapshots 221 | Sonatype OSS Snapshots 222 | https://oss.sonatype.org/content/repositories/snapshots/ 223 | false 224 | true 225 | 226 | 227 | 228 | 229 | 230 | fake-elastic-maven-repository 231 | 232 | 233 | 234 | ${user.home}/.m2/repository/org/elasticsearch/plugin/ingest-attachment/6.3.0/ingest-attachment-6.3.0.zip 235 | 236 | 237 | 238 | 239 | 240 | 241 | org.codehaus.mojo 242 | wagon-maven-plugin 243 | 1.0 244 | 245 | 246 | download-ingest-attachment 247 | initialize 248 | 249 | download-single 250 | 251 | 252 | https://artifacts.elastic.co 253 | downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-${elasticsearch.version}.zip 254 | ${plugin.dir}/${elasticsearch.version} 255 | 256 | 257 | 258 | 259 | 260 | org.apache.maven.plugins 261 | maven-install-plugin 262 | 2.5.2 263 | 264 | 265 | fake-elasticsearch-repository 266 | initialize 267 | 268 | install-file 269 | 270 | 271 | ${plugin.dir}/${elasticsearch.version}/ingest-attachment-${elasticsearch.version}.zip 272 | org.elasticsearch.plugin 273 | ingest-attachment 274 | ${elasticsearch.version} 275 | zip 276 | true 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | fake-elastic-maven-repository-for-old-plugin 286 | 287 | 288 | 289 | ${user.home}/.m2/repository/org/elasticsearch/plugin/ingest-attachment/5.6.10/ingest-attachment-5.6.10.zip 290 | 291 | 292 | 293 | 294 | 295 | 296 | org.codehaus.mojo 297 | wagon-maven-plugin 298 | 1.0 299 | 300 | 301 | download-ingest-attachment-old 302 | initialize 303 | 304 | download-single 305 | 306 | 307 | https://artifacts.elastic.co 308 | downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-${elasticsearch.version.old}.zip 309 | ${plugin.dir}/${elasticsearch.version.old} 310 | 311 | 312 | 313 | 314 | 315 | org.apache.maven.plugins 316 | maven-install-plugin 317 | 2.5.2 318 | 319 | 320 | fake-elasticsearch-repository-old 321 | initialize 322 | 323 | install-file 324 | 325 | 326 | ${plugin.dir}/${elasticsearch.version.old}/ingest-attachment-${elasticsearch.version.old}.zip 327 | org.elasticsearch.plugin 328 | ingest-attachment 329 | ${elasticsearch.version.old} 330 | zip 331 | true 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | release 342 | 343 | 344 | 345 | org.apache.maven.plugins 346 | maven-javadoc-plugin 347 | 2.10.4 348 | 349 | 350 | attach-javadocs 351 | 352 | jar 353 | 354 | 355 | 356 | 357 | 358 | org.apache.maven.plugins 359 | maven-source-plugin 360 | 3.0.1 361 | 362 | 363 | attach-sources 364 | 365 | jar-no-fork 366 | 367 | 368 | 369 | 370 | 371 | org.apache.maven.plugins 372 | maven-gpg-plugin 373 | 1.6 374 | 375 | 376 | sign-artifacts 377 | verify 378 | 379 | sign 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | import org.apache.http.HttpHost; 23 | import org.testcontainers.containers.BindMode; 24 | import org.testcontainers.containers.GenericContainer; 25 | import org.testcontainers.images.builder.ImageFromDockerfile; 26 | import org.testcontainers.shaded.com.google.common.collect.ImmutableSet; 27 | 28 | import java.io.IOException; 29 | import java.nio.file.Files; 30 | import java.nio.file.Path; 31 | import java.util.ArrayList; 32 | import java.util.HashMap; 33 | import java.util.List; 34 | import java.util.Map; 35 | import java.util.Properties; 36 | import java.util.Set; 37 | 38 | import static fr.pilato.elasticsearch.containers.ElasticsearchResource.FALLBACK_RESOURCE_NAME; 39 | 40 | /** 41 | * Represents an elasticsearch docker instance which exposes by default port 9200 and 9300 (transport.tcp.port) 42 | * The docker image is by default fetch from docker.elastic.co/elasticsearch/elasticsearch 43 | * @author dadoonet 44 | */ 45 | public class ElasticsearchContainer> extends GenericContainer { 46 | 47 | private static final int ELASTICSEARCH_DEFAULT_PORT = 9200; 48 | private static final int ELASTICSEARCH_DEFAULT_TCP_PORT = 9300; 49 | static final String ELASTICSEARCH_DEFAULT_BASE_URL; 50 | static final String ELASTICSEARCH_DEFAULT_VERSION; 51 | static { 52 | Properties props = new Properties(); 53 | try { 54 | props.load(ElasticsearchResource.class.getResourceAsStream(FALLBACK_RESOURCE_NAME)); 55 | } catch (IOException ignored) { 56 | } 57 | ELASTICSEARCH_DEFAULT_BASE_URL = props.getProperty("baseUrl"); 58 | ELASTICSEARCH_DEFAULT_VERSION = props.getProperty("version"); 59 | } 60 | 61 | private String baseUrl = ELASTICSEARCH_DEFAULT_BASE_URL; 62 | private String version = ELASTICSEARCH_DEFAULT_VERSION; 63 | private Path pluginDir = null; 64 | private List plugins = new ArrayList<>(); 65 | private Map securedKeys = new HashMap<>(); 66 | 67 | /** 68 | * Define the elasticsearch version to start 69 | * @param version Elasticsearch Version like 5.6.6 or 6.2.1 70 | * @return this 71 | */ 72 | public ElasticsearchContainer withVersion(String version) { 73 | this.version = version; 74 | return this; 75 | } 76 | 77 | /** 78 | * Define the elasticsearch docker registry base url 79 | * @param baseUrl defaults to docker.elastic.co/elasticsearch/elasticsearch 80 | * @return this 81 | */ 82 | public ElasticsearchContainer withBaseUrl(String baseUrl) { 83 | this.baseUrl = baseUrl; 84 | return this; 85 | } 86 | 87 | /** 88 | * Define the elasticsearch docker registry base url 89 | * @param key Key 90 | * @param value Value 91 | * @return this 92 | */ 93 | public ElasticsearchContainer withSecureSetting(String key, String value) { 94 | securedKeys.put(key, value); 95 | return this; 96 | } 97 | 98 | /** 99 | * Plugin name to install. Note that will download the plugin from internet the first time you build the image 100 | * @param pluginName plugins dir 101 | * @return this 102 | */ 103 | public ElasticsearchContainer withPlugin(String pluginName) { 104 | plugins.add(pluginName); 105 | return this; 106 | } 107 | 108 | /** 109 | * Path to plugin dir which contains plugins that needs to be installed 110 | * @param pluginDir plugins dir 111 | * @return this 112 | */ 113 | public ElasticsearchContainer withPluginDir(Path pluginDir) { 114 | if (pluginDir == null) { 115 | return this; 116 | } 117 | 118 | // When we have a plugin dir, we need to mount it in the docker instance 119 | this.pluginDir = createVolumeDirectory(true); 120 | 121 | // We create the volume that will be needed for plugins 122 | addFileSystemBind(this.pluginDir.toString(), "/plugins", BindMode.READ_ONLY); 123 | 124 | logger().debug("Installing plugins from [{}]", pluginDir); 125 | try { 126 | Files.list(pluginDir).forEach(path -> { 127 | logger().trace("File found in [{}]: [{}]", pluginDir, path); 128 | if (path.toString().endsWith(".zip")) { 129 | logger().debug("Copying [{}] to [{}]", path.getFileName(), this.pluginDir.toAbsolutePath().toString()); 130 | try { 131 | Files.copy(path, this.pluginDir.resolve(path.getFileName())); 132 | withPlugin("file:///tmp/plugins/" + path.getFileName()); 133 | } catch (IOException e) { 134 | logger().error("Error while copying", e); 135 | } 136 | } 137 | }); 138 | } catch (IOException e) { 139 | logger().error("Error listing plugins", e); 140 | } 141 | return this; 142 | } 143 | 144 | @Override 145 | public Set getLivenessCheckPortNumbers() { 146 | return ImmutableSet.of(getMappedPort(ELASTICSEARCH_DEFAULT_PORT)); 147 | } 148 | 149 | @Override 150 | protected void configure() { 151 | logger().info("Starting an elasticsearch container using version [{}] from [{}]", version, baseUrl); 152 | ImageFromDockerfile dockerImage = new ImageFromDockerfile() 153 | .withDockerfileFromBuilder(builder -> { 154 | builder.from(baseUrl + ":" + version); 155 | if (pluginDir != null) { 156 | // We need to map the local dir which contains plugins with the container 157 | builder.copy("/tmp/plugins", "/tmp/plugins"); 158 | } 159 | for (String plugin : plugins) { 160 | logger().debug("Installing plugin [{}]", plugin); 161 | builder.run("bin/elasticsearch-plugin install " + plugin + " --batch"); 162 | } 163 | // If we have any secured key, we need to create the keystore 164 | if (!securedKeys.isEmpty()) { 165 | builder.run("bin/elasticsearch-keystore create"); 166 | } 167 | for (Map.Entry secrets : securedKeys.entrySet()) { 168 | logger().debug("Adding secured key [{}]", secrets.getKey()); 169 | builder.run("echo '" + secrets.getValue() + "' | bin/elasticsearch-keystore add --stdin " + secrets.getKey()); 170 | } 171 | String s = builder.build(); 172 | 173 | logger().debug("Image generated: {}", s); 174 | }); 175 | 176 | if (pluginDir != null) { 177 | dockerImage.withFileFromFile("/tmp/plugins", this.pluginDir.toAbsolutePath().toFile()); 178 | } 179 | 180 | setImage(dockerImage); 181 | addExposedPort(ELASTICSEARCH_DEFAULT_PORT); 182 | addExposedPort(ELASTICSEARCH_DEFAULT_TCP_PORT); 183 | } 184 | 185 | public HttpHost getHost() { 186 | return new HttpHost(getContainerIpAddress(), getMappedPort(ELASTICSEARCH_DEFAULT_PORT)); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/fr/pilato/elasticsearch/containers/ElasticsearchResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | import org.apache.http.HttpHost; 23 | import org.jetbrains.annotations.Nullable; 24 | import org.junit.rules.ExternalResource; 25 | import org.rnorth.ducttape.Preconditions; 26 | 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | import java.nio.file.Path; 30 | import java.nio.file.Paths; 31 | import java.util.ArrayList; 32 | import java.util.Arrays; 33 | import java.util.Collections; 34 | import java.util.List; 35 | import java.util.Map; 36 | import java.util.Properties; 37 | 38 | import static fr.pilato.elasticsearch.containers.ElasticsearchContainer.ELASTICSEARCH_DEFAULT_BASE_URL; 39 | import static fr.pilato.elasticsearch.containers.ElasticsearchContainer.ELASTICSEARCH_DEFAULT_VERSION; 40 | 41 | /** 42 | *

Junit Test Resource for elasticsearch.

43 | */ 44 | public class ElasticsearchResource extends ExternalResource { 45 | 46 | private static final String DEFAULT_RESOURCE_NAME = "elasticsearch.properties"; 47 | static final String FALLBACK_RESOURCE_NAME = "elasticsearch-default.properties"; 48 | private final String baseUrl; 49 | private final String version; 50 | private final Path pluginDir; 51 | private final String password; 52 | private final List plugins; 53 | private final Map securedSettings; 54 | @Nullable private ElasticsearchContainer delegate; 55 | 56 | public ElasticsearchResource() { 57 | this(DEFAULT_RESOURCE_NAME); 58 | } 59 | 60 | /** 61 | * Generate a resource programmatically 62 | * @param baseUrl If null defaults to ELASTICSEARCH_DEFAULT_BASE_URL 63 | * @param version Elasticsearch version to start. If null defaults to ELASTICSEARCH_DEFAULT_VERSION 64 | * @param pluginDir Plugin dir which might contain plugins to install. Can be null. 65 | * @param plugins Plugins to install. Can be null. 66 | * @param securedSettings Map of secured settings (key/value). Can be null. 67 | * @param password X-Pack default password. Can be null. 68 | */ 69 | public ElasticsearchResource(String baseUrl, String version, Path pluginDir, List plugins, Map securedSettings, 70 | String password) { 71 | this.baseUrl = baseUrl == null ? ELASTICSEARCH_DEFAULT_BASE_URL : baseUrl; 72 | this.version = version == null ? ELASTICSEARCH_DEFAULT_VERSION : version; 73 | this.pluginDir = pluginDir; 74 | this.plugins = plugins; 75 | this.securedSettings = securedSettings; 76 | this.password = password; 77 | } 78 | 79 | public ElasticsearchResource(String resourceName) { 80 | // Find the latest version this project was built with 81 | String propVersion; 82 | String propBaseUrl; 83 | String propPlugins; 84 | String propPluginDir; 85 | String propPassword; 86 | String defaultBaseUrl = null; 87 | String defaultVersion = null; 88 | String defaultPlugins = null; 89 | String defaultPluginDir = null; 90 | String defaultPassword = null; 91 | Properties props = new Properties(); 92 | try { 93 | props.load(ElasticsearchResource.class.getResourceAsStream(FALLBACK_RESOURCE_NAME)); 94 | defaultBaseUrl = props.getProperty("baseUrl"); 95 | defaultVersion = props.getProperty("version"); 96 | defaultPlugins = props.getProperty("plugins"); 97 | defaultPluginDir = props.getProperty("pluginDir"); 98 | defaultPassword = props.getProperty("password"); 99 | } catch (IOException ignored) { 100 | // This can normally never happen unless someone modifies the JAR file o_O 101 | } 102 | try { 103 | InputStream stream = ElasticsearchResource.class.getResourceAsStream(resourceName); 104 | if (stream != null) { 105 | props.load(stream); 106 | propBaseUrl = props.getProperty("baseUrl", defaultBaseUrl); 107 | propVersion = props.getProperty("version", defaultVersion); 108 | propPlugins = props.getProperty("plugins", defaultPluginDir); 109 | propPluginDir = props.getProperty("pluginDir", defaultPluginDir); 110 | propPassword = props.getProperty("password", defaultPassword); 111 | } else { 112 | propBaseUrl = defaultBaseUrl; 113 | propVersion = defaultVersion; 114 | propPlugins = defaultPlugins; 115 | propPluginDir = defaultPluginDir; 116 | propPassword = defaultPassword; 117 | } 118 | } catch (IOException e) { 119 | // We might get that exception if the user provides a badly formatted property file 120 | propBaseUrl = null; 121 | propVersion = null; 122 | propPlugins = null; 123 | propPluginDir = null; 124 | propPassword = null; 125 | } 126 | baseUrl = propBaseUrl; 127 | version = propVersion; 128 | plugins = generateFromCommaSeparatedString(propPlugins); 129 | pluginDir = propPluginDir == null ? null : Paths.get(propPluginDir); 130 | password = propPassword; 131 | securedSettings = Collections.emptyMap(); 132 | } 133 | 134 | private List generateFromCommaSeparatedString(String value) { 135 | List values = new ArrayList<>(); 136 | if (value != null) { 137 | values.addAll(Arrays.asList(value.split(","))); 138 | } 139 | 140 | return values; 141 | } 142 | 143 | @Override 144 | protected void before() { 145 | Preconditions.check("baseUrl can't be null", baseUrl != null); 146 | Preconditions.check("version can't be null", version != null); 147 | Preconditions.check("plugins can't be null. Should be empty list instead", plugins != null); 148 | Preconditions.check("securedSettings can't be null. Should be empty map instead", securedSettings != null); 149 | delegate = new ElasticsearchContainer() 150 | .withBaseUrl(baseUrl) 151 | .withVersion(version) 152 | .withPluginDir(pluginDir); 153 | 154 | for (String plugin : plugins) { 155 | delegate.withPlugin(plugin); 156 | } 157 | 158 | for (Map.Entry securedSetting : securedSettings.entrySet()) { 159 | delegate.withSecureSetting(securedSetting.getKey(), securedSetting.getValue()); 160 | } 161 | 162 | if (password != null && !password.isEmpty()) { 163 | delegate.withEnv("ELASTIC_PASSWORD", password); 164 | } 165 | 166 | delegate.start(); 167 | } 168 | 169 | @Override 170 | protected void after() { 171 | Preconditions.check("delegate must have been created by before()", delegate != null); 172 | delegate.stop(); 173 | } 174 | 175 | /** 176 | * Get the HttpHost instance you can use to build an elasticsearch Rest client 177 | * @return an HttpHost 178 | */ 179 | public HttpHost getHost() { 180 | Preconditions.check("delegate must have been created by before()", delegate != null); 181 | return delegate.getHost(); 182 | } 183 | 184 | @Nullable 185 | public ElasticsearchContainer getContainer() { 186 | return delegate; 187 | } 188 | 189 | public String getPassword() { 190 | return password; 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /src/main/resources/fr/pilato/elasticsearch/containers/elasticsearch-default.properties: -------------------------------------------------------------------------------- 1 | baseUrl=docker.elastic.co/elasticsearch/elasticsearch 2 | version=${elasticsearch.version} 3 | password=${xpack.password} 4 | -------------------------------------------------------------------------------- /src/main/resources/org/apache/maven/plugin/announcement/announcement.vm: -------------------------------------------------------------------------------- 1 | ## Licensed to the Apache Software Foundation (ASF) under one 2 | ## or more contributor license agreements. See the NOTICE file 3 | ## distributed with this work for additional information 4 | ## regarding copyright ownership. The ASF licenses this file 5 | ## to you under the Apache License, Version 2.0 (the 6 | ## "License"); you may not use this file except in compliance 7 | ## with the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, 12 | ## software distributed under the License is distributed on an 13 | ## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | ## KIND, either express or implied. See the License for the 15 | ## specific language governing permissions and limitations 16 | ## under the License. 17 | The ${developmentTeam} is pleased to announce the **${finalName}** release! 18 | 19 | # ${project.name} 20 | 21 | ${introduction} 22 | 23 |

Usage

24 | 25 | Add this library to you Maven project: 26 | 27 | ``` 28 | 29 | ${project.groupId} 30 | ${project.artifactId} 31 | ${project.version} 32 | 33 | ``` 34 | 35 | Or if you are using Gradle: 36 | 37 | ``` 38 | compile group: '${project.groupId}', name: '${project.artifactId}', version: '${project.version}' 39 | ``` 40 | 41 | Then basically just start elasticsearch within Docker from your java code: 42 | 43 | ```java 44 | ElasticsearchContainer container = new ElasticsearchContainer().withVersion("$announceParameters.elasticsearch"); 45 | container.configure(); 46 | container.start(); 47 | ``` 48 | 49 | More details in the [documentation](${project.url}). 50 | 51 | #if ($release.getActions().size() == 0) 52 | No changes defined in this version. 53 | #else 54 | 55 | #if ($release.getActions('add').size() !=0) 56 |

New features

57 | 58 | #foreach($actionItem in $release.getActions('add')) 59 | #set($action=$actionItem.getAction()) 60 | #if ($actionItem.getIssue()) 61 | #set($issue=$actionItem.getIssue()) 62 | #else 63 | #set($issue="") 64 | #end 65 | #if ($actionItem.getDueTo()) 66 | #set($dueto=$actionItem.getDueTo()) 67 | #else 68 | #set($dueto="") 69 | #end 70 | * [#$issue](${project.url}/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end 71 | 72 | #set($issue="") 73 | #set($dueto="") 74 | #end 75 | #end 76 | 77 | #if ($release.getActions('fix').size() !=0) 78 |

Fixed Bugs

79 | 80 | #foreach($actionItem in $release.getActions('fix')) 81 | #set($action=$actionItem.getAction()) 82 | #if ($actionItem.getIssue()) 83 | #set($issue=$actionItem.getIssue()) 84 | #else 85 | #set($issue="") 86 | #end 87 | #if ($actionItem.getDueTo()) 88 | #set($dueto=$actionItem.getDueTo()) 89 | #else 90 | #set($dueto="") 91 | #end 92 | * [#$issue](${project.url}/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end 93 | 94 | #set($issue="") 95 | #set($dueto="") 96 | #end 97 | #end 98 | 99 | #if ($release.getActions('update').size() !=0) 100 |

Changes

101 | 102 | #foreach($actionItem in $release.getActions('update')) 103 | #set($action=$actionItem.getAction()) 104 | #if ($actionItem.getIssue()) 105 | #set($issue=$actionItem.getIssue()) 106 | #else 107 | #set($issue="") 108 | #end 109 | #if ($actionItem.getDueTo()) 110 | #set($dueto=$actionItem.getDueTo()) 111 | #else 112 | #set($dueto="") 113 | #end 114 | * [#$issue](${project.url}/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end 115 | 116 | #set($issue="") 117 | #set($dueto="") 118 | #end 119 | #end 120 | 121 | #if ($release.getActions('remove').size() !=0) 122 |

Removed

123 | 124 | #foreach($actionItem in $release.getActions('remove')) 125 | #set($action=$actionItem.getAction()) 126 | #if ($actionItem.getIssue()) 127 | #set($issue=$actionItem.getIssue()) 128 | #else 129 | #set($issue="") 130 | #end 131 | #if ($actionItem.getDueTo()) 132 | #set($dueto=$actionItem.getDueTo()) 133 | #else 134 | #set($dueto="") 135 | #end 136 | * [#$issue](${project.url}/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end 137 | 138 | #set($issue="") 139 | #set($dueto="") 140 | #end 141 | #end 142 | ## End of main loop 143 | #end 144 | 145 | Have fun! 146 | -${developmentTeam} 147 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchContainerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import com.github.dockerjava.api.exception.DockerClientException; 24 | import org.apache.http.auth.AuthScope; 25 | import org.apache.http.auth.UsernamePasswordCredentials; 26 | import org.apache.http.client.CredentialsProvider; 27 | import org.apache.http.impl.client.BasicCredentialsProvider; 28 | import org.apache.http.util.EntityUtils; 29 | import org.elasticsearch.client.Response; 30 | import org.elasticsearch.client.RestClient; 31 | import org.junit.After; 32 | import org.junit.Test; 33 | import org.testcontainers.containers.ContainerFetchException; 34 | 35 | import java.io.IOException; 36 | import java.nio.file.Paths; 37 | import java.util.Properties; 38 | 39 | import static fr.pilato.elasticsearch.containers.ElasticsearchContainer.ELASTICSEARCH_DEFAULT_BASE_URL; 40 | import static fr.pilato.elasticsearch.containers.ElasticsearchContainer.ELASTICSEARCH_DEFAULT_VERSION; 41 | import static org.hamcrest.CoreMatchers.containsString; 42 | import static org.hamcrest.CoreMatchers.instanceOf; 43 | import static org.hamcrest.CoreMatchers.is; 44 | import static org.hamcrest.MatcherAssert.assertThat; 45 | import static org.junit.Assume.assumeTrue; 46 | 47 | public class ElasticsearchContainerTest { 48 | 49 | private ElasticsearchContainer container = null; 50 | private RestClient client = null; 51 | 52 | @After 53 | public void stopRestClient() throws IOException { 54 | if (client != null) { 55 | client.close(); 56 | } 57 | } 58 | 59 | @After 60 | public void stopContainer() { 61 | if (container != null) { 62 | container.stop(); 63 | } 64 | } 65 | 66 | @Test 67 | public void elasticsearchNoVersionTest() throws IOException { 68 | container = new ElasticsearchContainer(); 69 | container.withEnv("ELASTIC_PASSWORD", "changeme"); 70 | container.start(); 71 | Response response = getClient(container).performRequest("GET", "/"); 72 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 73 | } 74 | 75 | @Test 76 | public void elasticsearchDefaultTest() throws IOException { 77 | container = new ElasticsearchContainer(); 78 | container.withVersion(ELASTICSEARCH_DEFAULT_VERSION); 79 | container.withEnv("ELASTIC_PASSWORD", "changeme"); 80 | container.start(); 81 | Response response = getClient(container).performRequest("GET", "/"); 82 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 83 | } 84 | 85 | @Test 86 | public void elasticsearchFullTest() throws IOException { 87 | container = new ElasticsearchContainer(); 88 | container.withVersion(ELASTICSEARCH_DEFAULT_VERSION); 89 | container.withBaseUrl(ELASTICSEARCH_DEFAULT_BASE_URL); 90 | 91 | // We need to read where we exactly put the files 92 | Properties props = new Properties(); 93 | try { 94 | props.load(ElasticsearchResource.class.getResourceAsStream("elasticsearch-plugins-dir.properties")); 95 | String pluginDir = props.getProperty("pluginDir"); 96 | container.withPluginDir(Paths.get(pluginDir)); 97 | } catch (IOException ignored) { 98 | // This can normally never happen unless someone modifies the test resources dir o_O 99 | } 100 | 101 | container.withEnv("ELASTIC_PASSWORD", "changeme"); 102 | 103 | container.start(); 104 | 105 | Response response = getClient(container).performRequest("GET", "/"); 106 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 107 | 108 | response = getClient(container).performRequest("GET", "/_cat/plugins"); 109 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 110 | String responseAsString = EntityUtils.toString(response.getEntity()); 111 | assertThat(responseAsString, containsString("ingest-attachment")); 112 | } 113 | 114 | @Test 115 | public void elasticsearchWithPlugin() throws IOException { 116 | // This test might fail if no internet connection is available 117 | // As elasticsearch-plugin would download files from internet 118 | // In which case, we should just ignore the test 119 | 120 | container = new ElasticsearchContainer(); 121 | container.withVersion(ELASTICSEARCH_DEFAULT_VERSION); 122 | container.withPlugin("discovery-gce"); 123 | container.withEnv("ELASTIC_PASSWORD", "changeme"); 124 | 125 | try { 126 | container.start(); 127 | Response response = getClient(container).performRequest("GET", "/"); 128 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 129 | 130 | response = getClient(container).performRequest("GET", "/_cat/plugins"); 131 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 132 | String responseAsString = EntityUtils.toString(response.getEntity()); 133 | assertThat(responseAsString, containsString("discovery-gce")); 134 | } catch (ContainerFetchException exception) { 135 | assertThat(exception.getCause(), instanceOf(DockerClientException.class)); 136 | assertThat(exception.getCause().getMessage(), containsString("The command '/bin/sh -c bin/elasticsearch-plugin install discovery-gce' returned a non-zero code: 1")); 137 | assumeTrue("We can't test this if internet is not available because we can't download elasticsearch plugins.", false); 138 | } 139 | } 140 | 141 | private RestClient getClient(ElasticsearchContainer container) { 142 | if (client == null) { 143 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 144 | credentialsProvider.setCredentials(AuthScope.ANY, 145 | new UsernamePasswordCredentials("elastic", "changeme")); 146 | 147 | client = RestClient.builder(container.getHost()) 148 | .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)) 149 | .build(); 150 | } 151 | 152 | return client; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceBaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.apache.http.auth.AuthScope; 24 | import org.apache.http.auth.UsernamePasswordCredentials; 25 | import org.apache.http.client.CredentialsProvider; 26 | import org.apache.http.impl.client.BasicCredentialsProvider; 27 | import org.elasticsearch.client.Response; 28 | import org.elasticsearch.client.RestClient; 29 | import org.junit.After; 30 | import org.junit.Before; 31 | import org.junit.Test; 32 | 33 | import java.io.IOException; 34 | 35 | import static org.hamcrest.CoreMatchers.is; 36 | import static org.hamcrest.MatcherAssert.assertThat; 37 | 38 | public abstract class ElasticsearchResourceBaseTest { 39 | 40 | abstract ElasticsearchResource getElasticsearchResource(); 41 | 42 | RestClient restClient = null; 43 | 44 | @Before 45 | public void createRestClient() { 46 | if (restClient == null) { 47 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 48 | credentialsProvider.setCredentials(AuthScope.ANY, 49 | new UsernamePasswordCredentials("elastic", getElasticsearchResource().getPassword())); 50 | 51 | restClient = RestClient.builder(getElasticsearchResource().getHost()) 52 | .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)) 53 | .build(); 54 | } 55 | } 56 | 57 | @After 58 | public void stopRestClient() throws IOException { 59 | if (restClient != null) { 60 | restClient.close(); 61 | } 62 | } 63 | 64 | @Test 65 | public void elasticsearchTest() throws IOException { 66 | Response response = restClient.performRequest("GET", "/"); 67 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceContructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.junit.Ignore; 24 | 25 | import java.nio.file.Paths; 26 | import java.util.Collections; 27 | 28 | /** 29 | * We just use this class to help for documenting the project. 30 | * We disable the test (well, it's not a test technically speaking) 31 | */ 32 | @Ignore 33 | public class ElasticsearchResourceContructorTest { 34 | 35 | // We don't annotate it as a Rule as we just want to have it here for documentation 36 | public ElasticsearchResource elasticsearch = new ElasticsearchResource( 37 | "docker.elastic.co/elasticsearch/elasticsearch", // baseUrl (can be null) 38 | "6.3.0", // version (can be null) 39 | Paths.get("/path/to/zipped-plugins-dir"), // pluginsDir (can be null) 40 | Collections.singletonList("ingest-attachment"), // standard plugins (can be empty) 41 | Collections.singletonMap("foo", "bar"), // Map of secured settings (can be empty) 42 | "changeme"); // X-Pack security password to set (can be null) 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceDefaultsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.junit.ClassRule; 24 | 25 | public class ElasticsearchResourceDefaultsTest extends ElasticsearchResourceBaseTest { 26 | @ClassRule 27 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource(); 28 | 29 | @Override 30 | ElasticsearchResource getElasticsearchResource() { 31 | return elasticsearch; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceWithOssImageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.apache.http.util.EntityUtils; 24 | import org.elasticsearch.client.Response; 25 | import org.junit.ClassRule; 26 | import org.junit.Test; 27 | 28 | import java.io.IOException; 29 | 30 | import static org.hamcrest.CoreMatchers.containsString; 31 | import static org.hamcrest.CoreMatchers.is; 32 | import static org.hamcrest.CoreMatchers.not; 33 | import static org.hamcrest.MatcherAssert.assertThat; 34 | 35 | public class ElasticsearchResourceWithOssImageTest extends ElasticsearchResourceBaseTest { 36 | @ClassRule 37 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource("elasticsearch-oss-image.properties"); 38 | 39 | @Override 40 | ElasticsearchResource getElasticsearchResource() { 41 | return elasticsearch; 42 | } 43 | 44 | @Test 45 | public void testXPackIsNotHere() throws IOException { 46 | Response response = restClient.performRequest("GET", "/_cat/plugins"); 47 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 48 | String responseAsString = EntityUtils.toString(response.getEntity()); 49 | assertThat(responseAsString, not(containsString("x-pack"))); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceWithPluginsAndPluginsDirTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.apache.http.util.EntityUtils; 24 | import org.elasticsearch.client.Response; 25 | import org.junit.BeforeClass; 26 | import org.junit.ClassRule; 27 | import org.junit.Test; 28 | import org.junit.rules.ExternalResource; 29 | 30 | import java.io.IOException; 31 | 32 | import static org.hamcrest.CoreMatchers.containsString; 33 | import static org.hamcrest.CoreMatchers.is; 34 | import static org.hamcrest.MatcherAssert.assertThat; 35 | import static org.junit.Assume.assumeTrue; 36 | 37 | /** 38 | * Note that this class requires internet to run as it will try to download an elasticsearch plugin 39 | */ 40 | public class ElasticsearchResourceWithPluginsAndPluginsDirTest extends ElasticsearchResourceBaseTest { 41 | 42 | @ClassRule 43 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource("elasticsearch-plugins-and-plugins-dir.properties"); 44 | 45 | @Override 46 | ElasticsearchResource getElasticsearchResource() { 47 | return elasticsearch; 48 | } 49 | 50 | @Test 51 | public void testPluginsAreInstalled() { 52 | String list = executeCommandInDocker("bin/elasticsearch-plugin", "list"); 53 | assertThat(list, containsString("ingest-attachment")); 54 | assertThat(list, containsString("discovery-gce")); 55 | } 56 | 57 | @Test 58 | public void testPluginsAreLoaded() throws IOException { 59 | Response response = restClient.performRequest("GET", "/_cat/plugins"); 60 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 61 | String responseAsString = EntityUtils.toString(response.getEntity()); 62 | assertThat(responseAsString, containsString("ingest-attachment")); 63 | assertThat(responseAsString, containsString("discovery-gce")); 64 | } 65 | 66 | private String executeCommandInDocker(String... params) { 67 | try { 68 | return elasticsearch.getContainer().execInContainer(params).getStdout(); 69 | } catch (IOException | InterruptedException e) { 70 | throw new RuntimeException(e); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceWithPluginsDirAndVersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.apache.http.util.EntityUtils; 24 | import org.elasticsearch.client.Response; 25 | import org.junit.ClassRule; 26 | import org.junit.Test; 27 | 28 | import java.io.IOException; 29 | 30 | import static org.hamcrest.CoreMatchers.containsString; 31 | import static org.hamcrest.CoreMatchers.is; 32 | import static org.hamcrest.MatcherAssert.assertThat; 33 | 34 | public class ElasticsearchResourceWithPluginsDirAndVersionTest extends ElasticsearchResourceBaseTest { 35 | @ClassRule 36 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource("elasticsearch-plugins-dir-version.properties"); 37 | 38 | @Override 39 | ElasticsearchResource getElasticsearchResource() { 40 | return elasticsearch; 41 | } 42 | 43 | @Test 44 | public void testPluginsAreInstalled() { 45 | String list = executeCommandInDocker("bin/elasticsearch-plugin", "list"); 46 | assertThat(list, containsString("ingest-attachment")); 47 | } 48 | 49 | @Test 50 | public void testPluginsAreLoaded() throws IOException { 51 | Response response = restClient.performRequest("GET", "/_cat/plugins"); 52 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 53 | String responseAsString = EntityUtils.toString(response.getEntity()); 54 | assertThat(responseAsString, containsString("ingest-attachment")); 55 | } 56 | 57 | private String executeCommandInDocker(String... params) { 58 | try { 59 | return elasticsearch.getContainer().execInContainer(params).getStdout(); 60 | } catch (IOException | InterruptedException e) { 61 | throw new RuntimeException(e); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceWithPluginsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.apache.http.util.EntityUtils; 24 | import org.elasticsearch.client.Response; 25 | import org.junit.ClassRule; 26 | import org.junit.Test; 27 | 28 | import java.io.IOException; 29 | 30 | import static org.hamcrest.CoreMatchers.containsString; 31 | import static org.hamcrest.CoreMatchers.is; 32 | import static org.hamcrest.MatcherAssert.assertThat; 33 | 34 | /** 35 | * Note that this class requires internet to run as it will try to download an elasticsearch plugin 36 | */ 37 | public class ElasticsearchResourceWithPluginsTest extends ElasticsearchResourceBaseTest { 38 | @ClassRule 39 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource("elasticsearch-plugins.properties"); 40 | 41 | @Override 42 | ElasticsearchResource getElasticsearchResource() { 43 | return elasticsearch; 44 | } 45 | 46 | @Test 47 | public void testPluginsAreInstalled() { 48 | String list = executeCommandInDocker("bin/elasticsearch-plugin", "list"); 49 | assertThat(list, containsString("ingest-attachment")); 50 | assertThat(list, containsString("discovery-gce")); 51 | } 52 | 53 | @Test 54 | public void testPluginsAreLoaded() throws IOException { 55 | Response response = restClient.performRequest("GET", "/_cat/plugins"); 56 | assertThat(response.getStatusLine().getStatusCode(), is(200)); 57 | String responseAsString = EntityUtils.toString(response.getEntity()); 58 | assertThat(responseAsString, containsString("ingest-attachment")); 59 | assertThat(responseAsString, containsString("discovery-gce")); 60 | } 61 | 62 | private String executeCommandInDocker(String... params) { 63 | try { 64 | return elasticsearch.getContainer().execInContainer(params).getStdout(); 65 | } catch (IOException | InterruptedException e) { 66 | throw new RuntimeException(e); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/fr/pilato/elasticsearch/containers/ElasticsearchResourceWithVersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to David Pilato (the "Author") under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. Author licenses this 6 | * file to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package fr.pilato.elasticsearch.containers; 21 | 22 | 23 | import org.junit.ClassRule; 24 | 25 | public class ElasticsearchResourceWithVersionTest extends ElasticsearchResourceBaseTest { 26 | @ClassRule 27 | public static ElasticsearchResource elasticsearch = new ElasticsearchResource("elasticsearch-version.properties"); 28 | 29 | @Override 30 | ElasticsearchResource getElasticsearchResource() { 31 | return elasticsearch; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-oss-image.properties: -------------------------------------------------------------------------------- 1 | baseUrl=docker.elastic.co/elasticsearch/elasticsearch-oss 2 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-plugins-and-plugins-dir.properties: -------------------------------------------------------------------------------- 1 | plugins=discovery-gce 2 | pluginDir=${plugin.dir}/${elasticsearch.version} 3 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-plugins-dir-version.properties: -------------------------------------------------------------------------------- 1 | version=${elasticsearch.version.old} 2 | pluginDir=${plugin.dir}/${elasticsearch.version.old} 3 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-plugins-dir.properties: -------------------------------------------------------------------------------- 1 | pluginDir=${plugin.dir}/${elasticsearch.version} 2 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-plugins.properties: -------------------------------------------------------------------------------- 1 | plugins=ingest-attachment,discovery-gce 2 | -------------------------------------------------------------------------------- /src/test/resources/fr/pilato/elasticsearch/containers/elasticsearch-version.properties: -------------------------------------------------------------------------------- 1 | version=${elasticsearch.version.old} 2 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{HH:mm:ss.SSS} %-5level %logger - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | PROFILER 28 | DENY 29 | 30 | 31 | --------------------------------------------------------------------------------