Skip to content

Commit 707c85d

Browse files
committed
fix: try fix redis test fail;
1 parent de2fac2 commit 707c85d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

test/ResponseCaching.Test.WebHost/Controllers/HotDataCacheController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class HotDataCacheController : TestControllerBase
1010

1111
[HttpGet]
1212
[HotDataCache(50, HotDataCachePolicy.LRU)]
13-
[ResponseCaching(10,
13+
[ResponseCaching(60,
1414
Mode = CacheMode.FullPathAndQuery,
1515
StoreLocation = CacheStoreLocation.Distributed)]
1616
[ExecutingLock(ExecutingLockMode.CacheKeySingle)]

test/ResponseCaching.Test/ResponseCaches/ResponseCacheTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public async Task GetSetResponseEntry()
3232
{
3333
//注意:redis所在系统时间与运行测试所在系统时间有误差时,会导致测试无法通过
3434
var duration = 2;
35-
var key = "ResponseCacheTestKey";
35+
var testId = Guid.NewGuid();
36+
var key = $"ResponseCacheTestKey-{testId}";
3637
var contentType = "application/json; charset=utf-8";
3738
var body = Encoding.UTF8.GetBytes(SimResponseContent);
3839
var entry = new ResponseCacheEntry(contentType, body, duration);
@@ -62,11 +63,12 @@ public virtual async Task InitAsync()
6263
public async Task ParallelGetSetResponseEntry()
6364
{
6465
//注意:redis所在系统时间与运行测试所在系统时间有误差时,会导致测试无法通过
65-
var duration = 1;
66+
var duration = 2;
67+
var testId = Guid.NewGuid();
6668

6769
var tasks = Enumerable.Range(0, 500).Select(async index =>
6870
{
69-
var key = $"ResponseCacheTestKey_{index}";
71+
var key = $"ResponseCacheTestKey-{testId}_{index}";
7072
var contentType = $"application/json; charset=utf-8; idx={index}";
7173
var body = Encoding.UTF8.GetBytes($"{SimResponseContent}_{index}");
7274
var entry = new ResponseCacheEntry(contentType, body, duration);
@@ -77,7 +79,7 @@ public async Task ParallelGetSetResponseEntry()
7779

7880
TestUtil.EntryEquals(entry, cachedEntry);
7981

80-
await Task.Delay(TimeSpan.FromSeconds(duration + 1));
82+
await Task.Delay(TimeSpan.FromSeconds(duration + 2));
8183

8284
cachedEntry = await ResponseCache.GetAsync(key, CancellationToken.None);
8385

0 commit comments

Comments
 (0)