// Entry for any of the 10 reads locks has to be found.
// Since they held in a loop, Lock origin for first 10 read locks (opsID 0-9) should be the same.
{
volume:"my-bucket",
path:"my-object",
opsID:"0",
readLock:true,
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Running",
expectedGlobalLockCount:10,
expectedRunningLockCount:10,
expectedBlockedLockCount:0,
expectedVolPathLockCount:10,
expectedVolPathRunningCount:10,
expectedVolPathBlockCount:0,
},
// Test case - 2.
// Case where the first 5 read locks are released.
// Entry for any of the 6-10th "Running" reads lock has to be found.
{
volume:"my-bucket",
path:"my-object",
opsID:"6",
readLock:true,
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Running",
expectedGlobalLockCount:5,
expectedRunningLockCount:5,
expectedBlockedLockCount:0,
expectedVolPathLockCount:5,
expectedVolPathRunningCount:5,
expectedVolPathBlockCount:0,
},
// Test case - 3.
{
volume:"my-bucket",
path:"my-object",
opsID:"10",
readLock:false,
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Running",
expectedGlobalLockCount:2,
expectedRunningLockCount:1,
expectedBlockedLockCount:1,
expectedVolPathLockCount:2,
expectedVolPathRunningCount:1,
expectedVolPathBlockCount:1,
},
// Test case - 4.
{
volume:"my-bucket",
path:"my-object",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Blocked",
expectedGlobalLockCount:1,
expectedRunningLockCount:0,
expectedBlockedLockCount:1,
expectedVolPathLockCount:1,
expectedVolPathRunningCount:0,
expectedVolPathBlockCount:1,
},
// Test case - 5.
{
volume:"my-bucket",
path:"my-object",
opsID:"11",
readLock:false,
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Running",
expectedGlobalLockCount:1,
expectedRunningLockCount:1,
expectedBlockedLockCount:0,
expectedVolPathLockCount:1,
expectedVolPathRunningCount:1,
expectedVolPathBlockCount:0,
},
// Test case - 6.
// Case where in the first 5 read locks are released, but 2 write locks are
// We check the entry for the first blocked write call here.
{
volume:"my-bucket",
path:"my-object",
opsID:"10",
readLock:false,
// write lock is held at line 318.
// this confirms that we are looking the right write lock.
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",
// expected metrics.
expectedErr:nil,
expectedLockStatus:"Blocked",
// count of held(running) + blocked locks.
expectedGlobalLockCount:7,
// count of acquired locks.
expectedRunningLockCount:5,
// 2 write calls are blocked, waiting for the remaining 5 read locks.
expectedBlockedLockCount:2,
expectedVolPathLockCount:7,
expectedVolPathRunningCount:5,
expectedVolPathBlockCount:2,
},
// Test case - 7.
// Case where in 9 out of 10 read locks are released.
// Since there's one more pending read lock, the 2 write locks are still blocked.
// Testing the entry for the last read lock.
{volume:"my-bucket",
path:"my-object",
opsID:"9",
readLock:true,
lockOrigin:"[lock held] in github.com/minio/minio/cmd.TestLockStats.func2[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:318]",