diff --git a/dd-java-agent/instrumentation/elasticsearch-rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy index d90d499267..a61bdd6b68 100644 --- a/dd-java-agent/instrumentation/elasticsearch-rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy @@ -22,33 +22,36 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() + @Shared + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared - static Node testNode - static File esWorkingDir - - @Shared - static RestClient client + RestClient client def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put("cluster.name", "test-cluster") .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() - client = RestClient.builder(new HttpHost("localhost", HTTP_PORT)) + client = RestClient.builder(new HttpHost("localhost", httpPort)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -107,7 +110,7 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { "$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_URL.key" "_cluster/health" "$Tags.PEER_HOSTNAME.key" "localhost" - "$Tags.PEER_PORT.key" HTTP_PORT + "$Tags.PEER_PORT.key" httpPort defaultTags() } } diff --git a/dd-java-agent/instrumentation/elasticsearch-rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy index 85bfee5ab2..c36dfd7e12 100644 --- a/dd-java-agent/instrumentation/elasticsearch-rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy @@ -24,27 +24,30 @@ class Elasticsearch5RestClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() - @Shared - static Node testNode - static File esWorkingDir + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared static RestClient client def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") @@ -52,7 +55,7 @@ class Elasticsearch5RestClientTest extends AgentTestRunner { testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() - client = RestClient.builder(new HttpHost("localhost", HTTP_PORT)) + client = RestClient.builder(new HttpHost("localhost", httpPort)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -95,7 +98,7 @@ class Elasticsearch5RestClientTest extends AgentTestRunner { "$Tags.HTTP_METHOD.key" "GET" "$Tags.HTTP_URL.key" "_cluster/health" "$Tags.PEER_HOSTNAME.key" "localhost" - "$Tags.PEER_PORT.key" HTTP_PORT + "$Tags.PEER_PORT.key" httpPort defaultTags() } } diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2NodeClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2NodeClientTest.groovy index 0caf378397..fb2b1406fb 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2NodeClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2NodeClientTest.groovy @@ -16,19 +16,22 @@ class Elasticsearch2NodeClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() - @Shared - static Node testNode - static File esWorkingDir + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir def client = testNode.client() def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" @@ -36,8 +39,8 @@ class Elasticsearch2NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .build() testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() testNode.start() diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2SpringTemplateTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2SpringTemplateTest.groovy index 013b15d4b9..bcec92ef99 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2SpringTemplateTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2SpringTemplateTest.groovy @@ -26,20 +26,23 @@ class Elasticsearch2SpringTemplateTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() + @Shared + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared - static Node testNode - static File esWorkingDir - - @Shared - static ElasticsearchTemplate template + ElasticsearchTemplate template def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" @@ -47,8 +50,8 @@ class Elasticsearch2SpringTemplateTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .build() testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() testNode.start() diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2TransportClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2TransportClientTest.groovy index 6efc693997..7b3d17fa99 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2TransportClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-2/src/test/groovy/Elasticsearch2TransportClientTest.groovy @@ -19,27 +19,30 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() + @Shared + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared - static Node testNode - static File esWorkingDir - - @Shared - static TransportClient client + TransportClient client def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .build() testNode = NodeBuilder.newInstance().clusterName("test-cluster").settings(settings).build() testNode.start() @@ -51,7 +54,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { .put("cluster.name", "test-cluster") .build() ).build() - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), TCP_PORT)) + client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) TEST_WRITER.clear() client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(5000) TEST_WRITER.waitForTraces(1) @@ -87,7 +90,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" defaultTags() @@ -185,7 +188,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "elasticsearch.request.indices" indexName "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort defaultTags() } } @@ -203,7 +206,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "elasticsearch.request" "ClusterHealthRequest" "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort defaultTags() } } @@ -219,7 +222,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName @@ -257,7 +260,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" "elasticsearch.request.indices" indexName @@ -277,7 +280,7 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5NodeClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5NodeClientTest.groovy index 7f61c662b8..ca7d7437d5 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5NodeClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5NodeClientTest.groovy @@ -19,19 +19,22 @@ class Elasticsearch5NodeClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() - @Shared - static Node testNode - static File esWorkingDir + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir def client = testNode.client() def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" @@ -39,8 +42,8 @@ class Elasticsearch5NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5TransportClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5TransportClientTest.groovy index 68f64e51c5..28fe33d7de 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5TransportClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-5/src/test/groovy/Elasticsearch5TransportClientTest.groovy @@ -23,27 +23,30 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() + @Shared + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared - static Node testNode - static File esWorkingDir - - @Shared - static TransportClient client + TransportClient client def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") @@ -58,7 +61,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") .build() ) - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), TCP_PORT)) + client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) TEST_WRITER.clear() client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(5000) TEST_WRITER.waitForTraces(1) @@ -94,7 +97,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" defaultTags() @@ -192,7 +195,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { "elasticsearch.request.indices" indexName "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort defaultTags() } } @@ -208,7 +211,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName @@ -245,7 +248,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" "elasticsearch.request.indices" indexName @@ -270,7 +273,7 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "127.0.0.1" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6NodeClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6NodeClientTest.groovy index b2d96f4680..1c86fff1c4 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6NodeClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6NodeClientTest.groovy @@ -18,19 +18,22 @@ class Elasticsearch6NodeClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() - @Shared - static Node testNode - static File esWorkingDir + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir def client = testNode.client() def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" @@ -38,8 +41,8 @@ class Elasticsearch6NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) diff --git a/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6TransportClientTest.groovy b/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6TransportClientTest.groovy index c0e595b6bb..b2f18b95dc 100644 --- a/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6TransportClientTest.groovy +++ b/dd-java-agent/instrumentation/elasticsearch-transport-6/src/test/groovy/Elasticsearch6TransportClientTest.groovy @@ -22,27 +22,30 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { System.setProperty("dd.integration.elasticsearch.enabled", "true") } - static final int HTTP_PORT = TestUtils.randomOpenPort() - static final int TCP_PORT = TestUtils.randomOpenPort() + @Shared + int httpPort + @Shared + int tcpPort + @Shared + Node testNode + @Shared + File esWorkingDir @Shared - static Node testNode - static File esWorkingDir - - @Shared - static TransportClient client + TransportClient client def setupSpec() { - esWorkingDir = File.createTempFile("test-es-working-dir-", "") - esWorkingDir.delete() - esWorkingDir.mkdir() + httpPort = TestUtils.randomOpenPort() + tcpPort = TestUtils.randomOpenPort() + + esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", HTTP_PORT) - .put("transport.tcp.port", TCP_PORT) + .put("http.port", httpPort) + .put("transport.tcp.port", tcpPort) .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) @@ -55,7 +58,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") .build() ) - client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), TCP_PORT)) + client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), tcpPort)) TEST_WRITER.clear() client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(5000) TEST_WRITER.waitForTraces(1) @@ -90,7 +93,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" defaultTags() @@ -185,7 +188,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" "elasticsearch.request.indices" indexName @@ -204,7 +207,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName @@ -241,7 +244,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" "elasticsearch.request.indices" indexName @@ -267,7 +270,7 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT "$Tags.PEER_HOSTNAME.key" "localhost" "$Tags.PEER_HOST_IPV4.key" "127.0.0.1" - "$Tags.PEER_PORT.key" TCP_PORT + "$Tags.PEER_PORT.key" tcpPort "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" "elasticsearch.request.indices" indexName