Skip to content

Commit

Permalink
Add test case for timing
Browse files Browse the repository at this point in the history
  • Loading branch information
samcook committed Apr 28, 2015
1 parent 3f6cead commit a72014c
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion RedLock.Tests/RedisLockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using log4net.Config;
using NUnit.Framework;
using RedLock.Logging;
using RedLock.Logging.Log4Net;
using RedLock.Util;

Expand All @@ -14,7 +15,7 @@ namespace RedLock.Tests
[TestFixture]
public class RedisLockTests
{
private Log4NetLogger logger;
private IRedLockLogger logger;

[TestFixtureSetUp]
public void TestFixtureSetUp()
Expand Down Expand Up @@ -296,5 +297,40 @@ private void CheckSingleRedisLock(IEnumerable<EndPoint> endPoints, bool expected
}
}
}

[Test]
[Ignore]
public void TimeLock()
{
var l = new TraceLogger
{
DebugEnabled = false,
ErrorEnabled = false
};
//var l = logger;

using (var redisLockFactory = new RedisLockFactory(AllActiveEndPoints, l))
{
var resource = String.Format("testredislock-{0}", Guid.NewGuid());

for (var i = 0; i < 10; i++)
{
var sw = Stopwatch.StartNew();

using (var redisLock = redisLockFactory.Create(resource, TimeSpan.FromSeconds(30)))
{
sw.Stop();

l.InfoWrite("Acquire {0} took {1} ticks, success {2}", i, sw.ElapsedTicks, redisLock.IsAcquired);

sw.Restart();
}

sw.Stop();

l.InfoWrite("Release {0} took {1} ticks, success", i, sw.ElapsedTicks);
}
}
}
}
}

0 comments on commit a72014c

Please sign in to comment.