예제 #1
0
        public static bool Equals(DMLibDataInfo infoA, DMLibDataInfo infoB)
        {
            bool result;

            bool aIsEmpty = infoA == null || infoA.RootNode.IsEmpty;
            bool bIsEmpty = infoB == null || infoB.RootNode.IsEmpty;

            if (aIsEmpty && bIsEmpty)
            {
                result = true;
            }
            else if (aIsEmpty || bIsEmpty)
            {
                result = false;
            }
            else
            {
                result = Equals(infoA.RootNode, infoB.RootNode);
            }

            if (!result)
            {
                Test.Info("-----Data Info A-----");
                MultiDirectionTestHelper.PrintTransferDataInfo(infoA);

                Test.Info("-----Data Info B-----");
                MultiDirectionTestHelper.PrintTransferDataInfo(infoB);
            }

            return(result);
        }
예제 #2
0
        public static void WaitUntilFileCreated(FileNode fileNode, DataAdaptor <DMLibDataInfo> dataAdaptor, DMLibDataType dataType, int timeoutInSec = 300)
        {
            Func <bool> checkFileCreated = null;

            if (dataType == DMLibDataType.Local)
            {
                string filePath = dataAdaptor.GetAddress() + fileNode.GetLocalRelativePath();
                checkFileCreated = () =>
                {
                    return(File.Exists(filePath));
                };
            }
            else if (dataType == DMLibDataType.PageBlob ||
                     dataType == DMLibDataType.AppendBlob)
            {
                CloudBlobDataAdaptor blobAdaptor = dataAdaptor as CloudBlobDataAdaptor;

                checkFileCreated = () =>
                {
                    CloudBlob cloudBlob = blobAdaptor.GetCloudBlobReference(fileNode);
                    return(cloudBlob.Exists(options: HelperConst.DefaultBlobOptions));
                };
            }
            else if (dataType == DMLibDataType.BlockBlob)
            {
                CloudBlobDataAdaptor blobAdaptor = dataAdaptor as CloudBlobDataAdaptor;

                checkFileCreated = () =>
                {
                    CloudBlockBlob blockBlob = blobAdaptor.GetCloudBlobReference(fileNode) as CloudBlockBlob;
                    try
                    {
                        return(blockBlob.DownloadBlockList(BlockListingFilter.All, options: HelperConst.DefaultBlobOptions).Any());
                    }
                    catch (StorageException)
                    {
                        return(false);
                    }
                };
            }
            else if (dataType == DMLibDataType.CloudFile)
            {
                CloudFileDataAdaptor fileAdaptor = dataAdaptor as CloudFileDataAdaptor;

                checkFileCreated = () =>
                {
                    CloudFile cloudFile = fileAdaptor.GetCloudFileReference(fileNode);
                    return(cloudFile.Exists(options: HelperConst.DefaultFileOptions));
                };
            }
            else
            {
                Test.Error("Unexpected data type: {0}", DMLibTestContext.SourceType);
            }

            MultiDirectionTestHelper.WaitUntil(checkFileCreated, timeoutInSec);
        }
        public static void Print()
        {
            Test.Info("-----Source Data-----");
            foreach (var sourceDataInfo in MultiDirectionTestInfo.GeneratedSourceDataInfos)
            {
                MultiDirectionTestHelper.PrintTransferDataInfo(sourceDataInfo);
            }

            Test.Info("-----Dest Data-----");
            foreach (var destDataInfo in MultiDirectionTestInfo.GeneratedDestDataInfos)
            {
                MultiDirectionTestHelper.PrintTransferDataInfo(destDataInfo);
            }
        }