# "codebase property already set" when running ESIntegTestCase

**URL:** <https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659>\
**Category:** Elasticsearch\
**Created:** [June 13, 2018, 9:11am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659 "2018-06-13T09:11:41Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 14, 2018, 11:28am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/21 "2018-06-14T11:28:30Z")

</div>

The docker container shuts down when the test exits. Any suggestions on how? The REST client works. Just not the transport client...

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2018, 11:39am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/22 "2018-06-14T11:39:29Z")

</div>

Add a breakpoint in your tests or a sleep that takes enough time for you to run docker ps and logs.

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 14, 2018, 12:08pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/23 "2018-06-14T12:08:24Z")

</div>

Oh yeah 🤦‍♀️

```auto
[2018-06-14T12:06:39,807][INFO][o.e.n.Node] [] initializing ...
[2018-06-14T12:06:39,902][INFO][o.e.e.NodeEnvironment] [zXCixBy] using [1] data paths, mounts [[/ (overlay)]], net usable_space [57.8gb], net total_space [62.7gb], types [overlay]
[2018-06-14T12:06:39,903][INFO][o.e.e.NodeEnvironment] [zXCixBy] heap size [1007.3mb], compressed ordinary object pointers [true]
[2018-06-14T12:06:39,905][INFO][o.e.n.Node] node name [zXCixBy] derived from node ID [zXCixByNTHSbNB09Bx5L-A]; set [node.name] to override
[2018-06-14T12:06:39,905][INFO][o.e.n.Node] version[6.2.4], pid[1], build[ccec39f/2018-04-12T20:37:28.497551Z], OS[Linux/4.9.87-linuxkit-aufs/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_161/25.161-b14]
[2018-06-14T12:06:39,905][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, -Djava.io.tmpdir=/tmp/elasticsearch.x74V4bHC, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config]
[2018-06-14T12:06:43,490][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [aggs-matrix-stats]
[2018-06-14T12:06:43,490][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [analysis-common]
[2018-06-14T12:06:43,490][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [ingest-common]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [lang-expression]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [lang-mustache]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [lang-painless]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [mapper-extras]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [parent-join]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [percolator]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [rank-eval]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [reindex]
[2018-06-14T12:06:43,491][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [repository-url]
[2018-06-14T12:06:43,492][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [transport-netty4]
[2018-06-14T12:06:43,492][INFO][o.e.p.PluginsService] [zXCixBy] loaded module [tribe]
[2018-06-14T12:06:43,492][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [ingest-geoip]
[2018-06-14T12:06:43,492][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [ingest-user-agent]
[2018-06-14T12:06:43,492][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-core]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-deprecation]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-graph]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-logstash]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-ml]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-monitoring]
[2018-06-14T12:06:43,493][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-security]
[2018-06-14T12:06:43,494][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-upgrade]
[2018-06-14T12:06:43,494][INFO][o.e.p.PluginsService] [zXCixBy] loaded plugin [x-pack-watcher]
[2018-06-14T12:06:50,083][INFO][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/204] [Main.cc@128] controller (64 bit): Version 6.2.4 (Build 524e7fe231abc1) Copyright (c) 2018 Elasticsearch BV
[2018-06-14T12:06:52,790][INFO][o.e.d.DiscoveryModule] [zXCixBy] using discovery type [zen]
[2018-06-14T12:06:54,928][INFO][o.e.n.Node] initialized
[2018-06-14T12:06:54,929][INFO][o.e.n.Node] [zXCixBy] starting ...
[2018-06-14T12:06:55,257][INFO][o.e.t.TransportService] [zXCixBy] publish_address {172.17.0.3:9300}, bound_addresses {0.0.0.0:9300}
[2018-06-14T12:06:55,291][INFO][o.e.b.BootstrapChecks] [zXCixBy] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2018-06-14T12:06:58,368][INFO][o.e.c.s.MasterService] [zXCixBy] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {zXCixBy}{zXCixByNTHSbNB09Bx5L-A}{rZ-BGNgCQ6-KX2Bfu3epdg}{172.17.0.3}{172.17.0.3:9300}{ml.machine_memory=2096066560, ml.max_open_jobs=20, ml.enabled=true}
[2018-06-14T12:06:58,379][INFO][o.e.c.s.ClusterApplierService] [zXCixBy] new_master {zXCixBy}{zXCixByNTHSbNB09Bx5L-A}{rZ-BGNgCQ6-KX2Bfu3epdg}{172.17.0.3}{172.17.0.3:9300}{ml.machine_memory=2096066560, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {zXCixBy}{zXCixByNTHSbNB09Bx5L-A}{rZ-BGNgCQ6-KX2Bfu3epdg}{172.17.0.3}{172.17.0.3:9300}{ml.machine_memory=2096066560, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-06-14T12:06:58,436][INFO][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [zXCixBy] publish_address {172.17.0.3:9200}, bound_addresses {0.0.0.0:9200}
[2018-06-14T12:06:58,436][INFO][o.e.n.Node] [zXCixBy] started
[2018-06-14T12:06:58,514][INFO][o.e.g.GatewayService] [zXCixBy] recovered [0] indices into cluster_state
[2018-06-14T12:06:59,617][INFO][o.e.l.LicenseService] [zXCixBy] license [25bb1a8c-40c7-4278-aafc-a867b5454666] mode [basic] - valid
[2018-06-14T12:07:05,751][INFO][o.e.c.m.MetaDataCreateIndexService] [zXCixBy] [.monitoring-es-6-2018.06.14] creating index, cause [auto(bulk api)], templates [.monitoring-es], shards [1]/[0], mappings [doc]
[2018-06-14T12:07:06,767][INFO][o.e.c.r.a.AllocationService] [zXCixBy] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.monitoring-es-6-2018.06.14][0]] ...]).

```

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 14, 2018, 12:13pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/24 "2018-06-14T12:13:26Z")

