public void ShowBlobWithLease() { string containerName = Utility.GenNameString("container"); string pageBlobName = Utility.GenNameString("page"); string blockBlobName = Utility.GenNameString("block"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent; try { CloudBlob pageBlob = blobUtil.CreatePageBlob(container, pageBlobName); CloudBlob blockBlob = blobUtil.CreateBlockBlob(container, blockBlobName); ((CloudPageBlob)pageBlob).AcquireLease(null, string.Empty); ((CloudBlockBlob)blockBlob).AcquireLease(null, string.Empty); pageBlob.FetchAttributes(); blockBlob.FetchAttributes(); Test.Assert(nodejsAgent.ShowAzureStorageBlob(pageBlobName, containerName), Utility.GenComparisonData("show blob with lease", true)); nodejsAgent.OutputValidation(new List <CloudBlob>() { pageBlob }); Test.Assert(nodejsAgent.ShowAzureStorageBlob(blockBlobName, containerName), Utility.GenComparisonData("show blob with lease", true)); nodejsAgent.OutputValidation(new List <CloudBlob>() { blockBlob }); } finally { blobUtil.RemoveContainer(containerName); } }
public void ShowBlobWithMetadata() { string containerName = Utility.GenNameString("container"); string pageBlobName = Utility.GenNameString("page"); string blockBlobName = Utility.GenNameString("block"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent; try { CloudBlob pageBlob = blobUtil.CreatePageBlob(container, pageBlobName); CloudBlob blockBlob = blobUtil.CreateBlockBlob(container, blockBlobName); int count = Utility.GetRandomTestCount(); for (int i = 0; i < count; i++) { pageBlob.Metadata.Add(Utility.GenNameString("ShowBlobWithMetadata"), Utility.GenNameString("ShowBlobWithMetadata")); pageBlob.SetMetadata(); blockBlob.Metadata.Add(Utility.GenNameString("ShowBlobWithMetadata"), Utility.GenNameString("ShowBlobWithMetadata")); blockBlob.SetMetadata(); } Test.Assert(nodejsAgent.ShowAzureStorageBlob(pageBlobName, containerName), Utility.GenComparisonData("show blob with metadata", true)); Test.Assert(nodejsAgent.Output.Count == 1, String.Format("Expect to retrieve {0} blobs, but retrieved {1} blobs", 1, nodejsAgent.Output.Count)); nodejsAgent.OutputValidation(new List <CloudBlob>() { pageBlob }); Test.Assert(nodejsAgent.ShowAzureStorageBlob(blockBlobName, containerName), Utility.GenComparisonData("show blob with metadata", true)); Test.Assert(nodejsAgent.Output.Count == 1, String.Format("Expect to retrieve {0} blobs, but retrieved {1} blobs", 1, nodejsAgent.Output.Count)); nodejsAgent.OutputValidation(new List <CloudBlob>() { blockBlob }); } finally { blobUtil.RemoveContainer(containerName); } }
internal void StorageTest(string caseName) { NodeJSAgent nodeAgent = (NodeJSAgent)CommandAgent; string containerName = Utility.GenNameString("astoria-"); string blobName = Utility.GenNameString("astoria-"); Test.Assert(!nodeAgent.NewAzureStorageContainer(containerName), Utility.GenComparisonData("NewAzureStorageContainer", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.GetAzureStorageContainer(containerName), Utility.GenComparisonData("GetAzureStorageContainer", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.SetAzureStorageContainerACL(containerName, BlobContainerPublicAccessType.Container), Utility.GenComparisonData("SetAzureStorageContainerACL", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.RemoveAzureStorageContainer(containerName), Utility.GenComparisonData("RemoveAzureStorageContainer", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.ShowAzureStorageContainer(containerName), Utility.GenComparisonData("ShowAzureStorageContainer", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.SetAzureStorageBlobContent(TempTestFile, containerName, BlobType.BlockBlob, blobName), Utility.GenComparisonData("SetAzureStorageBlobContent", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.SetAzureStorageBlobContent(TempTestFile, containerName, BlobType.PageBlob, blobName), Utility.GenComparisonData("SetAzureStorageBlobContent", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.GetAzureStorageBlobContent(blobName, TempTestFile, containerName), Utility.GenComparisonData("GetAzureStorageBlobContent", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.GetAzureStorageBlob(blobName, containerName), Utility.GenComparisonData("GetAzureStorageBlob", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.ShowAzureStorageBlob(blobName, containerName), Utility.GenComparisonData("ShowAzureStorageBlob", false)); nodeAgent.ValidateErrorMessage(caseName); Test.Assert(!nodeAgent.RemoveAzureStorageBlob(blobName, containerName), Utility.GenComparisonData("RemoveAzureStorageBlob", false)); nodeAgent.ValidateErrorMessage(caseName); }
public void ShowNonExistingBlob() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob", 12); CloudBlobContainer container = blobUtil.CreateContainer(containerName); NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent; try { string notExistingBlobName = "notexistingblob"; string BLOB_NAME = Utility.GenNameString("nonexisting"); Test.Assert(!nodejsAgent.ShowAzureStorageBlob(notExistingBlobName, containerName), Utility.GenComparisonData("show blob with not existing blob", false)); nodejsAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, notExistingBlobName, containerName); } finally { blobUtil.RemoveContainer(containerName); } }
public void ShowBlobWithSpecialChars(BlobType blobType) { CloudBlobContainer container = blobUtil.CreateContainer(); string blobName = SpecialChars; CloudBlob blob = blobUtil.CreateBlob(container, blobName, blobType); NodeJSAgent nodejsAgent = (NodeJSAgent)CommandAgent; try { Test.Assert(nodejsAgent.ShowAzureStorageBlob(blobName, container.Name), "show blob name with special chars should succeed"); blob.FetchAttributes(); nodejsAgent.OutputValidation(new List <CloudBlob>() { blob }); } finally { blobUtil.RemoveContainer(container.Name); } }
/// <summary> /// Functional Cases: /// 1. Upload a new blob file in the root container (Set-AzureStorageBlobContent Positive 2) /// 2. Get an existing blob in the root container (Get-AzureStorageBlob Positive 2) /// 3. Download an existing blob in the root container (Get-AzureStorageBlobContent Positive 2) /// 4. Remove an existing blob in the root container (Remove-AzureStorageBlob Positive 2) /// </summary> internal void RootBlobOperations(Agent agent, string UploadFilePath, string DownloadDirPath, Microsoft.WindowsAzure.Storage.Blob.BlobType Type) { const string ROOT_CONTAINER_NAME = "$root"; string blobName = Path.GetFileName(UploadFilePath); string downloadFilePath = Path.Combine(DownloadDirPath, blobName); Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> >(); Dictionary <string, object> dic = Utility.GenComparisonData(StorageObjectType.Blob, blobName); dic["BlobType"] = Type; comp.Add(dic); // create the container CloudBlobContainer container = StorageAccount.CreateCloudBlobClient().GetRootContainerReference(); container.CreateIfNotExists(); //--------------Upload operation-------------- Test.Assert(agent.SetAzureStorageBlobContent(UploadFilePath, ROOT_CONTAINER_NAME, Type), Utility.GenComparisonData("SendAzureStorageBlob", true)); CloudBlob blob = BlobHelper.QueryBlob(ROOT_CONTAINER_NAME, blobName); blob.FetchAttributes(); // Verification for returned values CloudBlobUtil.PackBlobCompareData(blob, dic); agent.OutputValidation(comp); Test.Assert(blob.Exists(), "blob " + blobName + " should exist!"); // validate the ContentType value for GetAzureStorageBlob operation // Remove the ContentType validation since it's not set/control by PowerShell, and is totally server behavior, and can change with server behavior change. //dic["ContentType"] = "application/octet-stream"; //--------------Get operation-------------- Test.Assert(agent.GetAzureStorageBlob(blobName, ROOT_CONTAINER_NAME), Utility.GenComparisonData("GetAzureStorageBlob", true)); // Verification for returned values agent.OutputValidation(comp); if (agent is NodeJSAgent) { NodeJSAgent nodejsAgent = (NodeJSAgent)agent; //--------------Show operation-------------- Test.Assert(nodejsAgent.ShowAzureStorageBlob(blobName, ROOT_CONTAINER_NAME), Utility.GenComparisonData("ShowAzureStorageBlob", true)); // Verification for returned values nodejsAgent.OutputValidation(comp); } //--------------Download operation-------------- downloadFilePath = Path.Combine(DownloadDirPath, blobName); Test.Assert(agent.GetAzureStorageBlobContent(blobName, downloadFilePath, ROOT_CONTAINER_NAME), Utility.GenComparisonData("GetAzureStorageBlobContent", true)); // Verification for returned values agent.OutputValidation(comp); Test.Assert(FileUtil.CompareTwoFiles(downloadFilePath, UploadFilePath), String.Format("File '{0}' should be bit-wise identicial to '{1}'", downloadFilePath, UploadFilePath)); //--------------Remove operation-------------- Test.Assert(agent.RemoveAzureStorageBlob(blobName, ROOT_CONTAINER_NAME), Utility.GenComparisonData("RemoveAzureStorageBlob", true)); blob = BlobHelper.QueryBlob(ROOT_CONTAINER_NAME, blobName); Test.Assert(blob == null, "blob {0} should not exist!", blobName); }