示例#1
0
        private static void UploadFile(string localFile, TestDrop testDrop, bool retryOnFailure = true)
        {
            int uploadRetryCount = 0;

            do
            {
                try
                {
                    Logger.LogMessage("Uploading file {0} to blob.", Path.GetFileName(localFile));
                    CloudBlobContainer container = new CloudBlobContainer(testDrop.AccessData.DropContainerUrl, new StorageCredentialsSharedAccessSignature(testDrop.AccessData.SasKey));
                    CloudBlockBlob     blob      = container.GetBlockBlobReference(Path.GetFileName(localFile.ToLower()));
                    using (var fileStream = File.OpenRead(localFile))
                    {
                        blob.UploadFromStream(fileStream);
                    }

                    return;
                }
                catch
                {
                    if (uploadRetryCount < 3)
                    {
                        uploadRetryCount++;
                    }
                    else
                    {
                        throw;
                    }
                }
            } while (true);
        }
示例#2
0
        /// <summary>
        /// Uploads the load test files in the given directory to the test drop location.
        /// </summary>
        /// <param name="localDirectory">the local dir that contains the test source files</param>
        /// <param name="testDrop">test drop to which the file should be uploaded</param>
        public static void Upload(string localDirectory, TestDrop testDrop)
        {
            List <string> files = new List <string>();

            if (Directory.Exists(localDirectory))
            {
                files.AddRange(Directory.GetFiles(localDirectory).ToArray());
            }

            files.ForEach(file => UploadFile(file, testDrop));
        }
 public static TestDrop CreateTestDrop()
 {
     try
     {
         var testDrop = new TestDrop()
         {
             DropType = TestDropType
         };
         return(CltHttpClientWrapper.Post <TestDrop>("/_apis/clt/testdrops", GetStringContentForObject(testDrop)).Result);
     }
     catch (AggregateException aggregateException)
     {
         Exception innerException   = aggregateException.InnerException;
         string    exceptionMessage = "Test Drop Creation failed with the following error";
         while (innerException != null)
         {
             exceptionMessage = exceptionMessage + "\n\t" + innerException.Message;
             innerException   = innerException.InnerException;
         }
         throw new Exception(exceptionMessage);
     }
 }