Пример #1
0
        public void UseInvalidAccount()
        {
            Agent agent = new PowerShellAgent();

            // Create an invalid account
            string StorageAccountKey = Test.Data.Get("StorageAccountKey");

            PowerShellAgent.SetStorageContext(INVALID_ACCOUNT_NAME, StorageAccountKey);

            //TODO The test is too large, need to split it into different tests
            StorageContainerTest(agent);

            StorageQueueTest(agent);
            StorageTableTest(agent);

            string BlockFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
            string PageFilePath  = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());

            FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(BlockFilePath));
            FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(PageFilePath));
            // Generate block file and page file which are used for uploading
            FileUtil.GenerateMediumFile(BlockFilePath, 1);
            FileUtil.GenerateMediumFile(PageFilePath, 1);

            StorageBlobTest(agent, BlockFilePath, StorageBlob.BlobType.BlockBlob);
            StorageBlobTest(agent, PageFilePath, StorageBlob.BlobType.PageBlob);
        }
Пример #2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Trace.WriteLine("ClassInit");
            Test.FullClassName = testContext.FullyQualifiedTestClassName;

            StorageAccount = TestBase.GetCloudStorageAccountFromConfig();

            //init the blob helper for blob related operations
            BlobHelper = new CloudBlobHelper(StorageAccount);

            // import module
            string moduleFilePath = Test.Data.Get("ModuleFilePath");

            if (moduleFilePath.Length > 0)
            {
                PowerShellAgent.ImportModule(moduleFilePath);
            }

            // $context = New-AzureStorageContext -ConnectionString ...
            PowerShellAgent.SetStorageContext(StorageAccount.ToString(true));

            BlockFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
            PageFilePath  = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
            FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(BlockFilePath));
            FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(PageFilePath));

            // Generate block file and page file which are used for uploading
            Helper.GenerateMediumFile(BlockFilePath, 1);
            Helper.GenerateMediumFile(PageFilePath, 1);
        }
Пример #3
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Test.FullClassName = testContext.FullyQualifiedTestClassName;

            srcConnectionString  = Test.Data.Get("StorageConnectionString");
            destConnectionString = Test.Data.Get("StorageConnectionString2");
            srcBlobHelper        = new CloudBlobHelper(CloudStorageAccount.Parse(srcConnectionString));
            destBlobHelper       = new CloudBlobHelper(CloudStorageAccount.Parse(destConnectionString));

            destStorageContext = PowerShellAgent.GetStorageContext(destConnectionString);

            FolderName = Test.Data.Get("FolderName");

            //delete perf files
            Helper.DeletePattern(FolderName + "_*");

            // import module
            PowerShellAgent.ImportModules(Constants.ServiceModulePaths);

            //set the default storage context
            PowerShellAgent.SetStorageContext(srcConnectionString);

            //set the ConcurrentTaskCount field
            PowerShellAgent.ConcurrentTaskCount = Environment.ProcessorCount * 8;

            // initialize the dictionary for saving perf data
            foreach (string operation in operations)
            {
                fileNumTimes.Add(operation, new Dictionary <int, double>());
                fileNumTimeSDs.Add(operation, new Dictionary <int, double>());
            }

            Trace.WriteLine("ClassInit");
        }
Пример #4
0
        public static void ClassInit(TestContext testContext)
        {
            TestBase.TestClassInitialize(testContext);

            // import module
            PowerShellAgent.ImportModules(Constants.ServiceModulePaths);

            //set the default storage context
            PowerShellAgent.SetStorageContext(StorageAccount.ToString(true));

            //set the ConcurrentTaskCount field
            PowerShellAgent.ConcurrentTaskCount = Environment.ProcessorCount * 8;
        }
Пример #5
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Trace.WriteLine("ClassInit");
            Test.FullClassName = testContext.FullyQualifiedTestClassName;

            _StorageAccount = TestBase.GetCloudStorageAccountFromConfig();

            // import module
            string moduleFilePath = Test.Data.Get("ModuleFilePath");

            if (moduleFilePath.Length > 0)
            {
                PowerShellAgent.ImportModule(moduleFilePath);
            }

            // $context = New-AzureStorageContext -ConnectionString ...
            PowerShellAgent.SetStorageContext(_StorageAccount.ToString(true));
        }
Пример #6
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);
        }