public void FilePattern_CloudBlob_Prefix_2()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "TeSTfIle"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, "TeSTfIle");
        }
        public void FilePattern_Local_FilePath_1()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder1", "4testfile"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(true, expectedResult, "folder1\\subfolder1\\4testfile");
        }
        public void FilePattern_CloudFile_Unicode_2()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder2", "测试四文件"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, "folder2/测试四文件");
        }
コード例 #4
0
        public void TransferBigSizeObject()
        {
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);
            DMLibDataHelper.AddMultipleFilesBigSize(sourceDataInfo.RootNode, DMLibTestBase.FileName);

            var result = this.ExecuteTestCase(sourceDataInfo, new TestExecutionOptions<DMLibDataInfo>());

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
        }
        public void FilePattern_Local_WildChar_4()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testXfile"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, "test?file");
        }
        public void FilePattern_Local_FilePath_3()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "f_arbitrary.exe"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, FormalizeSearchPattern("folder1\\subfolder2\\f_arbitrary.exe"));
        }
        public void FilePattern_CloudFile_FilePath_2()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "TestFile2"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, FormalizeSearchPattern("folder1\\TestFile2"));
        }
        public void FilePattern_Local_DoubleDotValid_3()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "..a123"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult, "..*");
        }
コード例 #9
0
        public void DummyDirectoryBlobDownload()
        {
            Dictionary <string, string> metadata = new Dictionary <string, string>();

            metadata.Add(Constants.DirectoryBlobMetadataKey, "true");

            Test.Info("Metadata is =====================");
            foreach (var keyValue in metadata)
            {
                Test.Info("name:{0}  value:{1}", keyValue.Key, keyValue.Value);
            }

            DMLibDataInfo sourceDataInfo  = new DMLibDataInfo(string.Empty);
            FileNode      dummyFolderNode = new FileNode(DMLibTestBase.FileName)
            {
                SizeInByte = 0L,
                Metadata   = metadata
            };

            DirNode  dirNode    = new DirNode(DMLibTestBase.FileName);
            FileNode actualFile = new FileNode(DMLibTestBase.FileName)
            {
                SizeInByte = DMLibTestBase.FileSizeInKB * 1024L,
            };

            dirNode.AddFileNode(actualFile);

            sourceDataInfo.RootNode.AddFileNode(dummyFolderNode);
            sourceDataInfo.RootNode.AddDirNode(dirNode);

            DMLibDataInfo destDataInfo = new DMLibDataInfo(string.Empty);

            var options = new TestExecutionOptions <DMLibDataInfo>();

            options.DestTransferDataInfo    = destDataInfo;
            options.DisableDestinationFetch = true;
            options.IsDirectoryTransfer     = true;
            options.TransferItemModifier    = (fileNode, transferItem) =>
            {
                dynamic transferOptions = DefaultTransferDirectoryOptions;
                transferOptions.Recursive = true;
                transferItem.Options      = transferOptions;
            };

            var result = this.ExecuteTestCase(sourceDataInfo, options);

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");

            DataAdaptor <DMLibDataInfo> destAdaptor = GetDestAdaptor(DMLibDataType.Local);

            destDataInfo = destAdaptor.GetTransferDataInfo(destDataInfo.RootPath);
            sourceDataInfo.RootNode.DeleteFileNode(DMLibTestBase.FileName);

            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, destDataInfo), "Verify transfer result.");
        }
コード例 #10
0
        public static string DetailedInfo(this DMLibDataInfo dataInfo)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(string.Format("TransferDataInfo root: {0}", dataInfo.RootPath));

            foreach (FileNode fileNode in dataInfo.EnumerateFileNodes())
            {
                builder.AppendLine(fileNode.DetailedInfo());
            }

            return(builder.ToString());
        }
コード例 #11
0
        private static DMLibDataInfo GetSourceDataInfo(string key)
        {
            DMLibDataInfo result;

            if (!sourceDataInfos.ContainsKey(key))
            {
                result = new DMLibDataInfo(string.Empty);

                sourceDataInfos.Add(key, result);
            }

            return(sourceDataInfos[key]);
        }
