private void TestPublishToWebSite(
            string templateName,
            string projectName,
            string moduleName,
            string textInResponse,
            string pythonVersion,
            int publishTimeout,
            string packageName = null
            )
        {
            using (var app = new VisualStudioApp()) {
                var pyProj = app.CreateProject(
                    PythonVisualStudioApp.TemplateLanguageName,
                    templateName,
                    TestData.GetTempPath(),
                    projectName
                    ).GetPythonProject();

                var factory = WebProjectTests.CreateVirtualEnvironment(pythonVersion, app, pyProj);

                WebProjectTests.InstallWebFramework(app, moduleName, packageName ?? moduleName, factory);

                _webSiteToDelete = Guid.NewGuid().ToString("N");
                var siteUri = app.PublishToAzureWebSite(_webSiteToDelete, publishSettingsFilePath);
                app.WaitForBuildComplete(publishTimeout);

                string text = WebDownloadUtility.GetString(siteUri);

                Console.WriteLine("Response from {0}", siteUri);
                Console.WriteLine(text);
                Assert.IsTrue(text.Contains(textInResponse), text);
            }
        }
示例#2
0
        private void TestPublishToWebSite(
            string languageName,
            string templateName,
            string projectName,
            string expectedProjectItem,
            string textInResponse,
            int publishTimeout
            )
        {
            using (var app = new VisualStudioApp()) {
                CreateProject(
                    app,
                    languageName,
                    templateName,
                    TestData.GetTempPath(),
                    projectName,
                    expectedProjectItem
                    );

                _webSiteToDelete = Guid.NewGuid().ToString("N");
                var siteUri = app.PublishToAzureWebSite(_webSiteToDelete, publishSettingsFilePath);
                app.WaitForBuildComplete(publishTimeout);

                string text = WebDownloadUtility.GetString(siteUri);
                Console.WriteLine("Response from {0}", siteUri);
                Console.WriteLine(text);
                Assert.IsTrue(text.Contains(textInResponse), text);
            }
        }
示例#3
0
        private static void LaunchAndVerifyDebug(VisualStudioApp app, int port, string textInResponse)
        {
            EndToEndLog("Building");
            app.Dte.Solution.SolutionBuild.Build(true);
            EndToEndLog("Starting debugging");
            if (!System.Threading.Tasks.Task.Run(() => app.Dte.Debugger.Go(false)).Wait(TimeSpan.FromSeconds(10)))
            {
                Assert.Fail("Run was interrupted by dialog");
            }
            EndToEndLog("Debugging started");

            string text = string.Empty;
            int    retries;

            try {
                for (retries = 100;
                     retries > 0 &&
                     (app.Dte.Debugger.CurrentMode != EnvDTE.dbgDebugMode.dbgRunMode ||
                      !IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().Any(p => p.Port == port));
                     --retries)
                {
                    Thread.Sleep(300);
                }

                if (retries > 0)
                {
                    EndToEndLog("Active at http://localhost:{0}/", port);
                }
                else
                {
                    EndToEndLog("Timed out waiting for http://localhost:{0}/", port);
                }
                text = WebDownloadUtility.GetString(new Uri(string.Format("http://localhost:{0}/", port)));
            } finally {
                app.Dte.Debugger.Stop();
            }

            EndToEndLog("Response from http://localhost:{0}/", port);
            EndToEndLog(text);
            Assert.IsTrue(text.Contains(textInResponse), text);

            for (retries = 20;
                 retries > 0 &&
                 (app.Dte.Debugger.CurrentMode != EnvDTE.dbgDebugMode.dbgRunMode ||
                  !IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().All(p => p.Port != port));
                 --retries)
            {
                Thread.Sleep(500);
            }
            if (retries > 0)
            {
                EndToEndLog("Debugging stopped");
            }
            else
            {
                EndToEndLog("Timed out waiting for debugging to stop");
            }
        }
示例#4
0
        private static void LaunchAndVerifyNoDebug(
            VisualStudioApp app,
            int port,
            string textInResponse
            )
        {
            bool   prevNormal = true, prevAbnormal = true;
            string text;
            int    retries;

            try {
                using (var processes = new ProcessScope("python")) {
                    EndToEndLog("Transitioning to UI thread to build");
                    app.ServiceProvider.GetUIThread().Invoke(() => {
                        EndToEndLog("Building");
                        app.Dte.Solution.SolutionBuild.Build(true);
                        EndToEndLog("Build output: {0}", app.GetOutputWindowText("Build"));
                        EndToEndLog("Updating settings");
                        prevNormal   = app.GetService <PythonToolsService>().DebuggerOptions.WaitOnNormalExit;
                        prevAbnormal = app.GetService <PythonToolsService>().DebuggerOptions.WaitOnAbnormalExit;
                        app.GetService <PythonToolsService>().DebuggerOptions.WaitOnNormalExit   = false;
                        app.GetService <PythonToolsService>().DebuggerOptions.WaitOnAbnormalExit = false;

                        EndToEndLog("Starting running");
                        app.Dte.Solution.SolutionBuild.Run();
                        EndToEndLog("Running");
                    });

                    var newProcesses = processes.WaitForNewProcess(TimeSpan.FromSeconds(30)).ToList();
                    Assert.IsTrue(newProcesses.Any(), "Did not find new Python process");
                    EndToEndLog("Found new processes with IDs {0}", string.Join(", ", newProcesses.Select(p => p.Id.ToString())));

                    for (retries = 100;
                         retries > 0 &&
                         !IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().Any(p => p.Port == port);
                         --retries)
                    {
                        Thread.Sleep(300);
                    }
                    EndToEndLog("Active at http://localhost:{0}/", port);

                    text = WebDownloadUtility.GetString(new Uri(string.Format("http://localhost:{0}/", port)));
                }
            } finally {
                app.ServiceProvider.GetUIThread().Invoke(() => {
                    app.GetService <PythonToolsService>().DebuggerOptions.WaitOnNormalExit   = prevNormal;
                    app.GetService <PythonToolsService>().DebuggerOptions.WaitOnAbnormalExit = prevAbnormal;
                });
            }

            EndToEndLog("Response from http://localhost:{0}/", port);
            EndToEndLog(text);
            Assert.IsTrue(text.Contains(textInResponse), text);

            for (retries = 20;
                 retries > 0 && !IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().All(p => p.Port != port);
                 --retries)
            {
                Thread.Sleep(500);
            }
            if (retries > 0)
            {
                EndToEndLog("Process ended");
            }
            else
            {
                EndToEndLog("Timed out waiting for process to exit");
            }
        }