Skip to content

Commit

Permalink
Added test for inifinite lease (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcardosos committed May 4, 2017
1 parent bc40f2d commit 186f113
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
17 changes: 17 additions & 0 deletions storage/leaseblob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ func (s *LeaseBlobSuite) TestAcquireLeaseWithBadProposedLeaseID(c *chk.C) {
c.Assert(err, chk.NotNil)
}

func (s *LeaseBlobSuite) TestAcquireInfiniteLease(c *chk.C) {
cli := getBlobClient(c)
rec := cli.client.appendRecorder(c)
defer rec.Stop()

cnt := cli.GetContainerReference(containerName(c))
b := cnt.GetBlobReference(blobName(c))
c.Assert(cnt.Create(nil), chk.IsNil)
defer cnt.Delete(nil)

c.Assert(b.putSingleBlockBlob([]byte("Hello!")), chk.IsNil)

proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
_, err := b.AcquireLease(-1, proposedLeaseID, nil)
c.Assert(err, chk.IsNil)
}

func (s *LeaseBlobSuite) TestRenewLeaseSuccessful(c *chk.C) {
cli := getBlobClient(c)
rec := cli.client.appendRecorder(c)
Expand Down
140 changes: 140 additions & 0 deletions storage/recordings/LeaseBlobSuite/TestAcquireInfiniteLease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
version: 1
rwmutex: {}
interactions:
- request:
body: ""
form: {}
headers:
Authorization:
- SharedKey golangrocksonazure:/TxslLjfP6iW5WDOz4DexmhfUAAqjUczGuhJiD7P2pk=
User-Agent:
- Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob
X-Ms-Date:
- Fri, 21 Apr 2017 02:57:04 GMT
X-Ms-Version:
- 2016-05-31
url: https://golangrocksonazure.blob.core.windows.net/cnt-39leaseblobsuitetestacquirei?restype=container
method: PUT
response:
body: ""
headers:
Date:
- Fri, 21 Apr 2017 02:57:04 GMT
Etag:
- '"0x8D488621753FA2E"'
Last-Modified:
- Fri, 21 Apr 2017 02:57:04 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id:
- a68a1e96-0001-0003-174a-ba01be000000
X-Ms-Version:
- 2016-05-31
status: 201 Created
code: 201
- request:
body: Hello!
form: {}
headers:
Authorization:
- SharedKey golangrocksonazure:cQnLL5ZMgcZVbdYFBxPPWKF8VI24LhjWPgMEM50LvOY=
Content-Length:
- "6"
User-Agent:
- Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob
X-Ms-Blob-Type:
- BlockBlob
X-Ms-Date:
- Fri, 21 Apr 2017 02:57:04 GMT
X-Ms-Version:
- 2016-05-31
url: https://golangrocksonazure.blob.core.windows.net/cnt-39leaseblobsuitetestacquirei/blob/39leaseblobsuitetestacquireinfinitelease
method: PUT
response:
body: ""
headers:
Content-Md5:
- lS0sVtBIWVgzZ0e83ZhZDQ==
Date:
- Fri, 21 Apr 2017 02:57:04 GMT
Etag:
- '"0x8D48862172DE5D9"'
Last-Modified:
- Fri, 21 Apr 2017 02:57:04 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id:
- a68a1e9c-0001-0003-1c4a-ba01be000000
X-Ms-Request-Server-Encrypted:
- "false"
X-Ms-Version:
- 2016-05-31
status: 201 Created
code: 201
- request:
body: ""
form: {}
headers:
Authorization:
- SharedKey golangrocksonazure:nCwSRG6YOK776VPfk756miIfDe+WXGYH+J+jV5lSawg=
User-Agent:
- Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob
X-Ms-Date:
- Fri, 21 Apr 2017 02:57:04 GMT
X-Ms-Lease-Action:
- acquire
X-Ms-Lease-Duration:
- "-1"
X-Ms-Proposed-Lease-Id:
- dfe6dde8-68d5-4910-9248-c97c61768fea
X-Ms-Version:
- 2016-05-31
url: https://golangrocksonazure.blob.core.windows.net/cnt-39leaseblobsuitetestacquirei/blob/39leaseblobsuitetestacquireinfinitelease?comp=lease
method: PUT
response:
body: ""
headers:
Date:
- Fri, 21 Apr 2017 02:57:04 GMT
Etag:
- '"0x8D48862172DE5D9"'
Last-Modified:
- Fri, 21 Apr 2017 02:57:04 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Lease-Id:
- dfe6dde8-68d5-4910-9248-c97c61768fea
X-Ms-Request-Id:
- a68a1ea7-0001-0003-264a-ba01be000000
X-Ms-Version:
- 2016-05-31
status: 201 Created
code: 201
- request:
body: ""
form: {}
headers:
Authorization:
- SharedKey golangrocksonazure:Ef9xwrB5zWWfkdXCUrgpqFnPkmTN5pVd2pAfKVuIvMs=
User-Agent:
- Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob
X-Ms-Date:
- Fri, 21 Apr 2017 02:57:04 GMT
X-Ms-Version:
- 2016-05-31
url: https://golangrocksonazure.blob.core.windows.net/cnt-39leaseblobsuitetestacquirei?restype=container
method: DELETE
response:
body: ""
headers:
Date:
- Fri, 21 Apr 2017 02:57:04 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
X-Ms-Request-Id:
- a68a1ead-0001-0003-2c4a-ba01be000000
X-Ms-Version:
- 2016-05-31
status: 202 Accepted
code: 202

0 comments on commit 186f113

Please sign in to comment.