コード例 #12
0
        public void FollowSymlink_1_BrokenSymlink()
        {
#if DNXCORE50
            if (!CrossPlatformHelpers.IsLinux)
            {
                return;
            }

            DMLibDataInfo sourceDataInfo = new DMLibDataInfo("rootfolder");

            var dirNode = new DirNode($"{UnicodeFileName}{FolderSuffix}");
            dirNode.AddFileNode(new FileNode($"{UnicodeFileName}{FileSuffix}")
            {
                SizeInByte = 1024
            });

            sourceDataInfo.RootNode.AddDirNode(dirNode);
            sourceDataInfo.RootNode.AddDirNode(DirNode.SymlinkedDir($"{UnicodeFileName}{SymlinkSuffix}", dirNode.Name, dirNode));
            dirNode = new DirNode($"{UnicodeFileName}{FolderSuffix}_1");
            sourceDataInfo.RootNode.AddDirNode(DirNode.SymlinkedDir($"{UnicodeFileName}{SymlinkSuffix}_1", dirNode.Name, dirNode));

            SourceAdaptor.GenerateData(sourceDataInfo);

            sourceDataInfo.RootNode.DeleteDirNode($"{UnicodeFileName}{SymlinkSuffix}_1");

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                IsDirectoryTransfer    = true,
                DisableSourceGenerator = true,
                DisableSourceCleaner   = true,
                TransferItemModifier   = (notUsed, item) =>
                {
                    dynamic transferOptions = DefaultTransferDirectoryOptions;
                    transferOptions.Recursive = true;
                    (transferOptions as UploadDirectoryOptions).FollowSymlink = true;
                    item.Options = transferOptions;
                },
            };

            var result = this.ExecuteTestCase(sourceDataInfo, options);

            // For sync copy, recalculate md5 of destination by downloading the file to local.
            if (IsCloudService(DMLibTestContext.DestType) && (DMLibTestContext.CopyMethod != DMLibCopyMethod.ServiceSideAsyncCopy))
            {
                DMLibDataHelper.SetCalculatedFileMD5(result.DataInfo, DestAdaptor);
            }

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
#endif
        }
コード例 #13
0
        public void FollowSymlink_DeadLoop_2()
        {
#if DNXCORE50
            if (!CrossPlatformHelpers.IsLinux)
            {
                return;
            }
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo("rootfolder");
            DMLibDataInfo targetDataInfo = new DMLibDataInfo("targetC");

            DirNode dirNodeC = new DirNode("folder_C");
            DirNode dirNodeB = new DirNode("folder_B");
            dirNodeB.AddFileNode(new FileNode("File_B")
            {
                SizeInByte = 1024
            });

            dirNodeC.AddDirNode(dirNodeB);
            dirNodeB.AddDirNode(DirNode.SymlinkedDir("symlinkToC", "../../folder_C", dirNodeC));
            targetDataInfo.RootNode.AddDirNode(dirNodeC);

            SourceAdaptor.CreateIfNotExists();
            SourceAdaptor.GenerateData(targetDataInfo);

            sourceDataInfo.RootNode.AddDirNode(DirNode.SymlinkedDir("symlinkToB", "../targetC/folder_C/folder_B", dirNodeB));

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                IsDirectoryTransfer  = true,
                TransferItemModifier = (notUsed, item) =>
                {
                    dynamic transferOptions = DefaultTransferDirectoryOptions;
                    transferOptions.Recursive = true;
                    (transferOptions as UploadDirectoryOptions).FollowSymlink = true;
                    item.Options = transferOptions;
                },
                DisableSourceCleaner = true,
            };

            // This case may takes very long time.
            options.TimeoutInMs = 60 * 60 * 1000;

            var result = this.ExecuteTestCase(sourceDataInfo, options);
            foreach (var exception in result.Exceptions)
            {
                Test.Info(exception.Message);
            }

            Test.Assert(result.Exceptions.Count == 1 && result.Exceptions[0] is TransferException && result.Exceptions[0].InnerException.Message.Contains("Too many levels of symbolic links"), "Verify expected exception is thrown.");
