Ejemplo n.º 1
0
        internal static void UploadBlobs(string folderPath, string containerName, int fileNum, BlobType blobType)
        {
            Stopwatch       sw    = new Stopwatch();
            PowerShellAgent agent = new PowerShellAgent();

            agent.AddPipelineScript(string.Format("ls -File -Path {0}", folderPath));

            sw.Start();
            Test.Assert(agent.SetAzureStorageBlobContent(string.Empty, containerName, blobType), "upload multiple files should succeed");
            sw.Stop();

            Test.Info("file number : {0}, upload time(ms) : {1}", fileNum, sw.ElapsedMilliseconds);
        }
Ejemplo n.º 2
0
        internal static void RunBlobCmdlet(string operation, string srcContainer, string destContainer, int fileNum, BlobType blobType)
        {
            List <long> fileTimeList = new List <long>();

            Stopwatch sw = new Stopwatch();

            for (int j = 0; j < 5; j++)
            {
                destBlobHelper.CleanupContainer(destContainer);
                PowerShellAgent agent = new PowerShellAgent();
                sw.Reset();

                switch (operation)
                {
                case GetBlobs:
                    sw.Start();
                    Test.Assert(agent.GetAzureStorageBlob("*", srcContainer), "get blob list should succeed");
                    break;

                case StartCopyBlobs:
                    agent.AddPipelineScript(string.Format("Get-AzureStorageBlob -Container {0}", srcContainer));
                    sw.Start();
                    Test.Assert(agent.StartAzureStorageBlobCopy(string.Empty, string.Empty, destContainer, string.Empty, destContext: destStorageContext), "start copy blob should be successful");
                    break;

                case GetCopyBlobState:
                    PowerShellAgent.SetStorageContext(destConnectionString);
                    agent.AddPipelineScript(string.Format("Get-AzureStorageBlob -Container {0}", destContainer));
                    sw.Start();
                    Test.Assert(agent.GetAzureStorageBlobCopyState(string.Empty, string.Empty, false), "Get copy state should be success");
                    break;

                case StopCopyBlobs:
                    PowerShellAgent.SetStorageContext(destConnectionString);
                    agent.AddPipelineScript(String.Format("Get-AzureStorageBlob -Container {0}", destContainer));
                    sw.Start();
                    Test.Assert(agent.StopAzureStorageBlobCopy(string.Empty, string.Empty, "*", true), "Stop multiple copy operations using blob pipeline should be successful");
                    break;

                case RemoveBlobs:
                    agent.AddPipelineScript(string.Format("Get-AzureStorageBlob -Container {0}", srcContainer));
                    sw.Start();
                    Test.Assert(agent.RemoveAzureStorageBlob(string.Empty, string.Empty), "remove blob list should succeed");
                    break;

                default:
                    throw new Exception("unknown operation : " + operation);
                }

                sw.Stop();
                fileTimeList.Add(sw.ElapsedMilliseconds);

                // Verification for returned values
                switch (operation)
                {
                case GetBlobs:
                    Test.Assert(agent.Output.Count == fileNum, "{0} row returned : {1}", fileNum, agent.Output.Count);
                    // compare the blob entities
                    List <CloudBlob> blobList = new List <CloudBlob>();
                    srcBlobHelper.ListBlobs(srcContainer, out blobList);
                    agent.OutputValidation(blobList);
                    break;

                case StartCopyBlobs:
                    Test.Assert(agent.Output.Count == fileNum, "{0} row returned : {1}", fileNum, agent.Output.Count);
                    break;
                }

                // set srcConnectionString as default ConnectionString
                PowerShellAgent.SetStorageContext(srcConnectionString);

                Test.Info("file number : {0} round : {1} {2} time(ms) : {3}", fileNum, j + 1, operation, sw.ElapsedMilliseconds);
            }

            double average   = fileTimeList.Average();
            var    deviation = fileTimeList.Select(num => Math.Pow(num - average, 2));
            double sd        = Math.Sqrt(deviation.Average());

            fileNumTimes[operation].Add(fileNum, average);
            fileNumTimeSDs[operation].Add(fileNum, sd);

            Test.Info("file number : {0} average time : {1}", fileNum, average);
            Test.Info("file number : {0} standard dev : {1}", fileNum, sd);
        }