3

I have written redis test cases with embedded redis and its worked fine without any issues in local. But when I moved to CI / CD pipeline with jenkins or gitlab. sometime, i am facing connection refused issue.

enviroment:

  • spring-data-redis:2.2.8
  • lettuce:5.5.2
  • eu.monniot.redis:embedded-redis:1.2.2

log:

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

code:

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()
        }
    }

I can't fix it. Can anybody help me?

Jun
  • 41
  • 2

0 Answers0