Пример #1
0
        public void TestFileShareSnapshotsDest()
        {
            string failError1 = "Failed to validate destination";
            string failError2 = "Cannot perform this operation on a share representing a snapshot.";

            //Prepare Data
            string        snapshotFile   = "snapshotFile";
            DMLibDataInfo sourceDataInfo = new DMLibDataInfo(string.Empty);

            DMLibDataHelper.AddOneFile(sourceDataInfo.RootNode, snapshotFile, 1024);
            SourceAdaptor.GenerateData(sourceDataInfo);

            DMLibDataInfo DestDataInfo = new DMLibDataInfo(string.Empty);

            DestDataInfo.IsFileShareSnapshot = true;
            DestAdaptor.GenerateData(DestDataInfo);

            CloudBlobDirectory SourceObject = SourceAdaptor.GetTransferObject(sourceDataInfo.RootPath, sourceDataInfo.RootNode) as CloudBlobDirectory;
            CloudFileDirectory DestObject   = DestAdaptor.GetTransferObject(DestDataInfo.RootPath, DestDataInfo.RootNode) as CloudFileDirectory;

            // transfer File and failed with expected Error
            Task <TransferStatus> task = TransferManager.CopyDirectoryAsync(
                SourceObject,
                DestObject,
                DMLibTestContext.IsAsync,
                new CopyDirectoryOptions()
            {
                Recursive = true
            },
                new DirectoryTransferContext()
            {
                ShouldOverwriteCallbackAsync = TransferContext.ForceOverwrite
            });

            try
            {
                task.Wait(15 * 60 * 100);
            }
            catch (Exception e)
            {
                Test.Assert(e.InnerException.Message.Contains(failError1), "Tansfer Exception should contain:" + failError1);
                Test.Assert(e.InnerException.InnerException.Message.Contains(failError2), "Tansfer Exception should contain:" + failError2);
            }
        }
Пример #2
0
        public TestResult <DMLibDataInfo> ExecuteTestCase(DMLibDataInfo sourceDataInfo, TestExecutionOptions <DMLibDataInfo> options)
        {
            this.CleanupData();
            SourceAdaptor.CreateIfNotExists();
            DestAdaptor.CreateIfNotExists();

            if (sourceDataInfo != null)
            {
                SourceAdaptor.GenerateData(sourceDataInfo);
            }

            if (options.DestTransferDataInfo != null)
            {
                DestAdaptor.GenerateData(options.DestTransferDataInfo);
            }

            if (options.AfterDataPrepared != null)
            {
                options.AfterDataPrepared();
            }

            List <TransferItem> allItems = new List <TransferItem>();

            foreach (var fileNode in sourceDataInfo.EnumerateFileNodes())
            {
                TransferItem item = new TransferItem()
                {
                    SourceObject  = SourceAdaptor.GetTransferObject(fileNode),
                    DestObject    = DestAdaptor.GetTransferObject(fileNode),
                    SourceType    = DMLibTestContext.SourceType,
                    DestType      = DMLibTestContext.DestType,
                    IsServiceCopy = DMLibTestContext.IsAsync,
                };

                if (options.TransferItemModifier != null)
                {
                    options.TransferItemModifier(fileNode, item);
                }

                allItems.Add(item);
            }

            return(this.RunTransferItems(allItems, options));
        }
        public TestResult <DMLibDataInfo> ExecuteTestCase(DMLibDataInfo sourceDataInfo, TestExecutionOptions <DMLibDataInfo> options)
        {
            if (options.DisableSourceCleaner)
            {
                this.CleanupData(false, true);
            }
            else
            {
                this.CleanupData();
            }
            SourceAdaptor.CreateIfNotExists();
            DestAdaptor.CreateIfNotExists();

            string  sourceRootPath = string.Empty;
            DirNode sourceRootNode = new DirNode(string.Empty);

            if (sourceDataInfo != null)
            {
                sourceRootPath = sourceDataInfo.RootPath;
                sourceRootNode = sourceDataInfo.RootNode;
                if (!options.DisableSourceGenerator)
                {
                    SourceAdaptor.GenerateData(sourceDataInfo);
                }
            }

            string destRootPath = string.Empty;

            if (options.DestTransferDataInfo != null)
            {
                destRootPath = options.DestTransferDataInfo.RootPath;
                DestAdaptor.GenerateData(options.DestTransferDataInfo);
            }

            if (options.AfterDataPrepared != null)
            {
                options.AfterDataPrepared();
            }

            List <TransferItem> allItems = new List <TransferItem>();

            if (options.IsDirectoryTransfer)
            {
                TransferItem item = new TransferItem()
                {
                    SourceObject        = SourceAdaptor.GetTransferObject(sourceRootPath, sourceRootNode, options.SourceCredentials),
                    DestObject          = DestAdaptor.GetTransferObject(destRootPath, sourceRootNode, options.DestCredentials),
                    SourceType          = DMLibTestContext.SourceType,
                    DestType            = DMLibTestContext.DestType,
                    IsServiceCopy       = DMLibTestContext.IsAsync,
                    IsDirectoryTransfer = true,
                };

                if (options.TransferItemModifier != null)
                {
                    options.TransferItemModifier(null, item);
                }

                allItems.Add(item);
            }
            else
            {
                foreach (var fileNode in sourceDataInfo.EnumerateFileNodes())
                {
                    TransferItem item = new TransferItem()
                    {
                        SourceObject  = SourceAdaptor.GetTransferObject(sourceDataInfo.RootPath, fileNode, options.SourceCredentials),
                        DestObject    = DestAdaptor.GetTransferObject(destRootPath, fileNode, options.DestCredentials),
                        SourceType    = DMLibTestContext.SourceType,
                        DestType      = DMLibTestContext.DestType,
                        IsServiceCopy = DMLibTestContext.IsAsync,
                    };

                    if (options.TransferItemModifier != null)
                    {
                        options.TransferItemModifier(fileNode, item);
                    }

                    allItems.Add(item);
                }
            }

            return(this.RunTransferItems(allItems, options));
        }