#endif
        }
        public void FilePattern_CloudBlob_Prefix_3()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "subfolder4", "test5"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "TESTFILE345"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "testYfile"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "f_arbitrary.exe"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder2", "测试x文件"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(true, expectedResult, "folder1/subfolder2");
        }
コード例 #15
0
        public void Upload_Symlinked_RootDir()
        {
#if DNXCORE50
            if (!CrossPlatformHelpers.IsLinux)
            {
                return;
            }
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo("");
            DMLibDataInfo targetDataInfo = new DMLibDataInfo("target");
            UnicodeFileName = "TempTestName";

            DirNode dirNode = new DirNode($"{UnicodeFileName}{FolderSuffix}");
            dirNode.AddFileNode(new FileNode($"{UnicodeFileName}{FileSuffix}")
            {
                SizeInByte = 1024
            });

            targetDataInfo.RootNode.AddDirNode(dirNode);

            SourceAdaptor.CreateIfNotExists();
            DestAdaptor.CreateIfNotExists();

            SourceAdaptor.GenerateData(targetDataInfo);
            sourceDataInfo.RootNode = DirNode.SymlinkedDir($"{UnicodeFileName}{SymlinkSuffix}", "target", targetDataInfo.RootNode);
            SourceAdaptor.GenerateData(sourceDataInfo);

            TransferItem item = new TransferItem()
            {
                SourceObject        = Path.Combine(SourceAdaptor.GetTransferObject(sourceDataInfo.RootPath, sourceDataInfo.RootNode) as string, sourceDataInfo.RootNode.Name),
                DestObject          = DestAdaptor.GetTransferObject(sourceDataInfo.RootPath, sourceDataInfo.RootNode),
                IsDirectoryTransfer = true,
                SourceType          = DMLibTestContext.SourceType,
                DestType            = DMLibTestContext.DestType,
                CopyMethod          = DMLibTestContext.CopyMethod.ToCopyMethod(),
                TransferContext     = new DirectoryTransferContext(),
                Options             = DefaultTransferDirectoryOptions
            };

            (item.Options as UploadDirectoryOptions).Recursive = true;

            var result = this.RunTransferItems(new List <TransferItem>()
            {
                item
            }, new TestExecutionOptions <DMLibDataInfo>());

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
#endif
        }
コード例 #16
0
        public void TransferDifferentSizeObject()
        {
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);

            DMLibDataHelper.AddMultipleFilesNormalSize(sourceDataInfo.RootNode, BVT.UnicodeFileName);

            var options = new TestExecutionOptions <DMLibDataInfo>();

            options.AfterDataPrepared = () =>
            {
                if ((DMLibTestContext.SourceType == DMLibDataType.CloudFile || DMLibTestContext.SourceType == DMLibDataType.PageBlob) &&
                    !DMLibTestContext.IsAsync)
                {
                    string sparseFileName = "SparseFile";

                    DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, sparseFileName, 1);
                    FileNode sparseFileNode = sourceDataInfo.RootNode.GetFileNode(sparseFileName);

                    if (DMLibTestContext.SourceType == DMLibDataType.CloudFile)
                    {
                        CloudFileDataAdaptor cloudFileDataAdaptor = SourceAdaptor as CloudFileDataAdaptor;
                        CloudFile            sparseCloudFile      = cloudFileDataAdaptor.GetCloudFileReference(sourceDataInfo.RootPath, sparseFileNode);
                        this.PrepareCloudFileWithDifferentSizeRange(sparseCloudFile);
                        sparseFileNode.MD5      = sparseCloudFile.Properties.ContentMD5;
                        sparseFileNode.Metadata = sparseCloudFile.Metadata;
                    }
                    else if (DMLibTestContext.SourceType == DMLibDataType.PageBlob)
                    {
                        CloudBlobDataAdaptor cloudBlobDataAdaptor = SourceAdaptor as CloudBlobDataAdaptor;
                        CloudPageBlob        sparsePageBlob       = cloudBlobDataAdaptor.GetCloudBlobReference(sourceDataInfo.RootPath, sparseFileNode) as CloudPageBlob;
                        this.PreparePageBlobWithDifferenSizePage(sparsePageBlob);
                        sparseFileNode.MD5      = sparsePageBlob.Properties.ContentMD5;
                        sparseFileNode.Metadata = sparsePageBlob.Metadata;
                    }
                }
            };

            var result = this.ExecuteTestCase(sourceDataInfo, options);

            // For sync copy, recalculate md5 of destination by downloading the file to local.
            if (IsCloudService(DMLibTestContext.DestType) && !DMLibTestContext.IsAsync)
            {
                DMLibDataHelper.SetCalculatedFileMD5(result.DataInfo, DestAdaptor);
            }

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
        }
        public void FilePattern_Local_NoPattern_2()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile1"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile2"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testXfile"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testXXfile"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "测试文件"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "..a123"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(false, expectedResult);
        }
