Example #1
0
        public void BlobListFlatNoIncludeTest()
        {
            var doc = _runner.ExecuteRequestResponse(
                "http://mydashserver/container/test?restype=container&comp=list&prefix=",
                "GET",
                expectedStatusCode: HttpStatusCode.OK);
            var enumerationResults = doc.Root;

            Assert.AreEqual(19, enumerationResults.Element("Blobs").Elements().Count());
            var nonSnapshotBlob = (XElement)enumerationResults.Element("Blobs").Elements().First();

            Assert.IsNull(nonSnapshotBlob.Element("Snapshot"));
            Assert.IsNull(nonSnapshotBlob.Element("Metadata"));
        }
Example #2
0
        public void ReplicateWithAsyncWorkerTest()
        {
            // We need exclusive access to the queue to validate queue behavior
            lock (this)
            {
                // Throw in the encodable name challenge here as well - unfortunately, the steps we've taken to ensure double-encoding works with IIS
                // doesn't apply when we're using HttpClient in direct mode - we have to have 2 encoded forms of the same name
                string blobSegment        = "workernode2.jokleinhbase.d6.internal.cloudapp.net%2C60020%2C1436223739284.1436223741878";
                string encodedBlobSegment = WebUtility.UrlEncode(blobSegment);
                string uniqueFolderName   = "test22/" + Guid.NewGuid().ToString();
                string baseBlobName       = uniqueFolderName + "/workernode2.jokleinhbase.d6.internal.cloudapp.net,60020,1436223739284/";
                string blobName           = baseBlobName + blobSegment;
                string encodedBlobName    = baseBlobName + encodedBlobSegment;
                string baseBlobUri        = "http://localhost/blob/" + ContainerName + "/" + baseBlobName;
                string blobUri            = baseBlobUri + blobSegment;
                string encodedBlobUri     = baseBlobUri + encodedBlobSegment;
                var    content            = new StringContent("hello world", System.Text.Encoding.UTF8, "text/plain");
                content.Headers.Add("x-ms-version", "2013-08-15");
                content.Headers.Add("x-ms-date", "Wed, 23 Oct 2013 22:33:355 GMT");
                content.Headers.Add("x-ms-blob-type", "BlockBlob");
                var response = _runner.ExecuteRequest(encodedBlobUri,
                                                      "PUT",
                                                      content,
                                                      HttpStatusCode.Created);
                // Fetch the blob so that we can determine it's primary data account
                var    result          = BlobRequest("HEAD", blobUri);
                string dataAccountName = new Uri(result.Location).Host.Split('.')[0];
                // Verify that the blob is replicated by the async worker
                AssertReplicationWorker(ContainerName, blobName, dataAccountName, false);

                // Verify that concurrent operations send us to the primary - read the ETag & modified dates first
                var listdoc = _runner.ExecuteRequestResponse(
                    "http://localhost/container/" + ContainerName + "?restype=container&comp=list&prefix=" + encodedBlobName + "&include=metadata",
                    "GET");
                var enumerationResults = listdoc.Root;
                var blobs        = enumerationResults.Element("Blobs");
                var eTag         = blobs.Element("Blob").Element("Properties").Element("Etag").Value;
                var lastModified = blobs.Element("Blob").Element("Properties").Element("Last-Modified").Value;
                AssertRedirectDataAccount("HEAD", blobUri, dataAccountName, null);
                AssertConcurrentReads(blobUri, dataAccountName, new[] {
                    Tuple.Create("If-Match", eTag),
                    Tuple.Create("If-None-Match", eTag),
                    Tuple.Create("If-Modified-Since", lastModified),
                    Tuple.Create("If-Unmodified-Since", lastModified),
                    Tuple.Create("x-ms-if-sequence-number-le", "100"),
                    Tuple.Create("x-ms-if-sequence-number-lt", "100"),
                    Tuple.Create("x-ms-if-sequence-number-eq", "100"),
                });
                // Cleanup - do an orphaned replica test on the way out
                _runner.ExecuteRequest(encodedBlobUri,
                                       "DELETE",
                                       expectedStatusCode: HttpStatusCode.Accepted);
                // The namespace has been marked for deletion & the primary blob has been deleted, but the replicas are now
                // orphaned waiting to be async deleted - verify that a blob listing at this time doesn't return the blob
                listdoc = _runner.ExecuteRequestResponse(
                    "http://localhost/container/" + ContainerName + "?restype=container&comp=list&prefix=" + encodedBlobName + "&include=metadata",
                    "GET");
                enumerationResults = listdoc.Root;
                Assert.AreEqual(0, enumerationResults.Element("Blobs").Elements().Count());
                // A special corner case for this same scenario is that we do a hierarchical listing a folder down (the container) & we
                // shouldn't see the containing folder as it doesn't contain any non-deleted primary blobs
                listdoc = _runner.ExecuteRequestResponse(
                    "http://localhost/container/" + ContainerName + "?restype=container&comp=list&delimiter=/&prefix=" + uniqueFolderName + "&include=metadata",
                    "GET");
                enumerationResults = listdoc.Root;
                Assert.AreEqual(0, enumerationResults.Element("Blobs").Elements().Count());

                // Verify the delete replica behavior
                AssertReplicationWorker(ContainerName, blobName, dataAccountName, true);
            }
        }