From bab9ccebf488809a40014512576bbacd8c01fd66 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 25 Oct 2023 16:21:13 +0200 Subject: [PATCH] Update tests for Jedis 5 (#3382) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../apm-jedis-4-plugin/pom.xml | 14 +++++ .../agent/jedis/Jedis4InstrumentationIT.java | 6 ++- .../apm-jedis-5-tests/pom.xml | 54 +++++++++++++++++++ .../java/jedis/Jedis5InstrumentationIT.java | 34 ++++++++++++ .../agent/jedis/Jedis1InstrumentationIT.java | 4 ++ apm-agent-plugins/apm-redis-plugin/pom.xml | 1 + docs/supported-technologies.asciidoc | 4 +- 7 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml create mode 100644 apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/src/test/java/jedis/Jedis5InstrumentationIT.java diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml index b079d966ed..b9502d7152 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml @@ -44,4 +44,18 @@ + + + + maven-jar-plugin + + + + test-jar + + + + + + diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis4InstrumentationIT.java b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis4InstrumentationIT.java index db867f3636..7fb48eb2b4 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis4InstrumentationIT.java +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis4InstrumentationIT.java @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class Jedis4InstrumentationIT extends Jedis1InstrumentationIT { +public class Jedis4InstrumentationIT extends Jedis1InstrumentationIT { private JedisSharding shardedJedis; private UnifiedJedis binaryJedis; @@ -50,6 +50,10 @@ void testShardedJedis() { shardedJedis.set("foo", "bar"); assertThat(shardedJedis.get("foo".getBytes())).isEqualTo("bar".getBytes()); + verifyShardedJedisSpan(); + } + + protected void verifyShardedJedisSpan() { assertTransactionWithRedisSpans("CLIENT", "CLIENT", "SET", "GET"); } diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml new file mode 100644 index 0000000000..80c85d75e9 --- /dev/null +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + + apm-redis-plugin + co.elastic.apm + 1.43.1-SNAPSHOT + + + apm-jedis-5-tests + ${project.groupId}:${project.artifactId} + + + ${project.basedir}/../../.. + + + + + ${project.groupId} + apm-redis-common + test-jar + ${project.version} + test + + + ${project.groupId} + apm-jedis-plugin + test-jar + ${project.version} + test + + + ${project.groupId} + apm-jedis-4-plugin + ${project.version} + test + + + ${project.groupId} + apm-jedis-4-plugin + test-jar + ${project.version} + test + + + redis.clients + jedis + 5.0.2 + test + + + + diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/src/test/java/jedis/Jedis5InstrumentationIT.java b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/src/test/java/jedis/Jedis5InstrumentationIT.java new file mode 100644 index 0000000000..dc5ba27cb3 --- /dev/null +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/src/test/java/jedis/Jedis5InstrumentationIT.java @@ -0,0 +1,34 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package jedis; + +import co.elastic.apm.agent.jedis.Jedis4InstrumentationIT; + +public class Jedis5InstrumentationIT extends Jedis4InstrumentationIT { + + @Override + protected void verifyShardedJedisSpan() { + assertTransactionWithRedisSpans("CLIENT", "CLIENT", "CLIENT", "CLIENT", "SET", "GET"); + } + + @Override + protected void verifyBasicJedisSpans() { + assertTransactionWithRedisSpans( "CLIENT", "CLIENT", "SET", "GET"); + } +} diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis1InstrumentationIT.java b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis1InstrumentationIT.java index 14c7b03f3e..6b50bfb29b 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis1InstrumentationIT.java +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/test/java/co/elastic/apm/agent/jedis/Jedis1InstrumentationIT.java @@ -55,6 +55,10 @@ void testJedis() { jedis.set("foo", "bar"); assertThat(jedis.get("foo".getBytes())).isEqualTo("bar".getBytes()); + verifyBasicJedisSpans(); + } + + protected void verifyBasicJedisSpans() { assertTransactionWithRedisSpans("SET", "GET"); } diff --git a/apm-agent-plugins/apm-redis-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/pom.xml index cda530e82c..a61351f2f7 100644 --- a/apm-agent-plugins/apm-redis-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/pom.xml @@ -20,6 +20,7 @@ apm-jedis-2-tests apm-jedis-3-tests apm-jedis-4-plugin + apm-jedis-5-tests apm-jedis-plugin apm-lettuce-3-tests apm-lettuce-plugin diff --git a/docs/supported-technologies.asciidoc b/docs/supported-technologies.asciidoc index 06c35e2260..b95f660781 100644 --- a/docs/supported-technologies.asciidoc +++ b/docs/supported-technologies.asciidoc @@ -254,9 +254,9 @@ Other Servlet 3+ compliant servers will most likely work as well. |1.9.0 |Redis Jedis -|1.4.0-4.x +|1.4.0-5.x |The agent creates spans for interactions with the Jedis client. -|1.10.0, 4.x since 1.31.0 +|1.10.0, 4+ since 1.31.0 |Redis Lettuce |3.4+