public async void LeaseBlobRenewAsync_RecentlyLeasedBlob_RenewsLease() { var minimumWaitTime = TimeSpan.FromSeconds(15); var moreThanMinimumWaitTime = minimumWaitTime.Add(TimeSpan.FromSeconds(1)); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); var leaseId = _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(15)); Thread.Sleep(moreThanMinimumWaitTime); await client.LeaseBlobRenewAsync(containerName, blobName, leaseId); _util.AssertBlobIsLeased(containerName, blobName, leaseId); }
public async void LeaseBlobRenewAsync_NonLeasedBlob_ThrowsLeaseIdMismatchException() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); await client.LeaseBlobRenewAsync(containerName, blobName, FakeLeaseId); // expects exception }
public async void LeaseBlobRenewAsync_LeasedBlob_RenewsActiveLease() { var minimumWaitTime = TimeSpan.FromSeconds(15); var halfOfMinimum = minimumWaitTime.Subtract(TimeSpan.FromSeconds(minimumWaitTime.TotalSeconds * 0.5)); var threeQuartersOfMinimum = minimumWaitTime.Subtract(TimeSpan.FromSeconds(minimumWaitTime.TotalSeconds * 0.75)); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); var leaseId = _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(15)); Thread.Sleep(halfOfMinimum); await client.LeaseBlobRenewAsync(containerName, blobName, leaseId); Thread.Sleep(threeQuartersOfMinimum); // wait again... if it didn't renew, by now it would be expired _util.AssertBlobIsLeased(containerName, blobName, leaseId); }