コード例 #18
0
        public void FollowSymlink_Random_SymlinkDir_OnSameLevel()
        {
#if DNXCORE50
            if (!CrossPlatformHelpers.IsLinux)
            {
                return;
            }
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo("rootfolder");

            int level = random.Next(2, 40);

            for (int i = 0; i < level; ++i)
            {
                var dirNode = new DirNode($"{UnicodeFileName}{FolderSuffix}_{i}");
                dirNode.AddFileNode(new FileNode($"{UnicodeFileName}{FileSuffix}")
                {
                    SizeInByte = 1024
                });

                sourceDataInfo.RootNode.AddDirNode(dirNode);
                sourceDataInfo.RootNode.AddDirNode(DirNode.SymlinkedDir($"{UnicodeFileName}{SymlinkSuffix}_{i}", dirNode.Name, dirNode));
            }

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                IsDirectoryTransfer  = true,
                TransferItemModifier = (notUsed, item) =>
                {
                    dynamic transferOptions = DefaultTransferDirectoryOptions;
                    transferOptions.Recursive = true;
                    (transferOptions as UploadDirectoryOptions).FollowSymlink = true;
                    item.Options = transferOptions;
                },
            };

            var result = this.ExecuteTestCase(sourceDataInfo, options);

            // For sync copy, recalculate md5 of destination by downloading the file to local.
            if (IsCloudService(DMLibTestContext.DestType) && !DMLibTestContext.IsAsync)
            {
                DMLibDataHelper.SetCalculatedFileMD5(result.DataInfo, DestAdaptor);
            }

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
#endif
        }
コード例 #19
0
        private static void PrepareSingleObjectSourceData(long fileSizeInB)
        {
            foreach (DMLibTransferDirection direction in GetAllValidDirections())
            {
                string fileName          = GetTransferFileName(direction);
                string sourceDataInfoKey = GetSourceDataInfoKey(direction);

                DMLibDataInfo sourceDataInfo = GetSourceDataInfo(sourceDataInfoKey);

                DMLibDataHelper.AddOneFileInBytes(sourceDataInfo.RootNode, fileName, fileSizeInB);

                FileNode sourceFileNode = sourceDataInfo.RootNode.GetFileNode(fileName);
                singleObjectNodes.Add(fileName, sourceFileNode);

                expectedFileNodes.Add(fileName, sourceFileNode);
            }
        }
        private void TestSearchPattern(bool recursive, DMLibDataInfo expectedResult, string searchPattern = null)
        {
            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                IsDirectoryTransfer  = true,
                TransferItemModifier = (notUsed, item) =>
                {
                    dynamic transferOptions = DefaultTransferDirectoryOptions;
                    transferOptions.Recursive     = recursive;
                    transferOptions.SearchPattern = searchPattern;
                    item.Options = transferOptions;
                },
            };

            var testResult = this.ExecuteTestCase(null, options);

            VerificationHelper.VerifyTransferSucceed(testResult, expectedResult);
        }
        public void FilePattern_Local_WildChar_2()
        {
            HashSet <FileNode> nodesToKeep    = new HashSet <FileNode>();
            DMLibDataInfo      expectedResult = SourceDataInfo.Clone();

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "subfolder1", "testfile2"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "testfile1"));
            if (CrossPlatformHelpers.IsWindows)
            {
                nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "folder1", "TestFile2"));
                nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile"));
            }

            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile1"));
            nodesToKeep.Add(DMLibDataHelper.GetFileNode(expectedResult.RootNode, "testfile2"));
            DMLibDataHelper.RemoveAllFileNodesExcept(expectedResult.RootNode, nodesToKeep);

            this.TestSearchPattern(true, expectedResult, "testfile?");
        }
