示例#1
0
        public static void Run(string applicationName, Action <ApplicationManager> action)
        {
            var appManager = CreateApplication(applicationName);
            var dumpPath   = Path.Combine(PathHelper.TestResultsPath, applicationName, applicationName + ".zip");

            try
            {
                action(appManager);

                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);
            }
            catch (Exception ex)
            {
                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);

                Debug.WriteLine(ex.Message);

                var httpResponseEx = ex as HttpUnsuccessfulRequestException;
                if (httpResponseEx != null)
                {
                    Debug.WriteLine(httpResponseEx.ResponseMessage);
                }
                throw;
            }
            finally
            {
                appManager.Delete();
            }
        }
示例#2
0
        public static async Task RunNoCatch(string testName, Func <ApplicationManager, Task> action)
        {
            TestTracer.Trace("Running test - {0}", testName);

            var appManager = CreateApplication(KuduUtils.GetRandomWebsiteName(testName), testName);

            if (KuduUtils.ReuseSameSiteForAllTests)
            {
                // In site reuse mode, clean out the existing site so we start clean
                appManager.RepositoryManager.Delete(deleteWebRoot: true, ignoreErrors: true).Wait();

                // Make sure we start with the correct default file as some tests expect it
                WriteIndexHtml(appManager);
            }

            const string siteBuilderFactory = "SCM_SITE_BUILDER_FACTORY";

            if (KuduUtils.TestOriginalSiteBuilderFactory)
            {
                appManager.SettingsManager.SetValue(siteBuilderFactory, "original").Wait();
            }
            else
            {
                appManager.SettingsManager.Delete(siteBuilderFactory).Wait();
            }

            var dumpPath = Path.Combine(PathHelper.TestResultsPath, testName, testName + ".zip");

            try
            {
                using (StartLogStream(appManager))
                {
                    await action(appManager);
                }

                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);
            }
            catch (Exception ex)
            {
                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);

                TestTracer.Trace("Run failed with exception\n{0}", ex);

                throw;
            }
            finally
            {
                SafeTraceDeploymentLogs(appManager);

                // Delete the site at the end, unless we're in site reuse mode
                if (!KuduUtils.ReuseSameSiteForAllTests)
                {
                    appManager.Delete();
                }
            }
        }
示例#3
0
        public static async Task RunNoCatch(string testName, Func <ApplicationManager, Task> action)
        {
            TestTracer.Trace("Running test - {0}", testName);

            var appManager = await SitePool.CreateApplicationAsync();

            TestTracer.Trace("Using site - {0}", appManager.SiteUrl);

            var  dumpPath = Path.Combine(PathHelper.TestResultsPath, testName, testName + ".zip");
            bool success  = true;

            try
            {
                using (StartLogStream(appManager))
                {
                    await action(appManager);
                }

                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);
            }
            catch (Exception ex)
            {
                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);

                // if not stop on failure, kill w3wp before reusing this site
                if (!KuduUtils.StopAfterFirstTestFailure)
                {
                    TestTracer.Trace("Killing kudu site - {0}", appManager.SiteUrl);

                    KuduUtils.KillKuduProcess(appManager.ServiceUrl);
                }

                TestTracer.Trace("Run failed with exception\n{0}", ex);

                success = false;

                _testFailureOccurred = true;

                throw;
            }
            finally
            {
                SafeTraceDeploymentLogs(appManager);

                SitePool.ReportTestCompletion(appManager, success);
            }
        }
示例#4
0
        public static void Run(string applicationName, Action <ApplicationManager> action)
        {
            var appManager = CreateApplication(applicationName);
            var dumpPath   = Path.Combine(PathHelper.TestResultsPath, applicationName, applicationName + ".zip");

            try
            {
                action(appManager);

                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);

                appManager.Delete();
            }
            catch (Exception ex)
            {
                KuduUtils.DownloadDump(appManager.ServiceUrl, dumpPath);

                Debug.WriteLine(ex.Message);
                throw;
            }
        }