Ejemplo n.º 1
0
        public DeployTest()
        {
            //if (!RunningAsAdmin())
            //{
            //    Assert.Inconclusive("Cannot Run Test: The Orleans deployment PowerShell scripts require Visual Studio to be run with elevated privileges.");
            //}

            // If the test does have elevated permission, make sure that it can run PowerShell scripts.
            Collection <PSObject> results = RunPowerShellCommand("Get-ExecutionPolicy");

            oldExecutionPolicy = results[0].ToString();
            if (string.Compare(oldExecutionPolicy, "restricted", true) == 0)
            {
                if (RunningAsAdmin())
                {
                    RunPowerShellCommand("Set-ExecutionPolicy RemoteSigned -Force -Scope LocalMachine");
                }
                else
                {
                    Assert.Inconclusive("Cannot Run Test: The Orleans deployment PowerShell scripts require ExecutionPolicy be set to RemoteSigned.");
                }
            }

            preTestFolder = Environment.CurrentDirectory;
        }
Ejemplo n.º 2
0
        public void StopOrleans_OrleansIsRunning_OrleansStopped()
        {
            Process[] orleansHostTestProcess = Process.GetProcessesByName("OrleansHost");

            // If Orleans is already running, there is really no need to start it up just to shut it down.
            if (orleansHostTestProcess.Count() < 1)
            {
                string targetFolder = PrepareTestFolderStructure("StopOrleansTest");
                // Get Orleans running.
                string           orleansHostPath  = Path.Combine(targetFolder, "OrleansHost.exe");
                ProcessStartInfo orleansStartInfo = new ProcessStartInfo(orleansHostPath);
                orleansStartInfo.UseShellExecute = false;
                Process orleansProcess = Process.Start(orleansStartInfo);
                // Pause to let Orleans get started up.
                System.Threading.Thread.Sleep(9000);
                orleansHostTestProcess = Process.GetProcessesByName("OrleansHost");
                if (orleansHostTestProcess.Count() < 1)
                {
                    Assert.Inconclusive("Cannot Run Test: Could not start an OrleansHost necessary to test the StopOrleans.ps1 script.");
                }
            }

            // Test script when Orleans Host is not running.
            Collection <PSObject> results = RunPowerShellCommand(".\\StopOrleans.ps1");

            System.Threading.Thread.Sleep(5000);

            // Check to see if Orleans Host is still running.
            orleansHostTestProcess = Process.GetProcessesByName("OrleansHost");
            Assert.IsTrue(orleansHostTestProcess.Count() < 1, "OrleansHost is still running.");

            // Check the results for an error or exception.
            CheckResultsForErrors(results);
        }
Ejemplo n.º 3
0
        private static PythonVersion FindInterpreter(string pythonVersion)
        {
            var interpreter = PythonPaths.GetVersionsByName(pythonVersion, HasSymbols).FirstOrDefault();

            if (interpreter == null)
            {
                Assert.Inconclusive($"Interpreter '{pythonVersion}' not installed.");
            }

            return(interpreter);
        }
Ejemplo n.º 4
0
        private static PythonVersion FindInterpreter(string pythonVersion)
        {
            // Examples of values for pythonVersion (match field names on PythonPaths):
            // "Python36"
            // "Python36|Python36_x64"
            var interpreter = pythonVersion.Split('|')
                              .Select(v => typeof(PythonPaths).GetField(v, BindingFlags.Static | BindingFlags.Public)?.GetValue(null) as PythonVersion)
                              .Where(HasSymbols)
                              .FirstOrDefault();

            if (interpreter == null)
            {
                Assert.Inconclusive($"Interpreter '{pythonVersion}' not installed.");
            }

            return(interpreter);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the path to the Orleans folder from the named configuration file.
        /// </summary>
        /// <param name="configFile">The name of the configuration file to load.</param>
        /// <returns>The path to the Orleans folder found in the configuration file.</returns>
        public string GetOrleansFolderFromConfig(string configFile)
        {
            // <TargetLocation Path="C:\Orleans" />
            string pathValue = string.Empty;

            if (!File.Exists(Path.Combine(Directory.GetCurrentDirectory(), configFile)))
            {
                Assert.Inconclusive("Cannot Run Test: Could not find configuration file {0}", configFile);
            }
            XDocument configDoc = XDocument.Load(configFile);

            Assert.IsNotNull(configDoc, string.Format("Could not load test configuration file: {0}", configFile));
            XNamespace deployNamespace = "urn:xcg-deployment";
            XElement   targetElement   = configDoc.Root.Element(deployNamespace + "TargetLocation");

            Assert.IsNotNull(targetElement, "Could not find the TargetLocation element in the configuration file: {0}", configFile);
            XAttribute pathAttribute = targetElement.Attribute("Path");

            Assert.IsNotNull(pathAttribute, "The Path attribute of the TargetLocation element in the configuration file is missing or does not have a value : {0}", configFile);
            pathValue = pathAttribute.Value;
            return(pathValue);
        }