有时候,embedded-redis(lettuce)在测试中不断尝试重新连接

问题描述 投票:0回答:1

我已经用嵌入式redis编写了redis测试用例,它在本地运行良好,没有任何问题。但是当我使用 jenkins 或 gitlab 迁移到 CI / CD 管道时。有时,我面临连接被拒绝的问题。

环境:

  • spring-data-redis:2.2.8
  • 生菜:5.5.2
  • eu.monniot.redis:嵌入式redis:1.2.2

日志:

org.springframework.test.context.event.EventPublishingTestExecutionListener]
    2020-08-24 14:22:02.281  INFO 4273 --- [    Test worker] t.a.d.r.DataRedisTestContextBootstrapper : Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@5c88a8a1, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@365ab4bb, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@65d657e9, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@34ad82d5, org.springframework.test.context.support.DirtiesContextTestExecutionListener@2d79e941, org.springframework.test.context.transaction.TransactionalTestExecutionListener@4ee57f39, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@19db0013, org.springframework.test.context.event.EventPublishingTestExecutionListener@413892d7, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@23e94850, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@4690f7a3, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@78aacfa, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@2a128f6, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6be35b3a]
    2020-08-24 14:22:02.405  INFO 4273 --- [llEventLoop-4-6] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:16379
    2020-08-24 14:22:02.405  INFO 4273 --- [llEventLoop-4-5] i.l.core.protocol.ReconnectionHandler    : Reconnected to localhost:16379
    2020-08-24 14:22:02.413  INFO 4273 --- [llEventLoop-7-2] i.l.core.protocol.ReconnectionHandler    : Reconnected to localhost:16379
    2020-08-24 14:22:02.414  INFO 4273 --- [llEventLoop-7-8] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:16379
    2020-08-24 14:22:02.504  INFO 4273 --- [llEventLoop-4-8] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:16379
    2020-08-24 14:22:02.613  INFO 4273 --- [llEventLoop-7-6] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:17379
    2020-08-24 14:22:02.613  INFO 4273 --- [llEventLoop-7-5] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:16379
    2020-08-24 14:22:02.704  INFO 4273 --- [llEventLoop-4-2] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:17379
    2020-08-24 14:22:05.313  INFO 4273 --- [llEventLoop-7-1] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:19379
    2020-08-24 14:22:05.505  INFO 4273 --- [llEventLoop-4-1] i.l.core.protocol.ReconnectionHandler    : Reconnected to 127.0.0.1:18369
    2020-08-24 14:22:07.012  INFO 4273 --- [xecutorLoop-5-1] i.l.core.protocol.ConnectionWatchdog     : Reconnecting, last destination was 127.0.0.1:16379
    2020-08-24 14:22:07.012  INFO 4273 --- [xecutorLoop-5-8] i.l.core.protocol.ConnectionWatchdog     : Reconnecting, last destination was localhost:16379
    2020-08-24 14:22:07.013  WARN 4273 --- [llEventLoop-7-4] i.l.core.protocol.ConnectionWatchdog     : Cannot reconnect to [127.0.0.1:16379]: finishConnect(..) failed: Connection refused: /127.0.0.1:16379
    2020-08-24 14:22:07.013  WARN 4273 --- [llEventLoop-7-3] i.l.core.protocol.ConnectionWatchdog     : Cannot reconnect to [localhost:16379]: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:16379
    2020-08-24 14:22:07.104  INFO 4273 --- [xecutorLoop-1-1] i.l.core.protocol.ConnectionWatchdog     : Reconnecting, last destination was localhost:16379
    2020-08-24 14:22:07.104  INFO 4273 --- [xecutorLoop-1-2] i.l.core.protocol.ConnectionWatchdog     : Reconnecting, last destination was 127.0.0.1:17379
    2020-08-24 14:22:07.104  INFO 4273 --- [xecutorLoop-1-8] i.l.core.protocol.ConnectionWatchdog     : Reconnecting, last destination was 127.0.0.1:16379
    2020-08-24 14:22:07.105  WARN 4273 --- [llEventLoop-4-2] i.l.core.protocol.ConnectionWatchdog     : Cannot reconnect to [127.0.0.1:16379]: finishConnect(..) failed: Connection refused: /127.0.0.1:16379
    2020-08-24 14:22:07.105  WARN 4273 --- [llEventLoop-4-1] i.l.core.protocol.ConnectionWatchdog     : Cannot reconnect to [127.0.0.1:17379]: finishConnect(..) failed: Connection refused: /127.0.0.1:17379
    2020-08-24 14:22:07.105  WARN 4273 --- [llEventLoop-4-8] i.l.core.protocol.ConnectionWatchdog     : Cannot reconnect to [localhost:16379]: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:16379

代码:

companion object {
        private lateinit var cluster: Redis

        @JvmStatic
        @BeforeAll
        @Timeout(120)
        fun beforeAll() {
            cluster = RedisCluster.Builder()
                .serverPorts(arrayListOf(16379, 17379, 18369, 19379))
                .numOfReplicates(1)
                .numOfRetries(12)
                .build()
            cluster.start()
        }

        @JvmStatic
        @AfterAll
        fun afterAll() {
            cluster.stop()
        }
    }

我无法修复它。有人可以帮助我吗?

redis spring-data-redis lettuce
1个回答
0
投票

我通过 github 操作遇到了与 CI/CD 管道相同的问题(并且在本地工作正常)。

问题解决了吗?

© www.soinside.com 2019 - 2024. All rights reserved.