</div>

It's ok. I've figured it out 🤦🏼‍♂️🤦🏼‍♂️🤦🏼‍♂️🤦🏼‍♂️🤦🏼‍♂️🤦🏼‍♂️🤦🏼‍♂️

I'll get my coat.

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 14, 2018, 12:14pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/25 "2018-06-14T12:14:10Z")

</div>

PS: Thanks for all your help. This is totally the best way to do it, and way better than what we were previously doing with the embedded node. 👍

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2018, 12:21pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/26 "2018-06-14T12:21:15Z")

</div>

For the record, could you share your findings here? That could help other readers.

> This is totally the best way to do it, and way better than what we were previously doing with the embedded node.

I'm glad you are agreeing on that!

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 14, 2018, 12:40pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/27 "2018-06-14T12:40:06Z")

</div>

Sure, my problem was that I was expecting the ES cluster to be called `elasticsearch`, when actually the dockerised cluster is called: `docker-cluster`.

If you specify the wrong cluster name in your TransportClient connection settings, it won't connect. If you need to confirm it, just `curl -XGET localhost:[REST PORT]` and see what the `cluster_name` property is.

TBH, I'm just glad I can still integration test my stuff without having to manage an integration-testing ES cluster myself as well. 👍

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2018, 3:23pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/28 "2018-06-14T15:23:42Z")

</div>

Great! I added some documentation based on that. Thanks!

> <https://github.com/dadoonet/testcontainers-java-module-elasticsearch/pull/29>

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 15, 2018, 8:50am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/29 "2018-06-15T08:50:03Z")

</div>

Is there currently a way to tell the container which port to map to? One of my tests checks that a reconnection is made if lost at any point.

I'm currently testing this by stopping and starting the container, but when it comes back up again, the ports have all changed. In reality that wouldn't happen.

Any ideas?

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 15, 2018, 9:22am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/30 "2018-06-15T09:22:25Z")

</div>

Also, if I do `elasticsearch.getContainer().stop()` and `elasticsearch.getContainer().start()` inside a test, this happens when the test exits:

```auto
[dockerjava-netty-1-5] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.NotFoundException: {"message":"No such container: 5cd80164de9986021cc59442425380afc2eab9b7efc669c9841674ca0dc02d23"}

```

I'm assuming when the `@Rule` `ElasticsearchResource` is torn down it assumes that the reference to the container it obtained when starting up is still the same...?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 15, 2018, 11:26am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/31 "2018-06-15T11:26:08Z")

</div>

I believe you'd like to have that?

> <https://github.com/dadoonet/testcontainers-java-module-elasticsearch/issues/22>

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 15, 2018, 11:27am UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/32 "2018-06-15T11:27:51Z")

</div>

In that case I'd not use `@Rule` annotation but control all that manually.

Like what I did here:

> <https://github.com/dadoonet/elasticsearch-integration-tests/blob/05-cloud/src/test/java/fr/pilato/talk/elasticsearch/tests/integration/ElasticsearchIT.java#L85-L93>

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [June 15, 2018, 12:08pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/33 "2018-06-15T12:08:26Z")

</div>

Yes! (also for Transport port, obviously 😉 )

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 13, 2018, 12:08pm UTC](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659/34 "2018-07-13T12:08:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

[Previous page](https://discuss.elastic.co/t/codebase-property-already-set-when-running-esintegtestcase/135659.md?page=1)
