yangfuhai / jboot

一个优雅的微服务框架,SpringCloud 之外的另一个选择,已经使用在用户量过亿的商业产品上,有超过1000家公司在使用Jboot做极速开发...
http://www.jboot.com.cn
Apache License 2.0
732 stars 252 forks source link

Fix flaky tests #117

Closed dserfe closed 1 year ago

dserfe commented 1 year ago

This PR is to fix several flaky tests.

Problem

For tests in io.jboot.test.cache.j2cache.J2CacheTester, if they are run before any of the following tests, the following test will fail

io.jboot.test.cache.caffeine.CaffeineTester#testDue,
io.jboot.test.cache.caffeine.CaffeineTester#testGet,
io.jboot.test.cache.caffeine.CaffeineTester#testPut,
io.jboot.test.cache.caffeine.CaffeineTester#testTtl,
io.jboot.test.cache.ehcache.EhCacheTester#testGet,
io.jboot.test.cache.ehcache.EhCacheTester#testPut

For example, we observed the following test failures when running io.jboot.test.cache.j2cache.J2CacheTester#testGet and io.jboot.test.cache.caffeine.CaffeineTester#testDue in sequence.

[ERROR]   CaffeineTester.testDue:45 » JedisConnection Could not get a resource from the pool
[ERROR]   J2CacheTester.testGet:21 » JedisConnection Could not get a resource from the pool

Root cause and fix

The config set up of j2cache in io.jboot.test.cache.j2cache.J2CacheTester will lead to errors of JedisConnection Could not get a resource from the pool. The fix is to use ehcache instead, which will make all tests pass.