コード例 #22
0
        public void FollowSymlink_Random_Levels_SymlinkDir()
        {
#if DNXCORE50
            if (!CrossPlatformHelpers.IsLinux)
            {
                return;
            }
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo("rootfolder");

            int level = random.Next(2, 40);

            Test.Info($"Testing {level} levels of symlinked dirs");

            BuildDeepSymlinkDir(sourceDataInfo.RootNode, sourceDataInfo.RootNode, level);

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                IsDirectoryTransfer  = true,
                TransferItemModifier = (notUsed, item) =>
                {
                    dynamic transferOptions = DefaultTransferDirectoryOptions;
                    transferOptions.Recursive = true;
                    (transferOptions as UploadDirectoryOptions).FollowSymlink = true;
                    item.Options = transferOptions;
                },
            };

            // This case may takes very long time.
            options.TimeoutInMs = 60 * 60 * 1000;

            var result = this.ExecuteTestCase(sourceDataInfo, options);

            // For sync copy, recalculate md5 of destination by downloading the file to local.
            if (IsCloudService(DMLibTestContext.DestType) && (DMLibTestContext.CopyMethod != DMLibCopyMethod.ServiceSideAsyncCopy))
            {
                DMLibDataHelper.SetCalculatedFileMD5(result.DataInfo, DestAdaptor);
            }

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
#endif
        }
コード例 #23
0
        private static void PrepareDirSourceData(long fileSizeInB)
        {
            foreach (DMLibTransferDirection direction in GetAllDirectoryValidDirections())
            {
                string dirName           = GetTransferDirName(direction);
                string fileName          = dirName;
                string sourceDataInfoKey = GetSourceDataInfoKey(direction);

                DMLibDataInfo sourceDataInfo = GetSourceDataInfo(sourceDataInfoKey);

                DirNode subDirNode = new DirNode(dirName);
                DMLibDataHelper.AddOneFileInBytes(subDirNode, fileName, fileSizeInB);

                sourceDataInfo.RootNode.AddDirNode(subDirNode);

                directoryNodes.Add(dirName, subDirNode);

                expectedFileNodes.Add(fileName, subDirNode.GetFileNode(fileName));
            }
        }
        public void TransferInAllDirections()
        {
            List <TransferItem> allItems = AllTransferDirectionTest.GetTransformItemsForAllDirections(resume: false);

            // Execution
            var result = this.RunTransferItems(allItems, new TestExecutionOptions <DMLibDataInfo>());

            // Verify all files are transfered successfully
            Test.Assert(result.Exceptions.Count == 0, "Verify no exception occurs.");
            foreach (DMLibDataType destDataType in DataTypes)
            {
                DataAdaptor <DMLibDataInfo> destAdaptor = GetSourceAdaptor(destDataType);
                DMLibDataInfo destDataInfo = destAdaptor.GetTransferDataInfo(string.Empty);

                foreach (FileNode destFileNode in destDataInfo.EnumerateFileNodes())
                {
                    FileNode sourceFileNode = expectedFileNodes[destFileNode.Name];
                    Test.Assert(DMLibDataHelper.Equals(sourceFileNode, destFileNode), "Verify transfer result.");
                }
            }
        }
