/// <summary> /// Positive functional test case 5.8.1 /// </summary> /// <remarks> /// RDTask 1414230: /// Test case DownloadExistingFile requires a 200G file already exist /// on the storage account in the file service. It does not make sense /// to generate a 200G file at runtime, upload it and download it in /// functional test cases. /// Currently, since the only test we could do is against dev fabric, /// we could not prepare such file on the cloud first. So the test case /// is temp blocked. /// Once the xSMB file service GAed, and we are testing against real /// storage accounts, we could put this case back online. /// </remarks> ////[TestMethod] ////[TestCategory(PsTag.File)] public void DownloadExistingFileTest() { string[] filesToDownload = Test.Data.Get("ExistingFilesToDownload").Split(';'); string[] md5Checksum = Test.Data.Get("ExistingFilesMD5").Split(';'); for (int i = 0; i < filesToDownload.Length; i++) { var destination = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName()); try { Test.Info("About to download: {0} to {1}", filesToDownload[i], destination); CommandAgent.DownloadFile(this.fileShare, filesToDownload[i], destination); var result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); result.AssertNoResult(); string destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(md5Checksum[i], StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", md5Checksum[i], destinationMD5); } finally { FileUtil.RemoveFile(destination); } } }
public void DownloadFileUsingRelativePathAfterChangedDefaultLocation() { string currentPath = CommandAgent.GetCurrentLocation(); try { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); CommandAgent.ChangeLocation(Test.Data.Get("TempDir")); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(this.fileShare, cloudFileName, ".", true)); var result = CommandAgent.Invoke(); result.AssertNoResult(); Test.Assert(new FileInfo(Path.Combine(Test.Data.Get("TempDir"), cloudFileName)).Exists, "File should exist after downloaded."); } finally { CommandAgent.Clear(); CommandAgent.ChangeLocation(currentPath); } }
public void DownloadToAnNonExistingFilePath() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); string localExistingPath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var destinationFolder = new DirectoryInfo(Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueDirectoryName())); if (destinationFolder.Exists) { destinationFolder.Delete(true); } var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(sourceFile, destination, false), () => Path.Combine(destinationFolder.FullName, CloudFileUtil.GenerateUniqueFileName()), false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.TransferExceptionFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void DownloadingNonExistingFile() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.DeleteFileIfExists(this.fileShare, cloudFileName); CommandAgent.DownloadFile(file, Test.Data.Get("TempDir"), true); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidOperationExceptionFullQualifiedErrorId, AssertUtil.PathNotFoundFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void DownloadFileUsingFileShareNameParameterSet() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true)); }
public void DownloadWithInvalidKeyValueTest() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.DeleteFileIfExists(this.fileShare, cloudFileName); // Creates an storage context object with invalid key value var invalidAccount = CloudFileUtil.MockupStorageAccount(StorageAccount, mockupAccountKey: true); object invalidStorageContextObject = CommandAgent.CreateStorageContextObject(invalidAccount.ToString(true)); CommandAgent.DownloadFile(this.fileShare.Name, file.Name, Test.Data.Get("TempDir"), true, invalidStorageContextObject); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.AuthenticationFailedFullQualifiedErrorId, AssertUtil.ProtocolErrorFullQualifiedErrorId)); }
public void DownloadWithInvalidAccountTest() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.DeleteFileIfExists(this.fileShare, cloudFileName); // Creates an storage context object with invalid account // name. var invalidAccount = CloudFileUtil.MockupStorageAccount(StorageAccount, mockupAccountName: true); object invalidStorageContextObject = CommandAgent.CreateStorageContextObject(invalidAccount.ToString(true)); CommandAgent.DownloadFile(this.fileShare.Name, file.Name, Test.Data.Get("TempDir"), true, invalidStorageContextObject); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.AccountIsDisabledFullQualifiedErrorId, AssertUtil.NameResolutionFailureFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId, AssertUtil.ProtocolErrorFullQualifiedErrorId, AssertUtil.InvalidResourceFullQualifiedErrorId)); }
public void DownloadUsingPath() { var baseDir = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c"); string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string cloudPath = "/a/b/c/" + cloudFileName; string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudPath, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(this.fileShare, cloudPath, destination, true)); }
public void DownloadFileInASubDirectory() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string directoryName = CloudFileUtil.GenerateUniqueDirectoryName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var subDirectory = fileUtil.EnsureDirectoryExists(this.fileShare, directoryName); var sourceFile = fileUtil.CreateFile(subDirectory, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(sourceFile, destination, true)); }
public void DownloadToAFolderAndOverwrite() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); string localExistingPath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); FileUtil.GenerateSmallFile(localExistingPath, Utility.GetRandomTestCount(5, 10), true); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(sourceFile, destination, true), () => Path.GetDirectoryName(localExistingPath)); }
/// <summary> /// Negative functional test case 5.8.5 /// </summary> ////[TestMethod] ////[TestCategory(PsTag.File)] public void DownloadToAnExistingFilePath() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); string localExistingPath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); FileUtil.GenerateSmallFile(localExistingPath, Utility.GetRandomTestCount(5, 10), true); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(sourceFile, destination, false), () => localExistingPath, false); CommandAgent.AssertErrors(err => err.AssertError("IOException")); }
public void DownloadAFileUsingFileObjectWhichHasJustBeenDeletedTest() { var share = fileUtil.EnsureFileShareExists(CloudFileUtil.GenerateUniqueFileShareName()); try { var file = fileUtil.CreateFile(share, CloudFileUtil.GenerateUniqueFileName()); file.Delete(); CommandAgent.DownloadFile(file, Test.Data.Get("TempDir"), true); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidOperationExceptionFullQualifiedErrorId, AssertUtil.InvalidOperationExceptionFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId)); } finally { if (share != null) { share.DeleteIfExists(); } } }
public void UploadAndDownload0SizeFile() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); string localFilePath2 = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, 0, true); CommandAgent.UploadFile(this.fileShare, localFilePath, cloudFileName, true); var result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); Test.Assert(fileShare.GetRootDirectoryReference().GetFileReference(cloudFileName).Exists(), "File should exist after uploaded."); CommandAgent.Clear(); CommandAgent.DownloadFile(this.fileShare.GetRootDirectoryReference(), cloudFileName, localFilePath2, true); result = CommandAgent.Invoke(); if (UtilBase.AgentOSType == OSType.Windows) { Test.Assert(File.Exists(localFilePath2), "File should exist after uploaded."); } Test.Assert(FileUtil.GetFileContentMD5(localFilePath) == FileUtil.GetFileContentMD5(localFilePath2), "The download file MD5 {0} should match Uploaded File MD5 {1}.", FileUtil.GetFileContentMD5(localFilePath2), FileUtil.GetFileContentMD5(localFilePath)); }
public void DownloadFileCheckMD5() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); string previousMD5 = FileUtil.GetFileContentMD5(localFilePath); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); if (sourceFile.Properties.ContentMD5 != previousMD5) { sourceFile.Properties.ContentMD5 = previousMD5; sourceFile.SetProperties(); } var destination = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); // Download file and check its MD5 CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: true); var result = CommandAgent.Invoke(); result.AssertNoResult(); string destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); sourceFile.Properties.ContentMD5 = ""; sourceFile.SetProperties(); // File's ContentMD5 property is empty, download file and check its MD5 CommandAgent.Clear(); CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: true); result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidOperationExceptionFullQualifiedErrorId)); destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); // File's ContentMD5 property is empty, download file without check MD5. CommandAgent.Clear(); CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: false); result = CommandAgent.Invoke(); result.AssertNoResult(); destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); }
public void DownloadFileFromSubDirectoryOfRootTest() { CommandAgent.DownloadFile(this.fileShare, "../a", Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()), true); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidResourceFullQualifiedErrorId)); }