Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 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");
        }
Esempio n. 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;
        }
Esempio n. 5
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);
        }
Esempio n. 6
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));
        }
Esempio n. 7
0
        public static void MyClassInitialize(TestContext testContext)
        {
            TestBase.TestClassInitialize(testContext);

            //delete perf files
            Helper.DeletePattern("testfile_*");

            BlobHelper = new CloudBlobHelper(StorageAccount);
            FileHelper = new CloudFileHelper(StorageAccount);

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

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

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

            Trace.WriteLine("ClassInit");
        }
Esempio n. 8
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Trace.WriteLine("ClassInit");
            Test.FullClassName = testContext.FullyQualifiedTestClassName;

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

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

            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);
        }
Esempio n. 9
0
        internal void StorageContextTest(Agent agent)
        {
            PowerShellAgent psAgent            = (PowerShellAgent)agent;
            string          StorageAccountName = Test.Data.Get("StorageAccountName");
            string          StorageAccountKey  = Test.Data.Get("StorageAccountKey");
            string          StorageEndPoint    = Test.Data.Get("StorageEndPoint");

            Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> >();
            bool useHttps = true; //default protocol is https

            string[] endPoints = Utility.GetStorageEndPoints(StorageAccountName, useHttps, StorageEndPoint);
            comp.Add(new Dictionary <string, object> {
                { "StorageAccountName", StorageAccountName },
                { "BlobEndPoint", endPoints[0] },
                { "QueueEndPoint", endPoints[1] },
                { "TableEndPoint", endPoints[2] }
            });

            //--------------New operation--------------
            Test.Assert(psAgent.NewAzureStorageContext(StorageAccountName, StorageAccountKey, StorageEndPoint), Utility.GenComparisonData("NewAzureStorageContext", true));
            // Verification for returned values
            agent.OutputValidation(comp);
        }
Esempio n. 10
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
            Helper.GenerateMediumFile(BlockFilePath, 1);
            Helper.GenerateMediumFile(PageFilePath, 1);

            StorageBlobTest(agent, BlockFilePath, StorageBlob.BlobType.BlockBlob);
            StorageBlobTest(agent, PageFilePath, StorageBlob.BlobType.PageBlob);
        }
Esempio n. 11
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);
        }