Skip to content

Commit 7cde053

Browse files
author
Siddharth Chatrola
committed
Revert "Fixing test TestingForceReconnect"
This reverts commit 6c1ba24.
1 parent 6c1ba24 commit 7cde053

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

test/RedisSessionStateProviderFunctionalTests/RedisConnectionWrapperFunctionalTests.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,6 @@ public void TestingForceReconnect()
779779
using (RedisServer redisServer = new RedisServer())
780780
{
781781
RedisSharedConnection.ReconnectFrequency = TimeSpan.FromMilliseconds(5);
782-
RedisSharedConnection.ReconnectErrorThreshold = TimeSpan.FromSeconds(1);
783782
RedisConnectionWrapper redisConn = GetRedisConnectionWrapperWithUniqueSession();
784783

785784
DateTimeOffset first_lastReconnectTime = RedisSharedConnection.lastReconnectTime;
@@ -788,31 +787,14 @@ public void TestingForceReconnect()
788787
data["key"] = "value";
789788
redisConn.Set(data, 900);
790789
Assert.Equal(first_lastReconnectTime, RedisSharedConnection.lastReconnectTime);
791-
Assert.Equal(DateTimeOffset.MinValue, RedisSharedConnection.firstErrorTime);
792-
Assert.Equal(DateTimeOffset.MinValue, RedisSharedConnection.previousErrorTime);
793-
794-
//First time RedisConnectionException this will set first and previous error
795790
System.Threading.Thread.Sleep(6);
796-
redisServer.KillRedisServers();
797-
try { redisConn.UpdateExpiryTime(900); } catch { }
798-
799-
Assert.NotEqual(DateTimeOffset.MinValue, RedisSharedConnection.firstErrorTime);
800-
Assert.NotEqual(DateTimeOffset.MinValue, RedisSharedConnection.previousErrorTime);
801-
Assert.Equal(first_lastReconnectTime, RedisSharedConnection.lastReconnectTime);
802791

803-
//This will make sure that elapsedSinceFirstError >= ReconnectErrorThreshold. But this is only second error,
804-
// so second condition won't be true so reconnect won't happen
805-
System.Threading.Thread.Sleep(1010);
806-
try { redisConn.UpdateExpiryTime(900); } catch { }
792+
//This should cause RedisConnectionException
793+
redisServer.Restart();
794+
redisConn.UpdateExpiryTime(900);
807795

808-
Assert.NotEqual(RedisSharedConnection.firstErrorTime.Ticks, RedisSharedConnection.previousErrorTime.Ticks);
809-
Assert.Equal(first_lastReconnectTime, RedisSharedConnection.lastReconnectTime);
810-
811-
//This will make sure that elapsedSinceMostRecentError <= ReconnectErrorThreshold. Reconnect happens now
812-
try { redisConn.UpdateExpiryTime(900); } catch { }
813796
// This proves that force reconnect happened
814797
Assert.NotEqual(first_lastReconnectTime, RedisSharedConnection.lastReconnectTime);
815-
816798
DisposeRedisConnectionWrapper(redisConn);
817799
}
818800
}

test/Shared/RedisServer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ private void WaitForRedisToStart()
3939

4040
public RedisServer()
4141
{
42-
KillRedisServers();
43-
Start();
42+
Restart();
4443
}
4544

46-
public void Start()
45+
public void Restart()
4746
{
47+
KillRedisServers();
4848
_server = new Process();
4949
_server.StartInfo.FileName = "..\\..\\..\\..\\..\\..\\packages\\redis-64.3.0.503\\tools\\redis-server.exe";
5050
_server.StartInfo.Arguments = "--maxmemory 20000000";
@@ -54,7 +54,7 @@ public void Start()
5454
}
5555

5656
// Make sure that no redis-server instance is running
57-
public void KillRedisServers()
57+
private void KillRedisServers()
5858
{
5959
foreach (var proc in Process.GetProcessesByName("redis-server"))
6060
{

0 commit comments

Comments
 (0)