Replace embedded Redis server with testcontainers in tests (#3011)

* Replace embedded Redis server with testcontainers in tests

* Update instrumentation/lettuce/lettuce-5.0/javaagent/src/test/groovy/LettuceReactiveClientTest.groovy

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
Nikita Salnikov-Tarnovski 2021-05-17 09:57:13 +03:00 committed by GitHub
parent bcfd6b4d67
commit 3ecce72298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 77 additions and 174 deletions

View File

@ -12,8 +12,6 @@ muzzle {
dependencies {
library "redis.clients:jedis:1.4.0"
testImplementation "com.github.kstyrc:embedded-redis:0.6"
// Jedis 3.0 has API changes that prevent instrumentation from applying
latestDepTestLibrary "redis.clients:jedis:2.+"
}

View File

@ -6,30 +6,25 @@
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.testcontainers.containers.GenericContainer
import redis.clients.jedis.Jedis
import redis.embedded.RedisServer
import spock.lang.Shared
class JedisClientTest extends AgentInstrumentationSpecification {
@Shared
int port = PortUtils.findOpenPort()
private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379)
@Shared
RedisServer redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind 127.0.0.1")
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
int port
@Shared
Jedis jedis = new Jedis("localhost", port)
Jedis jedis
def setupSpec() {
println "Using redis: $redisServer.args"
redisServer.start()
port = redisServer.getMappedPort(6379)
jedis = new Jedis("localhost", port)
}
def cleanupSpec() {

View File

@ -17,7 +17,6 @@ muzzle {
dependencies {
library "redis.clients:jedis:3.0.0"
testImplementation "com.github.kstyrc:embedded-redis:0.6"
// ensures jedis-1.4 instrumentation does not load with jedis 3.0+ by failing
// the tests in the event it does. The tests will end up with double spans
testInstrumentation project(':instrumentation:jedis:jedis-1.4:javaagent')

View File

@ -6,30 +6,25 @@
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.testcontainers.containers.GenericContainer
import redis.clients.jedis.Jedis
import redis.embedded.RedisServer
import spock.lang.Shared
class Jedis30ClientTest extends AgentInstrumentationSpecification {
@Shared
int port = PortUtils.findOpenPort()
private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379)
@Shared
RedisServer redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind 127.0.0.1")
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
int port
@Shared
Jedis jedis = new Jedis("localhost", port)
Jedis jedis
def setupSpec() {
println "Using redis: $redisServer.args"
redisServer.start()
port = redisServer.getMappedPort(6379)
jedis = new Jedis("localhost", port)
}
def cleanupSpec() {

View File

@ -13,8 +13,6 @@ muzzle {
dependencies {
library "biz.paluch.redis:lettuce:4.0.Final"
testImplementation "com.github.kstyrc:embedded-redis:0.6"
latestDepTestLibrary "biz.paluch.redis:lettuce:4.+"
}

View File

@ -25,7 +25,7 @@ import java.util.function.BiConsumer
import java.util.function.BiFunction
import java.util.function.Consumer
import java.util.function.Function
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
import spock.util.concurrent.AsyncConditions
@ -35,6 +35,8 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
// Disable autoreconnect so we do not get stray traces popping up on server shutdown
public static final ClientOptions CLIENT_OPTIONS = new ClientOptions.Builder().autoReconnect(false).build()
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
@Shared
int port
@Shared
@ -48,9 +50,6 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -71,18 +70,12 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
dbUriNonExistent = "redis://" + dbAddrNonExistent
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {
redisClient = RedisClient.create(embeddedDbUri)
println "Using redis: $redisServer.args"
redisServer.start()
redisClient.setOptions(CLIENT_OPTIONS)

View File

@ -14,7 +14,7 @@ import com.lambdaworks.redis.api.sync.RedisCommands
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
class LettuceSyncClientTest extends AgentInstrumentationSpecification {
@ -23,6 +23,8 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
// Disable autoreconnect so we do not get stray traces popping up on server shutdown
public static final ClientOptions CLIENT_OPTIONS = new ClientOptions.Builder().autoReconnect(false).build()
private static FixedHostPortGenericContainer redis = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
@Shared
int port
@Shared
@ -36,9 +38,6 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -58,18 +57,15 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
dbUriNonExistent = "redis://" + dbAddrNonExistent
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redis = redis.withFixedExposedPort(port, 6379)
}
def setup() {
//TODO do not restart server for every test
redis.start()
redisClient = RedisClient.create(embeddedDbUri)
redisServer.start()
connection = redisClient.connect()
syncCommands = connection.sync()
@ -82,7 +78,7 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
def cleanup() {
connection.close()
redisServer.stop()
redis.stop()
}
def "connect"() {

View File

@ -14,7 +14,6 @@ dependencies {
implementation project(':instrumentation:lettuce:lettuce-common:library')
testImplementation "com.github.kstyrc:embedded-redis:0.6"
testImplementation "io.lettuce:lettuce-core:5.0.0.RELEASE"
testInstrumentation project(':instrumentation:reactor-3.1:javaagent')
}

View File

@ -27,7 +27,7 @@ import java.util.function.BiConsumer
import java.util.function.BiFunction
import java.util.function.Consumer
import java.util.function.Function
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
import spock.util.concurrent.AsyncConditions
@ -38,6 +38,8 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
// Disable autoreconnect so we do not get stray traces popping up on server shutdown
public static final ClientOptions CLIENT_OPTIONS = ClientOptions.builder().autoReconnect(false).build()
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
@Shared
int port
@Shared
@ -51,9 +53,6 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -74,18 +73,12 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
dbUriNonExistent = "redis://" + dbAddrNonExistent
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + PEER_NAME)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {
redisClient = RedisClient.create(embeddedDbUri)
println "Using redis: $redisServer.args"
redisServer.start()
redisClient.setOptions(CLIENT_OPTIONS)

View File

@ -15,8 +15,8 @@ import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.function.Consumer
import org.testcontainers.containers.FixedHostPortGenericContainer
import reactor.core.scheduler.Schedulers
import redis.embedded.RedisServer
import spock.lang.Shared
import spock.util.concurrent.AsyncConditions
@ -27,11 +27,11 @@ class LettuceReactiveClientTest extends AgentInstrumentationSpecification {
// Disable autoreconnect so we do not get stray traces popping up on server shutdown
public static final ClientOptions CLIENT_OPTIONS = ClientOptions.builder().autoReconnect(false).build()
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
RedisClient redisClient
StatefulConnection connection
@ -43,18 +43,12 @@ class LettuceReactiveClientTest extends AgentInstrumentationSpecification {
String dbAddr = PEER_HOST + ":" + port + "/" + DB_INDEX
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + PEER_HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {
redisClient = RedisClient.create(embeddedDbUri)
println "Using redis: $redisServer.args"
redisServer.start()
redisClient.setOptions(CLIENT_OPTIONS)
@ -201,7 +195,7 @@ class LettuceReactiveClientTest extends AgentInstrumentationSpecification {
attributes {
"$SemanticAttributes.DB_SYSTEM.key" "redis"
"$SemanticAttributes.DB_STATEMENT.key" "COMMAND"
"lettuce.command.results.count" 157
"lettuce.command.results.count" { it > 100 }
}
}
}

View File

@ -15,7 +15,7 @@ import io.netty.channel.AbstractChannel
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
class LettuceSyncClientTest extends AgentInstrumentationSpecification {
@ -25,6 +25,8 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
// Disable autoreconnect so we do not get stray traces popping up on server shutdown
public static final ClientOptions CLIENT_OPTIONS = ClientOptions.builder().autoReconnect(false).build()
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
@Shared
int port
@Shared
@ -38,9 +40,6 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -60,12 +59,7 @@ class LettuceSyncClientTest extends AgentInstrumentationSpecification {
dbUriNonExistent = "redis://" + dbAddrNonExistent
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + PEER_NAME)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {

View File

@ -16,7 +16,6 @@ dependencies {
testImplementation project(':instrumentation:lettuce:lettuce-5.1:testing')
testImplementation "com.github.kstyrc:embedded-redis:0.6"
// Only 5.2+ will have command arguments in the db.statement tag.
testLibrary "io.lettuce:lettuce-core:5.2.0.RELEASE"
testInstrumentation project(':instrumentation:reactor-3.1:javaagent')

View File

@ -5,8 +5,7 @@ dependencies {
api "io.lettuce:lettuce-core:5.1.0.RELEASE"
api "com.github.kstyrc:embedded-redis:0.6"
implementation deps.testcontainers
implementation deps.guava
implementation deps.groovy

View File

@ -25,7 +25,7 @@ import java.util.function.BiConsumer
import java.util.function.BiFunction
import java.util.function.Consumer
import java.util.function.Function
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
import spock.util.concurrent.AsyncConditions
@ -33,6 +33,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati
public static final String HOST = "127.0.0.1"
public static final int DB_INDEX = 0
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
abstract RedisClient createClient(String uri)
@Shared
@ -48,9 +50,6 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -71,18 +70,12 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati
dbUriNonExistent = "redis://" + dbAddrNonExistent
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {
redisClient = createClient(embeddedDbUri)
println "Using redis: $redisServer.args"
redisServer.start()
redisClient.setOptions(LettuceTestUtil.CLIENT_OPTIONS)

View File

@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.function.Consumer
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
import spock.util.concurrent.AsyncConditions
@ -25,6 +25,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific
public static final String HOST = "127.0.0.1"
public static final int DB_INDEX = 0
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
abstract RedisClient createClient(String uri)
@Shared
@ -32,9 +34,6 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
RedisClient redisClient
StatefulConnection connection
RedisReactiveCommands<String, ?> reactiveCommands
@ -45,18 +44,12 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific
String dbAddr = HOST + ":" + port + "/" + DB_INDEX
embeddedDbUri = "redis://" + dbAddr
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {
redisClient = createClient(embeddedDbUri)
println "Using redis: $redisServer.args"
redisServer.start()
redisClient.setOptions(LettuceTestUtil.CLIENT_OPTIONS)

View File

@ -12,13 +12,15 @@ import io.lettuce.core.RedisClient
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecification {
public static final String HOST = "127.0.0.1"
public static final int DB_INDEX = 0
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
abstract RedisClient createClient(String uri)
@Shared
@ -30,9 +32,6 @@ abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecific
@Shared
String embeddedDbUri
@Shared
RedisServer redisServer
RedisClient redisClient
def setupSpec() {
@ -41,14 +40,9 @@ abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecific
embeddedDbUri = "redis://" + dbAddr
password = "password"
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
// Set password
.setting("requirepass " + password)
.port(port).build()
redisServer = redisServer
.withFixedExposedPort(port, 6379)
.withCommand("redis-server", "--requirepass $password")
}
def setup() {

View File

@ -19,13 +19,15 @@ import io.lettuce.core.api.sync.RedisCommands
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import redis.embedded.RedisServer
import org.testcontainers.containers.FixedHostPortGenericContainer
import spock.lang.Shared
abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecification {
public static final String HOST = "127.0.0.1"
public static final int DB_INDEX = 0
private static FixedHostPortGenericContainer redisServer = new FixedHostPortGenericContainer<>("redis:6.2.3-alpine")
abstract RedisClient createClient(String uri)
@Shared
@ -43,9 +45,6 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio
@Shared
String embeddedDbLocalhostUri
@Shared
RedisServer redisServer
@Shared
Map<String, String> testHashMap = [
firstname: "John",
@ -66,12 +65,7 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio
embeddedDbUri = "redis://" + dbAddr
embeddedDbLocalhostUri = "redis://localhost:" + port + "/" + DB_INDEX
redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind " + HOST)
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
redisServer = redisServer.withFixedExposedPort(port, 6379)
}
def setup() {

View File

@ -46,6 +46,4 @@ muzzle {
dependencies {
library "com.github.etaty:rediscala_2.11:1.8.0"
testImplementation "com.github.kstyrc:embedded-redis:0.6"
}

View File

@ -7,13 +7,12 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT
import akka.actor.ActorSystem
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.testcontainers.containers.GenericContainer
import redis.ByteStringDeserializerDefault
import redis.ByteStringSerializerLowPriority
import redis.RedisClient
import redis.RedisDispatcher
import redis.embedded.RedisServer
import scala.Option
import scala.concurrent.Await
import scala.concurrent.duration.Duration
@ -21,16 +20,10 @@ import spock.lang.Shared
class RediscalaClientTest extends AgentInstrumentationSpecification {
@Shared
int port = PortUtils.findOpenPort()
private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379)
@Shared
RedisServer redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind 127.0.0.1")
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
int port
@Shared
ActorSystem system
@ -39,6 +32,8 @@ class RediscalaClientTest extends AgentInstrumentationSpecification {
RedisClient redisClient
def setupSpec() {
redisServer.start()
port = redisServer.getMappedPort(6379)
system = ActorSystem.create()
redisClient = new RedisClient("localhost",
port,
@ -48,9 +43,6 @@ class RediscalaClientTest extends AgentInstrumentationSpecification {
Option.apply(null),
system,
new RedisDispatcher("rediscala.rediscala-client-worker-dispatcher"))
println "Using redis: $redisServer.args"
redisServer.start()
}
def cleanupSpec() {

View File

@ -10,7 +10,6 @@ muzzle {
dependencies {
library "org.redisson:redisson:3.0.0"
testImplementation "com.github.kstyrc:embedded-redis:0.6"
}
test {

View File

@ -6,7 +6,6 @@
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.TimeUnit
import org.redisson.Redisson
@ -17,33 +16,28 @@ import org.redisson.api.RSet
import org.redisson.api.RedissonClient
import org.redisson.config.Config
import org.redisson.config.SingleServerConfig
import redis.embedded.RedisServer
import org.testcontainers.containers.GenericContainer
import spock.lang.Shared
class RedissonAsyncClientTest extends AgentInstrumentationSpecification {
private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379)
@Shared
int port = PortUtils.findOpenPort()
int port
@Shared
RedisServer redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind 127.0.0.1")
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
@Shared
RedissonClient redisson
@Shared
String address = "localhost:" + port
String address
def setupSpec() {
redisServer.start()
port = redisServer.getMappedPort(6379)
address = "localhost:" + port
if (Boolean.getBoolean("testLatestDeps")) {
// Newer versions of redisson require scheme, older versions forbid it
address = "redis://" + address
}
println "Using redis: $redisServer.args"
redisServer.start()
}
def cleanupSpec() {

View File

@ -8,7 +8,6 @@ import static java.util.regex.Pattern.compile
import static java.util.regex.Pattern.quote
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.redisson.Redisson
import org.redisson.api.RAtomicLong
@ -22,33 +21,28 @@ import org.redisson.api.RSet
import org.redisson.api.RedissonClient
import org.redisson.config.Config
import org.redisson.config.SingleServerConfig
import redis.embedded.RedisServer
import org.testcontainers.containers.GenericContainer
import spock.lang.Shared
class RedissonClientTest extends AgentInstrumentationSpecification {
private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379)
@Shared
int port = PortUtils.findOpenPort()
int port
@Shared
RedisServer redisServer = RedisServer.builder()
// bind to localhost to avoid firewall popup
.setting("bind 127.0.0.1")
// set max memory to avoid problems in CI
.setting("maxmemory 128M")
.port(port).build()
@Shared
RedissonClient redisson
@Shared
String address = "localhost:" + port
String address
def setupSpec() {
redisServer.start()
port = redisServer.getMappedPort(6379)
address = "localhost:" + port
if (Boolean.getBoolean("testLatestDeps")) {
// Newer versions of redisson require scheme, older versions forbid it
address = "redis://" + address
}
println "Using redis: $redisServer.args"
redisServer.start()
}
def cleanupSpec() {