コード例 #25
0
        public void ToLbb_100MBBlockSizeAndSmallFiles()
        {
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);

            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName, 300 * 1024); // 300MB

            for (int i = 0; i < 10; i++)
            {
                DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + i, i);
            }

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                BlockSize = 100 * 1024 * 1024 // 100MB
            };
            var result = this.ExecuteTestCase(sourceDataInfo, options);

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
            this.ValidateDestinationMD5ByDownloading(result.DataInfo, options);
        }
コード例 #26
0
        public static void SetCalculatedFileMD5(DMLibDataInfo dataInfo, DataAdaptor <DMLibDataInfo> destAdaptor, bool disableMD5Check = false)
        {
            foreach (FileNode fileNode in dataInfo.EnumerateFileNodes())
            {
                if (DMLibTestBase.IsCloudBlob(DMLibTestContext.DestType))
                {
                    CloudBlobDataAdaptor cloudBlobDataAdaptor = destAdaptor as CloudBlobDataAdaptor;
                    CloudBlob            cloudBlob            = cloudBlobDataAdaptor.GetCloudBlobReference(fileNode);

                    fileNode.MD5 = CloudBlobHelper.CalculateMD5ByDownloading(cloudBlob, disableMD5Check);
                }
                else if (DMLibTestContext.DestType == DMLibDataType.CloudFile)
                {
                    CloudFileDataAdaptor cloudFileDataAdaptor = destAdaptor as CloudFileDataAdaptor;
                    CloudFile            cloudFile            = cloudFileDataAdaptor.GetCloudFileReference(fileNode);

                    fileNode.MD5 = CloudFileHelper.CalculateMD5ByDownloading(cloudFile, disableMD5Check);
                }

                // No need to set md5 for local destination
            }
        }
コード例 #27
0
        public void ToLbb_16MBBlockSizeAndSmallFiles()
        {
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);

            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + 36 + "MB", 36 * 1024); // 36MB, should use 16MB block size, PutBlock and PutBlockList
            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + 16 + "MB", 16 * 1024); // 16MB, should use 16MB block size, PutBlob
            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + 14 + "MB", 14 * 1024); // 14MB, should use 16MB block size, PutBlob
            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + 8 + "MB", 8 * 1024);   // 8MB, should use 8MB block size, PutBlob

            for (int i = 0; i < 2; i++)
            {
                DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, DMLibTestBase.FileName + "_" + i, i); // 0 and 1KB file
            }

            var options = new TestExecutionOptions <DMLibDataInfo>()
            {
                BlockSize = 16 * 1024 * 1024 // 16MB
            };
            var result = this.ExecuteTestCase(sourceDataInfo, options);

            Test.Assert(result.Exceptions.Count == 0, "Verify no exception is thrown.");
            Test.Assert(DMLibDataHelper.Equals(sourceDataInfo, result.DataInfo), "Verify transfer result.");
            this.ValidateDestinationMD5ByDownloading(result.DataInfo, options);
        }
        private static void PrepareData(SourceOrDest sourceOrDest, DMLibDataType dataType, DMLibDataInfo dataInfo)
        {
            var dataInfos = GetDataInfos(sourceOrDest);

            CleanupData(sourceOrDest, dataType);

            if (SourceOrDest.Source == sourceOrDest)
            {
                GetSourceAdaptor(dataType).GenerateData(dataInfo);
                SetSourceDataInfo(dataType, dataInfo);
            }
            else
            {
                GetDestAdaptor(dataType).GenerateData(dataInfo);
                SetDestDataInfo(dataType, dataInfo);
            }
        }
 protected static void SetDestDataInfo(DMLibDataType dataType, DMLibDataInfo dataInfo)
 {
     destDataInfos[dataType.ToString()] = dataInfo;
 }
 protected static void SetSourceDataInfo(DMLibDataType dataType, DMLibDataInfo dataInfo)
 {
     sourceDataInfos[dataType.ToString()] = dataInfo;
 }