我用嵌入式redis编写了redis测试用例,在本地没有任何问题。但当我和jenkins或gitlab一起转到ci/cd管道时。有时,我会面临连接被拒绝的问题。
环境:
Spring Data -redis:2.2.8
lettuce:5.5.2
欧盟蒙尼奥特。redis:embedded-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()
}
}
我修不好。有人能帮我吗?
暂无答案!
目前还没有任何答案,快来回答吧!